This guide explains how to properly configure the Enhanced Research Agent for both local and cloud environments.
- Model:
gemma2:2b(via Ollama) - Config:
.envfile - Dependencies: All installed locally
# The app automatically detects it's running locally
environment = "local"
model = "gemma2:2b" # Uses your local Ollama- Model:
microsoft/Phi-3-mini-4k-instruct(via Hugging Face) - Config: Streamlit secrets
- Dependencies: Installed from
requirements.txt
# The app automatically detects it's running in cloud
environment = "cloud"
model = "microsoft/Phi-3-mini-4k-instruct" # Uses Hugging FaceThe app uses this priority order for configuration:
- Environment Variables (highest priority)
- Streamlit Secrets (cloud only)
- Default Values (fallback)
# Set these in your environment
export LLM_MODEL="microsoft/Phi-3-mini-4k-instruct"
export OPENAI_API_KEY="your-key-here"
export LANGFUSE_PUBLIC_KEY="your-key-here"
export LANGFUSE_SECRET_KEY="your-key-here"In Streamlit Cloud, add these to your secrets:
# .streamlit/secrets.toml
LLM_MODEL = "microsoft/Phi-3-mini-4k-instruct"
OPENAI_API_KEY = "your-openai-api-key"
LANGFUSE_PUBLIC_KEY = "your-langfuse-public-key"
LANGFUSE_SECRET_KEY = "your-langfuse-secret-key"
LANGFUSE_HOST = "https://us.cloud.langfuse.com"# The app will automatically use the right model
# No code changes needed!- Go to Streamlit Cloud
- Connect your GitHub repository
- Set main file:
enhanced_agent_streamlit.py - Add secrets (optional, for full functionality)
# Local (uses gemma2:2b)
streamlit run enhanced_agent_streamlit.py
# Cloud (uses microsoft/Phi-3-mini-4k-instruct)
# Deploy to Streamlit Cloud| Environment | Model | Size | Speed | Reasoning | Best For |
|---|---|---|---|---|---|
| Local | gemma2:2b | 2B | ⭐⭐⭐⭐ | ⭐⭐⭐ | Private, fast |
| Cloud | Phi-3-mini | 3.8B | ⭐⭐⭐ | ⭐⭐⭐⭐ | Public, powerful |
-
"No module named 'dotenv'"
- ✅ Fixed: App now handles missing dotenv gracefully
- Solution: Uses environment variables instead
-
"Model not found"
- ✅ Fixed: App automatically selects appropriate model
- Solution: Uses Hugging Face models in cloud
-
"Configuration not loaded"
- ✅ Fixed: App uses multiple configuration sources
- Solution: Falls back to defaults if needed
The app will show:
🌍 Environment: local/cloud
🤖 Using model: gemma2:2b/microsoft/Phi-3-mini-4k-instruct
✅ Configuration helper loaded
- ✅ Uses
gemma2:2bvia Ollama - ✅ Loads
.envfile - ✅ Full DSPy structured reasoning
- ✅ Langfuse tracing
- ✅ MCP information gathering
- ✅ Uses
microsoft/Phi-3-mini-4k-instructvia Hugging Face - ✅ Loads Streamlit secrets
- ✅ Full DSPy structured reasoning
- ✅ Langfuse tracing (if API keys provided)
- ✅ MCP information gathering
- Automatic Detection: App knows which environment it's in
- Graceful Fallbacks: Works even with missing dependencies
- No Code Changes: Same code works in both environments
- Optimal Performance: Uses best model for each environment
- Easy Deployment: Just push to GitHub and deploy
The app is now truly cloud-ready! 🎉