Update app.py
Browse files
app.py
CHANGED
@@ -42,6 +42,10 @@ def generate_response(model_id, conversation, user_message, max_length=512, temp
|
|
42 |
# Build messages in proper chat format
|
43 |
messages = []
|
44 |
|
|
|
|
|
|
|
|
|
45 |
# Add conversation history
|
46 |
for user_msg, assistant_msg in conversation:
|
47 |
if user_msg:
|
@@ -130,10 +134,18 @@ css = """
|
|
130 |
#chatbot {
|
131 |
height: 600px;
|
132 |
}
|
133 |
-
.message {
|
134 |
-
padding:
|
135 |
-
margin:
|
136 |
-
border-radius:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
}
|
138 |
"""
|
139 |
|
@@ -142,46 +154,56 @@ with gr.Blocks(title="Athena Playground Chat", css=css) as demo:
|
|
142 |
gr.Markdown("# π Athena Playground Chat")
|
143 |
gr.Markdown("*Powered by HuggingFace ZeroGPU*")
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
with gr.Row():
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
model_choice = gr.Dropdown(
|
148 |
label="π± Model",
|
149 |
choices=list(MODELS.keys()),
|
150 |
value="Athena-R3X 8B",
|
151 |
info="Select which Athena model to use"
|
152 |
)
|
|
|
153 |
max_length = gr.Slider(
|
154 |
32, 2048, value=512,
|
155 |
label="π Max Tokens",
|
156 |
info="Maximum number of tokens to generate"
|
157 |
)
|
|
|
158 |
temperature = gr.Slider(
|
159 |
0.1, 2.0, value=0.7,
|
160 |
label="π¨ Creativity",
|
161 |
info="Higher values = more creative responses"
|
162 |
)
|
163 |
-
clear_btn = gr.Button("ποΈ Clear Chat", variant="secondary")
|
164 |
-
|
165 |
-
with gr.Column(scale=3):
|
166 |
-
chat_history = gr.Chatbot(
|
167 |
-
elem_id="chatbot",
|
168 |
-
show_label=False,
|
169 |
-
avatar_images=["π€", "π€"]
|
170 |
-
)
|
171 |
-
user_input = gr.Textbox(
|
172 |
-
placeholder="Ask Athena anything...",
|
173 |
-
label="Your message",
|
174 |
-
lines=2,
|
175 |
-
max_lines=10
|
176 |
-
)
|
177 |
-
with gr.Row():
|
178 |
-
submit_btn = gr.Button("π€ Send", variant="primary")
|
179 |
-
stats_output = gr.Textbox(
|
180 |
-
label="Stats",
|
181 |
-
interactive=False,
|
182 |
-
show_label=False,
|
183 |
-
placeholder="Stats will appear here..."
|
184 |
-
)
|
185 |
|
186 |
# Event handlers
|
187 |
submit_btn.click(
|
|
|
42 |
# Build messages in proper chat format
|
43 |
messages = []
|
44 |
|
45 |
+
# Add system prompt first
|
46 |
+
system_prompt = "You are Athena, a helpful, harmless, and honest AI assistant. You provide clear, accurate, and concise responses to user questions. You are knowledgeable across many domains and always aim to be respectful and helpful. You are finetuned by Aayan Mishra"
|
47 |
+
messages.append({"role": "system", "content": system_prompt})
|
48 |
+
|
49 |
# Add conversation history
|
50 |
for user_msg, assistant_msg in conversation:
|
51 |
if user_msg:
|
|
|
134 |
#chatbot {
|
135 |
height: 600px;
|
136 |
}
|
137 |
+
#chatbot .message {
|
138 |
+
padding: 8px 12px !important;
|
139 |
+
margin: 3px 0 !important;
|
140 |
+
border-radius: 8px !important;
|
141 |
+
max-width: 80% !important;
|
142 |
+
font-size: 14px !important;
|
143 |
+
}
|
144 |
+
#chatbot .message.user {
|
145 |
+
background-color: #e3f2fd !important;
|
146 |
+
}
|
147 |
+
#chatbot .message.bot {
|
148 |
+
background-color: #f5f5f5 !important;
|
149 |
}
|
150 |
"""
|
151 |
|
|
|
154 |
gr.Markdown("# π Athena Playground Chat")
|
155 |
gr.Markdown("*Powered by HuggingFace ZeroGPU*")
|
156 |
|
157 |
+
# Main chat interface
|
158 |
+
chat_history = gr.Chatbot(
|
159 |
+
elem_id="chatbot",
|
160 |
+
show_label=False,
|
161 |
+
show_share_button=False,
|
162 |
+
container=False
|
163 |
+
)
|
164 |
+
|
165 |
+
user_input = gr.Textbox(
|
166 |
+
placeholder="Ask Athena anything...",
|
167 |
+
label="Your message",
|
168 |
+
lines=2,
|
169 |
+
max_lines=10
|
170 |
+
)
|
171 |
+
|
172 |
with gr.Row():
|
173 |
+
submit_btn = gr.Button("π€ Send", variant="primary")
|
174 |
+
clear_btn = gr.Button("ποΈ Clear Chat", variant="secondary")
|
175 |
+
|
176 |
+
stats_output = gr.Textbox(
|
177 |
+
label="Stats",
|
178 |
+
interactive=False,
|
179 |
+
show_label=False,
|
180 |
+
placeholder="Stats will appear here..."
|
181 |
+
)
|
182 |
+
|
183 |
+
# Configuration settings at the bottom
|
184 |
+
gr.Markdown("---")
|
185 |
+
gr.Markdown("## βοΈ Configuration")
|
186 |
+
|
187 |
+
with gr.Row():
|
188 |
+
with gr.Column():
|
189 |
model_choice = gr.Dropdown(
|
190 |
label="π± Model",
|
191 |
choices=list(MODELS.keys()),
|
192 |
value="Athena-R3X 8B",
|
193 |
info="Select which Athena model to use"
|
194 |
)
|
195 |
+
with gr.Column():
|
196 |
max_length = gr.Slider(
|
197 |
32, 2048, value=512,
|
198 |
label="π Max Tokens",
|
199 |
info="Maximum number of tokens to generate"
|
200 |
)
|
201 |
+
with gr.Column():
|
202 |
temperature = gr.Slider(
|
203 |
0.1, 2.0, value=0.7,
|
204 |
label="π¨ Creativity",
|
205 |
info="Higher values = more creative responses"
|
206 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
|
208 |
# Event handlers
|
209 |
submit_btn.click(
|