xu song commited on
Commit
2e49897
1 Parent(s): d89d143
Files changed (1) hide show
  1. app_util.py +4 -5
app_util.py CHANGED
@@ -34,17 +34,16 @@ def generate_query(chatbot, history):
34
  yield query, chatbot, history
35
 
36
 
37
- def generate_response(query, chatbot, history):
38
  """
39
  auto-mode:query is None
40
  manual-mode:query 是用户输入
41
- :param query:
42
  :param chatbot:
43
  :param history:
44
  :return:
45
  """
46
- if query and history[-1]["role"] != "user":
47
- history.append({"role": "user", "content": query})
48
  query = history[-1]["content"]
49
 
50
  if history[-1]["role"] != "user":
@@ -64,7 +63,7 @@ def generate_response(query, chatbot, history):
64
 
65
  def generate(chatbot, history):
66
  if history[-1]["role"] == "assistant":
67
- return generate_query(chatbot, history)
68
  elif history[-1]["role"] in ["user", "system"]:
69
  return generate_query(chatbot, history)
70
  else:
 
34
  yield query, chatbot, history
35
 
36
 
37
+ def generate_response(chatbot, history, user_input=None):
38
  """
39
  auto-mode:query is None
40
  manual-mode:query 是用户输入
 
41
  :param chatbot:
42
  :param history:
43
  :return:
44
  """
45
+ if user_input and history[-1]["role"] != "user":
46
+ history.append({"role": "user", "content": user_input})
47
  query = history[-1]["content"]
48
 
49
  if history[-1]["role"] != "user":
 
63
 
64
  def generate(chatbot, history):
65
  if history[-1]["role"] == "assistant":
66
+ return generate_response(chatbot, history)
67
  elif history[-1]["role"] in ["user", "system"]:
68
  return generate_query(chatbot, history)
69
  else: