Files
Luminary/internal/model/model_entry.go
T
renjue a4274be444
CI / docker (push) Successful in 4m52s
Split ingress keys into text/image protocols with Replicate model listing.
Text keys use OpenAI routes; image keys use predictions with ingress Model ID,
owner/name or short name resolution, OpenAPI input schemas, editable workflows
with per-field defaults, protocol-aware admin whitelist, and in-app API docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 23:32:13 +08:00

59 lines
1.5 KiB
Go

package model
import "strings"
// IngressID returns the model name exposed to ingress API clients.
func (m ModelEntry) IngressID() string {
if m.Alias != "" {
return m.Alias
}
return m.ModelID
}
// SplitIngressOwnerName splits an ingress model identifier into Replicate owner/name parts.
func SplitIngressOwnerName(ingressID, providerName string) (owner, name string) {
if i := strings.Index(ingressID, "/"); i > 0 {
return ingressID[:i], ingressID[i+1:]
}
owner = providerName
if owner == "" {
owner = "luminary"
}
name = ingressID
if name == "" {
name = "model"
}
return owner, name
}
// OwnerName returns the Replicate-style owner/name for an ingress model entry.
func (m ModelEntry) OwnerName(providerName string) (string, string) {
return SplitIngressOwnerName(m.IngressID(), providerName)
}
// MatchesIngressName reports whether the entry matches an ingress model identifier.
func (m ModelEntry) MatchesIngressName(name string) bool {
if name == "" || !m.Enabled {
return false
}
if m.ModelID == name || m.VersionHash == name {
return true
}
return m.Alias != "" && m.Alias == name
}
// MatchesIngressRef reports whether ref identifies this model (ingress ID, owner/name, or short name).
func (m ModelEntry) MatchesIngressRef(ref, providerName string) bool {
if !m.Enabled || ref == "" {
return false
}
if m.MatchesIngressName(ref) {
return true
}
owner, name := m.OwnerName(providerName)
if ref == name || ref == owner+"/"+name {
return true
}
return false
}