Files
promptkit/internal/llm/provider.go

60 lines
1.7 KiB
Go

package llm
import (
"net/url"
"go.maximumdirect.net/promptkit/internal/domain"
)
// EffectiveProvider resolves an omitted provider to the generic conventions.
func EffectiveProvider(provider string) string {
if provider == "" {
return "openai-compatible"
}
return provider
}
// SupportedProvider reports whether a normalized provider selection is supported.
// An empty selection uses the generic OpenAI-compatible conventions.
func SupportedProvider(provider string) bool {
switch provider {
case "", "openai-compatible", "openrouter", "vllm":
return true
default:
return false
}
}
// AuthenticationAdapter selects declared diagnostic metadata or provider defaults.
func AuthenticationAdapter(provider string, smoke *domain.BackendSmokeTestConfig) string {
if smoke != nil && smoke.Authentication != nil && smoke.Authentication.Kind != nil {
return *smoke.Authentication.Kind
}
switch provider {
case "openrouter":
return "openrouter_key"
case "vllm":
return "vllm_models"
}
return ""
}
// AuthenticationEndpoint resolves a diagnostic destination without changing configuration.
func AuthenticationEndpoint(adapter, base string, smoke *domain.BackendSmokeTestConfig) (string, error) {
if smoke != nil && smoke.Authentication != nil && smoke.Authentication.Endpoint != nil {
return *smoke.Authentication.Endpoint, nil
}
if adapter == "openrouter_key" {
return OpenRouterKeyEndpoint(base)
}
if adapter == "vllm_models" {
return url.JoinPath(base, "models")
}
return base, nil
}
// SupportedAuthenticationAdapter identifies implemented authentication probes.
func SupportedAuthenticationAdapter(adapter string) bool {
return adapter == "openrouter_key" || adapter == "vllm_models"
}