feat: establish unified administration and model context baseline
This commit is contained in:
@@ -25,8 +25,26 @@ type ModelCatalog struct {
|
||||
}
|
||||
|
||||
type ModelCatalogDefaults struct {
|
||||
Session string `yaml:"session" json:"session"`
|
||||
MetadataGeneration string `yaml:"metadataGeneration,omitempty" json:"metadataGeneration,omitempty"`
|
||||
Interaction string `yaml:"interaction" json:"interaction"`
|
||||
// Legacy input only. NormalizeDefaults clears these before projections or serialization.
|
||||
Session string `yaml:"session,omitempty" json:"-"`
|
||||
MetadataGeneration string `yaml:"metadataGeneration,omitempty" json:"-"`
|
||||
}
|
||||
|
||||
// NormalizeDefaults accepts unambiguous legacy configuration without rewriting the source file.
|
||||
func (c *ModelCatalog) NormalizeDefaults() error {
|
||||
d := &c.Defaults
|
||||
if d.Interaction != "" && (d.Session != "" || d.MetadataGeneration != "") {
|
||||
return errors.New("migration_required: use only modelCatalog.defaults.interaction, not legacy defaults")
|
||||
}
|
||||
if d.Interaction == "" {
|
||||
if d.Session != "" && d.MetadataGeneration != "" && d.Session != d.MetadataGeneration {
|
||||
return errors.New("migration_required: session and metadataGeneration defaults differ; explicitly choose modelCatalog.defaults.interaction and remove both legacy defaults")
|
||||
}
|
||||
d.Interaction = d.Session
|
||||
}
|
||||
d.Session, d.MetadataGeneration = "", ""
|
||||
return nil
|
||||
}
|
||||
|
||||
type ModelCatalogEmbedding struct {
|
||||
@@ -138,8 +156,8 @@ func (c ModelCatalog) RuntimeModels() []RuntimeModel {
|
||||
|
||||
// Validate rejects ambiguous, duplicated, or runtime-incompatible catalog declarations.
|
||||
func (c ModelCatalog) Validate(environment map[string]string) error {
|
||||
if c.Defaults.Session == "" {
|
||||
return errors.New("modelCatalog.defaults.session is required")
|
||||
if c.Defaults.Interaction == "" {
|
||||
return errors.New("modelCatalog.defaults.interaction is required")
|
||||
}
|
||||
if !catalogModelIDPattern.MatchString(c.Embedding.ID) || !strings.HasPrefix(c.Embedding.ID, "ollama/") || c.Embedding.Dimensions <= 0 {
|
||||
return errors.New("modelCatalog.embedding requires an ollama canonical id and positive dimensions")
|
||||
@@ -206,17 +224,9 @@ func (c ModelCatalog) Validate(environment map[string]string) error {
|
||||
}
|
||||
|
||||
models := c.RuntimeModels()
|
||||
if !runtimeModelEligible(models, c.Defaults.Session, "session") {
|
||||
return fmt.Errorf("modelCatalog.defaults.session %q is not a session model", c.Defaults.Session)
|
||||
}
|
||||
if hasMetadata && c.Defaults.MetadataGeneration == "" {
|
||||
return errors.New("modelCatalog.defaults.metadataGeneration is required when metadata models are configured")
|
||||
}
|
||||
if !hasMetadata && c.Defaults.MetadataGeneration != "" {
|
||||
return errors.New("modelCatalog.defaults.metadataGeneration must be empty when metadata generation is unavailable")
|
||||
}
|
||||
if hasMetadata && !runtimeModelEligible(models, c.Defaults.MetadataGeneration, "metadata") {
|
||||
return fmt.Errorf("modelCatalog.defaults.metadataGeneration %q is not a metadata-generation model", c.Defaults.MetadataGeneration)
|
||||
if !runtimeModelEligible(models, c.Defaults.Interaction, "session") ||
|
||||
(hasMetadata && !runtimeModelEligible(models, c.Defaults.Interaction, "metadata")) {
|
||||
return fmt.Errorf("modelCatalog.defaults.interaction %q must support Core and every configured Admin LLM use", c.Defaults.Interaction)
|
||||
}
|
||||
return validateCatalogSecrets(environment, secretsNeeded)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user