Commit
·
f6bd140
1
Parent(s):
c285622
add youtube transcription
Browse files- agents/search_agent.py +5 -5
- graphs/evaluation.py +1 -3
agents/search_agent.py
CHANGED
|
@@ -7,14 +7,14 @@ langfuse_handler = CallbackHandler(host="https://cloud.langfuse.com")
|
|
| 7 |
|
| 8 |
class SearchAgent:
|
| 9 |
def __init__(self):
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
def __call__(self, question: str) -> str:
|
| 12 |
-
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 13 |
-
workflow = build_workflow()
|
| 14 |
-
|
| 15 |
messages = [HumanMessage(content=question)]
|
| 16 |
|
| 17 |
-
state = workflow.invoke({
|
| 18 |
"messages":messages,
|
| 19 |
"question": question,
|
| 20 |
}, config={"callbacks": [langfuse_handler]})
|
|
|
|
| 7 |
|
| 8 |
class SearchAgent:
|
| 9 |
def __init__(self):
|
| 10 |
+
"""
|
| 11 |
+
Initialize the SearchAgent with the workflow.
|
| 12 |
+
"""
|
| 13 |
+
self.workflow = build_workflow()
|
| 14 |
def __call__(self, question: str) -> str:
|
|
|
|
|
|
|
|
|
|
| 15 |
messages = [HumanMessage(content=question)]
|
| 16 |
|
| 17 |
+
state = self.workflow.invoke({
|
| 18 |
"messages":messages,
|
| 19 |
"question": question,
|
| 20 |
}, config={"callbacks": [langfuse_handler]})
|
graphs/evaluation.py
CHANGED
|
@@ -32,7 +32,6 @@ def call_node(state: EvaluationState):
|
|
| 32 |
"""
|
| 33 |
This node call the model with the question and the tools
|
| 34 |
"""
|
| 35 |
-
print(state["question"])
|
| 36 |
response = bound_model_llama.invoke(state["messages"])
|
| 37 |
|
| 38 |
state["messages"].append(response)
|
|
@@ -66,7 +65,7 @@ def map_answer(state: EvaluationState):
|
|
| 66 |
"""
|
| 67 |
Map the answer to the final answer
|
| 68 |
"""
|
| 69 |
-
answer = anthropic_model.invoke("Map the answer, I want only the number, string or list. ANSWER:"+ state["answer"])
|
| 70 |
|
| 71 |
return {
|
| 72 |
"answer": answer.content
|
|
@@ -85,7 +84,6 @@ def validator(state: EvaluationState):
|
|
| 85 |
|
| 86 |
# Check if we've hit the validator recursion limit
|
| 87 |
if state["step_counter"]["validator"] >= 3: # Smaller limit for validator recursion
|
| 88 |
-
print("Validator recursion limit reached. Accepting current answer format.")
|
| 89 |
state["is_valid_answer"] = True
|
| 90 |
return state
|
| 91 |
|
|
|
|
| 32 |
"""
|
| 33 |
This node call the model with the question and the tools
|
| 34 |
"""
|
|
|
|
| 35 |
response = bound_model_llama.invoke(state["messages"])
|
| 36 |
|
| 37 |
state["messages"].append(response)
|
|
|
|
| 65 |
"""
|
| 66 |
Map the answer to the final answer
|
| 67 |
"""
|
| 68 |
+
answer = anthropic_model.invoke("Map the answer, I want only the number, string or list. Remove quotes. ANSWER:"+ state["answer"])
|
| 69 |
|
| 70 |
return {
|
| 71 |
"answer": answer.content
|
|
|
|
| 84 |
|
| 85 |
# Check if we've hit the validator recursion limit
|
| 86 |
if state["step_counter"]["validator"] >= 3: # Smaller limit for validator recursion
|
|
|
|
| 87 |
state["is_valid_answer"] = True
|
| 88 |
return state
|
| 89 |
|