| from utils.agent_executor import create_agent_executor | |
| class BasicAgent: | |
| def __init__(self): | |
| print("BasicAgent initialized with LangChain tools.") | |
| self.agent_executor = create_agent_executor() | |
| def __call__(self, question_data: dict) -> str: | |
| question_text = question_data.get('text', '') | |
| file_url = question_data.get('file_url') | |
| print( | |
| f"Agent received question (task_id: {question_data.get('task_id')}) (first 50 chars): {question_text[:50]}...") | |
| if file_url: | |
| print(f"With attached file URL: {file_url}") | |
| print( | |
| f"Start processing question (task_id: {question_data.get('task_id')})") | |
| response = self.agent_executor.invoke( | |
| {"input": question_text, "file_url": file_url}) | |
| answer = response.get('output', 'No answer generated.') | |
| print( | |
| f"Agent generated answer (task_id: {question_data.get('task_id')}): {answer}") | |
| return answer | |