Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,17 +53,51 @@ def generate_response(user_input, chat_history):
|
|
| 53 |
|
| 54 |
return gr_chat_history, chat_history
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
|
|
|
|
|
|
|
|
|
| 65 |
user_input.submit(generate_response, [user_input, state], [chatbot, state])
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
demo.launch(share=True)
|
| 69 |
|
|
|
|
| 53 |
|
| 54 |
return gr_chat_history, chat_history
|
| 55 |
|
| 56 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="emerald", secondary_hue="slate")) as demo:
|
| 57 |
+
gr.HTML("""
|
| 58 |
+
<div style="text-align: center; margin-bottom: 20px;">
|
| 59 |
+
<h1 style="font-family: 'Inter', sans-serif; font-weight: 800; color: #047857; font-size: 2.2em;">
|
| 60 |
+
🧬 BioGenesis-ToT Chatbot
|
| 61 |
+
</h1>
|
| 62 |
+
<p style="color: #4B5563; font-size: 1.05em; margin-top: -10px;">
|
| 63 |
+
Your AI companion for biology, biochemistry, and life sciences.
|
| 64 |
+
</p>
|
| 65 |
+
</div>
|
| 66 |
+
""")
|
| 67 |
|
| 68 |
+
with gr.Row():
|
| 69 |
+
with gr.Column(scale=6):
|
| 70 |
+
chatbot = gr.Chatbot(
|
| 71 |
+
label="BioGenesis Chat",
|
| 72 |
+
height=550,
|
| 73 |
+
bubble_full_width=False,
|
| 74 |
+
show_copy_button=True,
|
| 75 |
+
avatar_images=(
|
| 76 |
+
"https://cdn-icons-png.flaticon.com/512/1077/1077012.png", # user icon
|
| 77 |
+
"https://cdn-icons-png.flaticon.com/512/4140/4140048.png", # bot icon
|
| 78 |
+
),
|
| 79 |
+
)
|
| 80 |
+
user_input = gr.Textbox(
|
| 81 |
+
placeholder="Ask me about cell biology, molecular structure, or biochemistry...",
|
| 82 |
+
label="💬 Your question",
|
| 83 |
+
lines=3,
|
| 84 |
+
autofocus=True,
|
| 85 |
+
)
|
| 86 |
+
with gr.Row():
|
| 87 |
+
send_btn = gr.Button("🚀 Send", variant="primary")
|
| 88 |
+
clear_btn = gr.Button("🧹 Clear Chat")
|
| 89 |
|
| 90 |
+
state = gr.State([])
|
| 91 |
+
|
| 92 |
+
send_btn.click(generate_response, [user_input, state], [chatbot, state])
|
| 93 |
user_input.submit(generate_response, [user_input, state], [chatbot, state])
|
| 94 |
+
clear_btn.click(lambda: ([], []), None, [chatbot, state])
|
| 95 |
+
|
| 96 |
+
gr.HTML("""
|
| 97 |
+
<div style="text-align: center; margin-top: 25px; color: #6B7280; font-size: 0.9em;">
|
| 98 |
+
Powered by <b>Qwen3-1.7B + BioGenesis-ToT</b> | Built with ❤️ using Gradio
|
| 99 |
+
</div>
|
| 100 |
+
""")
|
| 101 |
|
| 102 |
demo.launch(share=True)
|
| 103 |
|