Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

本地部署 chatglm3 6B, api 官方案列,关闭流式回复就出错 #1

Open
YunFenLei opened this issue Nov 8, 2023 · 0 comments

Comments

@YunFenLei
Copy link

OS: Ubuntu 22.04.2 LTS
GPU: 3090
描述:按照官方指导部署在本地,
以下为示例代码:
import openai
if name == "main":
openai.api_base = "http://192.168.100.118:8000/v1"
openai.api_key = "none"
for chunk in openai.ChatCompletion.create(
model="chatglm3-6b",
messages=[
{"role": "user", "content": "李焕英"}
],
stream=False
):
if hasattr(chunk.choices[0].delta, "content"):
print(chunk.choices[0].delta.content, end="", flush=True)

如果 stream=True 那回复内容正常。
如果 stream=False
就会出错,信息如下:

Traceback (most recent call last):
File "D:\python提交到qingyingkj\ooo.py", line 12, in
if hasattr(chunk.choices[0].delta, "content"):
AttributeError: 'str' object has no attribute 'choices'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant