File size: 960 Bytes
2f9e3a2 efd8150 494f954 efd8150 a4def59 f6bd140 a4def59 2f9e3a2 f6bd140 2f9e3a2 c285622 b97774a b4cd776 2f9e3a2 5d8f022 2f9e3a2 494f954 |
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 |
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"]
|