From 7da201a944a90ed49daef8a0265c959288dff83a Mon Sep 17 00:00:00 2001
From: jingyaogong <gongjy.cs@qq.com>
Date: Fri, 18 Apr 2025 12:43:57 +0800
Subject: [PATCH] update chat-openai-api

---
 scripts/chat_openai_api.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/chat_openai_api.py b/scripts/chat_openai_api.py
index 4ad5e55..2f2bc53 100644
--- a/scripts/chat_openai_api.py
+++ b/scripts/chat_openai_api.py
@@ -7,13 +7,13 @@ client = OpenAI(
 stream = True
 conversation_history_origin = []
 conversation_history = conversation_history_origin.copy()
+history_messages_num = 2  # 设置为偶数(Q+A),为0则每次不携带历史对话进行独立QA
 while True:
-    conversation_history = conversation_history_origin.copy()
     query = input('[Q]: ')
     conversation_history.append({"role": "user", "content": query})
     response = client.chat.completions.create(
         model="minimind",
-        messages=conversation_history,
+        messages=conversation_history[-history_messages_num:],
         stream=stream
     )
     if not stream: