'boolean', ]; /** * Available categories for knowledge base entries. */ public static function getCategories(): array { return [ 'company_info' => 'Informações da Empresa', 'products' => 'Produtos', 'services' => 'Serviços', 'faq' => 'Perguntas Frequentes', 'general' => 'Geral', ]; } /** * Scope to get only active entries. */ public function scopeActive($query) { return $query->where('active', true); } /** * Get all knowledge as a formatted text for the system prompt. */ public static function getFormattedKnowledge(): string { $entries = self::active()->orderBy('category')->orderBy('title')->get(); if ($entries->isEmpty()) { return ''; } $grouped = $entries->groupBy('category'); $categories = self::getCategories(); $output = ''; foreach ($grouped as $category => $items) { $label = $categories[$category] ?? $category; $output .= "\n## {$label}\n"; foreach ($items as $item) { $output .= "- **{$item->title}**: {$item->content}\n"; if ($item->restrictions) { $output .= " - ⚠️ Restrição: {$item->restrictions}\n"; } } } return $output; } }