2026-11-22 18:11:10 +00:00
|
|
|
package llm
|
|
|
|
|
|
2026-11-22 18:16:13 +00:00
|
|
|
import "go.maximumdirect.net/promptkit/internal/domain"
|
|
|
|
|
|
2026-11-22 18:13:17 +00:00
|
|
|
// EffectiveProvider resolves an omitted provider to the generic conventions.
|
|
|
|
|
func EffectiveProvider(provider string) string {
|
|
|
|
|
if provider == "" {
|
|
|
|
|
return "openai-compatible"
|
|
|
|
|
}
|
|
|
|
|
return provider
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-22 18:11:10 +00:00
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-11-22 18:16:13 +00:00
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
if provider == "openrouter" {
|
|
|
|
|
return "openrouter_key"
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
return base, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SupportedAuthenticationAdapter identifies implemented authentication probes.
|
|
|
|
|
func SupportedAuthenticationAdapter(adapter string) bool { return adapter == "openrouter_key" }
|