Spaces:
Sleeping
Sleeping
Commit ·
111c7c5
1
Parent(s): c1098a1
✅ Fix: Update to correct Gemini API models (gemini-2.0-flash, gemini-1.5-flash, gemini-1.5-pro) + Clean minimal chat UI
Browse files- app.py +60 -28
- rag_engine.py +9 -4
app.py
CHANGED
|
@@ -164,82 +164,114 @@ body {
|
|
| 164 |
font-size: 0.9rem !important;
|
| 165 |
}
|
| 166 |
|
| 167 |
-
/* Chat container */
|
| 168 |
.chat-container {
|
| 169 |
background: white !important;
|
| 170 |
-
border-radius:
|
| 171 |
-
border:
|
|
|
|
| 172 |
}
|
| 173 |
|
| 174 |
.gradio-chatbot {
|
| 175 |
background: white !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
}
|
| 177 |
|
| 178 |
/* Chat wrapper */
|
| 179 |
[data-testid="chatbot"] {
|
| 180 |
background: white !important;
|
|
|
|
| 181 |
}
|
| 182 |
|
| 183 |
.gr-box.gr-input-box {
|
| 184 |
background: white !important;
|
| 185 |
-
border:
|
|
|
|
| 186 |
}
|
| 187 |
|
| 188 |
-
/* Messages */
|
| 189 |
.message {
|
| 190 |
-
padding:
|
| 191 |
-
margin:
|
| 192 |
-
border-radius:
|
| 193 |
-
line-height: 1.
|
| 194 |
color: var(--text-primary) !important;
|
|
|
|
|
|
|
|
|
|
| 195 |
}
|
| 196 |
|
| 197 |
.message.user {
|
| 198 |
-
background:
|
| 199 |
-
border
|
| 200 |
-
margin
|
| 201 |
color: var(--text-primary) !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
}
|
| 203 |
|
| 204 |
.message.assistant {
|
| 205 |
background: white !important;
|
| 206 |
-
border
|
| 207 |
-
margin
|
| 208 |
color: var(--text-primary) !important;
|
|
|
|
|
|
|
| 209 |
}
|
| 210 |
|
| 211 |
.message .prose, .message .prose * {
|
| 212 |
color: var(--text-primary) !important;
|
| 213 |
background: transparent !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
}
|
| 215 |
|
| 216 |
-
/* Input */
|
| 217 |
.gr-textbox textarea {
|
| 218 |
color: var(--text-primary) !important;
|
| 219 |
-
background:
|
| 220 |
-
border:
|
| 221 |
-
border-
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
| 224 |
}
|
| 225 |
|
| 226 |
.gr-textbox textarea:focus {
|
| 227 |
-
border-
|
| 228 |
-
box-shadow:
|
|
|
|
| 229 |
}
|
| 230 |
|
| 231 |
.gr-textbox textarea::placeholder {
|
| 232 |
-
color:
|
| 233 |
}
|
| 234 |
|
| 235 |
-
/* Buttons */
|
| 236 |
.gr-button {
|
| 237 |
background: var(--primary) !important;
|
| 238 |
color: white !important;
|
| 239 |
border: none !important;
|
| 240 |
font-weight: 600 !important;
|
| 241 |
border-radius: 6px !important;
|
| 242 |
-
padding: 10px
|
| 243 |
}
|
| 244 |
|
| 245 |
.gr-button:hover {
|
|
@@ -247,13 +279,13 @@ body {
|
|
| 247 |
}
|
| 248 |
|
| 249 |
.gr-button.gr-button-secondary {
|
| 250 |
-
background:
|
| 251 |
-
color: var(--
|
| 252 |
border: 1px solid var(--border) !important;
|
| 253 |
}
|
| 254 |
|
| 255 |
.gr-button.gr-button-secondary:hover {
|
| 256 |
-
background:
|
| 257 |
}
|
| 258 |
|
| 259 |
/* Tables */
|
|
|
|
| 164 |
font-size: 0.9rem !important;
|
| 165 |
}
|
| 166 |
|
| 167 |
+
/* Chat container - Clean minimal design */
|
| 168 |
.chat-container {
|
| 169 |
background: white !important;
|
| 170 |
+
border-radius: 0 !important;
|
| 171 |
+
border: none !important;
|
| 172 |
+
padding: 0 !important;
|
| 173 |
}
|
| 174 |
|
| 175 |
.gradio-chatbot {
|
| 176 |
background: white !important;
|
| 177 |
+
border-radius: 0 !important;
|
| 178 |
+
border: none !important;
|
| 179 |
+
padding: 20px !important;
|
| 180 |
+
height: 500px !important;
|
| 181 |
}
|
| 182 |
|
| 183 |
/* Chat wrapper */
|
| 184 |
[data-testid="chatbot"] {
|
| 185 |
background: white !important;
|
| 186 |
+
border-radius: 0 !important;
|
| 187 |
}
|
| 188 |
|
| 189 |
.gr-box.gr-input-box {
|
| 190 |
background: white !important;
|
| 191 |
+
border: none !important;
|
| 192 |
+
border-top: 1px solid var(--border) !important;
|
| 193 |
}
|
| 194 |
|
| 195 |
+
/* Messages - Minimal, readable design */
|
| 196 |
.message {
|
| 197 |
+
padding: 20px 0 !important;
|
| 198 |
+
margin: 0 !important;
|
| 199 |
+
border-radius: 0 !important;
|
| 200 |
+
line-height: 1.7 !important;
|
| 201 |
color: var(--text-primary) !important;
|
| 202 |
+
background: transparent !important;
|
| 203 |
+
border: none !important;
|
| 204 |
+
font-size: 15px !important;
|
| 205 |
}
|
| 206 |
|
| 207 |
.message.user {
|
| 208 |
+
background: transparent !important;
|
| 209 |
+
border: none !important;
|
| 210 |
+
margin: 20px 0 !important;
|
| 211 |
color: var(--text-primary) !important;
|
| 212 |
+
text-align: right !important;
|
| 213 |
+
padding: 12px 16px !important;
|
| 214 |
+
background: #f3f4f6 !important;
|
| 215 |
+
border-radius: 8px !important;
|
| 216 |
}
|
| 217 |
|
| 218 |
.message.assistant {
|
| 219 |
background: white !important;
|
| 220 |
+
border: none !important;
|
| 221 |
+
margin: 20px 0 !important;
|
| 222 |
color: var(--text-primary) !important;
|
| 223 |
+
padding: 12px 16px !important;
|
| 224 |
+
text-align: left !important;
|
| 225 |
}
|
| 226 |
|
| 227 |
.message .prose, .message .prose * {
|
| 228 |
color: var(--text-primary) !important;
|
| 229 |
background: transparent !important;
|
| 230 |
+
font-size: 15px !important;
|
| 231 |
+
line-height: 1.7 !important;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
.message a {
|
| 235 |
+
color: var(--primary) !important;
|
| 236 |
+
text-decoration: underline !important;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.message h1, .message h2, .message h3 {
|
| 240 |
+
color: var(--text-primary) !important;
|
| 241 |
+
font-weight: 600 !important;
|
| 242 |
+
margin: 12px 0 !important;
|
| 243 |
}
|
| 244 |
|
| 245 |
+
/* Input - Clean minimal */
|
| 246 |
.gr-textbox textarea {
|
| 247 |
color: var(--text-primary) !important;
|
| 248 |
+
background: white !important;
|
| 249 |
+
border: none !important;
|
| 250 |
+
border-top: 1px solid var(--border) !important;
|
| 251 |
+
border-radius: 0 !important;
|
| 252 |
+
padding: 16px !important;
|
| 253 |
+
font-size: 15px !important;
|
| 254 |
+
min-height: 50px !important;
|
| 255 |
}
|
| 256 |
|
| 257 |
.gr-textbox textarea:focus {
|
| 258 |
+
border-top: 1px solid var(--border) !important;
|
| 259 |
+
box-shadow: none !important;
|
| 260 |
+
outline: none !important;
|
| 261 |
}
|
| 262 |
|
| 263 |
.gr-textbox textarea::placeholder {
|
| 264 |
+
color: #9ca3af !important;
|
| 265 |
}
|
| 266 |
|
| 267 |
+
/* Buttons - Minimal style */
|
| 268 |
.gr-button {
|
| 269 |
background: var(--primary) !important;
|
| 270 |
color: white !important;
|
| 271 |
border: none !important;
|
| 272 |
font-weight: 600 !important;
|
| 273 |
border-radius: 6px !important;
|
| 274 |
+
padding: 10px 20px !important;
|
| 275 |
}
|
| 276 |
|
| 277 |
.gr-button:hover {
|
|
|
|
| 279 |
}
|
| 280 |
|
| 281 |
.gr-button.gr-button-secondary {
|
| 282 |
+
background: transparent !important;
|
| 283 |
+
color: var(--text-secondary) !important;
|
| 284 |
border: 1px solid var(--border) !important;
|
| 285 |
}
|
| 286 |
|
| 287 |
.gr-button.gr-button-secondary:hover {
|
| 288 |
+
background: var(--bg-light) !important;
|
| 289 |
}
|
| 290 |
|
| 291 |
/* Tables */
|
rag_engine.py
CHANGED
|
@@ -403,7 +403,7 @@ User Question: {query}
|
|
| 403 |
Answer:"""
|
| 404 |
|
| 405 |
try:
|
| 406 |
-
model = genai.GenerativeModel('gemini-
|
| 407 |
response = model.generate_content(system_prompt + "\n\n" + prompt)
|
| 408 |
response_text = response.text
|
| 409 |
except Exception as e:
|
|
@@ -416,14 +416,19 @@ Answer:"""
|
|
| 416 |
response_text = "❌ API Permission Error: Check your API key has proper permissions"
|
| 417 |
elif "404" in error_msg or "not found" in error_msg or "not supported" in error_msg:
|
| 418 |
try:
|
| 419 |
-
model = genai.GenerativeModel('gemini-
|
| 420 |
response = model.generate_content(system_prompt + "\n\n" + prompt)
|
| 421 |
response_text = response.text
|
| 422 |
except Exception as e2:
|
| 423 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
else:
|
| 425 |
try:
|
| 426 |
-
model = genai.GenerativeModel('gemini-
|
| 427 |
response = model.generate_content(system_prompt + "\n\n" + prompt)
|
| 428 |
response_text = response.text
|
| 429 |
except Exception as e2:
|
|
|
|
| 403 |
Answer:"""
|
| 404 |
|
| 405 |
try:
|
| 406 |
+
model = genai.GenerativeModel('gemini-2.0-flash')
|
| 407 |
response = model.generate_content(system_prompt + "\n\n" + prompt)
|
| 408 |
response_text = response.text
|
| 409 |
except Exception as e:
|
|
|
|
| 416 |
response_text = "❌ API Permission Error: Check your API key has proper permissions"
|
| 417 |
elif "404" in error_msg or "not found" in error_msg or "not supported" in error_msg:
|
| 418 |
try:
|
| 419 |
+
model = genai.GenerativeModel('gemini-1.5-flash')
|
| 420 |
response = model.generate_content(system_prompt + "\n\n" + prompt)
|
| 421 |
response_text = response.text
|
| 422 |
except Exception as e2:
|
| 423 |
+
try:
|
| 424 |
+
model = genai.GenerativeModel('gemini-1.5-pro')
|
| 425 |
+
response = model.generate_content(system_prompt + "\n\n" + prompt)
|
| 426 |
+
response_text = response.text
|
| 427 |
+
except Exception as e3:
|
| 428 |
+
response_text = f"❌ Model Error: No available models. {str(e3)[:60]}"
|
| 429 |
else:
|
| 430 |
try:
|
| 431 |
+
model = genai.GenerativeModel('gemini-1.5-flash')
|
| 432 |
response = model.generate_content(system_prompt + "\n\n" + prompt)
|
| 433 |
response_text = response.text
|
| 434 |
except Exception as e2:
|