import os import streamlit as st from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() def get_api_key(key_name): """Get API key from environment variables or Streamlit secrets""" # Try to get from environment variables first api_key = os.getenv(key_name) # If not found in environment, try Streamlit secrets if not api_key and key_name in st.secrets: api_key = st.secrets[key_name] return api_key def check_api_configuration(): """Check if all required API keys are configured""" api_status = { "SERPER_API_KEY": bool(get_api_key("SERPER_API_KEY")), "TAVILY_API_KEY": bool(get_api_key("TAVILY_API_KEY")), "METAPHOR_API_KEY": bool(get_api_key("METAPHOR_API_KEY")), "FIRECRAWL_API_KEY": bool(get_api_key("FIRECRAWL_API_KEY")) } return api_status def display_api_configuration_status(): """Display API configuration status in the sidebar with improved styling""" api_status = check_api_configuration() st.sidebar.markdown("
To configure missing API keys, create a .env file in the project root with the following format:
SERPER_API_KEY=your_serper_api_key
TAVILY_API_KEY=your_tavily_api_key
METAPHOR_API_KEY=your_metaphor_api_key
FIRECRAWL_API_KEY=your_firecrawl_api_key
Alternatively, you can set these as environment variables in your system.