Files
Memoh/internal/providers/types.go
T
BBQ f9f968f13f feat(models): per-model probe testing with auto-detect UI (#133)
* feat(models): add per-model probe testing and auto-detect in UI

Move health probes from provider level to model level for precise
testing with real model_id and client_type. Provider test is now a
simple reachability check.

Backend:
- Add POST /models/:id/test endpoint that probes the model's provider
  using its actual model_id and client_type
- Add model healthcheck checker for bot health checks (chat/memory/embedding)
- Simplify provider test to reachability-only

Frontend:
- Auto-probe models on mount with status indicator (green/yellow/red dot + latency)
- Auto-probe provider reachability on load and on provider switch
- Fix missing faBolt icon registration
- Manual re-probe via refresh button

Closes #117

* fix(models): increase probe timeout to 15s for slow providers

Some providers (e.g. DashScope) exceed the 5s probe timeout, causing
false-negative "context deadline exceeded" errors. Increase per-probe
timeout to 15s and healthcheck overall timeout to 30s.

* fix(sdk): regenerate exports after merge conflict

Resolve duplicate SDK exports introduced by merge conflict resolution so the web build can compile again while preserving new model probe endpoints.
2026-03-02 14:59:15 +08:00

49 lines
1.6 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"`
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"`
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"` // masked in response
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"`
}