Documentation
¶
Index ¶
- Variables
- type AssistantChatCompletionMessageUnion
- type AssistantMessageAudio
- type AssistantMessageContentPartUnion
- type AssistantMessageContentUnion
- type AssistantMessageCustomToolCall
- type AssistantMessageCustomToolCallParam
- type AssistantMessageFunctionCall
- type AssistantMessageFunctionToolCall
- type AssistantMessageFunctionToolCallParam
- type AssistantMessageToolCallUnion
- type AudioParam
- type AudioPart
- type ChatCompletionChunk
- type ChatCompletionChunkChoice
- type ChatCompletionChunkChoiceDelta
- type ChatCompletionMessageUnion
- type Choice
- type ChoiceLogprobs
- type CompletionUsageCompletionTokensDetails
- type CompletionUsagePromptTokensDetails
- type ContentTypeFile
- type ContentTypeImageUrl
- type ContentTypeInputAudio
- type ContentTypeRefusal
- type ContentTypeText
- type DeveloperChatCompletionMessageUnion
- type DeveloperMessageContentUnion
- type File
- type FilePart
- type FunctionCallOptionParam
- type FunctionCallParam
- type FunctionChatCompletionMessageUnion
- type FunctionsParam
- type ImagePart
- type ImageUrl
- type InputAudio
- type OutputMessage
- type OutputMessageAudio
- type RefusalPart
- type Request
- type Response
- type ResponseChunk
- type StopParam
- type StreamOptionParam
- type StringConstant
- type SystemChatCompletionMessageUnion
- type SystemMessageContentUnion
- type TextPart
- type ToolCallTypeCustom
- type ToolCallTypeFunction
- type ToolChatCompletionMessageUnion
- type ToolMessageContentUnion
- type Usage
- type UserChatCompletionMessageUnion
- type UserMessageContentPartUnion
- type UserMessageContentUnion
Constants ¶
This section is empty.
Variables ¶
View Source
var RoleTool constants.Role = "tool"
Check if RoleTool exists in constants, if not we'll need to handle it
Functions ¶
This section is empty.
Types ¶
type AssistantChatCompletionMessageUnion ¶
type AssistantChatCompletionMessageUnion struct {
Refusal *string `json:"refusal,omitempty"`
Name *string `json:"name,omitempty"`
Audio AssistantMessageAudio `json:"audio,omitempty"`
Content AssistantMessageContentUnion `json:"content,omitempty"`
FunctionCall AssistantMessageFunctionCall `json:"function_call,omitempty"`
ToolCalls []AssistantMessageToolCallUnion `json:"tool_calls,omitempty"`
Role *string `json:"role,omitempty"` // "assistant"
}
type AssistantMessageAudio ¶
type AssistantMessageAudio struct {
ID string `json:"id"`
}
type AssistantMessageContentPartUnion ¶
type AssistantMessageContentPartUnion struct {
OfText *TextPart `json:",omitempty"`
OfRefusal *RefusalPart `json:",omitempty"`
}
func (*AssistantMessageContentPartUnion) MarshalJSON ¶
func (u *AssistantMessageContentPartUnion) MarshalJSON() ([]byte, error)
func (*AssistantMessageContentPartUnion) UnmarshalJSON ¶
func (u *AssistantMessageContentPartUnion) UnmarshalJSON(data []byte) error
type AssistantMessageContentUnion ¶
type AssistantMessageContentUnion struct {
OfString *string `json:",omitempty"`
OfList []AssistantMessageContentPartUnion `json:",omitempty"`
}
func (*AssistantMessageContentUnion) MarshalJSON ¶
func (u *AssistantMessageContentUnion) MarshalJSON() ([]byte, error)
func (*AssistantMessageContentUnion) UnmarshalJSON ¶
func (u *AssistantMessageContentUnion) UnmarshalJSON(data []byte) error
type AssistantMessageCustomToolCall ¶
type AssistantMessageCustomToolCall struct {
Type string `json:"type"` // "custom"
ID string `json:"id,omitempty"`
Custom AssistantMessageCustomToolCallParam `json:"custom"`
}
type AssistantMessageFunctionToolCall ¶
type AssistantMessageFunctionToolCall struct {
Type string `json:"type"` // "function"
ID string `json:"id,omitempty"`
Function AssistantMessageFunctionToolCallParam `json:"function"`
}
type AssistantMessageToolCallUnion ¶
type AssistantMessageToolCallUnion struct {
OfFunction AssistantMessageFunctionToolCall `json:",omitempty"`
OfCustom AssistantMessageCustomToolCall `json:",omitempty"`
}
func (*AssistantMessageToolCallUnion) MarshalJSON ¶
func (u *AssistantMessageToolCallUnion) MarshalJSON() ([]byte, error)
func (*AssistantMessageToolCallUnion) UnmarshalJSON ¶
func (u *AssistantMessageToolCallUnion) UnmarshalJSON(data []byte) error
type AudioParam ¶
type AudioPart ¶
type AudioPart struct {
Type string `json:"type,omitempty"` // "input_audio"
InputAudio InputAudio `json:"input_audio,omitempty"`
}
type ChatCompletionChunk ¶
type ChatCompletionChunk struct {
Id string `json:"id"`
Object string `json:"object"`
Created int `json:"created"`
Model string `json:"model"`
ServiceTier string `json:"service_tier"`
SystemFingerprint string `json:"system_fingerprint"`
Choices []ChatCompletionChunkChoice `json:"choices"`
Obfuscation string `json:"obfuscation"`
Usage *Usage `json:"usage,omitempty"`
}
type ChatCompletionChunkChoice ¶
type ChatCompletionChunkChoice struct {
Index int `json:"index"`
Delta ChatCompletionChunkChoiceDelta `json:"delta"`
FinishReason string `json:"finish_reason"`
Obfuscation *string `json:"obfuscation,omitempty"`
}
type ChatCompletionMessageUnion ¶
type ChatCompletionMessageUnion struct {
OfDeveloper *DeveloperChatCompletionMessageUnion `json:",omitzero"`
OfSystem *SystemChatCompletionMessageUnion `json:",omitzero"`
OfUser *UserChatCompletionMessageUnion `json:",omitzero"`
OfAssistant *AssistantChatCompletionMessageUnion `json:",omitzero"`
OfTool *ToolChatCompletionMessageUnion `json:",omitzero"`
OfFunction *FunctionChatCompletionMessageUnion `json:",omitzero"`
}
func (*ChatCompletionMessageUnion) MarshalJSON ¶
func (u *ChatCompletionMessageUnion) MarshalJSON() ([]byte, error)
func (*ChatCompletionMessageUnion) UnmarshalJSON ¶
func (u *ChatCompletionMessageUnion) UnmarshalJSON(data []byte) error
type Choice ¶
type Choice struct {
FinishReason string `json:"finish_reason"` // "stop", "length", "content_filter"
Index int64 `json:"index"`
Logprobs ChoiceLogprobs `json:"logprobs"`
Message OutputMessage `json:"message"`
}
type ChoiceLogprobs ¶
type CompletionUsageCompletionTokensDetails ¶
type CompletionUsageCompletionTokensDetails struct {
// When using Predicted Outputs, the number of tokens in the prediction that
// appeared in the completion.
AcceptedPredictionTokens int64 `json:"accepted_prediction_tokens"`
// Audio input tokens generated by the model.
AudioTokens int64 `json:"audio_tokens"`
// Tokens generated by the model for reasoning.
ReasoningTokens int64 `json:"reasoning_tokens"`
// When using Predicted Outputs, the number of tokens in the prediction that did
// not appear in the completion. However, like reasoning tokens, these tokens are
// still counted in the total completion tokens for purposes of billing, output,
// and context window limits.
RejectedPredictionTokens int64 `json:"rejected_prediction_tokens"`
}
type ContentTypeFile ¶
type ContentTypeFile string
func (*ContentTypeFile) MarshalJSON ¶
func (m *ContentTypeFile) MarshalJSON() ([]byte, error)
func (*ContentTypeFile) UnmarshalJSON ¶
func (m *ContentTypeFile) UnmarshalJSON(buf []byte) error
func (*ContentTypeFile) Value ¶
func (m *ContentTypeFile) Value() string
type ContentTypeImageUrl ¶
type ContentTypeImageUrl string
func (*ContentTypeImageUrl) MarshalJSON ¶
func (m *ContentTypeImageUrl) MarshalJSON() ([]byte, error)
func (*ContentTypeImageUrl) UnmarshalJSON ¶
func (m *ContentTypeImageUrl) UnmarshalJSON(buf []byte) error
func (*ContentTypeImageUrl) Value ¶
func (m *ContentTypeImageUrl) Value() string
type ContentTypeInputAudio ¶
type ContentTypeInputAudio string
func (*ContentTypeInputAudio) MarshalJSON ¶
func (m *ContentTypeInputAudio) MarshalJSON() ([]byte, error)
func (*ContentTypeInputAudio) UnmarshalJSON ¶
func (m *ContentTypeInputAudio) UnmarshalJSON(buf []byte) error
func (*ContentTypeInputAudio) Value ¶
func (m *ContentTypeInputAudio) Value() string
type ContentTypeRefusal ¶
type ContentTypeRefusal string
func (*ContentTypeRefusal) MarshalJSON ¶
func (m *ContentTypeRefusal) MarshalJSON() ([]byte, error)
func (*ContentTypeRefusal) UnmarshalJSON ¶
func (m *ContentTypeRefusal) UnmarshalJSON(buf []byte) error
func (*ContentTypeRefusal) Value ¶
func (m *ContentTypeRefusal) Value() string
type ContentTypeText ¶
type ContentTypeText string
func (*ContentTypeText) MarshalJSON ¶
func (m *ContentTypeText) MarshalJSON() ([]byte, error)
func (*ContentTypeText) UnmarshalJSON ¶
func (m *ContentTypeText) UnmarshalJSON(buf []byte) error
func (*ContentTypeText) Value ¶
func (m *ContentTypeText) Value() string
type DeveloperChatCompletionMessageUnion ¶
type DeveloperChatCompletionMessageUnion struct {
Name *string `json:"name,omitempty"`
Role constants.Role `json:"role,omitempty"` // "developer"
Content DeveloperMessageContentUnion `json:"content,omitempty"`
}
type DeveloperMessageContentUnion ¶
type DeveloperMessageContentUnion struct {
OfString *string `json:",omitempty"`
OfList []TextPart `json:",omitempty"`
}
func (*DeveloperMessageContentUnion) MarshalJSON ¶
func (u *DeveloperMessageContentUnion) MarshalJSON() ([]byte, error)
func (*DeveloperMessageContentUnion) UnmarshalJSON ¶
func (u *DeveloperMessageContentUnion) UnmarshalJSON(data []byte) error
type FunctionCallOptionParam ¶
type FunctionCallOptionParam struct {
Name string `json:"name"`
}
type FunctionCallParam ¶
type FunctionCallParam struct {
OfFunctionCallMode *string `json:",omitempty"`
OfFunctionCallOption *FunctionCallOptionParam `json:",omitempty"`
}
type FunctionsParam ¶
type InputAudio ¶
type OutputMessage ¶
type OutputMessage struct {
Role constants.Role `json:"role"`
Refusal string `json:"refusal"`
Content string `json:"content"`
FunctionCall AssistantMessageFunctionCall `json:"function_call"`
ToolCalls []ToolChatCompletionMessageUnion `json:"tool_calls"`
Audio OutputMessageAudio `json:"audio"`
}
type OutputMessageAudio ¶
type OutputMessageAudio struct {
}
type RefusalPart ¶
type Request ¶
type Request struct {
Messages []ChatCompletionMessageUnion `json:"messages"`
Model string `json:"model"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
Logprobs *bool `json:"logprobs,omitempty"`
MaxCompletionTokens *int64 `json:"max_completion_tokens,omitempty"`
MaxTokens *int64 `json:"max_tokens,omitempty"` // Deprecated in favour of `MaxCompletionTokens`
N *int64 `json:"n,omitempty"` // How many choices needs to be generated
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
Seed *int64 `json:"seed,omitempty"`
Store *bool `json:"store,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopLogprobs *int64 `json:"top_logprobs,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`
PromptCacheKey *string `json:"prompt_cache_key,omitempty"`
SafetyIdentifier *string `json:"safety_identifier,omitempty"`
User *string `json:"user,omitempty"`
Audio *AudioParam `json:"audio,omitempty"`
LogitBias map[string]int64 `json:"logit_bias,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Modalities []string `json:"modalities,omitempty"` // "text", "audio"
ReasoningEffort *string `json:"reasoning_effort,omitempty"` // "minimal", "low", "medium", "high"
ServiceTier *string `json:"service_tier,omitempty"` // "auto", "default", "flex", "scale", "priority"
Stop *StopParam `json:"stop,omitempty"`
Stream *bool `json:"stream,omitempty"`
StreamOptions *StreamOptionParam `json:"stream_options,omitempty"` // Set only when setting stream=true
Verbosity *string `json:"verbosity,omitempty"` // "low", "medium", "high"
FunctionCall *FunctionCallParam `json:"function_call,omitempty"` // Deprecated in favour of `tool_choice`
Functions []FunctionsParam `json:"functions,omitempty"` // Deprecated in favour of tools
Prediction any `json:"prediction,omitempty"`
ResponseFormat any `json:"response_format,omitempty"`
ToolChoice *string `json:"tool_choice,omitempty"`
Tools any `json:"tools,omitempty"`
WebSearchOptions any `json:"web_search_options,omitempty"`
}
func (*Request) IsStreamingRequest ¶
type ResponseChunk ¶
type ResponseChunk struct {
OfChatCompletionChunk *ChatCompletionChunk `json:",omitempty"`
}
func (*ResponseChunk) MarshalJSON ¶
func (u *ResponseChunk) MarshalJSON() ([]byte, error)
func (*ResponseChunk) UnmarshalJSON ¶
func (u *ResponseChunk) UnmarshalJSON(data []byte) error
type StreamOptionParam ¶
type StringConstant ¶
type StringConstant interface {
Value() string
}
type SystemChatCompletionMessageUnion ¶
type SystemChatCompletionMessageUnion struct {
Name *string `json:"name,omitempty"`
Role constants.Role `json:"role,omitempty"` // system
Content SystemMessageContentUnion `json:"content,omitempty"`
}
type SystemMessageContentUnion ¶
type SystemMessageContentUnion struct {
OfString *string `json:",omitempty"`
OfList []TextPart `json:",omitempty"`
}
func (*SystemMessageContentUnion) MarshalJSON ¶
func (u *SystemMessageContentUnion) MarshalJSON() ([]byte, error)
func (*SystemMessageContentUnion) UnmarshalJSON ¶
func (u *SystemMessageContentUnion) UnmarshalJSON(data []byte) error
type ToolCallTypeCustom ¶
type ToolCallTypeCustom string
func (*ToolCallTypeCustom) MarshalJSON ¶
func (m *ToolCallTypeCustom) MarshalJSON() ([]byte, error)
func (*ToolCallTypeCustom) UnmarshalJSON ¶
func (m *ToolCallTypeCustom) UnmarshalJSON(buf []byte) error
func (*ToolCallTypeCustom) Value ¶
func (m *ToolCallTypeCustom) Value() string
type ToolCallTypeFunction ¶
type ToolCallTypeFunction string
func (*ToolCallTypeFunction) MarshalJSON ¶
func (m *ToolCallTypeFunction) MarshalJSON() ([]byte, error)
func (*ToolCallTypeFunction) UnmarshalJSON ¶
func (m *ToolCallTypeFunction) UnmarshalJSON(buf []byte) error
func (*ToolCallTypeFunction) Value ¶
func (m *ToolCallTypeFunction) Value() string
type ToolChatCompletionMessageUnion ¶
type ToolChatCompletionMessageUnion struct {
Role constants.Role `json:"role,omitempty"` // tool
Content ToolMessageContentUnion `json:"content,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
}
type ToolMessageContentUnion ¶
type ToolMessageContentUnion struct {
OfString *string `json:",omitempty"`
OfList []TextPart `json:",omitempty"`
}
func (*ToolMessageContentUnion) MarshalJSON ¶
func (u *ToolMessageContentUnion) MarshalJSON() ([]byte, error)
func (*ToolMessageContentUnion) UnmarshalJSON ¶
func (u *ToolMessageContentUnion) UnmarshalJSON(data []byte) error
type Usage ¶
type Usage struct {
// Number of tokens in the generated completion.
CompletionTokens int64 `json:"completion_tokens,required"`
// Number of tokens in the prompt.
PromptTokens int64 `json:"prompt_tokens,required"`
// Total number of tokens used in the request (prompt + completion).
TotalTokens int64 `json:"total_tokens,required"`
// Breakdown of tokens used in a completion.
CompletionTokensDetails CompletionUsageCompletionTokensDetails `json:"completion_tokens_details"`
// Breakdown of tokens used in the prompt.
PromptTokensDetails CompletionUsagePromptTokensDetails `json:"prompt_tokens_details"`
}
type UserChatCompletionMessageUnion ¶
type UserChatCompletionMessageUnion struct {
Name *string `json:"name,omitempty"`
Role constants.Role `json:"role,omitempty"` // user
Content UserMessageContentUnion `json:"content,omitempty"`
}
type UserMessageContentPartUnion ¶
type UserMessageContentPartUnion struct {
OfText *TextPart `json:",omitempty"`
OfImageUrl *ImagePart `json:",omitempty"`
OfInputAudio *AudioPart `json:",omitempty"`
OfFile *FilePart `json:",omitempty"`
}
func (*UserMessageContentPartUnion) MarshalJSON ¶
func (u *UserMessageContentPartUnion) MarshalJSON() ([]byte, error)
func (*UserMessageContentPartUnion) UnmarshalJSON ¶
func (u *UserMessageContentPartUnion) UnmarshalJSON(data []byte) error
type UserMessageContentUnion ¶
type UserMessageContentUnion struct {
OfString *string `json:",omitempty"`
OfList []UserMessageContentPartUnion `json:",omitempty"`
}
func (*UserMessageContentUnion) MarshalJSON ¶
func (u *UserMessageContentUnion) MarshalJSON() ([]byte, error)
func (*UserMessageContentUnion) UnmarshalJSON ¶
func (u *UserMessageContentUnion) UnmarshalJSON(data []byte) error
Click to show internal directories.
Click to hide internal directories.