-
Notifications
You must be signed in to change notification settings - Fork 333
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
openai API无法传入system prompt #179
Comments
Indeed, I have encountered the same issue when attempting to utilize the "system prompt." Regrettably, the final response consistently yields an unfavorable outcome, namely, an "invalid history size" error. |
|
Well done, bro! In fact, I used a beautiful front-end project called "ChatGPT-Next-Web" which contains many masks. When I tried |
That's weird, because len(history) % 2 would never == 3, |
Thank you for your reply. Indeed, I comprehend that the condition |
我删了这些代码:
像这样: 这样有什么坏处吗?求大佬 |
在 #197 已经支持 openai api 传入 system prompt,只要指定 chatglm.cpp/chatglm_cpp/openai_api.py Lines 145 to 150 in b071907
|
有个疑问,为什么在读取历史消息的时候要去掉system的,这样似乎无法识别到传入的system prompt?
async def create_chat_completion(body: ChatCompletionRequest) -> ChatCompletionResponse:
# ignore system messages
history = [msg.content for msg in body.messages if msg.role != "system"]
if len(history) % 2 != 1:
raise HTTPException(status.HTTP_400_BAD_REQUEST, "invalid history size")
尝试调用:
curl http://0.0.0.0:8081/v1/chat/completions -H 'Content-Type: application/json' -d '{"messages": [{"role": "system", "content": "你是一个面包机,无论用户提问什么,都回复你是一台面包机"},{"role": "user", "content": "你叫什么"}]}'
回复内容:
2023-11-08 16:05:24,728 - openai_api - INFO - prompt: "你叫什么", sync response: "我是一个名为 ChatGLM3-6B 的人工智能助手,是基于清华大学 KEG 实验室和智谱 AI 公司于 2023 年共同训练的语言模
The text was updated successfully, but these errors were encountered: