Yoma commited on
Commit ·
7381450
1
Parent(s): b0ad516
enforce dark mode
Browse files
app.py
CHANGED
|
@@ -139,23 +139,31 @@ def generate_explanation(movie_id, persona_name, style):
|
|
| 139 |
return call_llm_with_fallback(full_prompt, movie_info, persona_name)
|
| 140 |
|
| 141 |
css = """
|
| 142 |
-
body { background-color: #f8fafc; }
|
| 143 |
.gradio-container { max-width: 1280px !important; margin: 0 auto !important; }
|
| 144 |
-
.view-container {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
.movie-card-container {
|
| 147 |
-
background:
|
| 148 |
border-radius: 1rem;
|
| 149 |
overflow: hidden;
|
| 150 |
-
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.
|
| 151 |
display: flex !important;
|
| 152 |
flex-direction: column !important;
|
| 153 |
height: 100%;
|
| 154 |
padding: 1rem;
|
| 155 |
gap: 1rem;
|
|
|
|
| 156 |
}
|
| 157 |
-
.movie-card-content { display: flex; flex-direction: column; flex-grow: 1; background-color: #
|
| 158 |
-
.poster-container { position: relative; aspect-ratio: 2/3; background: #
|
| 159 |
.poster-img { width: 100%; height: 100%; object-fit: cover; }
|
| 160 |
.movie-card-text-content {
|
| 161 |
display: flex;
|
|
@@ -165,38 +173,36 @@ body { background-color: #f8fafc; }
|
|
| 165 |
.movie-title {
|
| 166 |
font-weight: 700;
|
| 167 |
font-size: 1.125rem;
|
| 168 |
-
color: #
|
| 169 |
flex-shrink: 0;
|
| 170 |
-
/* FIX: Set fixed height to handle multi-line titles */
|
| 171 |
height: 2.5em;
|
| 172 |
line-height: 1.25em;
|
| 173 |
overflow: hidden;
|
| 174 |
}
|
| 175 |
-
.movie-year { font-size: 0.875rem; color: #
|
| 176 |
.catchy-phrase {
|
| 177 |
font-style: italic;
|
| 178 |
-
color: #
|
| 179 |
font-size: 1rem;
|
| 180 |
margin: 0.75rem 0;
|
| 181 |
-
/* FIX: Remove flex-grow and display:flex, left-align, and set fixed height */
|
| 182 |
text-align: left;
|
| 183 |
-
height: 2.5em;
|
| 184 |
line-height: 1.2em;
|
| 185 |
overflow: hidden;
|
| 186 |
}
|
| 187 |
.genre-pills-container { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 0.5rem; flex-shrink: 0; }
|
| 188 |
-
.genre-pill { background: #
|
| 189 |
.synthesis-pill {
|
| 190 |
position: absolute; top: 12px; left: 12px;
|
| 191 |
-
background: rgba(
|
| 192 |
color: white; padding: 4px 10px;
|
| 193 |
border-radius: 9999px; font-size: 12px; font-weight: 600;
|
| 194 |
backdrop-filter: blur(4px);
|
| 195 |
-
border: 1px solid rgba(255, 255, 255, 0.
|
| 196 |
}
|
| 197 |
|
| 198 |
.gradio-button {
|
| 199 |
-
background-color: #
|
| 200 |
color: white !important;
|
| 201 |
border: none !important;
|
| 202 |
border-radius: 0.5rem !important;
|
|
@@ -204,23 +210,20 @@ body { background-color: #f8fafc; }
|
|
| 204 |
transition: background-color 0.2s ease-in-out !important;
|
| 205 |
padding: 10px !important;
|
| 206 |
}
|
| 207 |
-
.gradio-button:hover { background-color: #
|
| 208 |
|
| 209 |
#persona_selection_view {
|
| 210 |
max-width: 800px;
|
| 211 |
margin: 40px auto !important;
|
| 212 |
}
|
| 213 |
|
| 214 |
-
#persona_selection_view h2 { color: #
|
| 215 |
-
|
| 216 |
-
#
|
| 217 |
-
|
| 218 |
-
#detail_view { padding: 20px; border: none; border-radius: 8px; margin-top: 20px; background: white; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); }
|
| 219 |
#detail_poster img { max-height: 450px; }
|
| 220 |
-
#
|
| 221 |
-
#
|
| 222 |
-
#detail_explanation
|
| 223 |
-
#detail_explanation { border: 1px solid #e2e8f0; padding: 1rem; border-radius: 0.5rem; }
|
| 224 |
|
| 225 |
#detail_view label {
|
| 226 |
color: white !important;
|
|
@@ -286,9 +289,10 @@ def update_home_cards_ui(persona_name, recommendations, is_live=False, time_take
|
|
| 286 |
|
| 287 |
|
| 288 |
# --- UI Construction ---
|
| 289 |
-
with gr.Blocks(css=css) as demo:
|
| 290 |
selected_persona = gr.State(None)
|
| 291 |
selected_movie_id = gr.State(None)
|
|
|
|
| 292 |
|
| 293 |
gr.Markdown("# 🎬 AI-Powered Explainable Recommendations")
|
| 294 |
|
|
|
|
| 139 |
return call_llm_with_fallback(full_prompt, movie_info, persona_name)
|
| 140 |
|
| 141 |
css = """
|
| 142 |
+
body { background-color: #0f172a !important; color: #f8fafc; }
|
| 143 |
.gradio-container { max-width: 1280px !important; margin: 0 auto !important; }
|
| 144 |
+
.view-container {
|
| 145 |
+
padding: 20px;
|
| 146 |
+
border: none;
|
| 147 |
+
border-radius: 8px;
|
| 148 |
+
margin-top: 20px;
|
| 149 |
+
background: #1e293b;
|
| 150 |
+
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.5);
|
| 151 |
+
}
|
| 152 |
|
| 153 |
.movie-card-container {
|
| 154 |
+
background: #1e293b;
|
| 155 |
border-radius: 1rem;
|
| 156 |
overflow: hidden;
|
| 157 |
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
|
| 158 |
display: flex !important;
|
| 159 |
flex-direction: column !important;
|
| 160 |
height: 100%;
|
| 161 |
padding: 1rem;
|
| 162 |
gap: 1rem;
|
| 163 |
+
border: 1px solid #334155;
|
| 164 |
}
|
| 165 |
+
.movie-card-content { display: flex; flex-direction: column; flex-grow: 1; background-color: #1e293b;}
|
| 166 |
+
.poster-container { position: relative; aspect-ratio: 2/3; background: #0f172a; }
|
| 167 |
.poster-img { width: 100%; height: 100%; object-fit: cover; }
|
| 168 |
.movie-card-text-content {
|
| 169 |
display: flex;
|
|
|
|
| 173 |
.movie-title {
|
| 174 |
font-weight: 700;
|
| 175 |
font-size: 1.125rem;
|
| 176 |
+
color: #f8fafc;
|
| 177 |
flex-shrink: 0;
|
|
|
|
| 178 |
height: 2.5em;
|
| 179 |
line-height: 1.25em;
|
| 180 |
overflow: hidden;
|
| 181 |
}
|
| 182 |
+
.movie-year { font-size: 0.875rem; color: #94a3b8; margin-top: 2px; flex-shrink: 0; }
|
| 183 |
.catchy-phrase {
|
| 184 |
font-style: italic;
|
| 185 |
+
color: #818cf8;
|
| 186 |
font-size: 1rem;
|
| 187 |
margin: 0.75rem 0;
|
|
|
|
| 188 |
text-align: left;
|
| 189 |
+
height: 2.5em;
|
| 190 |
line-height: 1.2em;
|
| 191 |
overflow: hidden;
|
| 192 |
}
|
| 193 |
.genre-pills-container { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 0.5rem; flex-shrink: 0; }
|
| 194 |
+
.genre-pill { background: #334155; color: #e2e8f0; padding: 4px 8px; border-radius: 9999px; font-size: 0.7rem; font-weight: 500; }
|
| 195 |
.synthesis-pill {
|
| 196 |
position: absolute; top: 12px; left: 12px;
|
| 197 |
+
background: rgba(15, 23, 42, 0.8);
|
| 198 |
color: white; padding: 4px 10px;
|
| 199 |
border-radius: 9999px; font-size: 12px; font-weight: 600;
|
| 200 |
backdrop-filter: blur(4px);
|
| 201 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 202 |
}
|
| 203 |
|
| 204 |
.gradio-button {
|
| 205 |
+
background-color: #3b82f6 !important;
|
| 206 |
color: white !important;
|
| 207 |
border: none !important;
|
| 208 |
border-radius: 0.5rem !important;
|
|
|
|
| 210 |
transition: background-color 0.2s ease-in-out !important;
|
| 211 |
padding: 10px !important;
|
| 212 |
}
|
| 213 |
+
.gradio-button:hover { background-color: #2563eb !important; }
|
| 214 |
|
| 215 |
#persona_selection_view {
|
| 216 |
max-width: 800px;
|
| 217 |
margin: 40px auto !important;
|
| 218 |
}
|
| 219 |
|
| 220 |
+
#persona_selection_view h2 { color: #f8fafc !important; }
|
| 221 |
+
#home_title h1, #home_title h2 { color: #f8fafc !important; }
|
| 222 |
+
#detail_view { padding: 20px; border: none; border-radius: 8px; margin-top: 20px; background: #1e293b; box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.5); }
|
|
|
|
|
|
|
| 223 |
#detail_poster img { max-height: 450px; }
|
| 224 |
+
#detail_title h2 { color: #f8fafc !important; }
|
| 225 |
+
#detail_explanation p { color: #e2e8f0 !important; }
|
| 226 |
+
#detail_explanation { border: 1px solid #334155; padding: 1rem; border-radius: 0.5rem; background: #0f172a; }
|
|
|
|
| 227 |
|
| 228 |
#detail_view label {
|
| 229 |
color: white !important;
|
|
|
|
| 289 |
|
| 290 |
|
| 291 |
# --- UI Construction ---
|
| 292 |
+
with gr.Blocks(css=css, js="() => document.body.classList.add('dark')") as demo:
|
| 293 |
selected_persona = gr.State(None)
|
| 294 |
selected_movie_id = gr.State(None)
|
| 295 |
+
|
| 296 |
|
| 297 |
gr.Markdown("# 🎬 AI-Powered Explainable Recommendations")
|
| 298 |
|