Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
|
|
|
|
6 |
|
7 |
# (Keep Constants as is)
|
8 |
# --- Constants ---
|
@@ -13,11 +15,15 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
13 |
class BasicAgent:
|
14 |
def __init__(self):
|
15 |
print("BasicAgent initialized.")
|
|
|
16 |
def __call__(self, question: str) -> str:
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
23 |
"""
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from agent import agent_graph
|
7 |
+
from langchain_core.messages import HumanMessage
|
8 |
|
9 |
# (Keep Constants as is)
|
10 |
# --- Constants ---
|
|
|
15 |
class BasicAgent:
|
16 |
def __init__(self):
|
17 |
print("BasicAgent initialized.")
|
18 |
+
self.graph = agent_graph
|
19 |
def __call__(self, question: str) -> str:
|
20 |
+
messages = [HumanMessage(content=question)]
|
21 |
+
response = self.graph.invoke({"messages": messages})
|
22 |
+
last_msg = response["messages"][-1].content
|
23 |
+
|
24 |
+
if "FINAL ANSWER:" in last_msg:
|
25 |
+
return last_msg.split("FINAL ANSWER:")[-1].strip()
|
26 |
+
return last_msg
|
27 |
|
28 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
29 |
"""
|