删除多余代码

This commit is contained in:
高子兴 2024-10-26 14:49:46 +08:00
parent 28cfe06155
commit d661cad5ca

View File

@ -29,10 +29,6 @@ class ConnectionManager:
async def send_personal_message(message: str, websocket: WebSocket): async def send_personal_message(message: str, websocket: WebSocket):
await websocket.send_text(message) await websocket.send_text(message)
async def broadcast(self, message: str):
for connection in self.active_connections:
await connection.send_text(message)
async def broadcast_json(self, data: dict): async def broadcast_json(self, data: dict):
for connection in self.active_connections: for connection in self.active_connections:
await connection.send_json(data) await connection.send_json(data)
@ -94,7 +90,6 @@ async def predict(file: UploadFile = File(...)):
if content: if content:
yield content yield content
# 同时将内容广播给所有WebSocket连接的客户端 # 同时将内容广播给所有WebSocket连接的客户端
# await manager.broadcast(content)
await manager.broadcast_json({"type": "text", "content": content}) await manager.broadcast_json({"type": "text", "content": content})
return StreamingResponse(stream_response(), media_type="text/plain") return StreamingResponse(stream_response(), media_type="text/plain")