Zenithwang commited on
Commit
0122097
1 Parent(s): b282751

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -42,7 +42,7 @@ system_prompt = f"<|im_start|>{system_role}\n{system_prompt}<|im_end|>"
42
  @spaces.GPU()
43
  def predict(message, history):
44
  # history = []
45
- history_transformer_format = history + [[message, ""]]
46
  stop = StopOnTokens()
47
 
48
  # Formatting the input for the model.
@@ -50,9 +50,11 @@ def predict(message, history):
50
  # for item in history_transformer_format])
51
 
52
  model_messages = []
53
- for item in history_transformer_format:
 
54
  model_messages.append({"role": user_role, "content": item[0]})
55
- model_messages.append({"role": assistant_role, "content": item[1]})
 
56
 
57
  print(f'model_messages: {model_messages}')
58
 
 
42
  @spaces.GPU()
43
  def predict(message, history):
44
  # history = []
45
+ # history_transformer_format = history + [[message, ""]]
46
  stop = StopOnTokens()
47
 
48
  # Formatting the input for the model.
 
50
  # for item in history_transformer_format])
51
 
52
  model_messages = []
53
+ print(f'history: {history}')
54
+ for i, item in enumerate(history):
55
  model_messages.append({"role": user_role, "content": item[0]})
56
+ if i < len(history) - 1:
57
+ model_messages.append({"role": assistant_role, "content": item[1]})
58
 
59
  print(f'model_messages: {model_messages}')
60