mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-02 01:27:14 +00:00
fix(core): Move the last user's information to the end (#960)
This commit is contained in:
13
dbgpt/model/proxy/llms/bard.py
Normal file → Executable file
13
dbgpt/model/proxy/llms/bard.py
Normal file → Executable file
@@ -25,14 +25,13 @@ def bard_generate_stream(
|
||||
else:
|
||||
pass
|
||||
|
||||
temp_his = history[::-1]
|
||||
last_user_input = None
|
||||
for m in temp_his:
|
||||
if m["role"] == "user":
|
||||
last_user_input = m
|
||||
last_user_input_index = None
|
||||
for i in range(len(history) - 1, -1, -1):
|
||||
if history[i]["role"] == "user":
|
||||
last_user_input_index = i
|
||||
break
|
||||
if last_user_input:
|
||||
history.remove(last_user_input)
|
||||
if last_user_input_index:
|
||||
last_user_input = history.pop(last_user_input_index)
|
||||
history.append(last_user_input)
|
||||
|
||||
msgs = []
|
||||
|
13
dbgpt/model/proxy/llms/chatgpt.py
Normal file → Executable file
13
dbgpt/model/proxy/llms/chatgpt.py
Normal file → Executable file
@@ -110,14 +110,13 @@ def _build_request(model: ProxyModel, params):
|
||||
pass
|
||||
|
||||
# Move the last user's information to the end
|
||||
temp_his = history[::-1]
|
||||
last_user_input = None
|
||||
for m in temp_his:
|
||||
if m["role"] == "user":
|
||||
last_user_input = m
|
||||
last_user_input_index = None
|
||||
for i in range(len(history) - 1, -1, -1):
|
||||
if history[i]["role"] == "user":
|
||||
last_user_input_index = i
|
||||
break
|
||||
if last_user_input:
|
||||
history.remove(last_user_input)
|
||||
if last_user_input_index:
|
||||
last_user_input = history.pop(last_user_input_index)
|
||||
history.append(last_user_input)
|
||||
|
||||
payloads = {
|
||||
|
Reference in New Issue
Block a user