@@ -35,7 +35,7 @@ func NewOpenAIAdapter(endpoint *provider.EndpointConfig, apiKey, model, lang str
|
||||
if endpoint != nil && endpoint.BaseURL != "" {
|
||||
// use custom endpoint
|
||||
clientConfig := openai.DefaultConfig(apiKey)
|
||||
clientConfig.BaseURL = endpoint.BaseURL + "/v1"
|
||||
clientConfig.BaseURL = strings.TrimRight(endpoint.BaseURL, "/") + "/v1"
|
||||
client = openai.NewClientWithConfig(clientConfig)
|
||||
} else {
|
||||
// default to OpenAI
|
||||
|
||||
@@ -31,8 +31,9 @@ type Config struct {
|
||||
Language string
|
||||
Model string
|
||||
Keywords []string
|
||||
Threads int // CPU threads for local transcription (0 = auto)
|
||||
Streaming bool // use streaming mode if model supports it
|
||||
Threads int // CPU threads for local transcription (0 = auto)
|
||||
Streaming bool // use streaming mode if model supports it
|
||||
BaseURL string // OpenAI-compatible base URL, without /v1
|
||||
}
|
||||
|
||||
// NewTranscriber creates a new transcriber based on model metadata
|
||||
@@ -55,6 +56,22 @@ func NewTranscriber(config Config) (Transcriber, error) {
|
||||
return nil, fmt.Errorf("%s API key required", cases.Title(language.English).String(registryProvider))
|
||||
}
|
||||
|
||||
// llama-swap proxies arbitrary OpenAI-compatible model IDs, so models are
|
||||
// intentionally configured by the user rather than limited to this registry.
|
||||
if registryProvider == provider.ProviderLlamaSwap {
|
||||
if config.Model == "" {
|
||||
return nil, fmt.Errorf("model is required for llama-swap")
|
||||
}
|
||||
if config.BaseURL == "" {
|
||||
return nil, fmt.Errorf("llama-swap base_url required")
|
||||
}
|
||||
if config.Streaming {
|
||||
return nil, fmt.Errorf("llama-swap transcription currently supports batch mode only (set streaming = false)")
|
||||
}
|
||||
endpoint := &provider.EndpointConfig{BaseURL: config.BaseURL}
|
||||
return NewSimpleTranscriber(config, NewOpenAIAdapter(endpoint, config.APIKey, config.Model, config.Language, config.Keywords, registryProvider)), nil
|
||||
}
|
||||
|
||||
// lookup model from provider
|
||||
model, err := provider.GetModel(registryProvider, config.Model)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user