Update app.py
Browse files
app.py
CHANGED
@@ -13,11 +13,22 @@ 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 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
23 |
"""
|
|
|
13 |
class BasicAgent:
|
14 |
def __init__(self):
|
15 |
print("BasicAgent initialized.")
|
16 |
+
self.graph = build_graph()
|
17 |
+
|
18 |
def __call__(self, question: str) -> str:
|
19 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
20 |
+
# Wrap the question in a HumanMessage from langchain_core
|
21 |
+
messages = [HumanMessage(content=question)]
|
22 |
+
messages = self.graph.invoke({"messages": messages})
|
23 |
+
answer = messages['messages'][-1].content
|
24 |
+
return answer[14:]
|
25 |
+
# def __init__(self):
|
26 |
+
# print("BasicAgent initialized.")
|
27 |
+
# def __call__(self, question: str) -> str:
|
28 |
+
# print(f"Agent received question (first 50 chars): {question[:50]}...")
|
29 |
+
# fixed_answer = "This is a default answer."
|
30 |
+
# print(f"Agent returning fixed answer: {fixed_answer}")
|
31 |
+
# return fixed_answer
|
32 |
|
33 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
34 |
"""
|