updated the graph call
Browse files
app.py
CHANGED
@@ -13,21 +13,18 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
13 |
|
14 |
# --- Basic Agent Definition ---
|
15 |
class BasicAgent:
|
16 |
-
"""
|
17 |
-
|
18 |
def __init__(self):
|
19 |
print("BasicAgent initialized.")
|
20 |
-
self.graph =
|
21 |
-
|
22 |
def __call__(self, question: str) -> str:
|
|
|
|
|
23 |
messages = [HumanMessage(content=question)]
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
# Assumes answer starts with "FINAL ANSWER: "
|
28 |
-
if final_response.startswith("FINAL ANSWER: "):
|
29 |
-
return final_response[len("FINAL ANSWER: "):].strip()
|
30 |
-
return final_response.strip()
|
31 |
|
32 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
33 |
"""
|
|
|
13 |
|
14 |
# --- Basic Agent Definition ---
|
15 |
class BasicAgent:
|
16 |
+
"""A langgraph agent."""
|
|
|
17 |
def __init__(self):
|
18 |
print("BasicAgent initialized.")
|
19 |
+
self.graph = build_graph()
|
20 |
+
|
21 |
def __call__(self, question: str) -> str:
|
22 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
23 |
+
# Wrap the question in a HumanMessage from langchain_core
|
24 |
messages = [HumanMessage(content=question)]
|
25 |
+
messages = self.graph.invoke({"messages": messages})
|
26 |
+
answer = messages['messages'][-1].content
|
27 |
+
return answer[14:]
|
|
|
|
|
|
|
|
|
28 |
|
29 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
30 |
"""
|