From a8455ca8a3ba44a04ba58e15b075a2a963d72231 Mon Sep 17 00:00:00 2001 From: jingyaogong Date: Sun, 4 Jan 2026 11:03:16 +0800 Subject: [PATCH] [fix] messages num --- scripts/chat_openai_api.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/chat_openai_api.py b/scripts/chat_openai_api.py index 57f61c9..d677835 100644 --- a/scripts/chat_openai_api.py +++ b/scripts/chat_openai_api.py @@ -7,14 +7,17 @@ client = OpenAI( stream = True conversation_history_origin = [] conversation_history = conversation_history_origin.copy() -history_messages_num = 2 # 设置为偶数(Q+A),为0则每次不携带历史对话进行独立QA +history_messages_num = 0 # 必须设置为偶数(Q+A),为0则不携带历史对话 while True: query = input('[Q]: ') conversation_history.append({"role": "user", "content": query}) response = client.chat.completions.create( model="minimind", - messages=conversation_history[-history_messages_num:], - stream=stream + messages=conversation_history[-(history_messages_num or 1):], + stream=stream, + temperature=0.7, + max_tokens=2048, + top_p=0.9 ) if not stream: assistant_res = response.choices[0].message.content