refactor provider interface to return models with metadata
- replaced old TranscriptionModels/LLMModels/SupportsX methods with Models() []Model - added DefaultModel(t ModelType), IsLocal() to interface - added helpers: GetModel, ModelsOfType, FindModelByID, ModelsForLanguage, ValidateModelLanguage - all providers now return full Model metadata with SupportedLanguages, AdapterType, Endpoint - groq distil-whisper-large-v3-en marked as english-only - updated TUI to use new interface
This commit is contained in:
+77
-19
@@ -1,6 +1,10 @@
|
||||
package provider
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/leonardotrapani/hyprvoice/internal/language"
|
||||
)
|
||||
|
||||
// OpenAIProvider implements Provider for OpenAI services
|
||||
type OpenAIProvider struct{}
|
||||
@@ -17,26 +21,80 @@ func (p *OpenAIProvider) ValidateAPIKey(key string) bool {
|
||||
return strings.HasPrefix(key, "sk-")
|
||||
}
|
||||
|
||||
func (p *OpenAIProvider) SupportsTranscription() bool {
|
||||
return true
|
||||
func (p *OpenAIProvider) IsLocal() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *OpenAIProvider) SupportsLLM() bool {
|
||||
return true
|
||||
func (p *OpenAIProvider) Models() []Model {
|
||||
allLangs := language.AllLanguageCodes()
|
||||
|
||||
return []Model{
|
||||
// transcription models
|
||||
{
|
||||
ID: "whisper-1",
|
||||
Name: "Whisper 1",
|
||||
Description: "OpenAI's production speech-to-text model",
|
||||
Type: Transcription,
|
||||
Streaming: false,
|
||||
Local: false,
|
||||
AdapterType: "openai",
|
||||
SupportedLanguages: allLangs,
|
||||
Endpoint: &EndpointConfig{BaseURL: "https://api.openai.com", Path: "/v1/audio/transcriptions"},
|
||||
},
|
||||
// LLM models
|
||||
{
|
||||
ID: "gpt-4o-mini",
|
||||
Name: "GPT-4o Mini",
|
||||
Description: "Fast and affordable GPT-4 variant",
|
||||
Type: LLM,
|
||||
Streaming: false,
|
||||
Local: false,
|
||||
AdapterType: "openai",
|
||||
SupportedLanguages: allLangs,
|
||||
Endpoint: &EndpointConfig{BaseURL: "https://api.openai.com", Path: "/v1/chat/completions"},
|
||||
},
|
||||
{
|
||||
ID: "gpt-4o",
|
||||
Name: "GPT-4o",
|
||||
Description: "Most capable GPT-4 model",
|
||||
Type: LLM,
|
||||
Streaming: false,
|
||||
Local: false,
|
||||
AdapterType: "openai",
|
||||
SupportedLanguages: allLangs,
|
||||
Endpoint: &EndpointConfig{BaseURL: "https://api.openai.com", Path: "/v1/chat/completions"},
|
||||
},
|
||||
{
|
||||
ID: "gpt-4-turbo",
|
||||
Name: "GPT-4 Turbo",
|
||||
Description: "Faster GPT-4 with large context window",
|
||||
Type: LLM,
|
||||
Streaming: false,
|
||||
Local: false,
|
||||
AdapterType: "openai",
|
||||
SupportedLanguages: allLangs,
|
||||
Endpoint: &EndpointConfig{BaseURL: "https://api.openai.com", Path: "/v1/chat/completions"},
|
||||
},
|
||||
{
|
||||
ID: "gpt-3.5-turbo",
|
||||
Name: "GPT-3.5 Turbo",
|
||||
Description: "Fast and cost-effective",
|
||||
Type: LLM,
|
||||
Streaming: false,
|
||||
Local: false,
|
||||
AdapterType: "openai",
|
||||
SupportedLanguages: allLangs,
|
||||
Endpoint: &EndpointConfig{BaseURL: "https://api.openai.com", Path: "/v1/chat/completions"},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (p *OpenAIProvider) DefaultTranscriptionModel() string {
|
||||
return "whisper-1"
|
||||
}
|
||||
|
||||
func (p *OpenAIProvider) DefaultLLMModel() string {
|
||||
return "gpt-4o-mini"
|
||||
}
|
||||
|
||||
func (p *OpenAIProvider) TranscriptionModels() []string {
|
||||
return []string{"whisper-1"}
|
||||
}
|
||||
|
||||
func (p *OpenAIProvider) LLMModels() []string {
|
||||
return []string{"gpt-4o-mini", "gpt-4o", "gpt-4-turbo", "gpt-3.5-turbo"}
|
||||
func (p *OpenAIProvider) DefaultModel(t ModelType) string {
|
||||
switch t {
|
||||
case Transcription:
|
||||
return "whisper-1"
|
||||
case LLM:
|
||||
return "gpt-4o-mini"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user