Spaces:
Runtime error
Runtime error
Finally FInaly
Browse files
app.py
CHANGED
@@ -47,38 +47,37 @@ def update_images(image_component, directory="/home/user/app/"):
|
|
47 |
return png_files[0]
|
48 |
return "No images available"
|
49 |
|
|
|
50 |
def create_chat_widget():
|
51 |
with gr.Blocks() as chatblock:
|
52 |
-
#
|
53 |
-
|
54 |
-
|
55 |
-
"
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
bubble_full_width=False,
|
69 |
-
height=600,
|
70 |
-
)
|
71 |
-
|
72 |
-
|
73 |
with gr.Row():
|
74 |
-
txt = gr.Textbox(
|
75 |
-
placeholder="Enter text and press enter to chat with the bot.",
|
76 |
-
show_label=False,
|
77 |
-
)
|
78 |
send_button = gr.Button("Send")
|
79 |
txt.submit(update_bot, inputs=[txt, chatbot], outputs=[chatbot, txt])
|
80 |
send_button.click(update_bot, inputs=[txt, chatbot], outputs=[chatbot, txt])
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
# Image display row
|
83 |
with gr.Row():
|
84 |
image_display = gr.Image()
|
@@ -86,6 +85,9 @@ def create_chat_widget():
|
|
86 |
update_image_button.click(update_images, inputs=[], outputs=image_display)
|
87 |
|
88 |
return chatblock
|
|
|
|
|
|
|
89 |
|
90 |
|
91 |
def update_bot(text, chatbot):
|
|
|
47 |
return png_files[0]
|
48 |
return "No images available"
|
49 |
|
50 |
+
|
51 |
def create_chat_widget():
|
52 |
with gr.Blocks() as chatblock:
|
53 |
+
# Declare chatbot and txt here so they are accessible later
|
54 |
+
chatbot = gr.Chatbot(
|
55 |
+
[],
|
56 |
+
elem_id="gpt4",
|
57 |
+
elem_classes="gpt4",
|
58 |
+
layout="llm",
|
59 |
+
bubble_full_width=False,
|
60 |
+
height=600,
|
61 |
+
)
|
62 |
+
txt = gr.Textbox(
|
63 |
+
placeholder="Enter text and press enter to chat with the bot.",
|
64 |
+
show_label=False,
|
65 |
+
)
|
66 |
+
|
67 |
+
|
68 |
+
# Main chat interface row
|
|
|
|
|
|
|
|
|
|
|
69 |
with gr.Row():
|
|
|
|
|
|
|
|
|
70 |
send_button = gr.Button("Send")
|
71 |
txt.submit(update_bot, inputs=[txt, chatbot], outputs=[chatbot, txt])
|
72 |
send_button.click(update_bot, inputs=[txt, chatbot], outputs=[chatbot, txt])
|
73 |
|
74 |
+
|
75 |
+
# Adding a row for the New Chat button at the top
|
76 |
+
with gr.Row():
|
77 |
+
new_chat_button = gr.Button("New Chat", scale=3, interactive=True)
|
78 |
+
# Ensure new_chat function resets both chatbot and txt components
|
79 |
+
new_chat_button.click(new_chat, inputs=[], outputs=[chatbot, txt])
|
80 |
+
|
81 |
# Image display row
|
82 |
with gr.Row():
|
83 |
image_display = gr.Image()
|
|
|
85 |
update_image_button.click(update_images, inputs=[], outputs=image_display)
|
86 |
|
87 |
return chatblock
|
88 |
+
|
89 |
+
def new_chat():
|
90 |
+
return [], ""
|
91 |
|
92 |
|
93 |
def update_bot(text, chatbot):
|