Documentation
¶
Overview ¶
Package output renders terminal messages, command results, and sidecars.
Index ¶
- Constants
- func ElapsedText(elapsed time.Duration) string
- func FlagEntry(flagNames []string, valueHint, detailText string) string
- func FlagSupportNote(param params.FlagType, provModelPairs []catalog.ProvModelPair) string
- func FlagValueHint(longName string, paramFlags []params.Flag, flagHints map[string]string) string
- func GenerationStatusText(frame rune, mediaKind media.Kind, elapsed time.Duration, styled bool) string
- func HelpTips(prov *catalog.Provider, styled bool) (string, error)
- func IndentText(steps int, text string) string
- func NoticeTexts(paramFlags []params.Flag, paramChanges []params.Adjustment, ...) []string
- func PrintAmbiguity(destination io.Writer, modelSpecifier string, ...) error
- func PrintError(destination io.Writer, err error, providerDisplayName, modelName string, ...) error
- func PrintGenerationCompleted(destination io.Writer, elapsedText string) error
- func PrintJSON(destination io.Writer, value any) error
- func PrintListing(destination io.Writer, page CatalogPage, ...) error
- func PrintModelInfo(destination io.Writer, provModelPair *catalog.ProvModelPair, ...) error
- func PrintProviderInfo(destination io.Writer, prov *catalog.Provider, pairs []catalog.ProvModelPair, ...) error
- func PrintReprompt(destination io.Writer, styled bool) error
- func PrintRunDetails(destination io.Writer, providerDisplayName, modelName string) error
- func PrintSavedFile(destination io.Writer, savedFile SavedFile, styled bool) error
- func PrintSingleWordPromptConfirmation(destination io.Writer, prompt string, styled bool) error
- func PrintTemplate(destination io.Writer, name, source string, data any, ...) error
- func PrintUsageError(destination io.Writer, err error, debugMode, styled bool) error
- func PrintUserConfigWarning(destination io.Writer, fault error, styled bool) error
- func RenderSidecar(prompt, modelID string, paramFlags []params.Flag, adjusted params.Values, ...) []byte
- func WrapDetails(steps int, detailText string) string
- func WriteText(destination io.Writer, format string, values ...any) error
- type Adjustment
- type CatalogPage
- type FailureOutcome
- type GenerationOutcome
- type SavedFile
Constants ¶
const ( PageFuncIndent = "indent" PageFuncWrap = "wrap" )
The template-function names the page templates call. The command layer's help printer registers the first two beside its own.
- PageFuncIndent: the indentation function
- PageFuncWrap: the paragraph-wrapping function
- pageFuncPad: the column-padding function the info pages call
- pageFuncModelRow: a model's listing row, which the nested listing calls
- pageFuncModelListingLines: the fully qualified model listings, which the flat directory calls
const ( APIKeyNotSet = "Your API key is not set" AliasMatchExample = "and '%s' matches the alias %s" AliasWordPlural = "aliases" AliasWordSingular = "alias" AllowedRange = "Allowed range: %s to %s" AllowedValues = "Allowed values: %s" AmbiguityCandidate = "%s%s/%s%s" AmbiguityHeading = "%[1]sThe model specifier %[3]s%[2]s%[4]q%[3]s%[1]s matches more than one model:%[3]s" CardPromptIgnored = "ignored (this model does not read a prompt)" CatalogCountForm = "%d %s models" CatalogCountFormOne = "%d %s model" CatalogSeparator = "·" ConfigFileUnreadable = "The config file %s could not be read and was ignored." ConfigLocationUnresolved = "The config file location could not be resolved, and no config file was read." ConfigUnknownProvider = "The config file %s names an unknown provider %q under api-keys, which was ignored." ConfigUnknownSetting = "The config file %s names an unknown setting %q, which was ignored." CounterHoursForm = "%dh %dm %s" CounterMinutesForm = "%dm %s" CounterSecondsForm = "%d.%ds" CredentialMissing = "%s. Set your API key and try again." CredentialMissingProvider = "%s. Set your %s API key and try again." EdgeIncrements = "%d-px increments" EdgeRange = "edge: %d-%d" ErrorPrefix = "Error" ExamplesSentence = "Examples: %s." FileSizeBytesForm = "%d B" FileSizeGBForm = "%.1f GB" FileSizeKBForm = "%.1f KB" FileSizeMBForm = "%.1f MB" FlagAdjusted = "%s adjusted or converted to %s." FlagAdjustedReason = "%s adjusted to %s (%s)." FlagBelowLimit = "Warning: %s '%s' is below %s; adjusted to %s." FlagChangedGuard = "Warning: %s changed (%s: %s to %s)." FlagExceedsLimit = "Warning: %s '%s' exceeds %s; adjusted to %s." FlagIgnored = "Warning: %s ignored, %s." FlagNotAllowed = "Warning: %s '%s' is not an allowed value and will be omitted." FlagNotSupported = "Warning: %s '%s' is not supported and will be omitted." FrameTimeInvalidGeneric = "The input media has invalid keyframe timing." FrontMatterModelForm = "model: %q" FrontMatterParamForm = "%s: %q" FrontMatterPromptForm = "prompt: %q" FrontMatterTimestampForm = "timestamp: %q" GenerationCanceled = "Generation canceled." GenerationCompleted = "✓ Completed (%s)" GenerationStatus = "%s Generating %s %s%s%s" GroupIntro = "For %s" GroupIntroRemainder = "For all models except those below" HelpTipsHeading = "TIPS:" InputMediaFormat = "The supplied input media %q is not in a supported format. Please use a PNG, JPEG, WebP, or MP4 source." InputMediaInvalid = "The input media you provided is not valid. Please supply a readable PNG, JPEG, WebP, or MP4 file or an HTTP(S) URL." InputMediaNotFound = "The input media was not found at %q. Check the path and try again." InputMediaSourceInvalid = "The input media %q is not valid. Please supply a readable PNG, JPEG, WebP, or MP4 file or an HTTP(S) URL." KeywordMatchExample = "For example, '%s' matches %s" ListLastAnd = "%s, and %s" ListLastOr = "%s, or %s" ListPairAnd = "%s and %s" ListPairOr = "%s or %s" ListSeparator = "," LongEdge = "long edge of %d when the size is derived from an aspect ratio" MaximumEdge = "maximum edge: %d" MaximumPixels = "maximum total pixels (width x height): %d" MaximumValue = "Maximum: %s" MediaLabelImages = "Images" MediaLabelVideo = "Video" MinimumEdge = "minimum edge: %d" MinimumPixels = "minimum total pixels (width x height): %d" MinimumValue = "Minimum: %s" ModelAliasListing = "%s (%s: %s)" ModelAmbiguous = "The model you entered matches more than one model. Use a full provider/model specifier." ModelHeader = "Model: %s" ModelUnknown = "Model %q is not supported. See 'bild list' for the supported models." ModelUnknownGeneric = "The model you specified is not supported. See 'bild list' for the supported models." NoAdditionalLimits = "No additional limits." NotUsedBy = "Not used by %s." OnlyForModels = "This option is available only for models %s." OutPathDisplayName = "Output path" OutputCleanupFailed = "We could not remove the temporary file %q." OutputReadFailed = "We could not read the generated media file %q." OutputWriteFailed = "We could not write the output to %q. Check the directory's permissions and free space." PixelRange = "total pixels (width x height): %d-%d" PollIdentity = "Model: %s; operation: %s." ProviderConfigBroken = "The %s provider configuration is malformed." ProviderConfigBrokenDetail = "The %s provider configuration is malformed. (%s)" ProviderFallbackAsName = "unknown provider" ProviderFallbackInSentence = "the provider" ProviderHeader = "Provider: %s" ProviderSelectModels = "%s (select models)" ProviderServerError = "%s, %s generation failed. Server error: %s" RatioBetween = "aspect ratio between 1:%[1]s and %[1]s:1" RepeatMaximum = "Repeat maximum: %s" Reprompt = "%[1]sEnter a full provider/model specifier, or leave blank to abort:%[2]s" RequiredLabel = "Required" ResponseUnusable = "" /* 161-byte string literal not displayed */ RuleDescription = "Rule: %s" SavedReport = "Saved: %s (%d bytes)" SavedReportStyled = "Saved: %[1]s%[2]s%[3]s %[4]s(%[5]s)%[3]s" SearchTooManyResults = "" /* 168-byte string literal not displayed */ SingleWordConfirmation = "" /* 144-byte string literal not displayed */ SizeRequirements = "<W>x<H> - Requirements: %s" TransportTimeout = "The request to %[1]s timed out. Check the %[1]s status page for performance issues or try again later." TransportUnreachable = "We could not reach %s to process your request. Check your network connection and try again." WarningPrefix = "Warning" WorkingDirFailed = "We could not determine the working directory. Rerun bild from an accessible directory." )
The internal/output section of the copy catalog, one constant per entry.
const (
StatusCanceled = "canceled"
)
Status values used by JSON generation outcomes.
- statusCompleted: the run produced its artifacts
- StatusCanceled: the user canceled the run
- statusFailed: the run stopped on a failure
Variables ¶
This section is empty.
Functions ¶
func ElapsedText ¶
ElapsedText formats elapsed time as seconds with one decimal place, truncating fractional tenths. It adds minutes at one minute and hours at one hour, as in 23.6s, 1m 23.6s, and 1h 2m 12.3s. Negative durations render as zero.
func FlagSupportNote ¶
func FlagSupportNote(param params.FlagType, provModelPairs []catalog.ProvModelPair) string
FlagSupportNote names providers that support the flag, marking partial support as "select models". It considers only media kinds for which some model declares the flag. If every model in those media kinds supports it, the note is empty.
func FlagValueHint ¶
FlagValueHint returns the parameter hint when present. Otherwise, it returns the command flag hint, or the long flag name if neither hint exists.
func GenerationStatusText ¶
func GenerationStatusText(frame rune, mediaKind media.Kind, elapsed time.Duration, styled bool) string
GenerationStatusText formats one status frame with the requested styling. It performs no cursor movement or animation.
func IndentText ¶
IndentText indents every line by the requested number of indentation steps.
func NoticeTexts ¶
func NoticeTexts(paramFlags []params.Flag, paramChanges []params.Adjustment, flagNames map[params.FlagType]string) []string
NoticeTexts formats parameter changes as user-facing notice strings.
func PrintAmbiguity ¶
func PrintAmbiguity(destination io.Writer, modelSpecifier string, modelMatches []catalog.ProvModelPair, styled bool) error
PrintAmbiguity writes the ambiguous specifier and its fully qualified candidates to the selected diagnostic destination.
func PrintError ¶
func PrintError(destination io.Writer, err error, providerDisplayName, modelName string, debugMode, styled bool) error
PrintError writes a mapped failure, cancellation notice, or raw diagnostic chain to the selected diagnostic destination and returns any delivery failure.
func PrintGenerationCompleted ¶
PrintGenerationCompleted writes the completion message with the supplied elapsed time and returns any write failure.
func PrintJSON ¶
PrintJSON writes one JSON document to destination, indenting successfully encoded values. If encoding fails, it writes a failure document and returns the original encoding error. A write failure is returned together with any encoding error.
func PrintListing ¶
func PrintListing(destination io.Writer, page CatalogPage, providersSelected, modelsSelected, jsonOutput bool) error
PrintListing writes the selected provider/model listing as text or JSON. It returns template, encoding, and delivery failures to the command.
func PrintModelInfo ¶
func PrintModelInfo(destination io.Writer, provModelPair *catalog.ProvModelPair, paramFlags []params.Flag, styled bool) error
PrintModelInfo writes the model card with the requested terminal styling. Template and delivery failures are returned to the command.
func PrintProviderInfo ¶
func PrintProviderInfo(destination io.Writer, prov *catalog.Provider, pairs []catalog.ProvModelPair, paramFlags []params.Flag, mediaFilterFlags map[media.Kind]string, styled bool) error
PrintProviderInfo writes the selected provider's detailed page or aggregator summary. It returns template and delivery failures to the command.
func PrintReprompt ¶
PrintReprompt renders the replacement-model question with the selected styling.
func PrintRunDetails ¶
PrintRunDetails writes the provider and model headers to destination.
func PrintSavedFile ¶
PrintSavedFile writes one completed file's path and size to destination. Styled output uses a human-readable size; plain output reports the byte count.
func PrintSingleWordPromptConfirmation ¶
PrintSingleWordPromptConfirmation renders the confirmation using the selected diagnostic styling and returns any failure to deliver it.
func PrintTemplate ¶
func PrintTemplate(destination io.Writer, name, source string, data any, functions template.FuncMap) error
PrintTemplate renders a command-supplied template with its required functions and data, and writes only a fully rendered page. Every failure is classified.
func PrintUsageError ¶
PrintUsageError writes the diagnostic and compact usage. If template rendering fails, it writes the diagnostic alone and returns the rendering error together with any write failure.
func PrintUserConfigWarning ¶
PrintUserConfigWarning writes a styled or plain configuration warning to destination and returns any write failure.
func RenderSidecar ¶
func RenderSidecar(prompt, modelID string, paramFlags []params.Flag, adjusted params.Values, inputMedia []media.Input, thoughts []string) []byte
RenderSidecar returns Markdown with the prompt, model ID, current UTC timestamp, and nonempty parameters in flag-record order. It records the supplied input-media sources under input-media and places thought chunks after the front matter, separated by fences.
func WrapDetails ¶
WrapDetails wraps and indents paragraphs to the page width, separated by blank lines.
Types ¶
type Adjustment ¶
type Adjustment struct {
Flag string `json:"flag"`
Submitted string `json:"submitted,omitempty"`
Used string `json:"used,omitempty"`
Notice string `json:"notice"`
}
Adjustment is one user-facing flag adjustment made before provider submission.
- Flag: the permanent parameter flag identifier
- Submitted, Used: the original and adjusted values in display form
- Notice: the rendered explanation of the change
func AdjustmentRecords ¶
func AdjustmentRecords(paramFlags []params.Flag, paramChanges []params.Adjustment, flagNames map[params.FlagType]string) []Adjustment
AdjustmentRecords formats parameter changes as user-facing JSON adjustment records.
type CatalogPage ¶
type CatalogPage struct {
Providers []providerRecord `json:"providers"`
Flags []params.Flag `json:"flags,omitempty"`
}
CatalogPage contains the providers, models, and parameter descriptions selected for a listing or information document. Its values are independent of the catalog. Empty listings retain an empty providers array; unneeded flag records are omitted.
- Providers: the selected provider and model descriptions
- Flags: the flag definitions referenced by information pages
func ListingPage ¶
func ListingPage(pairs []catalog.ProvModelPair, withModels, includeAliases bool) CatalogPage
ListingPage describes already selected provider/model pairs. Providers sort by display name, ignoring case, with aggregators last; models sort by identifier. Models and aliases appear only when requested. Listings never include parameters.
func ModelInfoPage ¶
func ModelInfoPage(pair *catalog.ProvModelPair, paramFlags []params.Flag) CatalogPage
ModelInfoPage describes one provider/model pair and its referenced parameter flags.
func ProviderInfoPage ¶
func ProviderInfoPage(prov *catalog.Provider, pairs []catalog.ProvModelPair, paramFlags []params.Flag) CatalogPage
ProviderInfoPage describes a provider and its already selected models in input order, followed by the referenced parameter flags in their declaration order.
type FailureOutcome ¶
FailureOutcome is the JSON result for a command that failed before producing a more specific outcome.
- Status: the failed command status
- Errors: the rendered command failure messages
func NewFailureOutcome ¶
func NewFailureOutcome(err error, providerDisplayName, modelName string, debugMode, usageError bool) FailureOutcome
NewFailureOutcome returns the failure document for a command or usage error.
type GenerationOutcome ¶
type GenerationOutcome struct {
Timestamp string `json:"timestamp"`
DurationMS int64 `json:"durationMs"`
Status string `json:"status"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Prompt string `json:"prompt"`
Flags map[string]any `json:"flags"`
Adjustments []Adjustment `json:"adjustments,omitempty"`
Artifacts []SavedFile `json:"artifacts,omitempty"`
Notices []string `json:"notices,omitempty"`
Errors []string `json:"errors,omitempty"`
}
GenerationOutcome is the complete user-facing JSON result of one generation request.
- Timestamp: the UTC start time in RFC 3339 format
- DurationMS: the elapsed run time in milliseconds
- Status: the completed, canceled, or failed result
- Provider, Model: the selected catalog identifiers
- Prompt: the submitted prompt
- Flags: the submitted values keyed by permanent flag identifier
- Adjustments: the changes made before submission
- Artifacts: the successfully saved files
- Notices: the rendered warnings and adjustment explanations
- Errors: the rendered run failure messages
func NewGenerationOutcome ¶
func NewGenerationOutcome(startedAt time.Time, prompt string, flags map[string]any) *GenerationOutcome
NewGenerationOutcome initializes a generation result with a UTC start time. The result retains the supplied flag map without copying it.