Langchain-Chatchat icon indicating copy to clipboard operation
Langchain-Chatchat copied to clipboard

API版本能否提供WEBSOCKET的流式接口

Open wangts108 opened this issue 1 year ago • 25 comments

webui 版本中,采用了WS的流式输出,整体感知反应很快 api版本中chat接口是get请求的,要等到内容全部响应完成才输出,等待时间过长

wangts108 avatar May 25 '23 02:05 wangts108

api.py中是有websocket接口的

imClumsyPanda avatar May 25 '23 02:05 imClumsyPanda

api版本中chat接口是否可以返回回复

webui 版本中,采用了WS的流式输出,整体感知反应很快 api版本中chat接口是get请求的,要等到内容全部响应完成才输出,等待时间过长

aappaappoo avatar May 25 '23 08:05 aappaappoo

api.py 有的,不过文档没有,我用postman试过 没有问题。你搜索stream_chat 就可以看到

shaolongcai avatar May 25 '23 13:05 shaolongcai

请问postman的stream_chat如何测试?我这边一直报403错误

evanweiguohua avatar May 25 '23 13:05 evanweiguohua

补充一下:测试用的url为:ws://3e78s46749.imdo.co:18101/stream-chat/motor_t700s,motor_t700s是我用接口上传的一个小的知识库

evanweiguohua avatar May 25 '23 13:05 evanweiguohua

补充一下:测试用的url为:ws://3e78s46749.imdo.co:18101/stream-chat/motor_t700s,motor_t700s是我用接口上传的一个小的知识库

我看了一下接口应该是:/local_doc_qa/stream-chat/{knowledge_base_id}。 你打开postman新开一个ws的请求,然后链接填 {公网ip:端口}/local_doc_qa/stream-chat/test1 ,message选择JSON image

shaolongcai avatar May 25 '23 13:05 shaolongcai

have a similar question about the api request, https://github.com/imClumsyPanda/langchain-ChatGLM/issues/465

ucas010 avatar May 26 '23 07:05 ucas010

+1 报错 返回Status Code: 400 Bad Request

tomiezhang avatar Jun 05 '23 06:06 tomiezhang

搞定了,postman里要在url前面显式的加一下wss:// url:port//local_doc_qa/stream-chat/{knowledge_base_id} 要不默认是http去请求。。。 脑残

tomiezhang avatar Jun 05 '23 06:06 tomiezhang

@tomiezhang @imClumsyPanda @Ayo616 @ucas010

问一下,stream-chat函数能使用curl1调用吗? 我下面这样调用,为什么报错:

curl -X 'POST'
'http://127.0.0.1:8000/local_doc_qa/stream-chat/baoxian_FAISS_20230602_172352'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-d '{ "question": "卡塔尔世界杯冠军是谁", "history": [], "knowledge_base_id": "baoxian_FAISS_20230602_172352", }'

cristianohello avatar Jun 07 '23 02:06 cristianohello

stream-chat流式调用应该用的是websocket吧? 所以应该是ws://ip:port/local_doc_qa/stream-chat/{knowledge_base_id}, 我认为应该是这样的,我还没测

wufxgtihub123 avatar Jun 07 '23 06:06 wufxgtihub123

@wufxgtihub123 大佬,问一下,启动api.py后,具体是怎么调用的呢?

cristianohello avatar Jun 08 '23 06:06 cristianohello

测试结果不对: ws://172.168.705.72:861/local_doc_qa/stream-chat/100270 { "question": "向量数据库是什么?", "history": [], "knowledge_base_id": "100270" } 返回: { "detail": "Not Found" }

ucas010 avatar Jun 09 '23 03:06 ucas010

url里去掉knowledge_id之后是可行的吗

Lychee X @.***>于2023年6月9日 周五11:41写道:

测试结果不对: ws://172.168.705.72:861/local_doc_qa/stream-chat/100270 { "question": "向量数据库是什么?", "history": [], "knowledge_base_id": "100270" } 返回: { "detail": "Not Found" }

— Reply to this email directly, view it on GitHub https://github.com/imClumsyPanda/langchain-ChatGLM/issues/464#issuecomment-1583922143, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLH5EQE2AEIIVMWTD3EP63XKKLNTANCNFSM6AAAAAAYOFMSOY . You are receiving this because you were mentioned.Message ID: @.***>

imClumsyPanda avatar Jun 09 '23 03:06 imClumsyPanda

No image

@imClumsyPanda

ucas010 avatar Jun 09 '23 03:06 ucas010

前面的post选项换掉,建议使用postman进行测试,apifox好像暂时不支持websocket测试

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Lychee X @.> 发送时间: 2023年6月9日 11:41 收件人: imClumsyPanda/langchain-ChatGLM @.> 抄送: Flylyy @.>, Mention @.> 主题: Re: [imClumsyPanda/langchain-ChatGLM] API版本能否提供WEBSOCKET的流式接口 (Issue #464)

测试结果不对: ws://172.168.705.72:861/local_doc_qa/stream-chat/100270 { "question": "向量数据库是什么?", "history": [], "knowledge_base_id": "100270" } 返回: { "detail": "Not Found" }

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

wufxgtihub123 avatar Jun 09 '23 03:06 wufxgtihub123

post换成啥?我这就是postman

ucas010 avatar Jun 09 '23 04:06 ucas010

post换成啥?我这就是postman

image 这样试一下

wufxgtihub123 avatar Jun 09 '23 04:06 wufxgtihub123

image

ucas010 avatar Jun 09 '23 05:06 ucas010

image

我的url后面跟了knowledge-base-id是可以调通的,你加上knowledge-base-id试一下?

wufxgtihub123 avatar Jun 09 '23 05:06 wufxgtihub123

返回数据呢? connected,,, image

ucas010 avatar Jun 09 '23 06:06 ucas010

返回数据呢? connected,,, image

image connect后有没有点击发送?

wufxgtihub123 avatar Jun 09 '23 06:06 wufxgtihub123

点击send后断开链接了,,, image

ucas010 avatar Jun 09 '23 06:06 ucas010

点击send后断开链接了,,, image

看下后端服务有无报错信息?

wufxgtihub123 avatar Jun 09 '23 06:06 wufxgtihub123

OK了,感谢 @wufxgtihub123 @wufxgtihub123

ucas010 avatar Jun 09 '23 06:06 ucas010

OK了,感谢 @wufxgtihub123 @wufxgtihub123

请问下这个base-id是从哪里得到的?我的只有个base-name,另外ip地址设置的位置是那些地方?,我设置server_config.p里面的DEFAULT_BIND_HOST为0.0.0.0之后就报错了

brealisty avatar Sep 12 '23 10:09 brealisty

我怎么搜索不到WEBSOCKET的接口,stream_chat还有吗,哪个分支

duanfakai avatar Sep 21 '23 09:09 duanfakai