shape

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shape reads the request schema that an image or video service publishes for a model, and shapes each request from it: the property names, the values each one accepts and the limits it states. Nothing in it is written for a particular model.

Index

Constants

View Source
const Uncapped = generation.Uncapped

Uncapped is the picture count for a schema with a list of pictures and an unstated limit.

Variables

This section is empty.

Functions

func Arguments

func Arguments(inputs ...Input) map[string]any

Arguments returns a JSON schema for an object with the properties that the call's shared arguments do not fill. The first input that states a property wins. The creative controls are among them, so image_generate reads their schemas there. It is nil when there are no such properties.

func Decoded

func Decoded(text string) any

Decoded returns a learned value in its JSON form: a number or a boolean, otherwise the text itself.

func FactorCap

func FactorCap(in Input, facts generation.Model) int

FactorCap returns the upscaler's factor limit taught by a refusal. It is 0 when a refusal did not teach a limit.

func Learn

func Learn(cfg *config.Config, service, model string, in Input, sent map[string]any, refusal listing.Refusal) bool

Learn reads the model's refusal for the sent request and saves the lesson, so the next request is shaped right: a field's accepted values, a stated limit, a field to leave out or a field to rename. It reports whether the lesson changes the next request, which is then sent once more.

func Media

func Media(value any) []string

Media returns the addresses in a reply's value, in order: a text with an address, an object's url, or the addresses in a list or in an object's values.

func Number

func Number(value any) (float64, bool)

Number returns a value as a number: a JSON number, or a text that starts with one, such as 8s. False for anything else.

func Renamed

func Renamed(field string) string

Renamed returns the remedy that sends a refused field's value under the field given.

func Resolved

func Resolved(input, document map[string]any) map[string]any

Resolved returns the request schema with its component references put in place, and a top level allOf merged into one object. The document is the schema's OpenAPI source document. It is nil when the schema stands alone.

func Text

func Text(value any) string

Text returns a value as text, a whole number without a decimal point. Empty for an object, a list or nil.

Types

type Ask

type Ask struct {
	Prompt, Negative string
	// Shape is a picture's shape: landscape, square or portrait. Empty for a video.
	Shape string
	// Ratio and Resolution are for a video, such as 16:9 and 720p.
	Ratio, Resolution      string
	Duration, Seed, Factor *int
	Audio                  *bool
	// Images are the pictures to edit, animate or upscale, the main one first. Those the schema's picture field does not take go with the
	// references. References are pictures that guide the look only. Video is the URL for a video to upscale.
	Images     []string
	References []string
	Video      string
	// Extra holds values for the schema's own properties, sent as given when the schema states the property.
	Extra map[string]any
}

Ask is one request as icebath's tools give it, before it is shaped for a model.

type Input

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

Input is a model's request schema as read: its properties by name, in the order the schema gives them, and the ones it requires.

func Read

func Read(s map[string]any) Input

Read returns the schema as read. A nil or empty schema reads as unknown, and every request built from it is the plain one.

func (Input) Aspect

func (in Input) Aspect() string

Aspect returns the property the aspect ratio goes under.

func (Input) Audio

func (in Input) Audio() string

Audio returns the switch that makes a video with sound.

func (Input) Build

func (in Input) Build(ask Ask, facts generation.Model) map[string]any

Build returns the request body for the ask, shaped by the schema and by the lessons from the model's refusals, which facts contains. An unknown schema gives the plain request: the prompt, the pictures and the asked values under the common field names.

func (Input) Cap

func (in Input) Cap() int

Cap returns the picture limit for one request. It is 0 when the schema does not accept pictures, and Uncapped when a list does not state its limit.

func (Input) Controls

func (in Input) Controls() []string

Controls returns the names of icebath's creative controls that the schema states, in the order image_generate lists them.

func (Input) Duration

func (in Input) Duration() string

Duration returns the property a video's length in seconds goes under.

func (Input) Edits

func (in Input) Edits() bool

Edits reports whether the schema takes pictures besides the prompt.

func (Input) Factor

func (in Input) Factor() string

Factor returns the number property an upscaler's factor goes under.

func (Input) Factors

func (in Input) Factors(most int) []int

Factors returns the whole factors an upscaler accepts, the schema's default first: the listed factors, otherwise every whole number from 2 to its stated maximum, otherwise 2 to 8 when the maximum is unstated. It is nil when the schema does not have a factor. most, when above zero, is a maximum taught by a refusal.

func (Input) Fill

func (in Input) Fill(m *generation.Model)

Fill puts what the schema states into the model's facts: the values each field accepts, the lengths, the pictures and the prompt limit.

func (Input) Fits

func (in Input) Fits(ask Ask) bool

Fits reports whether a request for the ask can be built: the schema takes the pictures or the video the ask gives, and every property it requires is filled. An unknown schema fits every ask.

func (Input) Has

func (in Input) Has(name string) bool

Has reports whether the schema states the property.

func (Input) Known

func (in Input) Known() bool

Known reports whether the schema states any property.

func (Input) Names

func (in Input) Names() []string

Names returns the property names in the schema's order.

func (Input) Negative

func (in Input) Negative() string

Negative returns the property a negative prompt goes under.

func (Input) Prompt

func (in Input) Prompt() string

Prompt returns the prompt property. It is empty when the schema has no prompt property.

func (Input) Property

func (in Input) Property(name string) map[string]any

Property returns the property's schema, nil when the schema does not state it.

func (Input) ReferenceCap

func (in Input) ReferenceCap() int

ReferenceCap returns the reference list's limit. It is 0 when the schema does not have a reference list, and Uncapped when the list does not state its limit.

func (Input) References

func (in Input) References() string

References returns the list property for reference pictures. It is empty when the schema has no such property.

func (Input) Requires

func (in Input) Requires(name string) bool

Requires reports whether the schema requires the property in every request.

func (Input) Resolution

func (in Input) Resolution() string

Resolution returns the property the resolution goes under.

func (Input) Schema

func (in Input) Schema() map[string]any

Schema returns the input's source schema.

func (Input) Seconds

func (in Input) Seconds() (listed []int, least, most int)

Seconds returns the video lengths a request accepts: the listed lengths, and the bounds, stated or taken from the list. A zero bound is unknown.

func (Input) Seed

func (in Input) Seed() string

Seed returns the property a seed goes under.

func (Input) Size

func (in Input) Size() string

Size returns the property for a picture's size: a named size, a WxH text or an object with width and height.

func (Input) Source

func (in Input) Source() string

Source returns the property for the picture to edit or animate: a single address, or a list of addresses. It is empty when the schema has no such property.

func (Input) Style

func (in Input) Style() bool

Style reports whether the schema's pictures give the look only: it has a reference list and does not accept a picture to edit.

func (Input) Upscales

func (in Input) Upscales(kind generation.Kind) bool

Upscales reports whether the schema belongs to an upscaler. A picture upscaler takes a picture and a factor, which image_upscale offers. A video upscaler takes a video and requires nothing else that can't be filled.

func (Input) Values

func (in Input) Values(name string) []string

Values returns the accepted values for a property as texts, in the schema's order. It is nil when the property has no list of values.

func (Input) Video

func (in Input) Video() string

Video returns the property for a video input. It is empty when the schema has no such property.

Jump to

Keyboard shortcuts

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