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:
@@ -19,6 +19,14 @@ class ArticleManager extends Component
|
||||
|
||||
public array $allowedActions = [];
|
||||
|
||||
public string $search = '';
|
||||
|
||||
public ?int $editingArticleId = null;
|
||||
|
||||
public string $editTitle = '';
|
||||
|
||||
public string $editContent = '';
|
||||
|
||||
public array $articleNotes = [];
|
||||
|
||||
public array $articleAllowedActions = [];
|
||||
@@ -55,6 +63,51 @@ class ArticleManager extends Component
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedSearch(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function startEdit(int $articleId, AdminArticleService $service): void
|
||||
{
|
||||
$article = $service->findById($articleId);
|
||||
if ($article === null) {
|
||||
session()->flash('success', "Artikel #{$articleId} bestaat niet meer.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->editingArticleId = $article->id;
|
||||
$this->editTitle = $article->title;
|
||||
$this->editContent = $article->content;
|
||||
}
|
||||
|
||||
public function cancelEdit(): void
|
||||
{
|
||||
$this->reset(['editingArticleId', 'editTitle', 'editContent']);
|
||||
$this->resetValidation(['editTitle', 'editContent']);
|
||||
}
|
||||
|
||||
public function saveEdit(AdminArticleService $service): void
|
||||
{
|
||||
if ($this->editingArticleId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->validate([
|
||||
'editTitle' => ['required', 'string', 'max:255'],
|
||||
'editContent' => ['required', 'string', 'max:12000'],
|
||||
]);
|
||||
|
||||
$updated = $service->updateContent($this->editingArticleId, $this->editTitle, $this->editContent);
|
||||
|
||||
session()->flash('success', $updated
|
||||
? "Artikel #{$this->editingArticleId} is bijgewerkt en wordt opnieuw geindexeerd."
|
||||
: "Artikel #{$this->editingArticleId} bestaat niet meer.");
|
||||
|
||||
$this->cancelEdit();
|
||||
}
|
||||
|
||||
public function saveMetadata(int $articleId, AdminArticleService $service): void
|
||||
{
|
||||
$this->validate([
|
||||
@@ -90,8 +143,8 @@ class ArticleManager extends Component
|
||||
|
||||
public function render(AdminArticleService $service, AdminQuickReplyService $quickReplyService)
|
||||
{
|
||||
$articles = $service->paginate(10);
|
||||
$this->hydrateArticleMetadataState($articles->items());
|
||||
$articles = $service->paginate(10, $this->search);
|
||||
$this->fillArticleMetadataState($articles->items());
|
||||
|
||||
return view('livewire.admin.article-manager', [
|
||||
'articles' => $articles,
|
||||
@@ -99,7 +152,7 @@ class ArticleManager extends Component
|
||||
]);
|
||||
}
|
||||
|
||||
private function hydrateArticleMetadataState(array $articles): void
|
||||
private function fillArticleMetadataState(array $articles): void
|
||||
{
|
||||
foreach ($articles as $article) {
|
||||
if (! array_key_exists($article->id, $this->articleNotes)) {
|
||||
|
||||
Reference in New Issue
Block a user