Spaces:
Sleeping
Sleeping
rework async
Browse files
app.py
CHANGED
|
@@ -29,11 +29,11 @@ class BasicAgent:
|
|
| 29 |
async def __call__(self, question: str) -> str:
|
| 30 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 31 |
# fixed_answer = await self.agent.run(question)
|
| 32 |
-
fixed_answer = self.agent.run(question)
|
| 33 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 34 |
return fixed_answer
|
| 35 |
|
| 36 |
-
|
| 37 |
"""
|
| 38 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 39 |
and displays the results.
|
|
@@ -107,7 +107,7 @@ async def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 107 |
print(f"Error processing file {file_name}: {e}")
|
| 108 |
try:
|
| 109 |
print("try question")
|
| 110 |
-
submitted_answer = agent(question_text)
|
| 111 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 112 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 113 |
print("results", results_log)
|
|
@@ -207,7 +207,7 @@ with gr.Blocks() as demo:
|
|
| 207 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 208 |
|
| 209 |
run_button.click(
|
| 210 |
-
fn=
|
| 211 |
outputs=[status_output, results_table]
|
| 212 |
)
|
| 213 |
|
|
|
|
| 29 |
async def __call__(self, question: str) -> str:
|
| 30 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 31 |
# fixed_answer = await self.agent.run(question)
|
| 32 |
+
fixed_answer = await self.agent.run(question)
|
| 33 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 34 |
return fixed_answer
|
| 35 |
|
| 36 |
+
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 37 |
"""
|
| 38 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 39 |
and displays the results.
|
|
|
|
| 107 |
print(f"Error processing file {file_name}: {e}")
|
| 108 |
try:
|
| 109 |
print("try question")
|
| 110 |
+
submitted_answer = asyncio.run(agent(question_text))
|
| 111 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 112 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 113 |
print("results", results_log)
|
|
|
|
| 207 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 208 |
|
| 209 |
run_button.click(
|
| 210 |
+
fn=run_and_submit_all,
|
| 211 |
outputs=[status_output, results_table]
|
| 212 |
)
|
| 213 |
|