Documentation ¶
Index ¶
- type ChatCompletion
- type ChatCompletionChoice
- type ChatCompletionMessage
- type ChatCompletionRequest
- type ChatCompletionResponseFormat
- type Embedding
- type EmbeddingList
- type EmbeddingsRequest
- type Error
- type ErrorResponse
- type FinishReason
- type Function
- type FunctionCall
- type Handler
- type Image
- type ImageCreateRequest
- type ImageList
- type ImageStyle
- type MessageContent
- type MessageContentType
- type MessageContentURL
- type MessageRole
- type Model
- type ModelList
- type ResponseFormat
- type Schema
- type SpeechRequest
- type Tool
- type ToolCall
- type ToolType
- type Transcription
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatCompletion ¶
type ChatCompletionChoice ¶
type ChatCompletionChoice struct { Index int `json:"index"` Delta *ChatCompletionMessage `json:"delta,omitempty"` Message *ChatCompletionMessage `json:"message,omitempty"` FinishReason *FinishReason `json:"finish_reason"` }
type ChatCompletionMessage ¶
type ChatCompletionMessage struct { Role MessageRole `json:"role,omitempty"` Content string `json:"content"` Contents []MessageContent `json:"-"` ToolCalls []ToolCall `json:"tool_calls,omitempty"` ToolCallID string `json:"tool_call_id,omitempty"` }
https://platform.openai.com/docs/api-reference/chat/object
func (*ChatCompletionMessage) MarshalJSON ¶
func (m *ChatCompletionMessage) MarshalJSON() ([]byte, error)
func (*ChatCompletionMessage) UnmarshalJSON ¶
func (m *ChatCompletionMessage) UnmarshalJSON(data []byte) error
type ChatCompletionRequest ¶
type ChatCompletionRequest struct { Model string `json:"model"` Messages []ChatCompletionMessage `json:"messages"` Stream bool `json:"stream,omitempty"` Stop any `json:"stop,omitempty"` Tools []Tool `json:"tools,omitempty"` MaxTokens *int `json:"max_tokens,omitempty"` Temperature *float32 `json:"temperature,omitempty"` ResponseFormat *ChatCompletionResponseFormat `json:"response_format,omitempty"` }
type ChatCompletionResponseFormat ¶
type ChatCompletionResponseFormat struct { Type ResponseFormat `json:"type"` JSONSchema *Schema `json:"json_schema,omitempty"` }
type Embedding ¶
type Embedding struct { Object string `json:"object"` // "embedding" Index int `json:"index"` Embedding []float32 `json:"embedding"` }
https://platform.openai.com/docs/api-reference/embeddings/object
type EmbeddingList ¶
type EmbeddingList struct { Object string `json:"object"` // "list" Model string `json:"model"` Data []Embedding `json:"data"` Usage *Usage `json:"usage,omitempty"` }
https://platform.openai.com/docs/api-reference/embeddings/create
type EmbeddingsRequest ¶
https://platform.openai.com/docs/api-reference/embeddings/create
func (*EmbeddingsRequest) UnmarshalJSON ¶
func (r *EmbeddingsRequest) UnmarshalJSON(data []byte) error
type ErrorResponse ¶
type ErrorResponse struct {
Error Error `json:"error,omitempty"`
}
type FinishReason ¶
type FinishReason string
https://platform.openai.com/docs/api-reference/chat/object
var ( FinishReasonStop FinishReason = "stop" FinishReasonLength FinishReason = "length" FinishReasonToolCalls FinishReason = "tool_calls" FinishReasonContentFilter FinishReason = "content_filter" )
type FunctionCall ¶
type Image ¶
type Image struct { URL string `json:"url,omitempty"` B64JSON string `json:"b64_json,omitempty"` RevisedPrompt string `json:"revised_prompt,omitempty"` }
https://platform.openai.com/docs/api-reference/images/object
type ImageCreateRequest ¶
type ImageCreateRequest struct { Model string `json:"model"` Prompt string `json:"prompt"` Style ImageStyle `json:"style,omitempty"` ResponseFormat string `json:"response_format,omitempty"` }
https://platform.openai.com/docs/api-reference/images/create
type ImageList ¶
type ImageList struct {
Images []Image `json:"data"`
}
https://platform.openai.com/docs/api-reference/images/create
type ImageStyle ¶
type ImageStyle string
const ( ImageStyleNatural ImageStyle = "natural" ImageStyleVivid ImageStyle = "vivid" )
type MessageContent ¶
type MessageContent struct { Type MessageContentType `json:"type,omitempty"` Text string `json:"text,omitempty"` FileURL *MessageContentURL `json:"file_url,omitempty"` // non-standard ImageURL *MessageContentURL `json:"image_url,omitempty"` }
type MessageContentType ¶
type MessageContentType string
var ( MessageContentTypeText MessageContentType = "text" MessageContentTypeFileURL MessageContentType = "file_url" // non-standard MessageContentTypeImageURL MessageContentType = "image_url" )
type MessageContentURL ¶
type MessageContentURL struct {
URL string `json:"url"`
}
type MessageRole ¶
type MessageRole string
var ( MessageRoleSystem MessageRole = "system" MessageRoleUser MessageRole = "user" MessageRoleAssistant MessageRole = "assistant" MessageRoleTool MessageRole = "tool" )
type Model ¶
type Model struct { Object string `json:"object"` // "model" ID string `json:"id"` Created int64 `json:"created"` OwnedBy string `json:"owned_by"` }
https://platform.openai.com/docs/api-reference/models/object
type ResponseFormat ¶
type ResponseFormat string
var ( ResponseFormatText ResponseFormat = "text" ResponseFormatJSONObject ResponseFormat = "json_object" ResponseFormatJSONSchema ResponseFormat = "json_schema" )
type SpeechRequest ¶
type SpeechRequest struct { Model string `json:"model"` Input string `json:"input"` Voice string `json:"voice"` }
https://platform.openai.com/docs/api-reference/audio/createSpeech
type ToolCall ¶
type ToolCall struct { ID string `json:"id"` Type ToolType `json:"type"` Index int `json:"index"` Function *FunctionCall `json:"function,omitempty"` }
type ToolType ¶
type ToolType string
https://platform.openai.com/docs/api-reference/chat/object
var (
ToolTypeFunction ToolType = "function"
)