Add admin views for quick replies, settings, and ticket details
- Created `quick-replies.blade.php` for managing quick replies. - Added `settings.blade.php` for admin settings management. - Implemented `ticket-show.blade.php` to display ticket details. - Introduced `timeline-card.blade.php` component for displaying timeline information. Enhance quick reply management functionality - Developed `quick-reply-manager.blade.php` for creating and editing quick replies. - Integrated Livewire for dynamic interaction and validation. Implement settings page for AI configuration - Created `settings-page.blade.php` for managing AI settings, including prompts and provider instances. - Added functionality for managing models and embeddings. Add ticket show functionality with real-time updates - Implemented ticket details view with processing status and tool call logs. - Added support for displaying article suggestions and error messages. Create unit tests for AI classifier and domain info tool - Added `AIClassifierServiceTest.php` to validate AI classifier functionality. - Implemented `DomainInfoToolTest.php` for domain parameter validation. - Created `OxxaClientTest.php` to test API interactions and password hashing.
This commit is contained in:
38
app/Services/ClassifierPromptBuilder.php
Normal file
38
app/Services/ClassifierPromptBuilder.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\DTOs\ArticleCandidateDTO;
|
||||
|
||||
class ClassifierPromptBuilder
|
||||
{
|
||||
/** @param array<ArticleCandidateDTO> $candidates */
|
||||
public function build(string $basePrompt, string $ticketMessage, array $candidates, string $language): string
|
||||
{
|
||||
$articlesBlock = collect($candidates)
|
||||
->map(fn (ArticleCandidateDTO $item, int $idx) => sprintf(
|
||||
"%d. article_id=%d\nTitle: %s\nSource URL: %s\nAllowed actions: %s\nInternal note for support assistant: %s\nContent: %s",
|
||||
$idx + 1,
|
||||
$item->articleId,
|
||||
$item->title,
|
||||
$item->sourceUrl ?? '-',
|
||||
$item->allowedActions === [] ? '[]' : json_encode($item->allowedActions, JSON_UNESCAPED_SLASHES),
|
||||
$item->note ?: '-',
|
||||
$item->content
|
||||
))
|
||||
->implode("\n\n");
|
||||
|
||||
return $basePrompt."\n\n".
|
||||
"User language: {$language}. Return explanation in this language.\n\n".
|
||||
"Return JSON only with this schema:\n".
|
||||
"{\n".
|
||||
" \"article_id\": number,\n".
|
||||
" \"confidence\": number,\n".
|
||||
" \"explanation\": string,\n".
|
||||
" \"tool_call\": null | {\"action\": \"domain_inf\", \"parameters\": {\"sld\": string, \"tld\": string}, \"reason\": string}\n".
|
||||
"}\n\n".
|
||||
"Only include a tool_call when the selected article lists that action in Allowed actions and both required parameters are present in the user question.\n".
|
||||
"Never invent sld or tld. If either parameter is missing, set tool_call to null.\n\n".
|
||||
"User question:\n\"{$ticketMessage}\"\n\nArticles:\n{$articlesBlock}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user