fix: reliably dispatch and return background tasks
Rebuild & Deploy / rebuild (push) Successful in 47s
Rebuild & Deploy / rebuild (push) Successful in 47s
This commit is contained in:
1 parent
746ca8dca9
commit
321421e37f
7 files changed
+310
-27
No files matched your search
@@ -36,7 +36,7 @@ class TaskWorker:
|
||||
|
||||
reg.add_step(self.task_id, "thinking", f"Starting: {self.description}")
|
||||
|
||||
client = AsyncOpenAI(base_url=base_url, api_key=api_key)
|
||||
client = AsyncOpenAI(base_url=base_url, api_key=api_key, timeout=60.0)
|
||||
tools = self._load_tools()
|
||||
|
||||
messages = [
|
||||
@@ -45,6 +45,12 @@ class TaskWorker:
|
||||
]
|
||||
|
||||
max_iterations = 10
|
||||
try:
|
||||
await self._run_loop(client, model, tools, messages, max_iterations, reg)
|
||||
finally:
|
||||
await client.close()
|
||||
|
||||
async def _run_loop(self, client, model, tools, messages, max_iterations, reg):
|
||||
for iteration in range(max_iterations):
|
||||
if self._cancelled:
|
||||
reg.fail(self.task_id, "Cancelled")
|
||||
@@ -106,7 +112,7 @@ class TaskWorker:
|
||||
return (
|
||||
"You are Hope's research assistant working on a background task. "
|
||||
"Use your tools to gather information thoroughly. When you have "
|
||||
"enough, provide a final answer in 2-4 sentences suitable for "
|
||||
"enough, provide a final answer in 1-3 sentences suitable for "
|
||||
"speaking aloud. Plain text only, no markdown or formatting."
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user