Files
Memoh/internal/registry/types.go
T
Acbox Liu b88ca96064 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.
2026-03-22 17:24:45 +08:00

26 lines
982 B
Go

package registry
// ProviderDefinition describes a built-in provider loaded from a YAML file.
type ProviderDefinition struct {
Name string `yaml:"name"`
ClientType string `yaml:"client_type"`
Icon string `yaml:"icon,omitempty"`
BaseURL string `yaml:"base_url"`
Models []ModelDefinition `yaml:"models"`
}
// ModelDefinition describes a model within a provider definition.
type ModelDefinition struct {
ModelID string `yaml:"model_id"`
Name string `yaml:"name"`
Type string `yaml:"type"`
Config ModelConfig `yaml:"config"`
}
// ModelConfig mirrors the JSONB config stored per model.
type ModelConfig struct {
Dimensions *int `yaml:"dimensions,omitempty" json:"dimensions,omitempty"`
Compatibilities []string `yaml:"compatibilities,omitempty" json:"compatibilities,omitempty"`
ContextWindow *int `yaml:"context_window,omitempty" json:"context_window,omitempty"`
}