protocol

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatCompletion

type ChatCompletion struct {
	GeneralResponse
	Usage Usage `json:"usage,omitempty"`
}

type ChatCompletionChunk

type ChatCompletionChunk struct {
	GeneralResponse
	Usage *Usage `json:"usage,omitempty"`
}

type Completion

type Completion struct {
	GeneralResponse
	Usage Usage `json:"usage,omitempty"`
}

type CompletionChunk

type CompletionChunk struct {
	GeneralResponse
	Usage *Usage `json:"usage,omitempty"`
}

type EmbedRequest

type EmbedRequest struct {
	Input          any    `json:"input"`
	Model          string `json:"model"`
	EncodingFormat string `json:"encoding_format"`
}

EmbedRequest represents the request structure for OpenAI embeddings.

type Embedding

type Embedding struct {
	Object    string    `json:"object"`
	Index     int       `json:"index"`
	Embedding []float32 `json:"embedding"`
}

Embedding represents the response structure for OpenAI embeddings. see more details from https://platform.openai.com/docs/guides/embeddings

type EmbeddingResponse

type EmbeddingResponse struct {
	Object string         `json:"object"`
	Data   []Embedding    `json:"data"`
	Model  string         `json:"model"`
	Usage  EmbeddingUsage `json:"usage"`
}

type EmbeddingUsage

type EmbeddingUsage struct {
	PromptTokens int `json:"prompt_tokens"`
	TotalTokens  int `json:"total_tokens"`
}

type Error

type Error struct {
	Message        string  `json:"message"`
	Type           string  `json:"type"`
	SequenceNumber int     `json:"sequence_number,omitempty"`
	Param          *string `json:"param"`
	Code           *string `json:"code"`
}

Error reference from https://platform.openai.com/docs/api-reference/responses-streaming/error

type ErrorResponse

type ErrorResponse struct {
	Error Error `json:"error"`
}

func NewError

func NewError(code int, message string) ErrorResponse

type GeneralRequest

type GeneralRequest struct {
	Model         string        `json:"model"`
	Stream        bool          `json:"stream"`
	StreamOptions StreamOptions `json:"stream_options,omitempty"`
}

type GeneralResponse

type GeneralResponse struct {
	Id      string `json:"id"`
	Object  string `json:"object"`
	Created int64  `json:"created"`
	Model   string `json:"model"`
}

type ImageObject

type ImageObject struct {
	B64Json       string `json:"b64_json"`
	URL           string `json:"url"`
	RevisedPrompt string `json:"revised_prompt,omitempty"`
}

ImageObject represents the structure of an image object in the OpenAI API response. see more details from https://platform.openai.com/docs/api-reference/images/object

type ImageResponse

type ImageResponse struct {
	Background   string        `json:"background,omitempty"`
	Created      int64         `json:"created"`
	Data         []ImageObject `json:"data"`
	OutputFormat string        `json:"output_format,omitempty"`
	Quality      string        `json:"quality,omitempty"`
	Size         string        `json:"size,omitempty"`
	Usage        ImageUsage    `json:"usage,omitempty"`
}

type ImageUsage

type ImageUsage struct {
	InputTokens        int                          `json:"input_tokens"`
	OutputTokens       int                          `json:"output_tokens"`
	TotalTokens        int                          `json:"total_tokens"`
	InputTokensDetails ImageUsageInputTokensDetails `json:"input_tokens_details,omitempty"`
}

type ImageUsageInputTokensDetails

type ImageUsageInputTokensDetails struct {
	ImageTokens int `json:"image_tokens"`
	TextTokens  int `json:"text_tokens"`
}

type StreamOptions

type StreamOptions struct {
	IncludeUsage *bool `json:"include_usage,omitempty"`
}

StreamOptions defines options for streaming requests options. Note: It is different from the OpenAI API, we'll set `include_usage` to true by default.

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

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