github-actions[bot]
Deploy from GitHub Actions (commit: eb2cb1538d89b3093b6b424824dd9aecfc99086b)
cff1e0e
| """ | |
| Step 1: API Configuration | |
| """ | |
| import streamlit as st | |
| from core.workflow import set_openai_api_key | |
| from services.key_manager import get_key_manager | |
| def render_step1(): | |
| """Render Step 1: Input API Keys""" | |
| st.header("Step 1: Input Your API Keys") | |
| st.markdown("Configure API keys for the models you want to use for evaluation. (Optional)") | |
| st.markdown("### π OpenAI Configuration") | |
| st.session_state.openai_key_input = st.text_input( | |
| "OpenAI API Key", | |
| type="password", | |
| value=st.session_state.get("openai_key_input", ""), | |
| help="Enter your OpenAI API key for GPT model evaluation (optional)", | |
| ) | |
| if st.session_state.openai_key_input: | |
| if st.button("Test OpenAI Connection", key="test_openai"): | |
| with st.spinner("Testing connection..."): | |
| try: | |
| from providers.openai_client import OpenAIClient | |
| client = OpenAIClient(st.session_state.openai_key_input) | |
| # Simple test - check if key is valid format | |
| if st.session_state.openai_key_input.startswith("sk-"): | |
| st.success("β OpenAI API key format is valid!") | |
| st.session_state.openai_configured = True | |
| st.session_state.openai_key = ( | |
| st.session_state.openai_key_input | |
| ) | |
| # Save to KeyManager | |
| key_manager = get_key_manager() | |
| key_manager.set_key("openai", st.session_state.openai_key) | |
| set_openai_api_key( | |
| st.session_state.openai_key | |
| ) # <-- initialize core | |
| else: | |
| st.error("β Invalid OpenAI API key format") | |
| st.session_state.openai_configured = False | |
| except Exception as e: | |
| st.error(f"β Error: {str(e)}") | |
| st.session_state.openai_configured = False | |
| if st.session_state.get("openai_configured", False): | |
| st.success("β OpenAI is configured and ready!") | |
| # Validation | |
| st.divider() | |
| if st.session_state.get("openai_configured", False): | |
| st.success("β API configured! You can proceed.") | |
| else: | |
| st.info("π‘ You can proceed without configuring an API key, or configure OpenAI above.") | |
| if st.button("Next: Upload File β", type="primary", use_container_width=True): | |
| st.session_state.step = 2 | |
| st.rerun() | |