Files
sm-golem-plugin/updates/01_ai_models.go
Jakub Zych c93e2d9142 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
2026-10-03 23:09:02 +02:00

42 lines
1.2 KiB
Go

package updates
import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)
// aiModelsMigration creates golem15_golem_models, one row per AI model
// (the WinterCMS plugin kept them as a repeater inside its system_settings
// row; golem:import-settings copies them over once).
var aiModelsMigration = &gormigrate.Migration{
ID: "202610030101_create_golem_models",
Migrate: func(tx *gorm.DB) error {
return tx.Exec(`
CREATE TABLE golem15_golem_models (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
adapter TEXT NOT NULL DEFAULT 'openai',
api_key TEXT,
base_url TEXT,
model TEXT NOT NULL,
system_prompt TEXT,
is_enabled BOOLEAN NOT NULL DEFAULT FALSE,
is_default BOOLEAN NOT NULL DEFAULT FALSE,
generates_images BOOLEAN NOT NULL DEFAULT FALSE,
accepts_images BOOLEAN NOT NULL DEFAULT FALSE,
has_files_endpoint BOOLEAN NOT NULL DEFAULT FALSE,
max_completion_tokens INTEGER DEFAULT 4096,
sort_order INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
)`).Error
},
Rollback: func(tx *gorm.DB) error {
return tx.Exec(`DROP TABLE IF EXISTS golem15_golem_models`).Error
},
}
func init() {
Register(aiModelsMigration)
}