wire

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidJSON = errors.New("request body must be valid JSON")
	ErrNotObject   = errors.New("request body must be a JSON object")
	ErrType        = errors.New("value has the wrong JSON type")
	ErrValue       = errors.New("value is not valid JSON")
)

Functions

func AudioMIME

func AudioMIME(format string) string

AudioMIME maps a short audio format name to a MIME type.

func Bool added in v0.3.0

func Bool(raw []byte, typ jsonparser.ValueType) (bool, error)

Bool decodes a borrowed JSON boolean.

func CollectText

func CollectText(parts []chat.Part) string

CollectText concatenates text and reasoning-summary parts.

func Copy added in v0.3.0

func Copy(raw []byte) jsontext.Value

Copy owns a raw JSON value after the request body is released.

func Error

func Error(param, message string, cause error) *chat.Error

Error builds an invalid_request_error chat.APIError for param with cause attached.

func Float added in v0.3.0

func Float(raw []byte, typ jsonparser.ValueType) (float64, error)

Float decodes a JSON number.

func InputTextParts

func InputTextParts(parts []chat.Part) []map[string]any

InputTextParts converts text parts into Responses input_text objects.

func Int added in v0.3.0

func Int(raw []byte, typ jsonparser.ValueType) (int, error)

Int decodes a JSON integer using the platform int range.

func MediaDataURL

func MediaDataURL(media chat.Media) (string, error)

MediaDataURL encodes inline media as a base64 data URL.

func OutputTextParts

func OutputTextParts(parts []chat.Part) []map[string]any

OutputTextParts converts text parts into Responses output_text objects.

func ParseDataURL

func ParseDataURL(value string) (chat.Media, error)

ParseDataURL decodes a base64 data URL into inline chat.Media.

func ParseFileData

func ParseFileData(value, param string) (chat.Media, error)

ParseFileData parses base64 or data URL file data into inline chat.Media.

func ParseFileMediaValue added in v0.3.0

func ParseFileMediaValue(value Value, param string) (chat.Media, string, error)

ParseFileMediaValue parses a borrowed file reference object without first materializing it as a map.

func ParseMediaURL

func ParseMediaURL(value, detail string) (chat.Media, error)

ParseMediaURL parses an HTTP(S) URL or data URL into chat.Media.

func String added in v0.3.0

func String(raw []byte, typ jsonparser.ValueType) (string, error)

String decodes a borrowed JSON string. JSON null has encoding/json's zero value semantics for optional scalar fields.

func Strings added in v0.3.0

func Strings(raw []byte, typ jsonparser.ValueType) ([]string, error)

Strings decodes a JSON array of strings.

func ValidateImageDetail

func ValidateImageDetail(detail, param string) error

ValidateImageDetail checks that detail is an allowed image detail value.

func ValidateObject added in v0.3.0

func ValidateObject(data []byte) error

ValidateObject validates one complete JSON object, including unique names, UTF-8, and nested values, before jsonparser traverses its borrowed slices.

Types

type Value added in v0.3.0

type Value struct {
	Raw  []byte
	Type jsonparser.ValueType
}

Value is a borrowed JSON value from the request body. Raw is valid until the current parse returns; parsers copy it when storing it in the result.

func (Value) Present added in v0.3.0

func (v Value) Present() bool

Present reports whether the field existed in the containing object.

Jump to

Keyboard shortcuts

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