refactor: provider & models (#277)

* refactor: move client_type to provider, replace model fields with config JSONB

- Move `client_type` from `models` to `llm_providers` table
- Add `icon` field to `llm_providers`
- Replace `dimensions`, `input_modalities`, `supports_reasoning` on `models`
  with a single `config` JSONB column containing `dimensions`,
  `compatibilities` (vision, tool-call, image-output, reasoning),
  and `context_window`
- Auto-imported models default to vision + tool-call + reasoning
- Update all backend consumers (agent, flow resolver, handlers, memory)
- Regenerate sqlc, swagger, and TypeScript SDK
- Update frontend forms, display, and i18n for new schema

* ui: show provider icon avatar in sidebar and detail header, remove icon input

* feat: add built-in provider registry with YAML definitions and enable toggle

- Add `enable` column to llm_providers (default true, backward-compatible)
- Create internal/registry package to load YAML provider/model definitions
  on startup and upsert into database (new providers disabled by default)
- Add conf/providers/ with OpenAI, Anthropic, Google YAML definitions
- Add RegistryConfig to TOML config (providers_dir, default conf/providers)
- Model listing APIs and conversation flow now filter by enabled providers
- Frontend: enable switch in provider form, green status dot in sidebar,
  enabled providers sorted to top

* fix: make 0041 migration idempotent for fresh databases

Guard data migration steps with column-existence checks so the
migration succeeds on databases created from the updated init schema.
This commit is contained in:
Acbox Liu
2026-03-22 17:24:45 +08:00
committed by GitHub
parent de62f94315
commit b88ca96064
60 changed files with 1599 additions and 1224 deletions
+1 -2
View File
@@ -369,9 +369,8 @@ SET compact_id = $1
WHERE id = ANY($2::uuid[]);
-- name: ListUncompactedMessagesBySession :many
SELECT id, chat_id, session_id, role, content, usage, platform, external_message_id, sender_channel_identity_id, compact_id, created_at
SELECT id, bot_id, session_id, role, content, usage, sender_channel_identity_id, compact_id, created_at
FROM bot_history_messages
WHERE session_id = $1
AND compact_id IS NULL
AND is_active = true
ORDER BY created_at ASC;