File size: 1,382 Bytes
fbf27f6
 
 
5757af2
 
fbf27f6
 
 
3872b2f
d198812
91afb60
cdf2804
 
5757af2
91afb60
2da1cbe
5757af2
2da1cbe
 
 
5757af2
91afb60
225675b
2da1cbe
5757af2
fbf27f6
5757af2
fbf27f6
 
b0365bd
fbf27f6
b0365bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
from functions import random_plot, add_message, chat_mem, print_like_dislike

# Ambil pesan awal dari chat_mem
initial_messages = [(None, "Selamat datang di chatbot Nopiyar.my.id! Ada yang bisa saya bantu?")]
fig = random_plot()

# Membuat antarmuka Gradio
with gr.Blocks(fill_height=True, css="footer {visibility: hidden}") as demo:
    gr.HTML("<div style='text-align: center;'><h2>Chat bot Nopiyar.my.id</h2></div>")  # Menambahkan judul di sini dengan CSS untuk memposisikan di tengah
    chatbot = gr.Chatbot(
        label="NPR",
        elem_id="chatbot",
        bubble_full_width=True,
        scale=1,
        avatar_images=(None, "https://iili.io/d5tk44a.md.png"),
        placeholder="Masukkan pesan...",
        render_markdown=True,
        sanitize_html=True,
        show_copy_button=True,
        value=initial_messages
    )
    
    chat_input = gr.Textbox(interactive=True, placeholder="Masukkan pesan...", show_label=False)
    
    chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
    bot_msg = chat_msg.then(chat_mem, inputs=[chat_input, chatbot], outputs=[chat_input, chatbot], api_name="bot_response")
    bot_msg.then(lambda: gr.Textbox(interactive=True), None, [chat_input])

    chatbot.like(print_like_dislike, None, None)  # Menjaga fitur like (tetap bisa digunakan jika perlu)

demo.launch()