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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -90,11 +90,11 @@ def print_like_dislike(x: gr.LikeData):
90
  print(x.index, x.value, x.liked)
91
 
92
  # Function to add messages to the chat history
93
- def add_message(history, message):
94
- for x in message["files"]:
95
- history.append(((x,), None))
96
- if message["text"] is not None:
97
- history.append((message["text"], None))
98
  return history, gr.update(value=None, interactive=True)
99
 
100
  # Function to simulate the bot response
@@ -110,18 +110,15 @@ fig = random_plot()
110
  with gr.Blocks(fill_height=True) as demo:
111
  chatbot = gr.Chatbot(elem_id="chatbot", bubble_full_width=False, scale=1)
112
 
113
- chat_input = gr.MultimodalTextbox(
114
- interactive=True,
115
- file_count="multiple",
116
- placeholder="Enter message or upload file...",
117
- show_label=False
118
- )
119
 
120
- chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
121
  bot_msg = chat_msg.then(bot, chatbot, chatbot)
122
  bot_msg.then(lambda: gr.update(interactive=True), None, [chat_input])
123
 
124
  chatbot.like(print_like_dislike, None, None)
125
 
126
  demo.queue()
127
- demo.launch()
 
90
  print(x.index, x.value, x.liked)
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
 
110
  with gr.Blocks(fill_height=True) as demo:
111
  chatbot = gr.Chatbot(elem_id="chatbot", bubble_full_width=False, scale=1)
112
 
113
+ with gr.Row():
114
+ chat_input = gr.Textbox(placeholder="Enter message...", show_label=False)
115
+ file_input = gr.File(label="Upload file(s)", file_count="multiple")
 
 
 
116
 
117
+ chat_msg = chat_input.submit(add_message, [chatbot, chat_input, file_input], [chatbot, chat_input])
118
  bot_msg = chat_msg.then(bot, chatbot, chatbot)
119
  bot_msg.then(lambda: gr.update(interactive=True), None, [chat_input])
120
 
121
  chatbot.like(print_like_dislike, None, None)
122
 
123
  demo.queue()
124
+ demo.launch()