from graphs.evaluation import build_workflow from langchain_core.messages import HumanMessage, SystemMessage from langfuse.callback import CallbackHandler from dotenv import load_dotenv import json load_dotenv() langfuse_handler = CallbackHandler(host="https://cloud.langfuse.com") class SearchAgent: def __init__(self): """ Initialize the SearchAgent with the workflow. """ self.workflow = build_workflow() def __call__(self, question: str) -> str: messages = [HumanMessage(content=question)] state = self.workflow.invoke({ "messages":messages, "question": question, "external_information": "", "is_valid_answer": False, "has_enough_information": False, "answer": "", "step_counter" : {"iteration": 0,"validator": 0}, }, config={"callbacks": [langfuse_handler]}) return state["answer"]