49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
// Package rankingcapability describes the scoring role only. Unknown models
|
|
// remain valid synthesis catalogue entries; discovery alone proves no capability.
|
|
package rankingcapability
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
type Capability struct {
|
|
Selectable bool `json:"selectable"`
|
|
Mode string `json:"mode,omitempty"`
|
|
Reason string `json:"reason,omitempty"`
|
|
}
|
|
|
|
// Deliberately exact model IDs: no guessed support for future/unknown names.
|
|
// OpenAI: https://developers.openai.com/api/docs/guides/structured-outputs
|
|
// Ollama local grammar: https://docs.ollama.com/capabilities/structured-outputs
|
|
func Lookup(provider, model, endpoint string) Capability {
|
|
supported := false
|
|
switch provider {
|
|
case "openai":
|
|
switch model {
|
|
case "gpt-6.1-terra", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4o-2024-08-06", "gpt-4o-2024-11-20":
|
|
supported = true
|
|
}
|
|
case "ollama":
|
|
switch model {
|
|
case "llama3", "llama3:8b", "llama3:70b", "qwen2.5:7b", "qwen3:8b":
|
|
supported = true
|
|
}
|
|
if endpoint != "" {
|
|
u, err := url.Parse(endpoint)
|
|
if err != nil || u.Hostname() == "" || (u.Scheme != "http" && u.Scheme != "https") {
|
|
supported = false
|
|
} else {
|
|
host := strings.ToLower(u.Hostname())
|
|
if host == "ollama.com" || strings.HasSuffix(host, ".ollama.com") {
|
|
supported = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if supported {
|
|
return Capability{Selectable: true, Mode: "json_schema"}
|
|
}
|
|
return Capability{Reason: "ranking_structured_output_unsupported"}
|
|
}
|