wire

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AudioMIME

func AudioMIME(format string) string

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

func CollectText

func CollectText(parts []chat.Part) string

CollectText concatenates text and reasoning-summary parts.

func DecodeBool

func DecodeBool(object map[string]jsontext.Value, key string) (*bool, error)

DecodeBool reads an optional boolean field from object.

func DecodeFloat

func DecodeFloat(object map[string]jsontext.Value, key string) (*float64, error)

DecodeFloat reads an optional number field from object.

func DecodeInt

func DecodeInt(object map[string]jsontext.Value, key string) (*int, error)

DecodeInt reads an optional integer field from object.

func DecodeObject

func DecodeObject(data []byte) (map[string]jsontext.Value, error)

DecodeObject decodes exactly one JSON object. encoding/json/v2 rejects duplicate names and trailing top-level values by default.

func DecodeString

func DecodeString(object map[string]jsontext.Value, key string) (string, bool, error)

DecodeString reads an optional string field from object.

func DecodeStringSlice

func DecodeStringSlice(object map[string]jsontext.Value, key string) ([]string, error)

DecodeStringSlice reads an optional string array field from object.

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 InputTextParts

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

InputTextParts converts text parts into Responses input_text objects.

func MediaDataURL

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

MediaDataURL encodes inline media as a base64 data URL.

func NamespacedExtensions

func NamespacedExtensions(object map[string]jsontext.Value, allowed map[string]bool) map[string]jsontext.Value

NamespacedExtensions collects x- prefixed and namespaced extension fields.

func OutputTextParts

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

OutputTextParts converts text parts into Responses output_text objects.

func ParseChatContent

func ParseChatContent(raw jsontext.Value) ([]chat.Part, error)

ParseChatContent parses OpenAI Chat Completions message content into parts.

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 ParseFileMedia

func ParseFileMedia(object map[string]jsontext.Value, param string) (chat.Media, string, error)

ParseFileMedia parses a file reference object into chat.Media and an optional filename.

func ParseMediaURL

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

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

func ParseStringOrContent

func ParseStringOrContent(raw jsontext.Value, param string, parser func(jsontext.Value) ([]chat.Part, error)) ([]chat.Part, error)

ParseStringOrContent accepts either a plain string or structured content via parser.

func RawArray

func RawArray(raw jsontext.Value, param string) ([]jsontext.Value, error)

RawArray decodes raw as a JSON array, reporting param on failure.

func RawObject

func RawObject(raw jsontext.Value, param string) (map[string]jsontext.Value, error)

RawObject decodes raw as a JSON object, reporting param on failure.

func RejectUnknown

func RejectUnknown(object map[string]jsontext.Value, allowed map[string]bool) error

RejectUnknown rejects object keys that are not allowed or namespaced extensions.

func RejectUnknownStrict

func RejectUnknownStrict(object map[string]jsontext.Value, allowed map[string]bool) error

RejectUnknownStrict rejects any object key not present in allowed.

func RequireString

func RequireString(object map[string]jsontext.Value, key string) (string, error)

RequireString reads a required non-empty string field from object.

func ValidateImageDetail

func ValidateImageDetail(detail, param string) error

ValidateImageDetail checks that detail is an allowed image detail value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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