feat: Enhance Support Reply Service with tone instructions and article details

- Added tone instruction retrieval to SupportReplyService.
- Improved user feedback when no relevant article is found.
- Included article URL and tone instruction in LLM prompt.
- Updated response format to include source information.
- Enhanced article management UI with search functionality and editing capabilities.
- Introduced a new API endpoint for nearest articles based on vector search.
- Added confidence badge component to display article confidence levels.
- Implemented tests for article searching, editing, and nearest article API.
- Removed obsolete .htaccess file.
This commit is contained in:
your name
2026-05-13 22:25:45 +02:00
parent c94d3f85e8
commit 9244899f9b
22 changed files with 813 additions and 123 deletions

View File

@@ -35,91 +35,142 @@
</div>
<div class="bg-white rounded-xl p-4 shadow">
<h2 class="font-semibold mb-3">Artikelen</h2>
<div class="flex flex-col gap-3 mb-4 lg:flex-row lg:items-end lg:justify-between">
<div>
<h2 class="font-semibold">Artikelen</h2>
<p class="text-sm text-slate-500">Zoek op titel, inhoud, bron of artikelnummer.</p>
</div>
<div class="w-full lg:w-96">
<label for="article-search" class="block text-xs font-semibold text-slate-500 mb-1">Zoeken</label>
<input id="article-search" wire:model.live.debounce.300ms="search" type="search"
class="w-full border rounded p-2" placeholder="Bijvoorbeeld: DNS, e-mail, #42">
</div>
</div>
<div class="space-y-3">
@foreach ($articles as $article)
<div class="border rounded p-3">
<div class="flex items-start justify-between gap-3">
<div>
<div class="font-medium">#{{ $article->id }} {{ $article->title }}</div>
@if (($article->status ?? 'published') === 'draft')
<span
class="inline-block mt-1 text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-800">Concept
(AI)</span>
@endif
</div>
<div class="flex items-center gap-3">
@if (($article->status ?? 'published') === 'draft')
<button type="button" wire:click="approveDraft({{ $article->id }})"
class="text-sm text-green-700 hover:underline">
Valideren & publiceren
</button>
@endif
<button type="button" wire:click="deleteArticle({{ $article->id }})"
wire:confirm="Weet je zeker dat je dit artikel wilt verwijderen?"
class="text-sm text-red-600 hover:underline">
Verwijderen
</button>
</div>
</div>
@if ($article->note)
<div class="mt-2 text-xs rounded bg-slate-50 p-2 text-slate-600">
<span class="font-semibold">LLM note:</span>
{{ \Illuminate\Support\Str::limit($article->note, 180) }}
</div>
@endif
@if (($article->allowed_actions ?? []) !== [])
<div class="mt-2 flex flex-wrap gap-1">
@foreach ($article->allowed_actions as $action)
<span
class="text-xs px-2 py-0.5 rounded bg-blue-100 text-blue-800">{{ $action }}</span>
@endforeach
</div>
@endif
<div class="text-sm text-slate-600">{{ \Illuminate\Support\Str::limit($article->content, 140) }}
</div>
<div class="mt-3 rounded bg-slate-50 p-3 space-y-2">
<label class="block text-xs font-semibold text-slate-500">LLM note</label>
<textarea wire:model="articleNotes.{{ $article->id }}" class="w-full border rounded p-2 min-h-20 text-sm"
placeholder="Interne aanwijzingen voor dit artikel"></textarea>
@error("articleNotes.{$article->id}")
<p class="text-red-600 text-sm">{{ $message }}</p>
@enderror
<label class="flex items-start gap-2 text-sm">
<input wire:model="articleAllowedActions.{{ $article->id }}" type="checkbox"
value="domain_inf" class="mt-1 rounded border-slate-300">
<span>domain_inf toestaan</span>
</label>
@error("articleAllowedActions.{$article->id}.*")
<p class="text-red-600 text-sm">{{ $message }}</p>
@enderror
<div>
<label class="block text-xs font-semibold text-slate-500 mb-1">Gekoppelde
snelantwoorden</label>
@if ($quickReplyOptions->isEmpty())
<p class="text-xs text-slate-500">Nog geen actieve snelantwoorden beschikbaar.</p>
@else
<div class="grid gap-1 sm:grid-cols-2">
@foreach ($quickReplyOptions as $quickReply)
<label class="flex items-center gap-2 text-sm">
<input wire:model="articleQuickReplies.{{ $article->id }}" type="checkbox"
value="{{ $quickReply->id }}" class="rounded border-slate-300">
<span>{{ $quickReply->title }}</span>
</label>
@endforeach
@forelse ($articles as $article)
<div class="border rounded p-3" wire:key="article-{{ $article->id }}">
@if ($editingArticleId === $article->id)
<form wire:submit="saveEdit" class="space-y-3">
<div class="flex items-start justify-between gap-3">
<div>
<div class="font-medium">Artikel #{{ $article->id }} bewerken</div>
<p class="text-sm text-slate-500">Na opslaan wordt het artikel opnieuw geindexeerd.</p>
</div>
@endif
@error("articleQuickReplies.{$article->id}.*")
<button type="button" wire:click="cancelEdit"
class="text-sm text-slate-600 hover:underline">
Annuleren
</button>
</div>
<div>
<label class="block text-xs font-semibold text-slate-500 mb-1">Titel</label>
<input wire:model="editTitle" type="text" class="w-full border rounded p-2">
@error('editTitle')
<p class="text-red-600 text-sm">{{ $message }}</p>
@enderror
</div>
<div>
<label class="block text-xs font-semibold text-slate-500 mb-1">Inhoud</label>
<textarea wire:model="editContent" class="w-full border rounded p-2 min-h-64"></textarea>
@error('editContent')
<p class="text-red-600 text-sm">{{ $message }}</p>
@enderror
</div>
<button class="bg-slate-900 text-white px-4 py-2 rounded" type="submit">
Wijzigingen opslaan
</button>
</form>
@else
<div class="flex items-start justify-between gap-3">
<div>
<div class="font-medium">#{{ $article->id }} {{ $article->title }}</div>
@if (($article->status ?? 'published') === 'draft')
<span
class="inline-block mt-1 text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-800">Concept
(AI)</span>
@endif
</div>
<div class="flex items-center gap-3">
@if (($article->status ?? 'published') === 'draft')
<button type="button" wire:click="approveDraft({{ $article->id }})"
class="text-sm text-green-700 hover:underline">
Valideren & publiceren
</button>
@endif
<button type="button" wire:click="startEdit({{ $article->id }})"
class="text-sm text-slate-700 hover:underline">
Bewerken
</button>
<button type="button" wire:click="deleteArticle({{ $article->id }})"
wire:confirm="Weet je zeker dat je dit artikel wilt verwijderen?"
class="text-sm text-red-600 hover:underline">
Verwijderen
</button>
</div>
</div>
@if ($article->note)
<div class="mt-2 text-xs rounded bg-slate-50 p-2 text-slate-600">
<span class="font-semibold">LLM note:</span>
{{ \Illuminate\Support\Str::limit($article->note, 180) }}
</div>
@endif
@if (($article->allowed_actions ?? []) !== [])
<div class="mt-2 flex flex-wrap gap-1">
@foreach ($article->allowed_actions as $action)
<span
class="text-xs px-2 py-0.5 rounded bg-blue-100 text-blue-800">{{ $action }}</span>
@endforeach
</div>
@endif
<div class="text-sm text-slate-600">{{ \Illuminate\Support\Str::limit($article->content, 140) }}
</div>
<div class="mt-3 rounded bg-slate-50 p-3 space-y-2">
<label class="block text-xs font-semibold text-slate-500">LLM note</label>
<textarea wire:model="articleNotes.{{ $article->id }}" class="w-full border rounded p-2 min-h-20 text-sm"
placeholder="Interne aanwijzingen voor dit artikel"></textarea>
@error("articleNotes.{$article->id}")
<p class="text-red-600 text-sm">{{ $message }}</p>
@enderror
<label class="flex items-start gap-2 text-sm">
<input wire:model="articleAllowedActions.{{ $article->id }}" type="checkbox"
value="domain_inf" class="mt-1 rounded border-slate-300">
<span>domain_inf toestaan</span>
</label>
@error("articleAllowedActions.{$article->id}.*")
<p class="text-red-600 text-sm">{{ $message }}</p>
@enderror
<div>
<label class="block text-xs font-semibold text-slate-500 mb-1">Gekoppelde
snelantwoorden</label>
@if ($quickReplyOptions->isEmpty())
<p class="text-xs text-slate-500">Nog geen actieve snelantwoorden beschikbaar.</p>
@else
<div class="grid gap-1 sm:grid-cols-2">
@foreach ($quickReplyOptions as $quickReply)
<label class="flex items-center gap-2 text-sm">
<input wire:model="articleQuickReplies.{{ $article->id }}"
type="checkbox" value="{{ $quickReply->id }}"
class="rounded border-slate-300">
<span>{{ $quickReply->title }}</span>
</label>
@endforeach
</div>
@endif
@error("articleQuickReplies.{$article->id}.*")
<p class="text-red-600 text-sm">{{ $message }}</p>
@enderror
</div>
<button type="button" wire:click="saveMetadata({{ $article->id }})"
class="text-sm px-3 py-1 rounded bg-slate-900 text-white">
Metadata opslaan
</button>
</div>
<button type="button" wire:click="saveMetadata({{ $article->id }})"
class="text-sm px-3 py-1 rounded bg-slate-900 text-white">
Metadata opslaan
</button>
</div>
@endif
</div>
@endforeach
@empty
<div class="border rounded p-4 text-sm text-slate-500">
Geen artikelen gevonden.
</div>
@endforelse
</div>
<div class="mt-4">{{ $articles->links() }}</div>
</div>

View File

@@ -64,8 +64,12 @@
</div>
<div class="text-sm text-slate-700 mb-2">{{ $ticket->message }}</div>
@if ($ticket->bestArticle)
<div class="text-sm">Article: #{{ $ticket->bestArticle->id }} | Confidence:
{{ number_format((float) $ticket->confidence, 2) }}</div>
<div class="flex flex-wrap items-center gap-2 text-sm">
<span>Article: #{{ $ticket->bestArticle->id }}</span>
@if ($ticket->confidence !== null)
<x-admin.confidence-badge :confidence="$ticket->confidence" />
@endif
</div>
<div class="text-xs text-slate-500">{{ $ticket->explanation }}</div>
@endif
<a class="text-sm underline"

View File

@@ -67,10 +67,20 @@
@endif
@if ($ticket->bestArticle)
<div class="mt-3 text-sm rounded bg-green-100 text-green-800 p-2">
Beste artikel: #{{ $ticket->bestArticle->id }} - {{ $ticket->bestArticle->title }}
<div class="flex flex-wrap items-center gap-2">
<span>Beste artikel: #{{ $ticket->bestArticle->id }} - {{ $ticket->bestArticle->title }}</span>
@if ($ticket->confidence !== null)
(confidence {{ number_format($ticket->confidence, 2) }})
<x-admin.confidence-badge :confidence="$ticket->confidence" />
@endif
</div>
<div class="mt-1">
Bron:
@if ($ticket->bestArticle->source_url)
<a href="{{ $ticket->bestArticle->source_url }}" target="_blank" class="underline">{{ $ticket->bestArticle->source_url }}</a>
@else
niet beschikbaar
@endif
</div>
</div>
@endif
</div>