add Model type with full metadata for provider architecture
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package provider
|
||||
|
||||
import "github.com/leonardotrapani/hyprvoice/internal/language"
|
||||
|
||||
// ModelType represents the type of a model
|
||||
type ModelType int
|
||||
|
||||
const (
|
||||
Transcription ModelType = iota
|
||||
LLM
|
||||
)
|
||||
|
||||
// Model represents a model with full metadata
|
||||
type Model struct {
|
||||
ID string // unique identifier (e.g., "whisper-1", "gpt-4o-mini")
|
||||
Name string // display name (e.g., "Whisper 1", "GPT-4o Mini")
|
||||
Description string // short description
|
||||
Type ModelType // transcription or LLM
|
||||
Streaming bool // supports streaming
|
||||
Local bool // runs locally (no API call)
|
||||
AdapterType string // which adapter to use (e.g., "openai", "elevenlabs", "whisper-cpp")
|
||||
SupportedLanguages []string // explicit list of supported language codes
|
||||
Endpoint *EndpointConfig // nil for local models
|
||||
LocalInfo *LocalModelInfo // nil for cloud models
|
||||
}
|
||||
|
||||
// EndpointConfig holds HTTP/WebSocket endpoint configuration
|
||||
type EndpointConfig struct {
|
||||
BaseURL string // e.g., "https://api.openai.com" or "wss://api.deepgram.com"
|
||||
Path string // e.g., "/v1/audio/transcriptions"
|
||||
}
|
||||
|
||||
// LocalModelInfo holds metadata for downloadable local models
|
||||
type LocalModelInfo struct {
|
||||
Filename string // e.g., "ggml-base.en.bin"
|
||||
Size string // human readable size (e.g., "142MB")
|
||||
DownloadURL string // full URL to download from
|
||||
}
|
||||
|
||||
// NeedsDownload returns true if this is a local model that requires downloading
|
||||
func (m *Model) NeedsDownload() bool {
|
||||
return m.LocalInfo != nil
|
||||
}
|
||||
|
||||
// IsStreaming returns true if this model supports streaming
|
||||
func (m *Model) IsStreaming() bool {
|
||||
return m.Streaming
|
||||
}
|
||||
|
||||
// SupportsLanguage returns true if the model supports the given language code.
|
||||
// Auto-detect (empty string) is always supported.
|
||||
func (m *Model) SupportsLanguage(code string) bool {
|
||||
if code == "" {
|
||||
return true // auto always supported
|
||||
}
|
||||
for _, supported := range m.SupportedLanguages {
|
||||
if supported == code {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// SupportsAllLanguages returns true if the model supports all 57 languages
|
||||
func (m *Model) SupportsAllLanguages() bool {
|
||||
allCodes := language.AllLanguageCodes()
|
||||
return len(m.SupportedLanguages) == len(allCodes)
|
||||
}
|
||||
Reference in New Issue
Block a user