Update app.py
Browse files
app.py
CHANGED
@@ -175,37 +175,153 @@ def ga_optimization(population, generations, mutation_rate):
|
|
175 |
|
176 |
return population[0] # Return the best individual
|
177 |
|
|
|
|
|
|
|
178 |
# ---- Gradio App Setup ----
|
179 |
auth = ("Tej", "186281mps", "ACC", "HIPE")
|
180 |
|
181 |
with gr.Blocks() as app:
|
|
|
182 |
gr.Markdown("# **Autistic Assistant vß Edition 2024 Ultra: Gertrude's Autistic Experience**")
|
183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
with gr.Row():
|
185 |
with gr.Column(scale=1):
|
186 |
-
|
187 |
-
submit_button = gr.Button("Send")
|
188 |
with gr.Column(scale=1):
|
189 |
-
|
190 |
|
191 |
-
#
|
192 |
gr.HTML("""
|
193 |
<style>
|
|
|
194 |
.gradio-container {
|
195 |
-
background-color: #
|
196 |
-
padding: 20px;
|
197 |
-
border-radius:
|
198 |
font-family: 'Comic Sans MS';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
}
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
</style>
|
205 |
""")
|
206 |
|
207 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
submit_button.click(chat_interface, inputs=user_input, outputs=chatbot)
|
|
|
|
|
209 |
|
210 |
# Launch the Gradio app
|
211 |
app.launch()
|
|
|
175 |
|
176 |
return population[0] # Return the best individual
|
177 |
|
178 |
+
# ---- Gradio App Setup ----
|
179 |
+
import gradio as gr
|
180 |
+
|
181 |
# ---- Gradio App Setup ----
|
182 |
auth = ("Tej", "186281mps", "ACC", "HIPE")
|
183 |
|
184 |
with gr.Blocks() as app:
|
185 |
+
# Header section
|
186 |
gr.Markdown("# **Autistic Assistant vß Edition 2024 Ultra: Gertrude's Autistic Experience**")
|
187 |
|
188 |
+
# User input and response UI layout
|
189 |
+
with gr.Row():
|
190 |
+
with gr.Column(scale=1):
|
191 |
+
user_input = gr.Textbox(
|
192 |
+
label="What will you say to Gertrude?",
|
193 |
+
placeholder="Type something here...",
|
194 |
+
lines=3, # Multiline input box for more comfortable typing
|
195 |
+
elem_id="user_input_box" # Custom ID for styling
|
196 |
+
)
|
197 |
+
submit_button = gr.Button("Send", elem_id="send_button")
|
198 |
+
|
199 |
+
with gr.Column(scale=1):
|
200 |
+
chatbot = gr.Textbox(
|
201 |
+
label="Gertrude's Response",
|
202 |
+
interactive=False,
|
203 |
+
elem_id="chatbot_output", # Custom ID for styling
|
204 |
+
lines=8 # Display more text for longer responses
|
205 |
+
)
|
206 |
+
|
207 |
+
# Buttons for "Pain" and "Pleasure" with cool animations
|
208 |
with gr.Row():
|
209 |
with gr.Column(scale=1):
|
210 |
+
pain_button = gr.Button("Pain", elem_id="pain_button", variant="stop", size="lg")
|
|
|
211 |
with gr.Column(scale=1):
|
212 |
+
pleasure_button = gr.Button("Pleasure", elem_id="pleasure_button", variant="primary", size="lg")
|
213 |
|
214 |
+
# Custom Styling for Buttons, Background, and Text
|
215 |
gr.HTML("""
|
216 |
<style>
|
217 |
+
/* Main Container Styling */
|
218 |
.gradio-container {
|
219 |
+
background-color: #F0F8FF;
|
220 |
+
padding: 20px;
|
221 |
+
border-radius: 20px;
|
222 |
font-family: 'Comic Sans MS';
|
223 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
224 |
+
}
|
225 |
+
|
226 |
+
/* Header Styling */
|
227 |
+
.gradio-markdown {
|
228 |
+
font-size: 28px;
|
229 |
+
font-weight: bold;
|
230 |
+
color: #3366CC;
|
231 |
+
text-align: center;
|
232 |
+
padding-bottom: 20px;
|
233 |
+
}
|
234 |
+
|
235 |
+
/* User Input Box Styling */
|
236 |
+
#user_input_box {
|
237 |
+
background-color: #E8F7FF;
|
238 |
+
border: 2px solid #A3C9F1;
|
239 |
+
border-radius: 10px;
|
240 |
+
padding: 10px;
|
241 |
+
}
|
242 |
+
|
243 |
+
/* Send Button Styling */
|
244 |
+
#send_button {
|
245 |
+
background-color: #4CAF50;
|
246 |
+
color: white;
|
247 |
+
font-size: 18px;
|
248 |
+
border-radius: 10px;
|
249 |
+
width: 100%;
|
250 |
+
padding: 15px;
|
251 |
+
}
|
252 |
+
|
253 |
+
/* Chatbot Output Styling */
|
254 |
+
#chatbot_output {
|
255 |
+
background-color: #FFFFFF;
|
256 |
+
border: 2px solid #A3C9F1;
|
257 |
+
border-radius: 10px;
|
258 |
+
padding: 10px;
|
259 |
+
font-size: 16px;
|
260 |
+
color: #333333;
|
261 |
+
overflow-y: scroll;
|
262 |
+
}
|
263 |
+
|
264 |
+
/* Pain and Pleasure Buttons Styling */
|
265 |
+
#pain_button {
|
266 |
+
background-color: #FF5733;
|
267 |
+
color: white;
|
268 |
+
width: 100%;
|
269 |
+
height: 50px;
|
270 |
+
font-size: 24px;
|
271 |
+
border-radius: 12px;
|
272 |
+
transition: transform 0.3s ease;
|
273 |
+
}
|
274 |
+
|
275 |
+
#pain_button:active {
|
276 |
+
transform: scale(0.95);
|
277 |
+
}
|
278 |
+
|
279 |
+
#pleasure_button {
|
280 |
+
background-color: #4CAF50;
|
281 |
+
color: white;
|
282 |
+
width: 100%;
|
283 |
+
height: 50px;
|
284 |
+
font-size: 24px;
|
285 |
+
border-radius: 12px;
|
286 |
+
transition: transform 0.3s ease;
|
287 |
}
|
288 |
+
|
289 |
+
#pleasure_button:active {
|
290 |
+
transform: scale(0.95);
|
291 |
+
}
|
292 |
+
|
293 |
+
/* Custom Animation for Button Clicks */
|
294 |
+
@keyframes pulse {
|
295 |
+
0% {
|
296 |
+
transform: scale(1);
|
297 |
+
}
|
298 |
+
50% {
|
299 |
+
transform: scale(1.1);
|
300 |
+
}
|
301 |
+
100% {
|
302 |
+
transform: scale(1);
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
.animate__pulse {
|
307 |
+
animation: pulse 0.5s ease;
|
308 |
}
|
309 |
</style>
|
310 |
""")
|
311 |
|
312 |
+
# Interaction Logic
|
313 |
+
def chat_interface(user_input):
|
314 |
+
response = advanced_agi_chat(user_input)
|
315 |
+
return response
|
316 |
+
|
317 |
+
def simulate_button_click(button_type):
|
318 |
+
# Just simulate the click animation and do nothing else
|
319 |
+
return gr.update(interactive=True, elem_id="chatbot_output")
|
320 |
+
|
321 |
+
# Set the button click events with animations
|
322 |
submit_button.click(chat_interface, inputs=user_input, outputs=chatbot)
|
323 |
+
pain_button.click(simulate_button_click, inputs="Pain", outputs=chatbot)
|
324 |
+
pleasure_button.click(simulate_button_click, inputs="Pleasure", outputs=chatbot)
|
325 |
|
326 |
# Launch the Gradio app
|
327 |
app.launch()
|