fix: 应用对话时如何模型未正确输出优化问题,则使用原问题进行问答

#13
This commit is contained in:
shaohuzhang1 2024-03-25 10:45:15 +08:00
parent e9fbe1b13b
commit f1b04e8a1b

View File

@ -28,7 +28,9 @@ class BaseResetProblemStep(IResetProblemStep):
range(start_index if start_index > 0 else 0, len(history_chat_record))]
message_list = [*flat_map(history_message),
HumanMessage(content=prompt.format(**{'question': problem_text}))]
response = chat_model(message_list)
response = chat_model.invoke(message_list)
padding_problem = problem_text
if response.content.__contains__("<data>") and response.content.__contains__('</data>'):
padding_problem = response.content[response.content.index('<data>') + 6:response.content.index('</data>')]
self.context['message_tokens'] = chat_model.get_num_tokens_from_messages(message_list)
self.context['answer_tokens'] = chat_model.get_num_tokens(padding_problem)