Help us shape the future of Go! Take the 2026 Go Developer Survey

generation

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package generation owns provider-neutral generation requests and media preparation.

Index

Constants

View Source
const (
	FrameAnchorConflict        = "%s and %s both request the %s frame."
	FrameCountExceeded         = "%d timed inputs exceed the model's opening and closing frames."
	FrameOnVideo               = "A video input cannot take a frame prefix: %s."
	FrameTimeShared            = "%s and %s share the frame time %g."
	ReasonAdoptedFromReference = "adopted from the reference image"
	ReasonFrameTimeSnapped     = "frame time %g snapped to the %s frame"
	ReasonMatchedToRequest     = "matched to %s request"
	ReasonNoFramePrefix        = "the model does not accept a frame prefix"
	ReasonNotConsumed          = "not consumed by %s"
)

The internal/generation section of the copy catalog, one constant per entry.

Variables

This section is empty.

Functions

func ConformInputMedia

func ConformInputMedia(model *catalog.Model, parameterValues params.Values, mediaInputs []media.Input) ([]params.Adjustment, error)

ConformInputMedia updates the supplied parameters and media slice to satisfy image dimensions. It records actual changes, retaining completed changes if a later image fails. An unresolved first image defers size adoption until its bytes become available.

func DropFramePrefixes

func DropFramePrefixes(mediaInputs []media.Input) []params.Adjustment

DropFramePrefixes clears frame markers in the supplied media slice and records each removal. The underlying media and bare sources remain unchanged.

func ResolveFrameAnchors

func ResolveFrameAnchors(mediaInputs []media.Input, parameterValues params.Values) ([]params.Adjustment, error)

ResolveFrameAnchors replaces numeric frame times in the supplied media with first/last anchors and records actual snaps. It rejects frame markers on video, conflicting anchors or times, and requests exceeding the two available frames.

func SelectSources

func SelectSources(sources []string, model *catalog.Model) []string

SelectSources returns only the arguments a model retains, before any source is opened.

Types

type Generation

type Generation struct {
	catalog.ProvModelPair
	Preparation

	Prompt string
	APIKey string
	Record *metadata.Record
}

Generation contains the selected model and prepared inputs for one provider request.

  • ProvModelPair: the selected provider and model
  • Preparation: the adjusted parameters and retained media
  • Prompt: the resolved generation prompt
  • APIKey: the resolved provider credential
  • Record: optional transaction history retained for the command to persist

type Generator

type Generator interface {
	AdjustParams(model *catalog.Model, inputs params.FlagInputs, mediaInputs []media.Input, reuse *metadata.Reuse) (Preparation, error)
	Generate(ctx context.Context, run *Generation) (Result, error)
}

Generator prepares a model's retained inputs and generates its artifacts.

  • AdjustParams: prepare inputs, retaining completed changes even when preparation fails
  • Generate: submit prepared inputs and collect the provider's result

type Preparation

type Preparation struct {
	Params     params.Values
	InputMedia []media.Input
	Changes    []params.Adjustment
	ReuseURI   string
}

Preparation owns the values and media records to be submitted to a provider. Bytes and timestamps referenced by InputMedia remain immutable; transformations replace them.

  • Params: the adjusted model parameters
  • InputMedia: the retained inputs, in submission order
  • Changes: the ordered reasons that supplied values changed
  • ReuseURI: the original provider reference for a follow-up request

func AdjustGeneration

func AdjustGeneration(model *catalog.Model, inputs params.FlagInputs, mediaInputs []media.Input) (Preparation, error)

AdjustGeneration selects owned media records and applies common scalar adjustments once. Completed records survive any later scalar failure, in their established presentation order.

func (*Preparation) Clone

func (preparedGeneration *Preparation) Clone() Preparation

Clone copies parameter values, media records, and adjustment records for independent mutation. Media bytes and timestamps remain shared and must stay immutable.

type Result

type Result struct {
	Preparation Preparation
	Artifacts   []artifact.Media
	Thoughts    []string
}

Result contains the outputs from one provider request.

  • Preparation: final submission facts, including completed changes on failure
  • Artifacts: the generated media
  • Thoughts: the provider's thought text

Jump to

Keyboard shortcuts

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