- 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.
77 lines
2.0 KiB
PHP
77 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Article;
|
|
use App\Services\ArticleIndexingService;
|
|
use Illuminate\Console\Command;
|
|
|
|
class GenerateArticleEmbeddingsCommand extends Command
|
|
{
|
|
protected $signature = 'articles:embed
|
|
{--force : Re-generate embeddings for all articles}
|
|
{--limit= : Maximum number of articles to process}';
|
|
|
|
protected $description = 'Generate missing (or all) embeddings for articles.';
|
|
|
|
public function handle(ArticleIndexingService $indexingService): int
|
|
{
|
|
$force = (bool) $this->option('force');
|
|
$limitOption = $this->option('limit');
|
|
$limit = is_numeric($limitOption) ? (int) $limitOption : null;
|
|
|
|
$query = Article::query()->orderBy('id');
|
|
if (! $force) {
|
|
$query->whereDoesntHave('chunks');
|
|
}
|
|
|
|
$total = (clone $query)->count();
|
|
if ($limit !== null && $limit > 0) {
|
|
$total = min($total, $limit);
|
|
}
|
|
|
|
if ($total === 0) {
|
|
$this->info('No articles to process.');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$bar = $this->output->createProgressBar($total);
|
|
$bar->start();
|
|
|
|
$processed = 0;
|
|
$updated = 0;
|
|
$failed = 0;
|
|
|
|
$query->chunkById(50, function ($articles) use ($indexingService, $limit, &$processed, &$updated, &$failed, $bar) {
|
|
foreach ($articles as $article) {
|
|
if ($limit !== null && $processed >= $limit) {
|
|
return false;
|
|
}
|
|
|
|
$processed++;
|
|
|
|
try {
|
|
$indexingService->indexArticle($article);
|
|
$updated++;
|
|
} catch (\Throwable) {
|
|
$failed++;
|
|
}
|
|
|
|
$bar->advance();
|
|
}
|
|
});
|
|
|
|
$bar->finish();
|
|
$this->newLine(2);
|
|
|
|
$this->table(['Metric', 'Value'], [
|
|
['Processed', $processed],
|
|
['Updated', $updated],
|
|
['Failed', $failed],
|
|
]);
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|