types

package
v0.0.0-...-153fcf6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SeparateTools

func SeparateTools(tools []Tool) (builtinTools []coreTypes.ActionDefinition, userTools []coreTypes.ActionDefinition)

SeparateTools separates a slice of Tools into builtin tools and user tools as ActionDefinitions

Types

type Content

type Content struct {
	Text  *string        `json:"-"`
	Items *[]ContentItem `json:"-"`
}

Content represents either a string or a slice of ContentItem

func (*Content) GetItems

func (c *Content) GetItems() []ContentItem

GetItems returns the items value or empty slice

func (*Content) GetText

func (c *Content) GetText() string

GetText returns the text value or empty string

func (*Content) IsItems

func (c *Content) IsItems() bool

IsItems returns true if the content contains items

func (*Content) IsText

func (c *Content) IsText() bool

IsText returns true if the content contains text

func (*Content) MarshalJSON

func (c *Content) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling for Content

func (*Content) UnmarshalJSON

func (c *Content) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling for Content

type ContentItem

type ContentItem struct {
	Type     string `json:"type"`
	Text     string `json:"text,omitempty"`
	ImageURL string `json:"image_url,omitempty"`
}

ContentItem represents an item in a content array

type FormatConfig

type FormatConfig struct {
	Type string `json:"type"`
}

FormatConfig represents format configuration options

type FunctionToolCall

type FunctionToolCall struct {
	Arguments string `json:"arguments"`
	CallID    string `json:"call_id"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	ID        string `json:"id"`
	Status    string `json:"status"`
}

FunctionToolCall represents a function tool call as a top-level object in the output array

type Input

type Input struct {
	Text     *string    `json:"-"`
	Messages *[]Message `json:"-"`
}

Input represents either a string or a slice of Message

func (*Input) GetMessages

func (i *Input) GetMessages() []Message

GetMessages returns the messages value or empty slice

func (*Input) GetText

func (i *Input) GetText() string

GetText returns the text value or empty string

func (*Input) IsMessages

func (i *Input) IsMessages() bool

IsMessages returns true if the input contains messages

func (*Input) IsText

func (i *Input) IsText() bool

IsText returns true if the input contains text

func (*Input) MarshalJSON

func (i *Input) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling for Input

func (*Input) UnmarshalJSON

func (i *Input) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling for Input

type InputMessage

type InputMessage struct {
	Role    string  `json:"role"`
	Content Content `json:"content"`
}

InputMessage represents a user input message

type Message

type Message struct {
	// Common fields
	Type string `json:"type,omitempty"`

	// InputMessage fields (when this is a regular chat message)
	Role    *string  `json:"role,omitempty"`
	Content *Content `json:"content,omitempty"`

	// WebSearchToolCall fields (when type == "web_search_call")
	ID     *string `json:"id,omitempty"`
	Status *string `json:"status,omitempty"`

	// Function call and function call output
	Arguments *string `json:"arguments,omitempty"`
	CallId    *string `json:"call_id,omitempty"`
	Name      *string `json:"name,omitempty"`
	Output    *string `json:"output,omitempty"`
}

Message represents different types of messages in the input

func (*Message) IsFunctionCall

func (m *Message) IsFunctionCall() bool

func (*Message) IsFunctionCallOutput

func (m *Message) IsFunctionCallOutput() bool

func (*Message) IsInputMessage

func (m *Message) IsInputMessage() bool

IsInputMessage returns true if this is a regular chat message

func (*Message) IsValidFunctionCallOutput

func (m *Message) IsValidFunctionCallOutput() (bool, error)

func (*Message) IsWebSearchCall

func (m *Message) IsWebSearchCall() bool

IsWebSearchCall returns true if this is a web search tool call

func (*Message) ToInputMessage

func (m *Message) ToInputMessage() *InputMessage

ToInputMessage converts to InputMessage if this is a regular message

type MessageContentItem

type MessageContentItem struct {
	Type        string        `json:"type"`
	Text        string        `json:"text"`
	Annotations []interface{} `json:"annotations"`
}

MessageContentItem represents a content item in a message

type ReasoningConfig

type ReasoningConfig struct {
	Effort  *string `json:"effort,omitempty"`
	Summary *string `json:"summary,omitempty"`
}

ReasoningConfig represents reasoning configuration options

type RequestBody

type RequestBody struct {
	Model              string            `json:"model"`
	Input              Input             `json:"input"`
	Include            []string          `json:"include,omitempty"`
	Instructions       *string           `json:"instructions,omitempty"`
	MaxOutputTokens    *int              `json:"max_output_tokens,omitempty"`
	Metadata           map[string]string `json:"metadata,omitempty"`
	ParallelToolCalls  *bool             `json:"parallel_tool_calls,omitempty"`
	PreviousResponseID *string           `json:"previous_response_id,omitempty"`
	Reasoning          *ReasoningConfig  `json:"reasoning,omitempty"`
	Store              *bool             `json:"store,omitempty"`
	Stream             *bool             `json:"stream,omitempty"`
	Temperature        *float64          `json:"temperature,omitempty"`
	Text               *TextConfig       `json:"text,omitempty"`
	ToolChoice         json.RawMessage   `json:"tool_choice,omitempty"`
	Tools              []Tool            `json:"tools,omitempty"`
	TopP               *float64          `json:"top_p,omitempty"`
	Truncation         *string           `json:"truncation,omitempty"`
}

RequestBody represents the request body structure for the OpenAI API

func (*RequestBody) SetInputByType

func (r *RequestBody) SetInputByType()

func (*RequestBody) ToChatCompletionMessages

func (r *RequestBody) ToChatCompletionMessages() []openai.ChatCompletionMessage

type ResponseBody

type ResponseBody struct {
	ID                 string                 `json:"id"`
	Object             string                 `json:"object"`
	CreatedAt          int64                  `json:"created_at"`
	Status             string                 `json:"status"`
	Error              interface{}            `json:"error"`
	IncompleteDetails  interface{}            `json:"incomplete_details"`
	Instructions       interface{}            `json:"instructions"`
	MaxOutputTokens    interface{}            `json:"max_output_tokens"`
	Model              string                 `json:"model"`
	Output             []interface{}          `json:"output"`
	ParallelToolCalls  bool                   `json:"parallel_tool_calls"`
	PreviousResponseID interface{}            `json:"previous_response_id"`
	Reasoning          ReasoningConfig        `json:"reasoning"`
	Store              bool                   `json:"store"`
	Temperature        float64                `json:"temperature"`
	Text               TextConfig             `json:"text"`
	ToolChoice         string                 `json:"tool_choice"`
	Tools              []Tool                 `json:"tools"`
	TopP               float64                `json:"top_p"`
	Truncation         string                 `json:"truncation"`
	Usage              UsageInfo              `json:"usage"`
	User               interface{}            `json:"user"`
	Metadata           map[string]interface{} `json:"metadata"`
}

ResponseBody represents the structure of the OpenAI API response

type ResponseMessage

type ResponseMessage struct {
	Type    string               `json:"type"`
	ID      string               `json:"id"`
	Status  string               `json:"status"`
	Role    string               `json:"role"`
	Content []MessageContentItem `json:"content"`
}

ResponseMessage represents a message in the response

type TextConfig

type TextConfig struct {
	Format *FormatConfig `json:"format,omitempty"`
}

TextConfig represents text configuration options

type TokenDetails

type TokenDetails struct {
	CachedTokens    int `json:"cached_tokens"`
	ReasoningTokens int `json:"reasoning_tokens,omitempty"`
}

TokenDetails represents details about token usage

type Tool

type Tool struct {
	Type string `json:"type"`

	// Function tool fields (used when type == "function")
	Name        *string                `json:"name,omitempty"`
	Description *string                `json:"description,omitempty"`
	Parameters  *jsonschema.Definition `json:"parameters,omitempty"`
	Strict      *bool                  `json:"strict,omitempty"`

	// Web search tool fields (used when type == "web_search_preview" etc.)
	SearchContextSize *string       `json:"search_context_size,omitempty"`
	UserLocation      *UserLocation `json:"user_location,omitempty"`
}

Tool represents a tool that can be called by the assistant

func (*Tool) IsFunction

func (t *Tool) IsFunction() bool

IsFunction returns true if this is a function tool

func (*Tool) IsWebSearch

func (t *Tool) IsWebSearch() bool

IsWebSearch returns true if this is a web search tool

func (*Tool) ToActionDefinition

func (t *Tool) ToActionDefinition() *coreTypes.ActionDefinition

ToActionDefinition converts this tool to an ActionDefinition

type ToolChoice

type ToolChoice struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type UsageInfo

type UsageInfo struct {
	InputTokens         int          `json:"input_tokens"`
	InputTokensDetails  TokenDetails `json:"input_tokens_details"`
	OutputTokens        int          `json:"output_tokens"`
	OutputTokensDetails TokenDetails `json:"output_tokens_details"`
	TotalTokens         int          `json:"total_tokens"`
}

UsageInfo represents token usage information

type UserLocation

type UserLocation struct {
	Type     string  `json:"type"`
	City     *string `json:"city,omitempty"`
	Country  *string `json:"country,omitempty"`
	Region   *string `json:"region,omitempty"`
	Timezone *string `json:"timezone,omitempty"`
}

UserLocation represents the user's location for web search

Jump to

Keyboard shortcuts

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