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