提交 660f8c67 作者: hzg0601

修改stream_chat的接口,在请求体中选择knowledge_base_id;增加stream_chat_bing接口

上级 987f5518
...@@ -305,7 +305,7 @@ async def chat( ...@@ -305,7 +305,7 @@ async def chat(
) )
async def stream_chat(websocket: WebSocket, knowledge_base_id: str): async def stream_chat(websocket: WebSocket):
await websocket.accept() await websocket.accept()
turn = 1 turn = 1
while True: while True:
...@@ -408,11 +408,15 @@ def api_start(host, port): ...@@ -408,11 +408,15 @@ def api_start(host, port):
allow_methods=["*"], allow_methods=["*"],
allow_headers=["*"], allow_headers=["*"],
) )
app.websocket("/local_doc_qa/stream-chat/{knowledge_base_id}")(stream_chat) # 修改了stream_chat的接口,直接通过ws://localhost:7861/local_doc_qa/stream_chat建立连接,在请求体中选择knowledge_base_id
app.websocket("/local_doc_qa/stream_chat")(stream_chat)
app.get("/", response_model=BaseResponse)(document) app.get("/", response_model=BaseResponse)(document)
# # 增加基于bing搜索的流式问答 # 增加基于bing搜索的流式问答
# 需要说明的是,如果想测试websocket的流式问答,需要使用支持websocket的测试工具,如postman,insomnia
# 强烈推荐开源的insomnia
# 在测试时选择new websocket request,并将url的协议改为ws,如ws://localhost:7861/local_doc_qa/stream_chat_bing
app.websocket("/local_doc_qa/stream_chat_bing")(stream_chat_bing) app.websocket("/local_doc_qa/stream_chat_bing")(stream_chat_bing)
app.post("/chat", response_model=ChatMessage)(chat) app.post("/chat", response_model=ChatMessage)(chat)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论