Spaces:
Paused
Paused
Update app.py
Browse files
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
|
95 |
-
history.append(((
|
96 |
-
if message
|
97 |
-
history.append((message
|
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 |
-
|
114 |
-
|
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()
|