THUDM / ChatGLM2-6B

ChatGLM2-6B: An Open Bilingual Chat LLM | 开源双语对话语言模型
Other
15.68k stars 1.85k forks source link

[BUG/Help] Readme中进行 openapi-api的API 调用的示例代码报错 #611

Open yecllsl opened 10 months ago

yecllsl commented 10 months ago

Is there an existing issue for this?

Current Behavior

运行python openai_api.py后,客户端运行Readme给的代码有误,报错requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read)) 。将stream=true改为false,正常返回,但报AttributeError: 'str' object has no attribute 'choices'错误。

Expected Behavior

No response

Steps To Reproduce

客户端运行Readme给的代码有误,报错requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read)) 。将stream=true改为false,正常返回,但报AttributeError: 'str' object has no attribute 'choices'错误。

Environment

- OS:Windows
- Python:3.10
- Transformers:4.30.2
- PyTorch:2.1.0+cpu
- CUDA Support (`python -c "import torch; print(torch.cuda.is_available())"`) :cpu

Anything else?

No response

XuHandsome commented 9 months ago

+1, 同样的问题。升级openai库到最新后, 报错 Data returned by API invalid for expected schema.

手动curl接口正常返回

XuHandsome commented 9 months ago

找到了解决方法 首先制定版本pip install openai==0.28.0 然后按照issue修改代码即可