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
+38 -57
View File
@@ -1914,22 +1914,14 @@ definitions:
type: object
models.AddRequest:
properties:
client_type:
$ref: '#/definitions/models.ClientType'
dimensions:
type: integer
input_modalities:
items:
type: string
type: array
config:
$ref: '#/definitions/models.ModelConfig'
llm_provider_id:
type: string
model_id:
type: string
name:
type: string
supports_reasoning:
type: boolean
type:
$ref: '#/definitions/models.ModelType'
type: object
@@ -1940,18 +1932,6 @@ definitions:
model_id:
type: string
type: object
models.ClientType:
enum:
- openai-responses
- openai-completions
- anthropic-messages
- google-generative-ai
type: string
x-enum-varnames:
- ClientTypeOpenAIResponses
- ClientTypeOpenAICompletions
- ClientTypeAnthropicMessages
- ClientTypeGoogleGenerativeAI
models.CountResponse:
properties:
count:
@@ -1959,27 +1939,30 @@ definitions:
type: object
models.GetResponse:
properties:
client_type:
$ref: '#/definitions/models.ClientType'
dimensions:
type: integer
config:
$ref: '#/definitions/models.ModelConfig'
id:
type: string
input_modalities:
items:
type: string
type: array
llm_provider_id:
type: string
model_id:
type: string
name:
type: string
supports_reasoning:
type: boolean
type:
$ref: '#/definitions/models.ModelType'
type: object
models.ModelConfig:
properties:
compatibilities:
items:
type: string
type: array
context_window:
type: integer
dimensions:
type: integer
type: object
models.ModelType:
enum:
- chat
@@ -2013,22 +1996,14 @@ definitions:
- TestStatusError
models.UpdateRequest:
properties:
client_type:
$ref: '#/definitions/models.ClientType'
dimensions:
type: integer
input_modalities:
items:
type: string
type: array
config:
$ref: '#/definitions/models.ModelConfig'
llm_provider_id:
type: string
model_id:
type: string
name:
type: string
supports_reasoning:
type: boolean
type:
$ref: '#/definitions/models.ModelType'
type: object
@@ -2043,6 +2018,10 @@ definitions:
type: string
base_url:
type: string
client_type:
type: string
icon:
type: string
metadata:
additionalProperties: {}
type: object
@@ -2050,6 +2029,7 @@ definitions:
type: string
required:
- base_url
- client_type
- name
type: object
providers.GetResponse:
@@ -2058,8 +2038,14 @@ definitions:
type: string
base_url:
type: string
client_type:
type: string
created_at:
type: string
enable:
type: boolean
icon:
type: string
id:
type: string
metadata:
@@ -2070,11 +2056,6 @@ definitions:
updated_at:
type: string
type: object
providers.ImportModelsRequest:
properties:
client_type:
type: string
type: object
providers.ImportModelsResponse:
properties:
created:
@@ -2101,6 +2082,12 @@ definitions:
type: string
base_url:
type: string
client_type:
type: string
enable:
type: boolean
icon:
type: string
metadata:
additionalProperties: {}
type: object
@@ -3079,7 +3066,7 @@ paths:
- local-channel
/bots/{bot_id}/compaction/logs:
delete:
description: Delete all context compaction logs for a bot
description: Delete all compaction logs for a bot
parameters:
- description: Bot ID
in: path
@@ -3101,7 +3088,7 @@ paths:
tags:
- compaction
get:
description: List context compaction logs for a bot
description: List compaction logs for a bot
parameters:
- description: Bot ID
in: path
@@ -7202,13 +7189,13 @@ paths:
/models:
get:
description: Get a list of all configured models, optionally filtered by type
or client type
or provider client type
parameters:
- description: Model type (chat, embedding)
in: query
name: type
type: string
- description: Client type (openai-responses, openai-completions, anthropic-messages,
- description: Provider client type (openai-responses, openai-completions, anthropic-messages,
google-generative-ai)
in: query
name: client_type
@@ -7664,12 +7651,6 @@ paths:
name: id
required: true
type: string
- description: Import configuration
in: body
name: request
required: true
schema:
$ref: '#/definitions/providers.ImportModelsRequest'
produces:
- application/json
responses: