mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
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:
@@ -525,14 +525,20 @@ func resolveDenseEmbeddingModel(ctx context.Context, queries *dbsqlc.Queries, mo
|
||||
if err != nil {
|
||||
return denseModelSpec{}, fmt.Errorf("dense runtime: get embedding provider: %w", err)
|
||||
}
|
||||
if !row.Dimensions.Valid || row.Dimensions.Int32 <= 0 {
|
||||
var cfg struct {
|
||||
Dimensions *int `json:"dimensions"`
|
||||
}
|
||||
if len(row.Config) > 0 {
|
||||
_ = json.Unmarshal(row.Config, &cfg)
|
||||
}
|
||||
if cfg.Dimensions == nil || *cfg.Dimensions <= 0 {
|
||||
return denseModelSpec{}, fmt.Errorf("dense runtime: embedding model %s missing dimensions", modelRef)
|
||||
}
|
||||
return denseModelSpec{
|
||||
modelID: strings.TrimSpace(row.ModelID),
|
||||
baseURL: strings.TrimSpace(provider.BaseUrl),
|
||||
apiKey: strings.TrimSpace(provider.ApiKey),
|
||||
dimensions: int(row.Dimensions.Int32),
|
||||
dimensions: *cfg.Dimensions,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user