Spaces:
Sleeping
Sleeping
| import logging | |
| from typing import Optional, Dict, Any, List | |
| from dataclasses import dataclass, field | |
| from enum import Enum | |
| logger = logging.getLogger(__name__) | |
| class IntentType(Enum): | |
| DOCUMENT_QUERY = "document_query" | |
| DATABASE_QUERY = "database_query" | |
| HYBRID_QUERY = "hybrid_query" | |
| CONVERSATIONAL = "conversational" | |
| AMBIGUOUS = "ambiguous" | |
| CRM_REFERRAL = "crm_referral" | |
| class ClassificationResult: | |
| # Result of intent classification | |
| intent: IntentType | |
| confidence: float | |
| reasoning: str | |
| suggested_tables: List[str] = field(default_factory=list) | |
| requires_clarification: bool = False | |
| classification_time_ms: float = 0.0 | |
| def is_database_related(self) -> bool: | |
| return self.intent in (IntentType.DATABASE_QUERY, IntentType.HYBRID_QUERY) | |
| def is_document_related(self) -> bool: | |
| return self.intent in (IntentType.DOCUMENT_QUERY, IntentType.HYBRID_QUERY) | |
| def to_dict(self) -> Dict[str, Any]: | |
| return { | |
| "intent": self.intent.value, | |
| "confidence": self.confidence, | |
| "reasoning": self.reasoning, | |
| "suggested_tables": self.suggested_tables, | |
| "requires_clarification": self.requires_clarification, | |
| "classification_time_ms": round(self.classification_time_ms, 2), | |
| } | |