feat(generation): score articles with selected relevance model (#48)

This commit is contained in:
2026-11-25 18:09:36 +01:00
parent c5b8d0d4da
commit 90dd2a65d2
53 changed files with 1639 additions and 105 deletions

View File

@ -0,0 +1,48 @@
// 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-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"}
}