Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -411,6 +411,137 @@ async def create_paper_audio_files(papers: List[Dict], input_question: str):
|
|
| 411 |
paper['full_audio'] = None
|
| 412 |
paper['download_base64'] = ''
|
| 413 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 414 |
def display_papers(papers: List[Dict], marquee_settings: Dict):
|
| 415 |
"""Display paper information with enhanced visualization."""
|
| 416 |
with PerformanceTimer("paper_display"):
|
|
|
|
| 411 |
paper['full_audio'] = None
|
| 412 |
paper['download_base64'] = ''
|
| 413 |
|
| 414 |
+
|
| 415 |
+
def initialize_marquee_settings():
|
| 416 |
+
"""Initialize default marquee settings if not present in session state."""
|
| 417 |
+
if 'marquee_settings' not in st.session_state:
|
| 418 |
+
st.session_state['marquee_settings'] = {
|
| 419 |
+
"background": "#1E1E1E",
|
| 420 |
+
"color": "#FFFFFF",
|
| 421 |
+
"font-size": "14px",
|
| 422 |
+
"animationDuration": "20s",
|
| 423 |
+
"width": "100%",
|
| 424 |
+
"lineHeight": "35px"
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
def get_marquee_settings():
|
| 428 |
+
"""Get current marquee settings, initializing if needed."""
|
| 429 |
+
initialize_marquee_settings()
|
| 430 |
+
return st.session_state['marquee_settings']
|
| 431 |
+
|
| 432 |
+
def update_marquee_settings_ui():
|
| 433 |
+
"""Add color pickers & sliders for marquee configuration in sidebar."""
|
| 434 |
+
st.sidebar.markdown("### 🎯 Marquee Settings")
|
| 435 |
+
|
| 436 |
+
# Create two columns for settings
|
| 437 |
+
cols = st.sidebar.columns(2)
|
| 438 |
+
|
| 439 |
+
# Column 1: Color settings
|
| 440 |
+
with cols[0]:
|
| 441 |
+
# Background color picker
|
| 442 |
+
bg_color = st.color_picker(
|
| 443 |
+
"🎨 Background",
|
| 444 |
+
st.session_state['marquee_settings']["background"],
|
| 445 |
+
key="bg_color_picker"
|
| 446 |
+
)
|
| 447 |
+
|
| 448 |
+
# Text color picker
|
| 449 |
+
text_color = st.color_picker(
|
| 450 |
+
"✍️ Text Color",
|
| 451 |
+
st.session_state['marquee_settings']["color"],
|
| 452 |
+
key="text_color_picker"
|
| 453 |
+
)
|
| 454 |
+
|
| 455 |
+
# Column 2: Size and speed settings
|
| 456 |
+
with cols[1]:
|
| 457 |
+
# Font size slider
|
| 458 |
+
font_size = st.slider(
|
| 459 |
+
"📏 Font Size",
|
| 460 |
+
10, 24, 14,
|
| 461 |
+
key="font_size_slider"
|
| 462 |
+
)
|
| 463 |
+
|
| 464 |
+
# Animation duration slider
|
| 465 |
+
duration = st.slider(
|
| 466 |
+
"⏱️ Animation Speed",
|
| 467 |
+
1, 20, 20,
|
| 468 |
+
key="duration_slider"
|
| 469 |
+
)
|
| 470 |
+
|
| 471 |
+
# Update session state with new settings
|
| 472 |
+
st.session_state['marquee_settings'].update({
|
| 473 |
+
"background": bg_color,
|
| 474 |
+
"color": text_color,
|
| 475 |
+
"font-size": f"{font_size}px",
|
| 476 |
+
"animationDuration": f"{duration}s"
|
| 477 |
+
})
|
| 478 |
+
|
| 479 |
+
def display_marquee(text: str, settings: dict, key_suffix: str = ""):
|
| 480 |
+
"""Show marquee text with specified style settings."""
|
| 481 |
+
# Truncate long text to prevent performance issues
|
| 482 |
+
truncated_text = text[:280] + "..." if len(text) > 280 else text
|
| 483 |
+
|
| 484 |
+
# Display the marquee
|
| 485 |
+
streamlit_marquee(
|
| 486 |
+
content=truncated_text,
|
| 487 |
+
**settings,
|
| 488 |
+
key=f"marquee_{key_suffix}"
|
| 489 |
+
)
|
| 490 |
+
|
| 491 |
+
# Add spacing after marquee
|
| 492 |
+
st.write("")
|
| 493 |
+
|
| 494 |
+
def create_paper_links_md(papers: list) -> str:
|
| 495 |
+
"""Creates a minimal markdown file linking to each paper's arxiv URL."""
|
| 496 |
+
lines = ["# Paper Links\n"]
|
| 497 |
+
for i, p in enumerate(papers, start=1):
|
| 498 |
+
lines.append(f"{i}. **{p['title']}** — [Arxiv]({p['url']})")
|
| 499 |
+
return "\n".join(lines)
|
| 500 |
+
|
| 501 |
+
def apply_custom_styling():
|
| 502 |
+
"""Apply custom CSS styling to the app."""
|
| 503 |
+
st.markdown("""
|
| 504 |
+
<style>
|
| 505 |
+
.main {
|
| 506 |
+
background: linear-gradient(to right, #1a1a1a, #2d2d2d);
|
| 507 |
+
color: #fff;
|
| 508 |
+
}
|
| 509 |
+
.stMarkdown {
|
| 510 |
+
font-family: 'Helvetica Neue', sans-serif;
|
| 511 |
+
}
|
| 512 |
+
.stButton>button {
|
| 513 |
+
margin-right: 0.5rem;
|
| 514 |
+
}
|
| 515 |
+
.streamlit-marquee {
|
| 516 |
+
margin: 1rem 0;
|
| 517 |
+
border-radius: 4px;
|
| 518 |
+
}
|
| 519 |
+
.st-emotion-cache-1y4p8pa {
|
| 520 |
+
padding: 1rem;
|
| 521 |
+
}
|
| 522 |
+
</style>
|
| 523 |
+
""", unsafe_allow_html=True)
|
| 524 |
+
|
| 525 |
+
def display_performance_metrics(timings: dict):
|
| 526 |
+
"""Display performance metrics with visualizations."""
|
| 527 |
+
st.sidebar.markdown("### ⏱️ Performance Metrics")
|
| 528 |
+
|
| 529 |
+
# Calculate total time
|
| 530 |
+
total_time = sum(timings.values())
|
| 531 |
+
st.sidebar.write(f"**Total Processing Time:** {total_time:.2f}s")
|
| 532 |
+
|
| 533 |
+
# Show breakdown of operations
|
| 534 |
+
st.sidebar.markdown("#### Operation Breakdown")
|
| 535 |
+
for operation, duration in timings.items():
|
| 536 |
+
percentage = (duration / total_time) * 100 if total_time > 0 else 0
|
| 537 |
+
st.sidebar.write(f"**{operation}:** {duration:.2f}s ({percentage:.1f}%)")
|
| 538 |
+
|
| 539 |
+
# Create a progress bar for visual representation
|
| 540 |
+
st.sidebar.progress(percentage / 100)
|
| 541 |
+
|
| 542 |
+
|
| 543 |
+
|
| 544 |
+
|
| 545 |
def display_papers(papers: List[Dict], marquee_settings: Dict):
|
| 546 |
"""Display paper information with enhanced visualization."""
|
| 547 |
with PerformanceTimer("paper_display"):
|