mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
b88ca96064
* 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.
78 lines
2.8 KiB
Go
78 lines
2.8 KiB
Go
package providers
|
|
|
|
import "time"
|
|
|
|
// CreateRequest represents a request to create a new LLM provider.
|
|
type CreateRequest struct {
|
|
Name string `json:"name" validate:"required"`
|
|
BaseURL string `json:"base_url" validate:"required,url"`
|
|
APIKey string `json:"api_key"` //nolint:gosec // intentional: LLM provider API key supplied by operator
|
|
ClientType string `json:"client_type" validate:"required"`
|
|
Icon string `json:"icon,omitempty"`
|
|
Metadata map[string]any `json:"metadata,omitempty"`
|
|
}
|
|
|
|
// UpdateRequest represents a request to update an existing LLM provider.
|
|
type UpdateRequest struct {
|
|
Name *string `json:"name,omitempty"`
|
|
BaseURL *string `json:"base_url,omitempty"`
|
|
APIKey *string `json:"api_key,omitempty"` //nolint:gosec // intentional: LLM provider API key update field
|
|
ClientType *string `json:"client_type,omitempty"`
|
|
Icon *string `json:"icon,omitempty"`
|
|
Enable *bool `json:"enable,omitempty"`
|
|
Metadata map[string]any `json:"metadata,omitempty"`
|
|
}
|
|
|
|
// GetResponse represents the response for getting a provider.
|
|
type GetResponse struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
BaseURL string `json:"base_url"`
|
|
APIKey string `json:"api_key,omitempty"` //nolint:gosec // intentional: partially masked API key for display
|
|
ClientType string `json:"client_type"`
|
|
Icon string `json:"icon,omitempty"`
|
|
Enable bool `json:"enable"`
|
|
Metadata map[string]any `json:"metadata,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// ListResponse represents the response for listing providers.
|
|
type ListResponse struct {
|
|
Providers []GetResponse `json:"providers"`
|
|
Total int64 `json:"total"`
|
|
}
|
|
|
|
// CountResponse represents the count response.
|
|
type CountResponse struct {
|
|
Count int64 `json:"count"`
|
|
}
|
|
|
|
// TestResponse is returned by POST /providers/:id/test.
|
|
type TestResponse struct {
|
|
Reachable bool `json:"reachable"`
|
|
LatencyMs int64 `json:"latency_ms,omitempty"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
|
|
// RemoteModel represents a model returned by the provider's /v1/models endpoint.
|
|
type RemoteModel struct {
|
|
ID string `json:"id"`
|
|
Object string `json:"object"`
|
|
Created int64 `json:"created"`
|
|
OwnedBy string `json:"owned_by"`
|
|
}
|
|
|
|
// FetchModelsResponse represents the response from the provider's /v1/models endpoint.
|
|
type FetchModelsResponse struct {
|
|
Object string `json:"object"`
|
|
Data []RemoteModel `json:"data"`
|
|
}
|
|
|
|
// ImportModelsResponse represents the response for importing models.
|
|
type ImportModelsResponse struct {
|
|
Created int `json:"created"`
|
|
Skipped int `json:"skipped"`
|
|
Models []string `json:"models"`
|
|
}
|