freddymx / ai-kit-ui-livewire
Livewire 4 chat UI for ai-kit: streaming RAG responses, markdown rendering, and source citations. No build step required.
Requires
- php: ^8.5
- freddymx/ai-kit-core: ^0.4
- illuminate/support: ^12.0|^13.0
- league/commonmark: ^2.4
- livewire/livewire: ^4.4
Requires (Dev)
- laravel/boost: ^2.10
- laravel/pao: ^1.1
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^5.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The Livewire chat UI for the ai-kit suite — a drop-in <livewire:ai-kit.chat /> component with streaming RAG answers, markdown, source citations, and conversation history. No build step required.
Guía de desarrollo (objetivos, stack, estructura, estado y relación con la suite): DEVELOPMENT.md
Why this package?
You have a knowledge base indexed with ai-kit-core
and want to let users chat with it — with streaming answers and clickable source
citations — without building a chat UI from scratch or setting up a JS build
pipeline. Drop in one Livewire tag and you're done. It talks to core's
ChatService, so the answers match your CLI, API, and MCP surfaces exactly.
Requirements
- PHP 8.5+, Laravel 12 or 13
- Livewire 4
Depends on
freddymx/ai-kit-core— the RAG engine (ingestion, retrieval, agents). It is a hard dependency and is installed automatically with this package; you configure your knowledge bases and AI provider there. This package is only the chat UI. Local models (Ollama, LM Studio, vLLM, llama.cpp) are configured in core viaAI_KIT_LOCAL_*or from the AI Settings page ofai-kit-filament; the component picks up whichever provider is active automatically.
Install
composer require freddymx/ai-kit-ui-livewire
Auto-discovered. Views are publishable if you want to customise them:
php artisan vendor:publish --tag=ai-kit-ui-views
Migrating from solution-forest/ai-kit-ui-livewire
Up to 0.2 this package was solution-forest/ai-kit-ui-livewire; from 0.3 it is
freddymx/ai-kit-ui-livewire. The PHP namespace SolutionForest\AiKit\ and the
<livewire:ai-kit.chat /> tag are unchanged.
composer remove solution-forest/ai-kit-ui-livewire composer require freddymx/ai-kit-ui-livewire:^0.4
Its dependency on core now points to freddymx/ai-kit-core:^0.4. The old
solution-forest/* packages remain on Packagist at v0.2.x.
Usage
Drop it into any Blade view:
<livewire:ai-kit.chat collection="handbook" />
Props
| Prop | Type | Default | Description |
|---|---|---|---|
collection |
string |
config default | Knowledge-base slug to search |
agent |
string (class) |
config agent | Agent class override (must extend RagAgent) |
placeholder |
string |
"Ask a question…" | Input placeholder |
history |
bool |
config('ai-kit.ui.history') (false) |
Show the conversation-history sidebar (needs an authenticated user) |
citations |
bool |
config('ai-kit.ui.citations') (true) |
Show source citation chips + popups (set false to hide, and skip retrieval for them) |
streaming |
bool |
config('ai-kit.chat.streaming') (true) |
Stream the answer token-by-token over SSE (else non-streamed) |
collectionSelector |
bool |
config('ai-kit.ui.collection_selector') (false) |
Show a knowledge-base picker inside the chat (list of seeded collections). When visible, changing the base resets messages, conversation id and draft; when hidden, the collection prop stays fixed |
Every boolean prop falls back to its config default when omitted, so you can set
an app-wide default in config/ai-kit.php and override per instance. For the
selector, core's default is driven by AI_KIT_UI_COLLECTION_SELECTOR=false; set
it to true to enable the picker on every chat instance, or pass
:collection-selector="true" (or false) on a single tag to override it:
<livewire:ai-kit.chat collection="handbook" :citations="false" :streaming="false" />
With the selector visible, users pick the base from a dropdown at the top of the chat. Switching bases starts a fresh conversation, so answers never mix sources from two knowledge bases:
<livewire:ai-kit.chat :collection-selector="true" />
<livewire:ai-kit.chat collection="handbook" :agent="\App\Ai\SupportAgent::class" :history="true" placeholder="Ask about the handbook…" />
Features
- Streaming — token-by-token over SSE (route
ai-kit.stream), controlled byconfig('ai-kit.chat.streaming'), with a non-streamed fallback that runs entirely inside Livewire. - Citations — every answer shows source chips (document title · chunk · relevance %). Click a chip to expand the source passage inline with a relevance meter.
- History — with
:history="true"and a signed-in user, a sidebar lists past conversations; click to reload, or start a New chat. Scoped to the current user. Each conversation also has a delete action behind a confirmation prompt: it removes that conversation and its messages, and only applies to the authenticated participant (someone else's conversation is never deleted). - Collection selector — opt in with
:collection-selector="true"(or globally viaAI_KIT_UI_COLLECTION_SELECTOR) to let users switch knowledge bases; changing the base resets the chat. Hidden by default, so thecollectionprop stays fixed and existing embeds are unaffected. - Empty state — when the collection is missing or has no embedded content, the component prompts you to create a knowledge base first.
- Markdown — assistant responses render GitHub-flavored markdown (HTML escaped).
Standalone (non-Filament) page
The component needs Livewire assets + a CSRF meta tag. Minimal host page:
<!DOCTYPE html> <html> <head> <meta name="csrf-token" content="{{ csrf_token() }}"> @livewireStyles </head> <body> <livewire:ai-kit.chat collection="handbook" :history="true" /> @livewireScripts </body> </html>
Conversation history + token logging require an authenticated user (the conversation participant). On a public page without auth, chat still works but nothing is persisted.
Theming
The component ships compiled, scoped CSS using CSS variables — override them in your own stylesheet:
.ck-root { --ck-accent: #16a34a; /* buttons, links, active states */ --ck-user: #16a34a; /* user bubble */ --ck-radius: 12px; /* --ck-bg, --ck-fg, --ck-muted, --ck-border, --ck-assistant, --ck-user-fg */ }
Dark mode is handled automatically via prefers-color-scheme. There is no separate chat header: the New chat action lives in the history sidebar, so no props or CSS variables are needed for a header.
How streaming works
On send, the component dispatches a browser event; JS opens an EventSource to ai-kit.stream (StreamController), which streams the answer and emits delta frames, then a done frame carrying the final text + conversation id. The route middleware is configurable via config('ai-kit.ui.stream_middleware') (default ['web']).
Architecture
The component is a thin view over the core ChatService. Both the non-streamed
path and the SSE StreamController delegate to
SolutionForest\AiKit\Services\ChatService, so RAG mode (tool/inject),
conversation persistence, citations, and token usage are handled once in core
and shared with the CLI, HTTP API, and MCP server.
The ai-kit suite
| Package | Purpose |
|---|---|
| freddymx/ai-kit-core | Ingestion, retrieval, agents + CLI, HTTP API, MCP |
| freddymx/ai-kit-ui-livewire (this) | Livewire 4 chat component |
| freddymx/ai-kit-filament | Filament v5 admin panel |
Prefer a headless UI? The same chat is available as an HTTP API or MCP server in
ai-kit-core — no Livewire required.
Upgrading from ai-kit 0.2
This package is part of the 0.3 breaking release of the ai-kit suite: PHP
8.5+, Livewire ^4.4, Pest 5, ai-kit-core at ^0.3, and dev-main
aliased to 0.3.x-dev. Upgrade core (and Filament, if you use it) in lockstep.
The Laravel AI SDK v1 schema dropped the user_id column, so conversation
history is now scoped by participant_type / participant_id. On an existing
app, publish and run core's AI SDK backfill migration before deploying — see the
core upgrade notes.
Nothing else in this package's public API changed: the <livewire:ai-kit.chat />
tag, its props, streaming and citations behave the same.
Continuous integration
.github/workflows/tests.yml runs the suite on a GitHub release (and manual
dispatch) — not on every push. composer.json declares a local path
repository at ../ai-kit-core so cross-package changes can be tested together,
so CI clones that sibling first. The package itself is published on Packagist as
freddymx/ai-kit-ui-livewire; the clone step is only about the local path repo
and can be dropped together with it if you stop developing both side by side.
Author
Created and maintained by Alfredo Pineda (freddy@canariasnetworks.com).
Originally published under the SolutionForest
organization; from 0.3 on, published in the freddymx Packagist namespace.
License
MIT © SolutionForest, Alfredo Pineda

