Spaces:
Sleeping
Sleeping
File size: 1,619 Bytes
6df13ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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)."""
|