# services/agents/translator_agent.py """ Translation Agent - Wraps utilities/translator.py """ from typing import Dict, Any from services.agents.base_agent import BaseUtilityAgent from utilities.translator import translate_remote class TranslatorAgent(BaseUtilityAgent): """ Autonomous agent for language translation. """ def __init__(self): super().__init__( name="translate", role="Translation Specialist", goal="Provide accurate, natural translations while preserving meaning and context", backstory="""You are an expert translator fluent in multiple languages. You understand nuances, idioms, and cultural context. You can assess translation quality for accuracy, fluency, and preservation of meaning. You validate translations for correctness and naturalness.""", utility_function=translate_remote ) def _prepare_task_description(self, input_data: Dict[str, Any]) -> str: """Prepare task description for the agent.""" target_lang = input_data.get("target_lang", "unknown language") 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 translation of {source} to {target_lang}. Assess translation quality: - Accuracy: Is meaning preserved? - Fluency: Is translation natural in target language? - Completeness: Is all content translated? - Context: Are cultural/contextual nuances handled well? Provide confidence score (0.0-1.0)."""