Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,24 +9,71 @@ quick_quizzes = [
|
|
| 9 |
"Fetch content from https://stellar.org",
|
| 10 |
]
|
| 11 |
|
| 12 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
gr.Markdown("""
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
""")
|
| 17 |
|
| 18 |
-
chatbot = gr.Chatbot(
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
with gr.Row():
|
| 22 |
for quiz in quick_quizzes:
|
| 23 |
-
gr.Button(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
def respond(history, user_message):
|
| 26 |
answer = handle_user_query(user_message)
|
| 27 |
history.append((user_message, answer))
|
| 28 |
return history, ""
|
| 29 |
|
|
|
|
| 30 |
msg.submit(respond, inputs=[chatbot, msg], outputs=[chatbot, msg])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
demo.launch()
|
|
|
|
| 9 |
"Fetch content from https://stellar.org",
|
| 10 |
]
|
| 11 |
|
| 12 |
+
with gr.Blocks(
|
| 13 |
+
theme=gr.themes.Default(
|
| 14 |
+
primary_hue="blue", # Stellar-like deep blue
|
| 15 |
+
secondary_hue="orange" # Orange accent (send buttons etc.)
|
| 16 |
+
)
|
| 17 |
+
) as demo:
|
| 18 |
gr.Markdown("""
|
| 19 |
+
<div style='text-align: center;'>
|
| 20 |
+
<h1 style='font-size: 2em; color: #1a3c8b;'>✨ Stellar Knowledge Agent</h1>
|
| 21 |
+
<p style='font-size: 1em; color: #444;'>Ask about Stellar, Soroban, wallets, Horizon — your Web3 companion!</p>
|
| 22 |
+
</div>
|
| 23 |
""")
|
| 24 |
|
| 25 |
+
chatbot = gr.Chatbot(
|
| 26 |
+
label="💬 Stellar Assistant",
|
| 27 |
+
bubble_full_width=False,
|
| 28 |
+
height=400,
|
| 29 |
+
elem_classes="chatbot-style"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
msg = gr.Textbox(
|
| 33 |
+
placeholder="Type your Stellar question here & hit Enter...",
|
| 34 |
+
show_label=False
|
| 35 |
+
)
|
| 36 |
|
| 37 |
with gr.Row():
|
| 38 |
for quiz in quick_quizzes:
|
| 39 |
+
gr.Button(
|
| 40 |
+
quiz,
|
| 41 |
+
elem_classes="quiz-btn"
|
| 42 |
+
).click(
|
| 43 |
+
lambda q=quiz: ([(q, handle_user_query(q))], ""),
|
| 44 |
+
outputs=[chatbot, msg]
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
send_btn = gr.Button("🚀 Send", elem_classes="send-btn")
|
| 48 |
|
| 49 |
def respond(history, user_message):
|
| 50 |
answer = handle_user_query(user_message)
|
| 51 |
history.append((user_message, answer))
|
| 52 |
return history, ""
|
| 53 |
|
| 54 |
+
# Press Enter or click Send
|
| 55 |
msg.submit(respond, inputs=[chatbot, msg], outputs=[chatbot, msg])
|
| 56 |
+
send_btn.click(respond, inputs=[chatbot, msg], outputs=[chatbot, msg])
|
| 57 |
+
|
| 58 |
+
# Custom CSS to make it prettier
|
| 59 |
+
demo.css = """
|
| 60 |
+
.chatbot-style {
|
| 61 |
+
border: 2px solid #1a3c8b;
|
| 62 |
+
border-radius: 12px;
|
| 63 |
+
}
|
| 64 |
+
.send-btn {
|
| 65 |
+
background: #f97316 !important; /* Orange */
|
| 66 |
+
color: white !important;
|
| 67 |
+
border-radius: 8px;
|
| 68 |
+
font-weight: bold;
|
| 69 |
+
}
|
| 70 |
+
.quiz-btn {
|
| 71 |
+
background: #1a3c8b !important; /* Deep Stellar blue */
|
| 72 |
+
color: white !important;
|
| 73 |
+
margin: 2px;
|
| 74 |
+
border-radius: 6px;
|
| 75 |
+
font-size: 0.9em;
|
| 76 |
+
}
|
| 77 |
+
"""
|
| 78 |
|
| 79 |
demo.launch()
|