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:
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use App\Casts\VectorCast;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Article extends Model
|
||||
@@ -12,16 +13,23 @@ class Article extends Model
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'content',
|
||||
'note',
|
||||
'allowed_actions',
|
||||
'status',
|
||||
'is_ai_draft',
|
||||
'embedding',
|
||||
'source',
|
||||
'source_url',
|
||||
'source_article_id',
|
||||
'category_id',
|
||||
'subcategory_id',
|
||||
'source_ticket_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'embedding' => VectorCast::class,
|
||||
'allowed_actions' => 'array',
|
||||
'is_ai_draft' => 'boolean',
|
||||
];
|
||||
|
||||
public function decisions(): HasMany
|
||||
@@ -38,4 +46,24 @@ class Article extends Model
|
||||
{
|
||||
return $this->belongsTo(Category::class, 'subcategory_id');
|
||||
}
|
||||
|
||||
public function sourceTicket(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ticket::class, 'source_ticket_id');
|
||||
}
|
||||
|
||||
public function chunks(): HasMany
|
||||
{
|
||||
return $this->hasMany(ArticleChunk::class);
|
||||
}
|
||||
|
||||
public function quickReplies(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(QuickReply::class)->withTimestamps();
|
||||
}
|
||||
|
||||
public function activeQuickReplies(): BelongsToMany
|
||||
{
|
||||
return $this->quickReplies()->where('is_active', true);
|
||||
}
|
||||
}
|
||||
|
||||
30
app/Models/ArticleChunk.php
Normal file
30
app/Models/ArticleChunk.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Casts\VectorCast;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ArticleChunk extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'article_id',
|
||||
'chunk_index',
|
||||
'content',
|
||||
'embedding',
|
||||
'embedding_provider_instance_id',
|
||||
'embedding_model',
|
||||
'embedded_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'embedding' => VectorCast::class,
|
||||
'embedded_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function article(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Article::class);
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@ class EmbeddingCache extends Model
|
||||
{
|
||||
protected $table = 'embedding_cache';
|
||||
|
||||
protected $fillable = ['text_hash', 'text', 'embedding'];
|
||||
protected $fillable = ['provider_instance_id', 'embedding_model', 'text_hash', 'text', 'embedding'];
|
||||
|
||||
protected $casts = [
|
||||
'embedding' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ class Feedback extends Model
|
||||
protected $table = 'feedback';
|
||||
|
||||
protected $fillable = ['ticket_id', 'article_id', 'is_correct', 'notes'];
|
||||
}
|
||||
}
|
||||
|
||||
24
app/Models/QuickReply.php
Normal file
24
app/Models/QuickReply.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class QuickReply extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'content',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function articles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Article::class)->withTimestamps();
|
||||
}
|
||||
}
|
||||
10
app/Models/Setting.php
Normal file
10
app/Models/Setting.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $fillable = ['key', 'value'];
|
||||
}
|
||||
@@ -4,14 +4,40 @@ namespace App\Models;
|
||||
|
||||
use App\Casts\VectorCast;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Ticket extends Model
|
||||
{
|
||||
protected $fillable = ['message', 'embedding'];
|
||||
protected $fillable = [
|
||||
'message',
|
||||
'normalized_message',
|
||||
'redaction_report',
|
||||
'embedding',
|
||||
'embedding_provider_instance_id',
|
||||
'embedding_model',
|
||||
'embedded_at',
|
||||
'status',
|
||||
'best_article_id',
|
||||
'confidence',
|
||||
'explanation',
|
||||
'support_reply',
|
||||
'needs_article_draft',
|
||||
'draft_article_id',
|
||||
'result_payload',
|
||||
'api_credentials',
|
||||
'error_message',
|
||||
'processed_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'embedding' => VectorCast::class,
|
||||
'redaction_report' => 'array',
|
||||
'result_payload' => 'array',
|
||||
'api_credentials' => 'encrypted:array',
|
||||
'needs_article_draft' => 'boolean',
|
||||
'embedded_at' => 'datetime',
|
||||
'processed_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function decisions(): HasMany
|
||||
@@ -23,4 +49,28 @@ class Ticket extends Model
|
||||
{
|
||||
return $this->hasMany(Feedback::class);
|
||||
}
|
||||
|
||||
public function logs(): HasMany
|
||||
{
|
||||
return $this->hasMany(TicketProcessingLog::class)
|
||||
->orderByDesc('created_at')
|
||||
->orderByDesc('id');
|
||||
}
|
||||
|
||||
public function toolCalls(): HasMany
|
||||
{
|
||||
return $this->hasMany(TicketToolCall::class)
|
||||
->orderByDesc('created_at')
|
||||
->orderByDesc('id');
|
||||
}
|
||||
|
||||
public function bestArticle(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Article::class, 'best_article_id');
|
||||
}
|
||||
|
||||
public function draftArticle(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Article::class, 'draft_article_id');
|
||||
}
|
||||
}
|
||||
|
||||
20
app/Models/TicketProcessingLog.php
Normal file
20
app/Models/TicketProcessingLog.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class TicketProcessingLog extends Model
|
||||
{
|
||||
protected $fillable = ['ticket_id', 'step', 'status', 'message', 'context'];
|
||||
|
||||
protected $casts = [
|
||||
'context' => 'array',
|
||||
];
|
||||
|
||||
public function ticket(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ticket::class);
|
||||
}
|
||||
}
|
||||
36
app/Models/TicketToolCall.php
Normal file
36
app/Models/TicketToolCall.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class TicketToolCall extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'ticket_id',
|
||||
'article_id',
|
||||
'action',
|
||||
'status',
|
||||
'parameters',
|
||||
'response',
|
||||
'error',
|
||||
'executed_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'parameters' => 'array',
|
||||
'response' => 'array',
|
||||
'executed_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function ticket(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ticket::class);
|
||||
}
|
||||
|
||||
public function article(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Article::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user