1.2 KiB
1.2 KiB
Streamlit Chat App Implementation Plan
Project Setup
# Create and activate virtual environment
uv venv -p 3.12 env
source env/bin/activate
# Install dependencies using UV
uv pip install -e .
Configuration Management
- Edit
config/config.ini:
[openai]
api_key = your_api_key_here
base_url = https://api.openai.com/v1
model = gpt-3.5-turbo
- Security practices:
- Never commit config.ini to version control
- Use environment variables for production deployment
Modular Code Structure
graph TD
A[app.py] --> B[OpenAIClient]
B --> C[config.ini]
A --> D[Streamlit Components]
style A fill:#4CAF50
style B fill:#2196F3
style C fill:#FF9800
Key Modules:
openai_client.py: API communication layerapp.py: Streamlit UI and business logicconfig/: Centralized configuration management
Development Workflow
- Testing:
streamlit run src/app.py
- Maintenance:
- Update dependencies with
uv pip install -r requirements.txt - Validate config changes before deployment
Best Practices
- Type hints for all function signatures
- Separate UI logic from business logic
- Use Streamlit session state judiciously