mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
a04b8fd564
- Rename `llm_providers` → `providers`, `llm_provider_oauth_tokens` → `provider_oauth_tokens` - Remove `tts_providers` and `tts_models` tables; speech models now live in the unified `models` table with `type = 'speech'` - Replace top-level `api_key`/`base_url` columns with a JSONB `config` field on `providers` - Rename `llm_provider_id` → `provider_id` across all references - Add `edge-speech` client type and `conf/providers/edge.yaml` default provider - Create new read-only speech endpoints (`/speech-providers`, `/speech-models`) backed by filtered views of the unified tables - Remove old TTS CRUD handlers; simplify speech page to read-only + test - Update registry loader to skip malformed YAML files instead of failing entirely - Fix YAML quoting for model names containing colons in openrouter.yaml - Regenerate sqlc, swagger, and TypeScript SDK
88 lines
3.0 KiB
Go
88 lines
3.0 KiB
Go
package providers
|
|
|
|
import "time"
|
|
|
|
// CreateRequest represents a request to create a new provider.
|
|
type CreateRequest struct {
|
|
Name string `json:"name" validate:"required"`
|
|
ClientType string `json:"client_type" validate:"required"`
|
|
Icon string `json:"icon,omitempty"`
|
|
Config map[string]any `json:"config,omitempty"`
|
|
Metadata map[string]any `json:"metadata,omitempty"`
|
|
}
|
|
|
|
// UpdateRequest represents a request to update an existing provider.
|
|
type UpdateRequest struct {
|
|
Name *string `json:"name,omitempty"`
|
|
ClientType *string `json:"client_type,omitempty"`
|
|
Icon *string `json:"icon,omitempty"`
|
|
Enable *bool `json:"enable,omitempty"`
|
|
Config map[string]any `json:"config,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"`
|
|
ClientType string `json:"client_type"`
|
|
Icon string `json:"icon,omitempty"`
|
|
Enable bool `json:"enable"`
|
|
Config map[string]any `json:"config,omitempty"`
|
|
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"`
|
|
}
|
|
|
|
// OAuthStatus is returned by GET /providers/:id/oauth/status.
|
|
type OAuthStatus struct {
|
|
Configured bool `json:"configured"`
|
|
HasToken bool `json:"has_token"`
|
|
Expired bool `json:"expired"`
|
|
ExpiresAt *time.Time `json:"expires_at,omitempty"`
|
|
CallbackURL string `json:"callback_url"`
|
|
}
|
|
|
|
// 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"`
|
|
Name string `json:"name,omitempty"`
|
|
Type string `json:"type,omitempty"`
|
|
Compatibilities []string `json:"compatibilities,omitempty"`
|
|
ReasoningEfforts []string `json:"reasoning_efforts,omitempty"`
|
|
}
|
|
|
|
// 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"`
|
|
}
|