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
- func Arguments(inputs ...Input) map[string]any
- func Decoded(text string) any
- func FactorCap(in Input, facts generation.Model) int
- func Learn(cfg *config.Config, service, model string, in Input, sent map[string]any, ...) bool
- func Media(value any) []string
- func Number(value any) (float64, bool)
- func Renamed(field string) string
- func Resolved(input, document map[string]any) map[string]any
- func Text(value any) string
- type Ask
- type Input
- func (in Input) Aspect() string
- func (in Input) Audio() string
- func (in Input) Build(ask Ask, facts generation.Model) map[string]any
- func (in Input) Cap() int
- func (in Input) Controls() []string
- func (in Input) Duration() string
- func (in Input) Edits() bool
- func (in Input) Factor() string
- func (in Input) Factors(most int) []int
- func (in Input) Fill(m *generation.Model)
- func (in Input) Fits(ask Ask) bool
- func (in Input) Has(name string) bool
- func (in Input) Known() bool
- func (in Input) Names() []string
- func (in Input) Negative() string
- func (in Input) Prompt() string
- func (in Input) Property(name string) map[string]any
- func (in Input) ReferenceCap() int
- func (in Input) References() string
- func (in Input) Requires(name string) bool
- func (in Input) Resolution() string
- func (in Input) Schema() map[string]any
- func (in Input) Seconds() (listed []int, least, most int)
- func (in Input) Seed() string
- func (in Input) Size() string
- func (in Input) Source() string
- func (in Input) Style() bool
- func (in Input) Upscales(kind generation.Kind) bool
- func (in Input) Values(name string) []string
- func (in Input) Video() string
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
Number returns a value as a number: a JSON number, or a text that starts with one, such as 8s. False for anything else.
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 ¶
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) Build ¶
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 ¶
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 ¶
Controls returns the names of icebath's creative controls that the schema states, in the order image_generate lists them.
func (Input) Factors ¶
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 ¶
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) Prompt ¶
Prompt returns the prompt property. It is empty when the schema has no prompt property.
func (Input) Property ¶
Property returns the property's schema, nil when the schema does not state it.
func (Input) ReferenceCap ¶
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 ¶
References returns the list property for reference pictures. It is empty when the schema has no such property.
func (Input) Resolution ¶
Resolution returns the property the resolution goes under.
func (Input) Seconds ¶
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) Size ¶
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 ¶
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 ¶
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.