Documentation
¶
Index ¶
- type ChatCompletion
- type ChatCompletionChunk
- type Completion
- type CompletionChunk
- type EmbedRequest
- type Embedding
- type EmbeddingResponse
- type EmbeddingUsage
- type Error
- type ErrorResponse
- type GeneralRequest
- type GeneralResponse
- type ImageObject
- type ImageResponse
- type ImageUsage
- type ImageUsageInputTokensDetails
- type StreamOptions
- type Usage
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 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 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 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.
Click to show internal directories.
Click to hide internal directories.