Spaces:
Sleeping
Sleeping
make it async
Browse files
app.py
CHANGED
|
@@ -68,15 +68,15 @@ class BasicAgent:
|
|
| 68 |
except Exception as e:
|
| 69 |
print(f"Error intialising agent: {e}")
|
| 70 |
|
| 71 |
-
def __call__(self, input_text: str):
|
| 72 |
"""Make the agent callable directly."""
|
| 73 |
return self.agent.run(input_text)
|
| 74 |
|
| 75 |
-
def run(self, input_text: str):
|
| 76 |
"""Alternative explicit method."""
|
| 77 |
return self.agent.run(input_text)
|
| 78 |
|
| 79 |
-
def stream(self, input_text: str):
|
| 80 |
# Use `.stream_response()` for a streaming output
|
| 81 |
for chunk in self.agent.stream_response(input_text):
|
| 82 |
yield chunk.delta
|
|
@@ -143,7 +143,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 143 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 144 |
continue
|
| 145 |
try:
|
| 146 |
-
submitted_answer = agent(question_text)
|
| 147 |
answers_payload.append(
|
| 148 |
{"task_id": task_id, "submitted_answer": submitted_answer}
|
| 149 |
)
|
|
|
|
| 68 |
except Exception as e:
|
| 69 |
print(f"Error intialising agent: {e}")
|
| 70 |
|
| 71 |
+
async def __call__(self, input_text: str):
|
| 72 |
"""Make the agent callable directly."""
|
| 73 |
return self.agent.run(input_text)
|
| 74 |
|
| 75 |
+
async def run(self, input_text: str):
|
| 76 |
"""Alternative explicit method."""
|
| 77 |
return self.agent.run(input_text)
|
| 78 |
|
| 79 |
+
async def stream(self, input_text: str):
|
| 80 |
# Use `.stream_response()` for a streaming output
|
| 81 |
for chunk in self.agent.stream_response(input_text):
|
| 82 |
yield chunk.delta
|
|
|
|
| 143 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 144 |
continue
|
| 145 |
try:
|
| 146 |
+
submitted_answer = await agent(question_text)
|
| 147 |
answers_payload.append(
|
| 148 |
{"task_id": task_id, "submitted_answer": submitted_answer}
|
| 149 |
)
|