feat: AI models admin, settings import, Anthropic adapter and the rest of AIService

- golem15_golem_models (encrypted write-only api_key) with its cabana list
  and form under golem15.golem.access_settings, and the Settings lookups
  (Models, DefaultModel with PHP's position-0 quirk, Vision, Image, File,
  ByName), every one Trusted
- golem:import-settings copies the WinterCMS golem_settings repeater once
- AnthropicAdapter; SendStream, SendFile/SendFilePath/SendFileReader,
  SendWithModel, SendToImageModel, SendToVisionModel, GenerateImage, Ask
- PromptFactory; README documents the config keys, the environment
  variable, the command and the admin screen
This commit is contained in:
Jakub Zych
2026-10-03 23:09:02 +02:00
parent da9fcde725
commit c93e2d9142
27 changed files with 2760 additions and 14 deletions

View File

@@ -2,22 +2,31 @@
// SummerCMS applications. It ports the WinterCMS Golem15.Golem plugin's AI
// service (provider adapters for the Anthropic Messages API and the
// OpenAI-compatible chat completions API, prompts, image generation, file
// uploads, streaming) and its SSRF guard.
// uploads, streaming), its AI model settings with their admin screen and
// its SSRF guard.
package golem
import (
"embed"
"io/fs"
"git.golem15.com/golem15/sm-golem-plugin/console"
"git.golem15.com/golem15/sm-golem-plugin/models"
"git.golem15.com/golem15/sm-golem-plugin/updates"
"git.golem15.com/golem15/summercms/modules/backpack"
"git.golem15.com/golem15/summercms/modules/bonfire"
"git.golem15.com/golem15/summercms/modules/pact"
"git.golem15.com/golem15/summercms/modules/party"
"github.com/go-gormigrate/gormigrate/v2"
)
var (
_ party.Plugin = (*Plugin)(nil)
_ pact.HasConfig = (*Plugin)(nil)
_ pact.HasLang = (*Plugin)(nil)
_ party.Plugin = (*Plugin)(nil)
_ pact.HasConfig = (*Plugin)(nil)
_ pact.HasLang = (*Plugin)(nil)
_ pact.HasMigrations = (*Plugin)(nil)
_ pact.HasModels = (*Plugin)(nil)
_ pact.HasCommands = (*Plugin)(nil)
)
//go:embed config
@@ -55,6 +64,17 @@ func (p *Plugin) ConfigFS() fs.FS { return configFS }
// LangFS ships the golem15.golem lang namespace.
func (p *Plugin) LangFS() fs.FS { return langFS }
// Migrations creates golem15_golem_models.
func (p *Plugin) Migrations() []*gormigrate.Migration { return updates.All() }
// Models is AiModel.
func (p *Plugin) Models() []any { return models.All() }
// Commands is golem:import-settings.
func (p *Plugin) Commands() []bonfire.Command {
return []bonfire.Command{console.ImportSettings(p.app)}
}
func init() {
party.Register(&Plugin{})
}