input

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package input provides types that can be used as input when sending messages. Only types that can be used as input but not as output are included. Types that can be used as both input and output are in the output package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Any

type Any struct {
	Type string `json:"type"`
	// contains filtered or unexported fields
}

Any is a partial representation of a content object with only the "type" field unmarshaled. It can be used to find a correct type and further unmarshal the raw content.

func (Any) MarshalJSON

func (a Any) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It just returns the saved raw content.

func (Any) String

func (a Any) String() string

String implements the fmt.Stringer interface. Returns the raw content as a string.

func (*Any) Unmarshal

func (a *Any) Unmarshal() (any, error)

Unmarshal unmarshals the full content into a type specified in the "type" field.

func (*Any) UnmarshalJSON

func (a *Any) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. It extracts only the "type" field, then saves the raw JSON for later.

func (*Any) UnmarshalToTarget

func (a *Any) UnmarshalToTarget(target any) error

UnmarshalToTarget unmarshals the content into a given target.

type ImageFile

type ImageFile struct {
	Type string `json:"type"` // "image_file"
	File struct {
		FileID string `json:"file_id"`          // required
		Detail string `json:"detail,omitempty"` // optional; "auto", "high", "low"
	} `json:"image_file"`
}

ImageFile is an image referenced by a file ID.

func (ImageFile) MarshalJSON

func (i ImageFile) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It fills in the "type" field with "image_file", discarding any prior value.

func (ImageFile) String

func (i ImageFile) String() string

String implements the fmt.Stringer interface. Returns the image file content.

type ImageURL

type ImageURL struct {
	Type  string `json:"type"` // "image_url"
	Image struct {
		URL    string `json:"url"`              // required
		Detail string `json:"detail,omitempty"` // optional; "auto", "high", "low"
	} `json:"image_url"`
}

ImageURL is an image referenced by a URL or as base64 encoded data.

func (ImageURL) MarshalJSON

func (i ImageURL) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It fills in the "type" field with "image_url", discarding any prior value.

func (ImageURL) String

func (i ImageURL) String() string

String implements the fmt.Stringer interface. Returns the image URL content.

type InputFile

type InputFile struct {
	Type     string `json:"type"` // "input_file"
	FileData string `json:"file_data,omitempty"`
	FileName string `json:"filename,omitempty"`
	FileID   string `json:"file_id,omitempty"`
}

InputFile is a file given to the model.

func (InputFile) MarshalJSON

func (i InputFile) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It fills in the "type" field with "input_file", discarding any prior value.

type InputImage

type InputImage struct {
	Type     string `json:"type"`             // "input_image"
	Detail   string `json:"detail,omitempty"` // "auto", "high", "low"
	ImageURL string `json:"image_url,omitempty"`
	FileID   string `json:"file_id,omitempty"`
}

InputImage is an image given to the model.

func (InputImage) MarshalJSON

func (i InputImage) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It fills in the "type" field with "input_image", discarding any prior value.

type InputText

type InputText struct {
	Type string `json:"type"` // "input_text"
	Text string `json:"text"`
}

InputText is a text content.

func (InputText) MarshalJSON

func (i InputText) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It fills in the "type" field with "input_text", discarding any prior value.

func (InputText) String

func (i InputText) String() string

String implements the fmt.Stringer interface. Returns the text content.

type ItemReference

type ItemReference struct {
	Type string `json:"type"` // "item_reference"
	ID   string `json:"id"`
}

ItemReference describes a reference to an item by ID.

func (ItemReference) MarshalJSON

func (i ItemReference) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It fills in the "type" field with "item_reference", discarding any prior value.

type Text

type Text struct {
	Type string `json:"type"` // "text"
	Text string `json:"text"`
}

Text is a string content.

func (Text) MarshalJSON

func (t Text) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It fills in the "type" field with "text", discarding any prior value.

func (Text) String

func (t Text) String() string

String implements the fmt.Stringer interface. Returns the text content.

Jump to

Keyboard shortcuts

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