Commit 1e9efa79 by 陈正乐

在更新历史的时候判断question和answer是否为空

parent 194e12f2
......@@ -82,10 +82,13 @@ class QA:
return self.history
def update_history(self):
self.history.append((self.cur_question, self.cur_answer))
self.crud.update_last(chat_id=self.chat_id)
self.crud.insert_turn_qa(chat_id=self.chat_id, question=self.cur_question, answer=self.cur_answer,
turn_number=len(self.history), is_last=1)
if self.cur_question == '' and self.cur_answer == '':
pass
else:
self.history.append((self.cur_question, self.cur_answer))
self.crud.update_last(chat_id=self.chat_id)
self.crud.insert_turn_qa(chat_id=self.chat_id, question=self.cur_question, answer=self.cur_answer,
turn_number=len(self.history), is_last=1)
if __name__ == "__main__":
......
from src.server.qa import chat
print(chat("当别人想你说你好的时候,你也应该说你好", "你好"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment