File size: 2,231 Bytes
2263ee0
 
 
afde740
 
 
 
 
 
 
 
d1e236b
 
 
 
 
 
afde740
d1e236b
 
 
 
afde740
 
d1e236b
 
 
 
 
 
 
 
 
 
 
afde740
2263ee0
afde740
d1e236b
 
 
 
 
 
 
 
 
afde740
2263ee0
 
 
 
 
d1e236b
afde740
d1e236b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2263ee0
afde740
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import gradio as gr
from agent import handle_user_query

quick_quizzes = [
    "What is Soroban in Stellar?",
    "List top Stellar wallets.",
    "Explain the Horizon API in simple terms.",
    "Show me key Stellar docs.",
    "Fetch content from https://stellar.org",
]

with gr.Blocks(
    theme=gr.themes.Default(
        primary_hue="blue",   # Stellar-like deep blue
        secondary_hue="orange"  # Orange accent (send buttons etc.)
    )
) as demo:
    gr.Markdown("""
<div style='text-align: center;'>
    <h1 style='font-size: 2em; color: #1a3c8b;'>✨ Stellar Knowledge Agent</h1>
    <p style='font-size: 1em; color: #444;'>Ask about Stellar, Soroban, wallets, Horizon — your Web3 companion!</p>
</div>
""")

    chatbot = gr.Chatbot(
        label="💬 Stellar Assistant",
        bubble_full_width=False,
        height=400,
        elem_classes="chatbot-style"
    )

    msg = gr.Textbox(
        placeholder="Type your Stellar question here & hit Enter...",
        show_label=False
    )

    with gr.Row():
        for quiz in quick_quizzes:
            gr.Button(
                quiz,
                elem_classes="quiz-btn"
            ).click(
                lambda q=quiz: ([(q, handle_user_query(q))], ""),
                outputs=[chatbot, msg]
            )

    send_btn = gr.Button("🚀 Send", elem_classes="send-btn")

    def respond(history, user_message):
        answer = handle_user_query(user_message)
        history.append((user_message, answer))
        return history, ""

    # Press Enter or click Send
    msg.submit(respond, inputs=[chatbot, msg], outputs=[chatbot, msg])
    send_btn.click(respond, inputs=[chatbot, msg], outputs=[chatbot, msg])

    # Custom CSS to make it prettier
    demo.css = """
    .chatbot-style { 
        border: 2px solid #1a3c8b; 
        border-radius: 12px;
    }
    .send-btn {
        background: #f97316 !important;   /* Orange */
        color: white !important;
        border-radius: 8px;
        font-weight: bold;
    }
    .quiz-btn {
        background: #1a3c8b !important;   /* Deep Stellar blue */
        color: white !important;
        margin: 2px;
        border-radius: 6px;
        font-size: 0.9em;
    }
    """

demo.launch()