Vitrous commited on
Commit
e4ec528
1 Parent(s): 95e8cfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -91,17 +91,19 @@ def print_like_dislike(x: gr.LikeData):
91
 
92
  # Function to add messages to the chat history
93
  def add_message(history, message, files):
94
- for file in files:
95
- history.append(((file,), None))
 
96
  if message is not None:
97
  history.append((message, None))
98
  return history, gr.update(value=None, interactive=True)
99
 
100
  # Function to simulate the bot response
101
  def bot(history):
102
- user_message = history[-1][0]
103
- bot_response = chat_response(user_message)
104
- history[-1][1] = bot_response
 
105
  return history
106
 
107
  fig = random_plot()
 
91
 
92
  # Function to add messages to the chat history
93
  def add_message(history, message, files):
94
+ if files is not None:
95
+ for file in files:
96
+ history.append(((file,), None))
97
  if message is not None:
98
  history.append((message, None))
99
  return history, gr.update(value=None, interactive=True)
100
 
101
  # Function to simulate the bot response
102
  def bot(history):
103
+ if history:
104
+ user_message = history[-1][0]
105
+ bot_response = chat_response(user_message)
106
+ history[-1][1] = bot_response
107
  return history
108
 
109
  fig = random_plot()