feat: task cancellation (wip)
This commit is contained in:
1 parent
25b5fbd22a
commit
77addb889d
10 files changed
+319
-60
No files matched your search
+2
-22
@@ -224,22 +224,8 @@ async def start_server(app):
|
||||
'nonce': nonce
|
||||
})
|
||||
|
||||
elif action == "get-agent-run":
|
||||
await send({
|
||||
'run': await app.get_agent_run(body['runId']),
|
||||
'nonce': nonce
|
||||
})
|
||||
stream_id = body['streamId']
|
||||
print("Read Stream" + str(stream_id))
|
||||
stream = app.streams.get(stream_id)
|
||||
if stream is None:
|
||||
await send({'error': 'bad stream id: ' + str(stream_id), 'nonce': nonce})
|
||||
else:
|
||||
async def chunk_fn(chunk):
|
||||
await send({'data': chunk, 'eof': False, 'nonce': nonce})
|
||||
async def eof_fn():
|
||||
await send({'eof': True, 'fullData': stream.content, 'nonce': nonce})
|
||||
stream.listen(chunk_fn, eof_fn)
|
||||
elif action == "cancel-agent-run":
|
||||
await app.cancel_agent_run(body['runId'])
|
||||
|
||||
elif action == "create-chat":
|
||||
chat_id = await app.create_chat(
|
||||
@@ -315,12 +301,6 @@ async def start_server(app):
|
||||
response = await response.content_wait()
|
||||
await send({'message': "prompt sent", 'response': response, 'nonce': nonce})
|
||||
|
||||
elif action == "get-agent-runs":
|
||||
await send({
|
||||
'runs': await app.get_agent_runs(agent_id=body.get('agentId'), user_id=user_id),
|
||||
'nonce': nonce
|
||||
})
|
||||
|
||||
elif action == "read-stream":
|
||||
stream_id = body['streamId']
|
||||
print("Read Stream" + str(stream_id))
|
||||
|
||||
Reference in new issue
Block a user