Update app.py
Browse files
app.py
CHANGED
@@ -11,31 +11,25 @@ from agent import build_graph
|
|
11 |
# --- Constants ---
|
12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
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 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
return answer[14:]
|
36 |
-
except Exception as e:
|
37 |
-
return(e)
|
38 |
-
|
39 |
|
40 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
41 |
"""
|
|
|
11 |
# --- Constants ---
|
12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
13 |
|
|
|
14 |
class BasicAgent:
|
|
|
15 |
def __init__(self):
|
16 |
print("BasicAgent initialized.")
|
17 |
+
self.graph = build_graph()
|
18 |
|
19 |
def __call__(self, question: str) -> str:
|
20 |
+
messages = [HumanMessage(content=question)]
|
21 |
+
state = {
|
22 |
+
"messages": messages,
|
23 |
+
"query": question,
|
24 |
+
"agent_type": "",
|
25 |
+
"final_answer": "",
|
26 |
+
"perf": {},
|
27 |
+
"agno_resp": ""
|
28 |
+
}
|
29 |
+
config = {"configurable": {"thread_id": f"eval_{hash(question)}"}}
|
30 |
+
result = self.graph.invoke(state, config)
|
31 |
+
answer = result['messages'][-1].content
|
32 |
+
return answer[14:]
|
|
|
|
|
|
|
|
|
33 |
|
34 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
35 |
"""
|