update app and agent
Browse files
agent.py
CHANGED
|
@@ -126,8 +126,9 @@ graph.add_edge("solve", END)
|
|
| 126 |
graph.add_conditional_edges("tool", _route)
|
| 127 |
graph.add_edge(START, "plan")
|
| 128 |
|
| 129 |
-
|
| 130 |
|
| 131 |
-
|
|
|
|
| 132 |
print(s)
|
| 133 |
-
print("---")
|
|
|
|
| 126 |
graph.add_conditional_edges("tool", _route)
|
| 127 |
graph.add_edge(START, "plan")
|
| 128 |
|
| 129 |
+
rewoo_graph = graph.compile()
|
| 130 |
|
| 131 |
+
|
| 132 |
+
for s in rewoo_graph.stream({"task": task}):
|
| 133 |
print(s)
|
| 134 |
+
print("---")
|
app.py
CHANGED
|
@@ -4,6 +4,8 @@ import requests
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
|
|
|
|
|
|
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -13,10 +15,14 @@ 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 |
return fixed_answer
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
|
| 7 |
+
from langchain_core.messages import HumanMessage
|
| 8 |
+
from agent import rewoo_graph
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
| 11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 15 |
class BasicAgent:
|
| 16 |
def __init__(self):
|
| 17 |
print("BasicAgent initialized.")
|
| 18 |
+
self.graph = rewoo_graph()
|
| 19 |
+
|
| 20 |
def __call__(self, question: str) -> str:
|
| 21 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 22 |
+
messages = [HumanMessage(content=question)]
|
| 23 |
+
result = self.graph.invoke({"messages": messages})
|
| 24 |
+
answer = result['messages'][-1].content
|
| 25 |
+
return answer # kein [14:] mehr nötig!
|
| 26 |
return fixed_answer
|
| 27 |
|
| 28 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|