Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,13 +14,19 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 14 |
class BasicAgent:
|
| 15 |
def __init__(self):
|
| 16 |
# print("BasicAgent initialized.")
|
| 17 |
-
self.agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=InferenceClientModel())
|
|
|
|
| 18 |
def __call__(self, question: str) -> str:
|
| 19 |
-
|
| 20 |
# fixed_answer = "This is a default answer."
|
| 21 |
# print(f"Agent returning fixed answer: {fixed_answer}")
|
| 22 |
# return fixed_answer
|
| 23 |
-
return self.agent.run(str)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 26 |
"""
|
|
|
|
| 14 |
class BasicAgent:
|
| 15 |
def __init__(self):
|
| 16 |
# print("BasicAgent initialized.")
|
| 17 |
+
#self.agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=InferenceClientModel())
|
| 18 |
+
self.graph = build_graph()
|
| 19 |
def __call__(self, question: str) -> str:
|
| 20 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 21 |
# fixed_answer = "This is a default answer."
|
| 22 |
# print(f"Agent returning fixed answer: {fixed_answer}")
|
| 23 |
# return fixed_answer
|
| 24 |
+
# return self.agent.run(str)
|
| 25 |
+
# Wrap the question in a HumanMessage from langchain_core
|
| 26 |
+
messages = [HumanMessage(content=question)]
|
| 27 |
+
messages = self.graph.invoke({"messages": messages})
|
| 28 |
+
answer = messages['messages'][-1].content
|
| 29 |
+
return answer[14:]
|
| 30 |
|
| 31 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 32 |
"""
|