solinm commited on
Commit
3a0ffaf
·
verified ·
1 Parent(s): 128c833

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -26
app.py CHANGED
@@ -23,6 +23,9 @@ def chat_with_bot_stream(user_input):
23
  "suggest multiple options when possible, and encourage users to explore new sounds. "
24
  "If requested, provide brief descriptions of artists or genres, and explain why a "
25
  "recommendation might suit the user."
 
 
 
26
  )
27
  })
28
 
@@ -31,7 +34,7 @@ def chat_with_bot_stream(user_input):
31
  messages=conversation_history,
32
  temperature=0.95,
33
  max_tokens=1024,
34
- top_p=1,
35
  stream=True,
36
  )
37
 
@@ -52,41 +55,44 @@ translations = {
52
  "English": {
53
  "header_description": "Your own personal music discovery assistant!",
54
  "user_input_placeholder": "Enter your music-related questions here!",
55
- "send_button": "Send",
 
56
  "settings_markdown": "### Settings",
57
  "apply_settings_button": "Apply Settings",
58
- "select_language_label": "Language",
59
- "theme_label": "Theme",
60
  "theme_choices": ["Dark", "Light"],
61
- "font_size_label": "Font Size",
62
  "font_size_choices": ["Small", "Medium", "Large"],
63
- "language_choices": ["English", "Spanish", "French"]
64
  },
65
  "Spanish": {
66
  "header_description": "¡Tu asistente personal para descubrir música!",
67
  "user_input_placeholder": "¡Introduce tus preguntas relacionadas con la música!",
68
- "send_button": "Enviar",
 
69
  "settings_markdown": "### Configuración",
70
  "apply_settings_button": "Aplicar Configuración",
71
  "select_language_label": "🌐 Idioma",
72
- "theme_label": "Tema",
73
  "theme_choices": ["Oscuro", "Claro"],
74
- "font_size_label": "Tamaño de Fuente",
75
  "font_size_choices": ["Pequeño", "Mediano", "Grande"],
76
- "language_choices": ["Inglés", "Español", "Francés"]
77
  },
78
  "French": {
79
  "header_description": "Votre assistant personnel pour découvrir de la musique !",
80
  "user_input_placeholder": "Entrez vos questions sur la musique ici !",
81
- "send_button": "Envoyer",
 
82
  "settings_markdown": "### Paramètres",
83
  "apply_settings_button": "Appliquer les paramètres",
84
  "select_language_label": "🌐 Langue",
85
- "theme_label": "Thème",
86
  "theme_choices": ["Sombre", "Clair"],
87
- "font_size_label": "Taille de police",
88
  "font_size_choices": ["Petit", "Moyen", "Grand"],
89
- "language_choices": ["Anglais", "Espagnol", "Français"]
90
  }
91
  }
92
 
@@ -183,9 +189,11 @@ def update_styles(theme, font_size):
183
  radio_bg = "#2E2E2E"
184
  settings_heading_color = text_color
185
  border_color = "#444444"
186
- placeholder_color = "#888888"
187
  chatbot_bg = "#18181B"
188
  chatbot_text_color = "#ffffff"
 
 
189
  else:
190
  bg = "#ffffff"
191
  text_color = "#000000"
@@ -196,9 +204,11 @@ def update_styles(theme, font_size):
196
  radio_bg = "#e0e0e0"
197
  settings_heading_color = "#333333"
198
  border_color = "#cccccc"
199
- placeholder_color = "#666666"
200
  chatbot_bg = "#cfcfcf"
201
  chatbot_text_color = "#000000"
 
 
202
 
203
  if font_size == "Small":
204
  fsize = "0.8rem"
@@ -245,6 +255,12 @@ def update_styles(theme, font_size):
245
 
246
  h3 {{
247
  color: {text_color} !important;
 
 
 
 
 
 
248
  }}
249
 
250
  #chatbot {{
@@ -263,29 +279,32 @@ def update_styles(theme, font_size):
263
  }}
264
 
265
  #user_input {{
266
- background-color: {button_bg} !important;
267
- border: 1px solid {border_color} !important;
268
  height: 65px;
269
  }}
 
270
  #user_input textarea {{
271
- background-color: {input_bg} !important;
272
  color: {text_color} !important;
273
  font-size: {fsize} !important;
274
- border: 1px solid {border_color} !important;
275
  padding: 10px;
276
  border: none;
277
  }}
 
278
  #user_input textarea::placeholder {{
 
279
  color: {placeholder_color} !important;
280
  font-size: {fsize} !important;
281
  opacity: 0.73;
282
  }}
283
 
284
  #send_button {{
285
- background-color: {button_bg} !important;
286
- color: {text_color} !important;
287
  font-size: {fsize} !important;
288
- border: 1px solid {border_color} !important;
289
  margin-left: 1px;
290
  font-family: 'Inter', sans-serif;
291
  height: 67px;
@@ -302,6 +321,7 @@ def update_styles(theme, font_size):
302
  font-size: {fsize} !important;
303
  border: 1px solid {border_color} !important;
304
  }}
 
305
  #settings_box .gr-markdown h3 {{
306
  color: {settings_heading_color} !important;
307
  font-size: {fsize} !important;
@@ -315,8 +335,8 @@ def update_styles(theme, font_size):
315
  }}
316
 
317
  #apply_settings_button {{
318
- background-color: {apply_button_bg} !important;
319
- color: {text_color} !important;
320
  font-size: {fsize} !important;
321
  border: 1px solid {border_color} !important;
322
  }}
@@ -408,7 +428,7 @@ with gr.Blocks(css=None) as demo:
408
  )
409
 
410
  # SETTINGS PAGE
411
- with gr.TabItem("⚙️ Settings"):
412
  with gr.Column(elem_id="settings_box"):
413
  settings_md = gr.Markdown(translations["English"]["settings_markdown"])
414
  theme_radio = gr.Radio(
 
23
  "suggest multiple options when possible, and encourage users to explore new sounds. "
24
  "If requested, provide brief descriptions of artists or genres, and explain why a "
25
  "recommendation might suit the user."
26
+ "If asked about visibility on the website, such as font sizing and themes (dark or light mode ONLY), direct them to the settings tab at the top of the chatbot."
27
+ "If asked about the languages you speak, you can say that you speak English, Spanish, and French ONLY. Direct the user to the settings tab to change the language."
28
+ "Limit your responses to music-related inquiries only. Limit your responses to 10 lines or less."
29
  )
30
  })
31
 
 
34
  messages=conversation_history,
35
  temperature=0.95,
36
  max_tokens=1024,
37
+ top_p=0.9,
38
  stream=True,
39
  )
40
 
 
55
  "English": {
56
  "header_description": "Your own personal music discovery assistant!",
57
  "user_input_placeholder": "Enter your music-related questions here!",
58
+ "send_button": "↗️ Send",
59
+ "settings_tab_item": "⚙️ Settings",
60
  "settings_markdown": "### Settings",
61
  "apply_settings_button": "Apply Settings",
62
+ "select_language_label": "🌐 Language",
63
+ "theme_label": "🌗 Theme",
64
  "theme_choices": ["Dark", "Light"],
65
+ "font_size_label": "🗛 Font Size",
66
  "font_size_choices": ["Small", "Medium", "Large"],
67
+ "language_choices": ["English", "Español", "Français"]
68
  },
69
  "Spanish": {
70
  "header_description": "¡Tu asistente personal para descubrir música!",
71
  "user_input_placeholder": "¡Introduce tus preguntas relacionadas con la música!",
72
+ "send_button": "↗️ Enviar",
73
+ "settings_tab_item": "⚙️ Configuración",
74
  "settings_markdown": "### Configuración",
75
  "apply_settings_button": "Aplicar Configuración",
76
  "select_language_label": "🌐 Idioma",
77
+ "theme_label": "🌗 Tema",
78
  "theme_choices": ["Oscuro", "Claro"],
79
+ "font_size_label": "🗛 Tamaño de Fuente",
80
  "font_size_choices": ["Pequeño", "Mediano", "Grande"],
81
+ "language_choices": ["English", "Español", "Français"]
82
  },
83
  "French": {
84
  "header_description": "Votre assistant personnel pour découvrir de la musique !",
85
  "user_input_placeholder": "Entrez vos questions sur la musique ici !",
86
+ "send_button": "↗️ Envoyer",
87
+ "settings_tab_item": "⚙️ Paramètres",
88
  "settings_markdown": "### Paramètres",
89
  "apply_settings_button": "Appliquer les paramètres",
90
  "select_language_label": "🌐 Langue",
91
+ "theme_label": "🌗 Thème",
92
  "theme_choices": ["Sombre", "Clair"],
93
+ "font_size_label": "🗛 Taille de police",
94
  "font_size_choices": ["Petit", "Moyen", "Grand"],
95
+ "language_choices": ["English", "Español", "Français"]
96
  }
97
  }
98
 
 
189
  radio_bg = "#2E2E2E"
190
  settings_heading_color = text_color
191
  border_color = "#444444"
192
+ placeholder_color = "#e8e8e8"
193
  chatbot_bg = "#18181B"
194
  chatbot_text_color = "#ffffff"
195
+ purple="#56246B"
196
+ light_purple="#795699"
197
  else:
198
  bg = "#ffffff"
199
  text_color = "#000000"
 
204
  radio_bg = "#e0e0e0"
205
  settings_heading_color = "#333333"
206
  border_color = "#cccccc"
207
+ placeholder_color = "#e8e8e8"
208
  chatbot_bg = "#cfcfcf"
209
  chatbot_text_color = "#000000"
210
+ purple="#56246B"
211
+ light_purple="#795699"
212
 
213
  if font_size == "Small":
214
  fsize = "0.8rem"
 
255
 
256
  h3 {{
257
  color: {text_color} !important;
258
+ text-align: center;
259
+ display: flex;
260
+ justify-content: center;
261
+ align-items: center;
262
+ height: 100%;
263
+ font-size: {fsize} !important;
264
  }}
265
 
266
  #chatbot {{
 
279
  }}
280
 
281
  #user_input {{
282
+ background-color: {purple} !important;
283
+ border: 1px solid {purple} !important;
284
  height: 65px;
285
  }}
286
+
287
  #user_input textarea {{
288
+ background-color: {light_purple} !important;
289
  color: {text_color} !important;
290
  font-size: {fsize} !important;
291
+ border: 1px solid {light_purple} !important;
292
  padding: 10px;
293
  border: none;
294
  }}
295
+
296
  #user_input textarea::placeholder {{
297
+ background-color: {light_purple} !important;
298
  color: {placeholder_color} !important;
299
  font-size: {fsize} !important;
300
  opacity: 0.73;
301
  }}
302
 
303
  #send_button {{
304
+ background-color: {purple} !important;
305
+ color: {placeholder_color} !important;
306
  font-size: {fsize} !important;
307
+ border: 1px solid {purple} !important;
308
  margin-left: 1px;
309
  font-family: 'Inter', sans-serif;
310
  height: 67px;
 
321
  font-size: {fsize} !important;
322
  border: 1px solid {border_color} !important;
323
  }}
324
+
325
  #settings_box .gr-markdown h3 {{
326
  color: {settings_heading_color} !important;
327
  font-size: {fsize} !important;
 
335
  }}
336
 
337
  #apply_settings_button {{
338
+ background-color: {purple} !important;
339
+ color: {placeholder_color} !important;
340
  font-size: {fsize} !important;
341
  border: 1px solid {border_color} !important;
342
  }}
 
428
  )
429
 
430
  # SETTINGS PAGE
431
+ with gr.TabItem(translations["English"]["settings_tab_item"]):
432
  with gr.Column(elem_id="settings_box"):
433
  settings_md = gr.Markdown(translations["English"]["settings_markdown"])
434
  theme_radio = gr.Radio(