Chat building blocks
How the pieces around an AI chat fit together: starter prompts on an empty conversation, an answer with citations and sources, feedback and generation stats under it, and an agent handoff when the work moves on. Then a settings page for the providers behind it, with API key fields and provider status. For what an agent is doing while it works, see showing agent activity.

Nothing here calls a model, stores a key or fetches anything. Your server does those things and renders the result; every piece takes its state from props. The message bubbles, the composer and the markdown are yours.
An empty conversation
<form method="post" action="{{ route('chats.messages.store', $chat) }}" class="flex flex-col gap-4">
@csrf
@if ($chat->messages->isEmpty())
<x-ds::empty-state title="Ask anything about your orders" icon="chat-bubble-left-right" :bare="true" />
<x-ds::starter-prompts variant="cards" for="message" :prompts="[
['label' => 'Where is my order?', 'icon' => 'truck', 'description' => 'Tracking for the last one'],
['label' => 'Start a return', 'icon' => 'arrow-uturn-left', 'description' => 'For anything in the last 30 days'],
]" />
@endif
<x-ds::input as="textarea" id="message" name="prompt" label="Message" />
<x-ds::button type="submit">Send</x-ds::button>
</form>
With for, a suggestion fills the box for the reader to edit; without the
script, it posts the prompt straight away, which is just as good.
An answer
<article class="group/message flex flex-col gap-3">
<div id="answer-{{ $message->id }}" class="text-body text-fg-body">
<p>
Orders can be refunded for 30 days after delivery<x-ds::citation number="1" :anchor="'m'.$message->id.'-source'" :title="$message->sources[0]['title']" :url="$message->sources[0]['url']" />.
</p>
</div>
<x-ds::sources :collapsed="true" :anchor="'m'.$message->id.'-source'" :sources="$message->sources" />
<div class="flex flex-wrap items-center justify-between gap-2">
<x-ds::response-feedback :showOnHover="true"
:action="route('messages.feedback', $message)" :value="$message->rating"
:copy="'answer-'.$message->id" :reasons="['wrong' => 'Not correct', 'unhelpful' => 'Not helpful']" />
<x-ds::generation-stats variant="popover" :model="$message->model"
:inputTokens="$message->input_tokens" :outputTokens="$message->output_tokens"
:duration="$message->duration_ms" :cost="$message->cost" :finishReason="$message->stop_reason" />
</div>
</article>
Each answer gives its sources an anchor of its own, so citation 1 in the
third answer goes to that answer's source 1.
The citation's title, url and snippet are what its hover card shows:
pass them from the same row the sources list draws, so the two agree.
Handing over
When the conversation moves to another agent, or a person:
<x-ds::agent-handoff variant="divider" from="Support agent" to="Billing agent" :time="$handoff->at" timeFormat="relative" />
<x-ds::agent-handoff :from="['name' => 'Billing agent']" :to="['name' => $agent->name, 'kind' => 'human']"
reason="A refund over £500 needs a person" :summary="$handoff->notes" status="waiting">
<x-slot:actions><x-ds::button size="sm" wire:click="takeOver">Take over</x-ds::button></x-slot:actions>
</x-ds::agent-handoff>
Settings: providers
A page where an admin enters keys and sees whether each provider is up. The status is checked on the server on a schedule; the page polls for it.
<div class="flex flex-col gap-6">
<div class="flex items-center justify-between gap-3" wire:poll.60s>
<h1 class="text-heading text-fg">AI providers</h1>
<x-ds::provider-status variant="inline" :providers="$statuses" />
</div>
<x-ds::provider-keys :action="route('settings.keys.update')" description="Stored encrypted. Only the last four characters are ever shown."
:providers="$keys" />
<x-ds::panel title="Status" body="plain">
<x-ds::provider-status :providers="$statuses" />
</x-ds::panel>
</div>
$keys holds a masked hint for each saved key, never the key: see
API key field.
Which need the script
| Piece | Without Alpine and the package's script |
|---|---|
| Starter prompts | Links, or submit buttons posting the prompt. for does nothing. |
| Sources, source card | Everything. No script is involved. |
| Citation | A link to its source card. No hover card. |
| Response feedback | With an action, an ordinary form that posts and reloads. Without one, nothing is saved. |
| Generation stats | Everything; the popover is a native disclosure that closes when its button is pressed again. |
| Agent handoff | Everything. |
| API key field | A form that posts the key and intent=test; no reveal, and Remove (which asks first) does nothing. |
| Provider status | Everything. |
From the package repo: edit this page on GitHub.