Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,6 +74,7 @@ def initialize_groq_client(api_key: str) -> Optional[Groq]:
|
|
| 74 |
if "401" in error_msg:
|
| 75 |
st.error("❌ Invalid API key: Authentication failed")
|
| 76 |
elif "403" in error_msg:
|
|
|
|
| 77 |
st.error("❌ API key doesn't have permission to access Groq API")
|
| 78 |
else:
|
| 79 |
st.error(f"❌ Failed to initialize Groq client: {error_msg}")
|
|
@@ -197,6 +198,150 @@ class NoteSection:
|
|
| 197 |
markdown_content += self.get_markdown_content(content, level + 1)
|
| 198 |
return markdown_content
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
# Manual implementation of retry logic (replacing backoff library)
|
| 201 |
def retry_with_exponential_backoff(max_tries=MAX_RETRIES, initial_wait=INITIAL_WAIT, max_wait=MAX_WAIT):
|
| 202 |
"""
|
|
|
|
| 74 |
if "401" in error_msg:
|
| 75 |
st.error("❌ Invalid API key: Authentication failed")
|
| 76 |
elif "403" in error_msg:
|
| 77 |
+
|
| 78 |
st.error("❌ API key doesn't have permission to access Groq API")
|
| 79 |
else:
|
| 80 |
st.error(f"❌ Failed to initialize Groq client: {error_msg}")
|
|
|
|
| 198 |
markdown_content += self.get_markdown_content(content, level + 1)
|
| 199 |
return markdown_content
|
| 200 |
|
| 201 |
+
def set_custom_theme():
|
| 202 |
+
# Add custom CSS
|
| 203 |
+
st.markdown("""
|
| 204 |
+
<style>
|
| 205 |
+
/* Main theme colors */
|
| 206 |
+
:root {
|
| 207 |
+
--primary-color: #4A6FDC;
|
| 208 |
+
--secondary-color: #45B7D1;
|
| 209 |
+
--background-color: #F5F7FF;
|
| 210 |
+
--text-color: #333333;
|
| 211 |
+
--accent-color: #FF6B6B;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/* Header styling */
|
| 215 |
+
.main-header {
|
| 216 |
+
background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
|
| 217 |
+
color: white;
|
| 218 |
+
padding: 1.5rem 1rem;
|
| 219 |
+
border-radius: 10px;
|
| 220 |
+
margin-bottom: 2rem;
|
| 221 |
+
text-align: center;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
.main-header h1 {
|
| 225 |
+
font-weight: 700;
|
| 226 |
+
margin-bottom: 0.5rem;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
.main-header p {
|
| 230 |
+
font-size: 1.1rem;
|
| 231 |
+
opacity: 0.9;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
/* Card styling */
|
| 235 |
+
.stCard {
|
| 236 |
+
border-radius: 10px;
|
| 237 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
|
| 238 |
+
padding: 1.5rem;
|
| 239 |
+
margin-bottom: 1rem;
|
| 240 |
+
background-color: white;
|
| 241 |
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.stCard:hover {
|
| 245 |
+
transform: translateY(-2px);
|
| 246 |
+
box-shadow: 0 6px 12px rgba(0,0,0,0.1);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
/* Button styling */
|
| 250 |
+
.stButton>button {
|
| 251 |
+
border-radius: 20px;
|
| 252 |
+
padding: 0.5rem 1.5rem;
|
| 253 |
+
font-weight: 500;
|
| 254 |
+
transition: all 0.2s ease;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
.primary-button button {
|
| 258 |
+
background-color: var(--primary-color);
|
| 259 |
+
color: white;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
.secondary-button button {
|
| 263 |
+
background-color: transparent;
|
| 264 |
+
color: var(--primary-color);
|
| 265 |
+
border: 1px solid var(--primary-color);
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
/* Input method selection */
|
| 269 |
+
.input-method-selector {
|
| 270 |
+
display: flex;
|
| 271 |
+
justify-content: space-evenly;
|
| 272 |
+
margin-bottom: 2rem;
|
| 273 |
+
flex-wrap: wrap;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
.input-method-card {
|
| 277 |
+
width: 140px;
|
| 278 |
+
height: 120px;
|
| 279 |
+
border-radius: 10px;
|
| 280 |
+
display: flex;
|
| 281 |
+
flex-direction: column;
|
| 282 |
+
align-items: center;
|
| 283 |
+
justify-content: center;
|
| 284 |
+
cursor: pointer;
|
| 285 |
+
padding: 1rem;
|
| 286 |
+
margin: 0.5rem;
|
| 287 |
+
transition: all 0.2s ease;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.input-method-card.selected {
|
| 291 |
+
border: 2px solid var(--primary-color);
|
| 292 |
+
background-color: rgba(74, 111, 220, 0.1);
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
.input-method-card:hover {
|
| 296 |
+
transform: translateY(-3px);
|
| 297 |
+
box-shadow: 0 6px 12px rgba(0,0,0,0.1);
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
.input-method-card i {
|
| 301 |
+
font-size: 2.5rem;
|
| 302 |
+
margin-bottom: 0.5rem;
|
| 303 |
+
color: var(--primary-color);
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
.input-method-card p {
|
| 307 |
+
font-size: 0.9rem;
|
| 308 |
+
text-align: center;
|
| 309 |
+
margin: 0;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
/* Note visualization */
|
| 313 |
+
.note-section {
|
| 314 |
+
padding: 1rem;
|
| 315 |
+
border-radius: 8px;
|
| 316 |
+
background-color: white;
|
| 317 |
+
margin-bottom: 1rem;
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
.note-section h2 {
|
| 321 |
+
color: var(--primary-color);
|
| 322 |
+
border-bottom: 1px solid #eaeaea;
|
| 323 |
+
padding-bottom: 0.5rem;
|
| 324 |
+
margin-bottom: 0.5rem;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
/* Expander customization */
|
| 328 |
+
.st-expander {
|
| 329 |
+
border-radius: 8px;
|
| 330 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
/* Footer styling */
|
| 334 |
+
.footer {
|
| 335 |
+
margin-top: 3rem;
|
| 336 |
+
padding-top: 1rem;
|
| 337 |
+
border-top: 1px solid #eaeaea;
|
| 338 |
+
text-align: center;
|
| 339 |
+
font-size: 0.9rem;
|
| 340 |
+
color: #888;
|
| 341 |
+
}
|
| 342 |
+
</style>
|
| 343 |
+
""", unsafe_allow_html=True)
|
| 344 |
+
|
| 345 |
# Manual implementation of retry logic (replacing backoff library)
|
| 346 |
def retry_with_exponential_backoff(max_tries=MAX_RETRIES, initial_wait=INITIAL_WAIT, max_wait=MAX_WAIT):
|
| 347 |
"""
|