feat(builtin-models): add YAML-based declarative config with ${ENV} interpolation

Allow built-in models to be declared in config/builtin_models.yaml
instead of inserting rows via SQL. On every startup the file is read
and each entry is UPSERT-ed into the models table (is_builtin=true)
by stable id.

Any string field may reference an environment variable with ${NAME}.
Unset variables are left as the literal placeholder so
misconfiguration surfaces clearly in provider calls rather than
failing silently with an empty token.

The file is optional: missing file, parse errors, and per-entry
upsert failures all log a warning without aborting startup.
docker-compose.yml adds env_file (.env, required:false) so
deployment-specific variables are passed through automatically.
This commit is contained in:
jackson.jia
2026-05-22 23:15:12 +08:00
committed by lyingbug
parent e9be53e830
commit d439b3ae07
8 changed files with 475 additions and 113 deletions

View File

@@ -41,12 +41,23 @@ services:
- ./config/config.yaml:/app/config/config.yaml
# Optional: mount custom skills directory (allows adding skills without rebuilding image)
- ./skills/preloaded:/app/skills/preloaded
# Optional: declarative built-in models. Copy config/builtin_models.yaml.example
# to config/builtin_models.yaml, edit it for your deployment, then
# uncomment the line below. See docs/BUILTIN_MODELS.md.
# - ./config/builtin_models.yaml:/app/config/builtin_models.yaml:ro
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# Optional: source .env so deployment-specific vars (e.g. those referenced
# by config/builtin_models.yaml via ${ENV}) reach the app container without
# having to be listed individually under `environment:`. Falls back
# silently when .env is absent (e.g. fresh upstream clone).
env_file:
- path: .env
required: false
environment:
- LOG_LEVEL=${LOG_LEVEL:-}
- COS_SECRET_ID=${COS_SECRET_ID:-}