修正newbing交互的不合理代码

This commit is contained in:
binary-husky 2023-04-24 20:14:23 +08:00
parent 8f571ff68f
commit 8e59412c47

View File

@ -88,14 +88,14 @@ class NewBingHandle(Process):
if a not in self.local_history: if a not in self.local_history:
self.local_history.append(a) self.local_history.append(a)
prompt += a + '\n' prompt += a + '\n'
if b not in self.local_history: # if b not in self.local_history:
self.local_history.append(b) # self.local_history.append(b)
prompt += b + '\n' # prompt += b + '\n'
# 问题 # 问题
prompt += question prompt += question
self.local_history.append(question) self.local_history.append(question)
print('question:', question)
# 提交 # 提交
async for final, response in self.newbing_model.ask_stream( async for final, response in self.newbing_model.ask_stream(
prompt=question, prompt=question,
@ -108,7 +108,8 @@ class NewBingHandle(Process):
else: else:
print('-------- receive final ---------') print('-------- receive final ---------')
self.child.send('[Finish]') self.child.send('[Finish]')
# self.local_history.append(response)
def run(self): def run(self):
""" """
@ -245,6 +246,6 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
chatbot[-1] = (inputs, preprocess_newbing_out(response)) chatbot[-1] = (inputs, preprocess_newbing_out(response))
yield from update_ui(chatbot=chatbot, history=history, msg="NewBing响应缓慢尚未完成全部响应请耐心完成后再提交新问题。") yield from update_ui(chatbot=chatbot, history=history, msg="NewBing响应缓慢尚未完成全部响应请耐心完成后再提交新问题。")
history.extend([inputs, preprocess_newbing_out(response)]) history.extend([inputs, response])
yield from update_ui(chatbot=chatbot, history=history, msg="完成全部响应,请提交新问题。") yield from update_ui(chatbot=chatbot, history=history, msg="完成全部响应,请提交新问题。")