修改stream_chat的接口,在请求体中选择knowledge_base_id;增加stream_chat_bing接口
This commit is contained in:
parent
987f5518f2
commit
660f8c6715
10
api.py
10
api.py
|
|
@ -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):
|
||||||
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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue