Spaces:
Sleeping
Sleeping
| # services/agents/classifier_agent.py | |
| """ | |
| Classification Agent - Wraps utilities/classify.py | |
| """ | |
| from typing import Dict, Any | |
| from services.agents.base_agent import BaseUtilityAgent | |
| from utilities.classify import classify_remote | |
| class ClassifierAgent(BaseUtilityAgent): | |
| """ | |
| Autonomous agent for content classification. | |
| """ | |
| def __init__(self): | |
| super().__init__( | |
| name="classify", | |
| role="Content Classification Specialist", | |
| goal="Accurately categorize documents and text into appropriate classes", | |
| backstory="""You are an expert in text classification and content categorization. | |
| You understand document types, topics, and can assign appropriate labels based | |
| on content analysis. You validate classifications for accuracy and consistency.""", | |
| utility_function=classify_remote | |
| ) | |
| def _prepare_task_description(self, input_data: Dict[str, Any]) -> str: | |
| """Prepare task description for the agent.""" | |
| has_text = "text" in input_data | |
| filename = input_data.get("filename", "document") | |
| source = "provided text" if has_text else f"{filename}" | |
| return f"""Validate the classification results for {source}. | |
| Assess classification quality: | |
| - Accuracy: Is the assigned category appropriate? | |
| - Specificity: Is classification specific enough? | |
| - Consistency: Would similar content be classified the same? | |
| - Justification: Is classification well-reasoned? | |
| Provide confidence score (0.0-1.0).""" | |