ai

package
v0.0.0-...-9c07e03 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: 0BSD Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorCodes = xyz.AccessorFor(ErrorCode.Values)
View Source
var FinishReasons = xyz.AccessorFor(FinishReason.Values)
View Source
var Messages = xyz.AccessorFor(Message.Values)
View Source
var ResponseFormats = xyz.AccessorFor(ResponseFormat.Values)
View Source
var Roles = xyz.AccessorFor(Role.Values)
View Source
var ToolChoices = xyz.AccessorFor(ToolChoice.Values)
View Source
var Tools = xyz.AccessorFor(Tool.Values)

Functions

func Client

func Client(key string) *http.Client

Client authentication.

Types

type Assistant

type Assistant struct {
	Name string `json:"name,omitempty"
		of the system.`
	Content string `json:"content"
		of the message.`
	ToolCalls []Tool `json:"tool_calls,omitempty"
		made by the assistant.`
}

type ChatCompletion

type ChatCompletion struct {
	ID string `json:"id"
		is a unique identifier for the chat completion.`
	Object  isChatCompletion `json:"object"`
	Created unix.Seconds     `json:"created"
		time when the chat completion was created.`
	Model Model `json:"model"
		used for the chat completion.`
	Choices []Choice `json:"choices"
		list of chat completion choices. Can be more than one if n is greater than 1.`
	Usage Usage `json:"usage"
		statistics for the completion request.`
	SystemFingerprint string `json:"system_fingerprint,omitempty"
		represents the backend configuration that the model runs with.`
}

type ChatCompletionChunk

type ChatCompletionChunk struct {
	ID string `json:"id"
		is a unique identifier for the chat completion.`
	Object  isChatCompletionChunk `json:"object"`
	Created unix.Seconds          `json:"created"
		time when the chat completion was created.`
	Model Model `json:"model"
		used for the chat completion.`
	Choices []ChoiceChunk `json:"choices"
		list of chat completion choices. Can be more than one if n is greater than 1.`
}

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Messages []Message `json:"messages"
		comprising the conversation so far.`
	Model Model `json:"model"
		model to use.`
	FrequencyPenalty float64 `` /* 227-byte string literal not displayed */

	MaxTokens uint `` /* 166-byte string literal not displayed */

	PresencePenalty float64 `` /* 213-byte string literal not displayed */

	ResponseFormat ResponseFormat `json:"response_format,omitzero"
		An object specifying the format that the model must output.`
	Stop []string `json:"stop,omitempty"
		up to 4 sequences where the API will stop generating further tokens.`
	Temperature *float64 `` /* 250-byte string literal not displayed */

	TopP *float64 `` /* 333-byte string literal not displayed */

	Tools []Tool `json:"tools,omitempty"
		the model may call.`
	ToolChoice ToolChoice `json:"tool_choice,omitzero"
		controls which (if any) tool is called by the model.`
	LogProbs bool `` /* 190-byte string literal not displayed */

	TopLogProbs uint `` /* 238-byte string literal not displayed */

}

type Choice

type Choice struct {
	Index int `json:"index"
		of the choice in the list of choices.`
	Message Message `json:"message"
		generated by the model.`
	LoggedProbabilities []LoggedProbability `json:"logprobs,omitempty"
		of the generated tokens.`
	FinishReason FinishReason `json:"finish_reason"
		why the model stopped generating tokens.`
}

type ChoiceChunk

type ChoiceChunk struct {
	Index int `json:"index"
		of the choice in the list of choices.`
	Delta Message `json:"delta"
		generated by streamed model responses.`
	FinishReason FinishReason `json:"finish_reason"
		why the model stopped generating tokens.`
}

type Error

type Error struct {
	Code ErrorCode `json:"code"`
}

func (Error) Error

func (e Error) Error() string

type ErrorCode

type ErrorCode xyz.Switch[string, struct {
	ContextLengthExceeded ErrorCode `json:"context_length_exceeded"`
	ModelNotFound         ErrorCode `json:"model_not_found"`
}]

type FinishReason

type FinishReason xyz.Switch[string, struct {
	Stop FinishReason `json:"stop"
		the model hit a natural stop point or a provided stop sequence.`
	Length FinishReason `json:"length"
		the maximum number of tokens specified in the request was reached`
	ContentFilter FinishReason `json:"content_filter"
		the model's content filter stopped the model from generating more tokens.`
	ToolCalls FinishReason `json:"tool_calls"
		the model's tool calls stopped the model from generating more tokens.`
}]

type Function

type Function struct {
	Name string `json:"name"
		of the function to call.`
	Description string `json:"description,omitempty"
		of what the function does, used by the model to choose when and how to call the function.`
	Arguments string `json:"arguments,omitempty"
		(for function calls) to call the function with.`
}

type FunctionCall

type FunctionCall struct {
	ID       ToolCallID `json:"id"`
	Function Function   `json:"function"`
}

type LoggedProbability

type LoggedProbability struct {
	Content []TokenProbability `json:"content"`
	Refusal []TokenProbability `json:"refusal,omitempty"`
}

type Message

type Message xyz.Tagged[any, struct {
	System    xyz.Case[Message, System]     `json:"?role=system"`
	User      xyz.Case[Message, User]       `json:"?role=user"`
	Assistant xyz.Case[Message, Assistant]  `json:"?role=assistant"`
	Tool      xyz.Case[Message, ToolOutput] `json:"?role=tool"`
}]

type Model

type Model string

type PromptTokensDetails

type PromptTokensDetails struct {
	TextTokens   int `json:"text_tokens"`
	AudioTokens  int `json:"audio_tokens"`
	ImageTokens  int `json:"image_tokens"`
	CachedTokens int `json:"cached_tokens"`
}

type ResponseFormat

type ResponseFormat xyz.Tagged[any, struct {
	JSON ResponseFormat `json:"?type=json_object"`
}]

type Role

type Role xyz.Switch[string, struct {
	System    Role `json:"system"`
	Assistant Role `json:"assistant"`
	User      Role `json:"user"`
	Function  Role `json:"function"`
}]

type StreamedChatCompletionRequest

type StreamedChatCompletionRequest struct {
	ChatCompletionRequest

	Stream isTrue `json:"stream"`
}

type System

type System struct {
	Name string `json:"name,omitempty"
		of the system.`
	Content string `json:"content"
		of the message.`
}

type Token

type Token string

type TokenProbability

type TokenProbability struct {
	Bytes            []rune             `json:"bytes"`
	Probability      float64            `json:"probability"`
	Token            string             `json:"token"`
	TopProbabilities []TokenProbability `json:"top_logprobs,omitempty"`
}

type Tool

type Tool xyz.Tagged[any, struct {
	Function Function `json:"function?type=function"`
}]

type ToolCallID

type ToolCallID string

type ToolChoice

type ToolChoice xyz.Tagged[any, struct {
	None     ToolChoice                     `json:"none"`
	Auto     ToolChoice                     `json:"auto"`
	Required ToolChoice                     `json:"required"`
	Specific xyz.Case[ToolChoice, Function] `json:"function?type=function"`
}]

type ToolOutput

type ToolOutput struct {
	ToolCallID ToolCallID `json:"tool_call_id,omitempty"
		identifies the tool call.`
	Content string `json:"content"
		of the message.`
}

type Usage

type Usage struct {
	PromptTokens int `json:"prompt_tokens"
		is the number of tokens in the prompt.`
	CompletionTokens int `json:"completion_tokens"
		is the number of tokens in the generated completion.`
	TotalTokens int `json:"total_tokens"
		is the total number of tokens used in the request (prompt + completion).`
	PromptTokensDetails PromptTokensDetails `json:"prompt_tokens_details"`
}

type User

type User struct {
	Name string `json:"name,omitempty"
		of the system.`
	Content string `json:"content"
		of the message.`
}

Jump to

Keyboard shortcuts

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