This commit is contained in:
2025-02-24 19:51:35 +08:00
parent 336f3b2b34
commit 89728ada0b
2 changed files with 284 additions and 3 deletions

View File

@@ -220,8 +220,8 @@ async def chat(websocket: WebSocket):
async for message in stream:
if isinstance(message, TaskResult):
continue
print(f"----------------{message.source}----------------\n {message.content}")
if message.type == 'TextMessage' and message.type == 'HandoffMessage':
if message.type == 'TextMessage' or message.type == 'HandoffMessage':
print(f"----------------{message.source}----------------\n {message.content}")
await websocket.send_json(message.model_dump())
if not isinstance(message, UserInputRequestedEvent):
history.append(message.model_dump())
@@ -338,7 +338,8 @@ async def websocket_endpoint(websocket: WebSocket, camera_id: str):
send_task.cancel()
await asyncio.gather(capture_task, send_task, return_exceptions=True)
finally:
process.kill()
if process and process.poll() is None: # Check if the process is still running
process.kill()
await websocket.close()