import streamlit as st import asyncio from research import deep_research from PIL import Image # Page configuration st.set_page_config( page_title="Open DeepResearch", page_icon="🔍", layout="wide", initial_sidebar_state="expanded" ) # Load and display logo in sidebar logo = Image.open('logo.png') st.sidebar.image(logo, width=200, use_container_width=True) # Initialize session state for API keys if 'api_keys_configured' not in st.session_state: st.session_state.api_keys_configured = False # Custom CSS (previous CSS remains the same) st.markdown(""" """, unsafe_allow_html=True) # Sidebar for API Configuration with st.sidebar: st.markdown("### ⚙️ API Configuration") st.info("Please configure your API keys before starting research.") with st.expander("Configure API Keys", expanded=not st.session_state.api_keys_configured): api_form = st.form("api_keys_form") with api_form: openrouter_key = api_form.text_input( "OpenRouter API Key", type="password", value=st.session_state.get('openrouter_key', ''), help="Required for language model access" ) serpapi_key = api_form.text_input( "SerpAPI Key", type="password", value=st.session_state.get('serpapi_key', ''), help="Required for web search functionality" ) jina_key = api_form.text_input( "Jina API Key", type="password", value=st.session_state.get('jina_key', ''), help="Required for content extraction" ) if api_form.form_submit_button("Save API Keys"): if not all([openrouter_key, serpapi_key, jina_key]): st.error("❌ All API keys are required!") else: # Store API keys in session state st.session_state.openrouter_key = openrouter_key st.session_state.serpapi_key = serpapi_key st.session_state.jina_key = jina_key st.session_state.api_keys_configured = True st.success("✅ API keys saved successfully!") st.rerun() if st.session_state.api_keys_configured: st.success("✅ API Keys configured") # Add links to get API keys st.markdown("### 🔑 Get API Keys") st.markdown(""" - [OpenRouter API Key](https://openrouter.ai/keys) - [SerpAPI Key](https://serpapi.com/manage-api-key) - [Jina API Key](https://jina.ai/api-key) """) def run_research(user_query, iteration_limit): # Set API keys in the research module deep_research.OPENROUTER_API_KEY = st.session_state.openrouter_key deep_research.SERPAPI_API_KEY = st.session_state.serpapi_key deep_research.JINA_API_KEY = st.session_state.jina_key return asyncio.run(deep_research.research_flow(user_query, iteration_limit)) # Main content if not st.session_state.api_keys_configured: st.warning("⚠️ Please configure your API keys in the sidebar before proceeding.") else: # Title and description st.title("🔍 Open DeepResearch") st.markdown("""
This application helps you conduct comprehensive research on any topic by:
• Generating relevant search queries
• Analyzing multiple sources
• Synthesizing information into a detailed report
Please try again with a different query or contact support if the issue persists.
Built by GitsSaikat ❤️