Spaces:
Sleeping
Sleeping
improve processing
Browse files
app.py
CHANGED
|
@@ -59,7 +59,6 @@ class BasicAgent:
|
|
| 59 |
llm = HuggingFaceInferenceAPI(
|
| 60 |
model_name="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 61 |
token = hf_api_key,
|
| 62 |
-
max_tokens=32767
|
| 63 |
)
|
| 64 |
|
| 65 |
# Create agent with function-calling-compatible LLM
|
|
@@ -77,6 +76,12 @@ class BasicAgent:
|
|
| 77 |
)
|
| 78 |
print("✅ BasicAgent initialized.")
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
async def __call__(self, input_text: str):
|
| 81 |
# Use run() within async context
|
| 82 |
return await self.agent.run(input_text)
|
|
@@ -149,7 +154,7 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 149 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 150 |
continue
|
| 151 |
try:
|
| 152 |
-
submitted_answer = await agent(question_text)
|
| 153 |
answers_payload.append(
|
| 154 |
{"task_id": task_id, "submitted_answer": submitted_answer}
|
| 155 |
)
|
|
|
|
| 59 |
llm = HuggingFaceInferenceAPI(
|
| 60 |
model_name="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 61 |
token = hf_api_key,
|
|
|
|
| 62 |
)
|
| 63 |
|
| 64 |
# Create agent with function-calling-compatible LLM
|
|
|
|
| 76 |
)
|
| 77 |
print("✅ BasicAgent initialized.")
|
| 78 |
|
| 79 |
+
async def answer_once(self, prompt: str) -> str:
|
| 80 |
+
"""Ask one question, then clear the dialogue so tokens never pile up."""
|
| 81 |
+
reply = await self.agent.run(prompt)
|
| 82 |
+
self.agent.reset() # <<< flush conversation context
|
| 83 |
+
return reply
|
| 84 |
+
|
| 85 |
async def __call__(self, input_text: str):
|
| 86 |
# Use run() within async context
|
| 87 |
return await self.agent.run(input_text)
|
|
|
|
| 154 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 155 |
continue
|
| 156 |
try:
|
| 157 |
+
submitted_answer = await agent.answer_once(question_text)
|
| 158 |
answers_payload.append(
|
| 159 |
{"task_id": task_id, "submitted_answer": submitted_answer}
|
| 160 |
)
|