identityai

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package identityai is an optional module that asks a configured text AI connection for identity suggestions (palette, fonts, taglines, a logo brief) and writes them to the Appearance → Identity draft, never live. It produces text only: no image, vector or GIF is ever generated or claimed.

Index

Constants

View Source
const (
	// SettingEnabled switches the module (kernel.AddonEnabled): false turns it off.
	SettingEnabled = "addons.identityai.enabled"
	// PermGenerate is the permission the page requires (the same as the identity page).
	PermGenerate = "settings.manage"
)
View Source
const PricesAsOf = "2026-10-22"

PricesAsOf is the date the table below was copied from the public lists.

View Source
const PromptVersion = "identityai-prompt-v1"

PromptVersion identifies the system prompt wording; it is part of the request fingerprint and of every audit row, so a changed prompt is a different request.

Variables

View Source
var ErrDestinationChanged = errors.New("identityai: destination changed since it was reviewed")

ErrDestinationChanged is what Hooks.Complete returns when the destination differs from the reviewed fingerprint; the module then sends nothing and records nothing.

Functions

func ClientCannotDrive

func ClientCannotDrive(provider, model string) bool

ClientCannotDrive reports a model the shared AI client cannot call: OpenAI reasoning models require max_completion_tokens on chat/completions, which the client does not send.

Types

type Brief

type Brief struct {
	Connection string // connection id; "" = the site's writing settings
	Sector     string
	Audience   string
	Tone       string
	Keep       string // what must stay (existing logo, a colour)
	Languages  string // "ar", "en" or "both"
}

Brief is what the operator tells the model.

type Connection

type Connection struct {
	ID, Name, Provider, Model, Host, TestStatus string
}

Connection describes an AI connection profile for display: never a secret.

func (Connection) Unsupported

func (c Connection) Unsupported() bool

Unsupported reports a connection whose model the client cannot drive.

type Estimate

type Estimate struct {
	Known            bool
	USD              float64
	InputTokens      int
	OutputTokens     int
	AsOf             string
	Source           string
	PerMillionInput  float64
	PerMillionOutput float64
}

Estimate is the cost of one generation.

func EstimateCost

func EstimateCost(provider, model string, inputTokens, outputTokens int) Estimate

EstimateCost looks up provider/model and prices inputTokens + outputTokens.

func (Estimate) Text

func (e Estimate) Text() string

Text formats the estimate for the page ("≈ $0.0043").

type Hooks

type Hooks struct {
	// Complete sends one system + user turn through connectionID (""
	// means the site's writing settings) with at most maxTokens of reply
	// and returns the reply text. It must refuse with ErrDestinationChanged
	// when the destination no longer matches expectFingerprint.
	Complete func(ctx context.Context, d *kernel.Deps, connectionID, model, system, input string, maxTokens int, expectFingerprint string) (string, error)
	// Connections lists the saved AI connection profiles (for the select).
	Connections func(ctx context.Context, d *kernel.Deps) ([]Connection, error)
	// Destination returns, from one read, what the operator is shown for
	// connectionID ("" is the site's writing settings) and the fingerprint
	// of exactly those stored values (provider, endpoint, model, connection
	// version and the stored credential, hashed). ok is false when the
	// destination cannot be resolved or its credential is unreadable.
	Destination func(ctx context.Context, d *kernel.Deps, connectionID string) (Connection, string, bool)
}

Hooks are the admin-owned AI functions the module depends on, injected at boot (like workagents), so this package never reads credentials.

type IdentityStore

type IdentityStore interface {
	Active(ctx context.Context) theme.Info
	LiveIdentity(ctx context.Context, slug string) theme.IdentitySnapshot
	IdentityDraft(ctx context.Context, slug string) (theme.IdentityDraft, bool)
	SaveIdentityDraft(ctx context.Context, snap theme.IdentitySnapshot) error
}

IdentityStore is what the module needs from the theme service.

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module is the identityai kernel.Module.

func New

func New(h Hooks) *Module

New returns the module with its AI hooks.

func (*Module) Catalogs

func (*Module) Catalogs() fs.FS

func (*Module) Enabled

func (*Module) Enabled(ctx context.Context, d *sql.DB) (bool, error)

Enabled implements kernel.OptionalModule through the shared addon gate: on unless addons.identityai.enabled is false (System → Modules), like the other optional modules. Being on only adds the page; nothing is sent to a provider without a reviewed, approved request.

func (*Module) Migrations

func (*Module) Migrations() fs.FS

func (*Module) Name

func (*Module) Name() string

func (*Module) Register

func (m *Module) Register(d *kernel.Deps) error

Register mounts the page and its navigation entry.

type Suggestion

type Suggestion struct {
	Accent, Background, Text         string
	HeadingFont, BodyFont, LatinFont string
	Radius, Spacing                  string
	TaglineAR, TaglineEN, LogoBrief  string
	HeadingFontLabel, BodyFontLabel  string
	LatinFontLabel                   string
	ContrastRatio                    string
	SavedAR, SavedEN                 bool // which tagline went into the draft
	Values                           map[string]string
}

Suggestion is the model's answer after validation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL