Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ import inspect
|
|
4 |
import gradio as gr
|
5 |
import requests
|
6 |
import pandas as pd
|
7 |
-
import time
|
8 |
from langchain_core.messages import HumanMessage
|
9 |
from agent import build_graph
|
10 |
|
@@ -26,11 +25,11 @@ class BasicAgent:
|
|
26 |
|
27 |
def __call__(self, question: str) -> str:
|
28 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
29 |
-
# Wrap the question in a HumanMessage from langchain_core
|
30 |
messages = [HumanMessage(content=question)]
|
31 |
-
|
32 |
-
answer =
|
33 |
-
return answer[14:]
|
|
|
34 |
|
35 |
|
36 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
@@ -93,9 +92,6 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
93 |
if not task_id or question_text is None:
|
94 |
print(f"Skipping item with missing task_id or question: {item}")
|
95 |
continue
|
96 |
-
|
97 |
-
# time.sleep(10)
|
98 |
-
|
99 |
try:
|
100 |
submitted_answer = agent(question_text)
|
101 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
@@ -208,4 +204,4 @@ if __name__ == "__main__":
|
|
208 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
209 |
|
210 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
211 |
-
demo.launch(debug=True, share=False)
|
|
|
4 |
import gradio as gr
|
5 |
import requests
|
6 |
import pandas as pd
|
|
|
7 |
from langchain_core.messages import HumanMessage
|
8 |
from agent import build_graph
|
9 |
|
|
|
25 |
|
26 |
def __call__(self, question: str) -> str:
|
27 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
|
|
28 |
messages = [HumanMessage(content=question)]
|
29 |
+
result = self.graph.invoke({"messages": messages})
|
30 |
+
answer = result['messages'][-1].content
|
31 |
+
return answer # kein [14:] mehr nötig!
|
32 |
+
|
33 |
|
34 |
|
35 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
|
92 |
if not task_id or question_text is None:
|
93 |
print(f"Skipping item with missing task_id or question: {item}")
|
94 |
continue
|
|
|
|
|
|
|
95 |
try:
|
96 |
submitted_answer = agent(question_text)
|
97 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
|
|
204 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
205 |
|
206 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
207 |
+
demo.launch(debug=True, share=False)
|