// Package services is the AI service of the golem15.golem plugin: the // model configuration a call runs with, the admin-configured models and // AIService, which sends prompts through the provider adapters. package services // ModelConfig is one AI model a call runs with (PHP's model config // array): the adapter (openai or anthropic), the API key, the base URL ("" means // the provider default), the model id and the model's default system // prompt. Trusted is set only for models an operator configured in the // admin: their calls may reach local-network endpoints (fetchguard // TrustedMode). Every other config, such as a user's or an organisation's // own key, runs guarded (fetchguard PublicOnlyMode). APIKey is a secret: // never log or serialize a ModelConfig. type ModelConfig struct { Name string `json:"-"` Adapter string `json:"-"` APIKey string `json:"-"` BaseURL string `json:"-"` Model string `json:"-"` SystemPrompt string `json:"-"` MaxCompletionTokens int `json:"-"` HasFilesEndpoint bool `json:"-"` AcceptsImages bool `json:"-"` GeneratesImages bool `json:"-"` Trusted bool `json:"-"` // Position is an admin model's place among all configured models // (the WinterCMS repeater index); only the configs Models returns // carry one. Position int `json:"-"` isDefault bool } // DefaultModelID is the model a config without one uses (PHP's // `$config['model'] ?? 'gpt-4o'`). const DefaultModelID = "gpt-4o" func (c *ModelConfig) modelID(def string) string { if c.Model == "" { return def } return c.Model }