yentinglin commited on
Commit
a0b0fa4
1 Parent(s): 5fa64e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -137,8 +137,10 @@ with gr.Blocks() as demo:
137
  def bot(history, max_new_tokens, temperature, top_p, system_prompt):
138
  messages = [{"role": "system", "content": system_prompt}]
139
  for user, bot in history:
140
- messages.append({"role": "user", "content": user})
141
- messages.append({"role": "assistant", "content": bot})
 
 
142
 
143
  history[-1][1] = ""
144
  response = openai.ChatCompletion.create(
 
137
  def bot(history, max_new_tokens, temperature, top_p, system_prompt):
138
  messages = [{"role": "system", "content": system_prompt}]
139
  for user, bot in history:
140
+ if user is not None:
141
+ messages.append({"role": "user", "content": user})
142
+ if bot is not None:
143
+ messages.append({"role": "assistant", "content": bot})
144
 
145
  history[-1][1] = ""
146
  response = openai.ChatCompletion.create(