# requirements.txt additions:
"""
streamlit-marquee
"""
# app.py
import streamlit as st
import anthropic, openai, base64, cv2, glob, json, math, os, pytz, random, re, requests, time, zipfile
import plotly.graph_objects as go
import streamlit.components.v1 as components
from datetime import datetime
from audio_recorder_streamlit import audio_recorder
from collections import defaultdict, deque, Counter
from dotenv import load_dotenv
from gradio_client import Client
from huggingface_hub import InferenceClient
from io import BytesIO
from PIL import Image
from PyPDF2 import PdfReader
from urllib.parse import quote
from xml.etree import ElementTree as ET
from openai import OpenAI
import extra_streamlit_components as stx
import asyncio
import edge_tts
from streamlit_marquee import st_marquee
# Core setup
st.set_page_config(
page_title="π²TalkingAIResearcherπ",
page_icon="π²π",
layout="wide",
initial_sidebar_state="auto",
)
# Initialize session state
if 'tts_voice' not in st.session_state:
st.session_state['tts_voice'] = "en-US-AriaNeural"
if 'audio_format' not in st.session_state:
st.session_state['audio_format'] = 'mp3'
if 'scroll_text' not in st.session_state:
st.session_state['scroll_text'] = ''
EDGE_TTS_VOICES = [
"en-US-AriaNeural",
"en-US-GuyNeural",
"en-US-JennyNeural",
"en-GB-SoniaNeural",
]
FILE_EMOJIS = {
"md": "π",
"mp3": "π΅",
"wav": "π",
"txt": "π",
"pdf": "π",
"json": "π",
"csv": "π",
"zip": "π¦"
}
@st.cache_resource
def get_cached_audio_b64(file_path):
"""Cache audio file as base64"""
with open(file_path, "rb") as f:
return base64.b64encode(f.read()).decode()
def beautify_filename(filename):
"""Make filename more readable"""
name = os.path.splitext(filename)[0]
name = name.replace('_', ' ').replace('.', ' ')
return name
def load_files_for_sidebar():
"""Load and group files by timestamp prefix"""
md_files = glob.glob("*.md")
mp3_files = glob.glob("*.mp3")
wav_files = glob.glob("*.wav")
md_files = [f for f in md_files if os.path.basename(f).lower() != 'readme.md']
all_files = md_files + mp3_files + wav_files
groups = defaultdict(list)
for f in all_files:
basename = os.path.basename(f)
group_name = basename[:9] if len(basename) >= 9 else 'Other'
groups[group_name].append(f)
return sorted(groups.items(),
key=lambda x: max(os.path.getmtime(f) for f in x[1]),
reverse=True)
def display_file_manager_sidebar(groups_sorted):
"""Enhanced sidebar with audio players and beautified names"""
st.sidebar.title("π File Manager")
all_md, all_mp3, all_wav = [], [], []
for _, files in groups_sorted:
for f in files:
if f.endswith(".md"): all_md.append(f)
elif f.endswith(".mp3"): all_mp3.append(f)
elif f.endswith(".wav"): all_wav.append(f)
# File management buttons
cols = st.sidebar.columns(4)
with cols[0]:
if st.button("ποΈ MD"):
[os.remove(f) for f in all_md]
st.session_state.should_rerun = True
with cols[1]:
if st.button("ποΈ MP3"):
[os.remove(f) for f in all_mp3]
st.session_state.should_rerun = True
with cols[2]:
if st.button("ποΈ WAV"):
[os.remove(f) for f in all_wav]
st.session_state.should_rerun = True
with cols[3]:
if st.button("π¦ Zip"):
zip_name = create_zip_of_files(all_md, all_mp3, all_wav,
st.session_state.get('last_query', ''))
if zip_name:
st.sidebar.markdown(get_download_link(zip_name), unsafe_allow_html=True)
# Display file groups
for group_name, files in groups_sorted:
timestamp_dt = datetime.strptime(group_name, "%y%m_%H%M") if len(group_name) == 9 else None
group_label = timestamp_dt.strftime("%Y-%m-%d %H:%M") if timestamp_dt else group_name
with st.sidebar.expander(f"π {group_label} ({len(files)})", expanded=True):
c1, c2 = st.columns(2)
with c1:
if st.button("π", key=f"view_{group_name}"):
st.session_state.viewing_prefix = group_name
with c2:
if st.button("ποΈ", key=f"del_{group_name}"):
[os.remove(f) for f in files]
st.session_state.should_rerun = True
for f in files:
ext = os.path.splitext(f)[1].lower().strip('.')
emoji = FILE_EMOJIS.get(ext, 'π')
pretty_name = beautify_filename(os.path.basename(f))
st.write(f"{emoji} **{pretty_name}**")
if ext in ['mp3', 'wav']:
audio_b64 = get_cached_audio_b64(f)
st.audio(f)
cols = st.columns([3,1])
with cols[1]:
if st.button("π", key=f"loop_{f}"):
components.html(
f'''
''',
height=0
)
def main():
# Add scrolling banner
st_marquee(
text=" | ".join(st.session_state.get('scroll_text', 'π Welcome to TalkingAIResearcher').split('\n')),
font_size=20,
)
# Rest of the main UI code...
# (Keep existing main() implementation but with beautified filenames)
# Compressed sidebar markdown
sidebar_md = """
# π§ AGI Levels
L0 β No AI
L1 π± Emerging (ChatGPT, Bard)
L2 πͺ Competent (Watson)
L3 π― Expert (DALLΒ·E)
L4 π Virtuoso (AlphaGo)
L5 π Superhuman (AlphaFold)
# 𧬠AlphaFold2
1. 𧬠Input Seq
2. π DB Search
3. 𧩠MSA
4. π Templates
5. π Evoformer
6. 𧱠Structure
7. π― 3D Predict
8. β»οΈ Recycle x3
"""
if __name__=="__main__":
main()