# --- Base Agent with file support --- class FileAwareAgent: """ Minimal base that accepts a question and an optional file_path. Subclasses can override `answer` to implement custom logic. """ def __call__(self, question: str, file_path: str | None = None) -> str: preview = question[:50] if isinstance(question, str) else str(question)[:50] print(f"Agent received question (first 50 chars): {preview}...") if file_path: print(f"Agent received file_path: {file_path}") fixed_answer = self.answer(question, file_path) print(f"Agent returning answer: {fixed_answer}") return fixed_answer def answer(self, question: str, file_path: str | None = None) -> str: raise NotImplementedError # --- Basic Agent Definition --- class BasicAgent(FileAwareAgent): def __init__(self): print("BasicAgent initialized.") def answer(self, question: str, file_path: str | None = None) -> str: # Placeholder logic; replace with real solution strategy. return "This is a default answer." class LangAgent(FileAwareAgent): def __init__(self): print("LangAgent initialized.") def answer(self, question: str, file_path: str | None = None) -> str: # Placeholder logic; replace with language-model-based solution. if file_path: # Keep the intent (point to the file) but fix formatting. return f"To answer this question I should read this file: {file_path}" else: return "This is a default answer."