mirror of
https://github.com/QwenLM/Qwen.git
synced 2026-05-21 00:45:48 +08:00
add stop word on openai api ChatCompletion
This commit is contained in:
@@ -323,6 +323,7 @@ for chunk in openai.ChatCompletion.create(
|
||||
{"role": "user", "content": "你好"}
|
||||
],
|
||||
stream=True
|
||||
# 流式输出的自定义stopwords功能尚未支持,正在开发中
|
||||
):
|
||||
if hasattr(chunk.choices[0].delta, "content"):
|
||||
print(chunk.choices[0].delta.content, end="", flush=True)
|
||||
@@ -333,7 +334,8 @@ response = openai.ChatCompletion.create(
|
||||
messages=[
|
||||
{"role": "user", "content": "你好"}
|
||||
],
|
||||
stream=False
|
||||
stream=False,
|
||||
stop=[] # 在此处添加自定义的stop words 例如ReAct prompting时需要增加: stop=["Observation:"]。
|
||||
)
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user