Design: Load Local Env File
Overview
The app should support the common local workflow:
- Copy
.env.exampleto.env. - Fill in local endpoints and keys.
- Start the app without additional shell exports.
Use python-dotenv because it is small, conventional, and avoids custom parsing. Call load_dotenv() at import time before constants such as MINICPM_VISION_BASE_URL, KLEIN_MODAL_ENDPOINT, and LLAMA_CPP_BASE_URL are read.
Startup Flow
In app.py:
- import
load_dotenvnear other third-party imports - call
load_dotenv()before configuration constants are assigned - keep existing
os.getenv(...)calls unchanged after that point
python-dotenv does not override already-set process environment variables by default, which is the desired precedence.
Dependency
Add python-dotenv to requirements.txt. Pinning is not required unless the repository already pins direct dependencies strictly.
Documentation
Update local setup docs to say:
.env.exampleis a template.envis ignored by git.envis loaded automatically by the app- process environment values still override
.env
Avoid showing real API keys or suggesting that users commit .env.
Verification
Extend scripts/verify.py to check:
requirements.txtincludespython-dotenvapp.pyimports and callsload_dotenv()- the call appears before core env constants are read
.env.examplestill exists and remains free of real-looking secrets
The verifier should not require a real .env file.