tamplate
Browse files
main.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from functions import random_plot, add_message, chat_mem, print_like_dislike
|
3 |
+
|
4 |
+
fig = random_plot()
|
5 |
+
|
6 |
+
# Membuat antarmuka Gradio
|
7 |
+
with gr.Blocks(fill_height=True) as demo:
|
8 |
+
chatbot = gr.Chatbot(
|
9 |
+
elem_id="chatbot",
|
10 |
+
bubble_full_width=False,
|
11 |
+
scale=1,
|
12 |
+
)
|
13 |
+
|
14 |
+
chat_input = gr.Textbox(interactive=True,
|
15 |
+
placeholder="Enter message...", show_label=False)
|
16 |
+
|
17 |
+
chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
|
18 |
+
bot_msg = chat_msg.then(chat_mem, inputs=[chat_input, chatbot], outputs=[chat_input, chatbot], api_name="bot_response")
|
19 |
+
bot_msg.then(lambda: gr.Textbox(interactive=True), None, [chat_input])
|
20 |
+
|
21 |
+
chatbot.like(print_like_dislike, None, None)
|
22 |
+
|
23 |
+
demo.launch()
|