Documentation
¶
Index ¶
- Constants
- type ChatChunkCompletion
- type ChatCompletion
- type Choice
- type ChoiceChunk
- type ChoiceDelta
- type ChoiceDeltaFunctionCall
- type ChoiceDeltaToolCall
- type ChoiceDeltaToolCallFunction
- type ChoiceLogprobs
- type ChoiceLogprobsContent
- type ChoiceLogprobsContentTopLogprob
- type ChoiceMessage
- type ChoiceMessageToolCall
- type ChoiceMessageToolCallFunction
- type Client
- type ClientOption
- type CompletionCreateParams
- type Error
- type ErrorResponse
- type Message
- type MessageToolCall
- type MessageToolCallFunction
- type ResponseFormat
- type ResponseFormatString
- type SSEvent
- type StreamReader
- type TimestampGranularity
- type Tool
- type ToolChoice
- type ToolChoiceToolChoice
- type ToolChoiceToolChoiceFunction
- type ToolFunction
- type TranscriptionCreateParams
- type TranslationModel
- type Usage
- type XGroq
Constants ¶
const ( TimestampGranularity_Word = "word" TimestampGranularity_Segment = "segment" )
const ( ResponseFormatString_JSON = "json" ResponseFormatString_Text = "text" ResponseFormatString_Srt = "srt" ResponseFormatString_VerboseJSON = "verbose_json" ResponseFormatString_Vtt = "vtt" )
const TranslationModel_WhisperLargeV3 = "whisper-large-v3"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatChunkCompletion ¶
type ChatChunkCompletion struct {
ID *string `json:"id"`
Choices []ChoiceChunk `json:"choices"`
Created *int `json:"created"`
Model *string `json:"model"`
Object *string `json:"object"`
SystemFingerprint *string `json:"systemFingerprint"`
XGroq *XGroq `json:"xGroq,omitempty"`
// contains filtered or unexported fields
}
ChatCompletion struct to represent the overall completion
type ChatCompletion ¶
type ChatCompletion struct {
ID string `json:"id"`
Choices []Choice `json:"choices"`
Created int `json:"created"`
Model string `json:"model"`
Object string `json:"object"`
SystemFingerprint string `json:"systemFingerprint"`
Usage Usage `json:"usage,omitempty"`
Stream chan *ChatChunkCompletion `json:"-"`
}
ChatCompletion struct to represent the overall completion
type Choice ¶
type Choice struct {
FinishReason string `json:"finishReason"`
Index int `json:"index"`
Logprobs ChoiceLogprobs `json:"logprobs"`
Message ChoiceMessage `json:"message"`
}
Choice struct to handle individual choices in a completion
type ChoiceChunk ¶
type ChoiceChunk struct {
Delta ChoiceDelta `json:"delta"`
FinishReason string `json:"finishReason"`
Index int `json:"index"`
Logprobs ChoiceLogprobs `json:"logprobs"`
}
Choice struct for handling choices in completion chunks
type ChoiceDelta ¶
type ChoiceDelta struct {
Content string `json:"content"`
Role string `json:"role"`
FunctionCall *ChoiceDeltaFunctionCall `json:"functionCall,omitempty"`
ToolCalls []ChoiceDeltaToolCall `json:"toolCalls,omitempty"`
}
ChoiceDelta struct for deltas within choices
type ChoiceDeltaFunctionCall ¶
type ChoiceDeltaFunctionCall struct {
Arguments *string `json:"arguments,omitempty"`
Name *string `json:"name,omitempty"`
}
ChoiceDeltaFunctionCall struct for details of function calls
type ChoiceDeltaToolCall ¶
type ChoiceDeltaToolCall struct {
Index int `json:"index"`
ID *string `json:"id,omitempty"`
Function ChoiceDeltaToolCallFunction `json:"function,omitempty"`
Type *string `json:"type,omitempty"`
}
ChoiceDeltaToolCall struct for tool call details within deltas
type ChoiceDeltaToolCallFunction ¶
type ChoiceDeltaToolCallFunction struct {
Arguments *string `json:"arguments,omitempty"`
Name *string `json:"name,omitempty"`
}
ChoiceDeltaToolCallFunction struct for tool call function details
type ChoiceLogprobs ¶
type ChoiceLogprobs struct {
Content []ChoiceLogprobsContent `json:"content,omitempty"`
}
ChoiceLogprobs struct to contain multiple log probability contents
type ChoiceLogprobsContent ¶
type ChoiceLogprobsContent struct {
Token *string `json:"token,omitempty"`
Bytes []int `json:"bytes,omitempty"`
Logprob *float64 `json:"logprob,omitempty"`
TopLogprobs []ChoiceLogprobsContentTopLogprob `json:"topLogprobs,omitempty"`
}
ChoiceLogprobsContent struct to handle content log probabilities
type ChoiceLogprobsContentTopLogprob ¶
type ChoiceLogprobsContentTopLogprob struct {
Token *string `json:"token,omitempty"`
Bytes []int `json:"bytes,omitempty"`
Logprob *float64 `json:"logprob,omitempty"`
}
ChoiceLogprobsContentTopLogprob struct to represent detailed log probabilities
type ChoiceMessage ¶
type ChoiceMessage struct {
Content string `json:"content"`
Role string `json:"role"`
ToolCalls []ChoiceMessageToolCall `json:"toolCalls,omitempty"`
}
ChoiceMessage struct for messages within choices
type ChoiceMessageToolCall ¶
type ChoiceMessageToolCall struct {
ID *string `json:"id,omitempty"`
Function ChoiceMessageToolCallFunction `json:"function,omitempty"`
Type *string `json:"type,omitempty"`
}
ChoiceMessageToolCall struct to represent a tool call in a message
type ChoiceMessageToolCallFunction ¶
type ChoiceMessageToolCallFunction struct {
Arguments *string `json:"arguments,omitempty"`
Name *string `json:"name,omitempty"`
}
ChoiceMessageToolCallFunction struct to describe the function called by the tool
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
func (*Client) CreateChatCompletion ¶
func (c *Client) CreateChatCompletion(params CompletionCreateParams) (*ChatCompletion, error)
func (*Client) CreateTranscription ¶
func (c *Client) CreateTranscription(params TranscriptionCreateParams) (*ChatCompletion, error)
type ClientOption ¶
type ClientOption func(*Client)
func WithAPIKey ¶
func WithAPIKey(apiKey string) ClientOption
func WithDebug ¶
func WithDebug(debug bool) ClientOption
type CompletionCreateParams ¶
type CompletionCreateParams struct {
Messages []Message `json:"messages"`
Model string `json:"model"`
FrequencyPenalty float32 `json:"frequency_penalty,omitempty"`
LogitBias map[string]int `json:"logit_bias,omitempty"`
Logprobs bool `json:"logprobs,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
N int `json:"n,omitempty"`
PresencePenalty float32 `json:"presence_penalty,omitempty"`
ResponseFormat ResponseFormat `json:"response_format,omitempty"`
Seed int `json:"seed,omitempty"`
Stop []string `json:"stop,omitempty"`
Stream bool `json:"stream,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
ToolChoice ToolChoice `json:"tool_choice,omitempty"`
Tools []Tool `json:"tools,omitempty"`
TopLogprobs int `json:"top_logprobs,omitempty"`
TopP float32 `json:"top_p,omitempty"`
User string `json:"user,omitempty"`
}
CompletionCreateParams struct to handle API parameters
type Error ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error Error `json:"error"`
}
type Message ¶
type Message struct {
Content string `json:"content"` // Required fields, not omitting in JSON
Role string `json:"role"` // Required fields, not omitting in JSON
Name string `json:"name,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolCalls []MessageToolCall `json:"tool_calls,omitempty"`
}
Message struct to handle messages
type MessageToolCall ¶
type MessageToolCall struct {
ID string `json:"id,omitempty"`
Function MessageToolCallFunction `json:"function,omitempty"`
Type string `json:"type,omitempty"`
}
MessageToolCall struct to handle tool calls in messages
type MessageToolCallFunction ¶
type MessageToolCallFunction struct {
Arguments string `json:"arguments,omitempty"`
Name string `json:"name,omitempty"`
}
MessageToolCallFunction struct to handle function details
type ResponseFormat ¶
type ResponseFormat struct {
Type string `json:"type,omitempty"`
}
ResponseFormat struct to handle response formatting
type ResponseFormatString ¶
type ResponseFormatString string
type SSEvent ¶
func SSEventFromBytes ¶
type StreamReader ¶
type StreamReader struct {
// contains filtered or unexported fields
}
func NewStreamReader ¶
func NewStreamReader(eventStream io.Reader) *StreamReader
func (*StreamReader) Next ¶
func (e *StreamReader) Next() (*SSEvent, error)
type TimestampGranularity ¶
type TimestampGranularity string
type Tool ¶
type Tool struct {
Function ToolFunction `json:"function,omitempty"`
Type string `json:"type,omitempty"`
}
Tool struct to handle tools
type ToolChoice ¶
type ToolChoice string
const ( ToolChoiceAuto ToolChoice = "auto" ToolChoiceNone ToolChoice = "none" )
type ToolChoiceToolChoice ¶
type ToolChoiceToolChoice struct {
Function ToolChoiceToolChoiceFunction `json:"function,omitempty"`
Type string `json:"type,omitempty"`
}
ToolChoiceToolChoice struct to handle nested tool choices
type ToolChoiceToolChoiceFunction ¶
type ToolChoiceToolChoiceFunction struct {
Name string `json:"name,omitempty"`
}
ToolChoiceToolChoiceFunction struct to handle tool choice functions
type ToolFunction ¶
type ToolFunction struct {
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
}
ToolFunction struct to handle tool functions
type TranscriptionCreateParams ¶
type TranscriptionCreateParams struct {
File *os.File `json:"file"`
Model TranslationModel `json:"model"`
Language string `json:"language,omitempty"`
Prompt string `json:"prompt,omitempty"`
ResponseFormat ResponseFormatString `json:"response_format,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TimestampGranularities TimestampGranularity `json:"timestamp_granularity,omitempty"`
}
type TranslationModel ¶
type TranslationModel string
type Usage ¶
type Usage struct {
CompletionTime *float64 `json:"completionTime,omitempty"`
CompletionTokens *int `json:"completionTokens,omitempty"`
PromptTime *float64 `json:"promptTime,omitempty"`
PromptTokens *int `json:"promptTokens,omitempty"`
QueueTime *float64 `json:"queueTime,omitempty"`
TotalTime *float64 `json:"totalTime,omitempty"`
TotalTokens *int `json:"totalTokens,omitempty"`
}
Usage struct to handle usage data
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
completion
command
|
|
|
streaming
command
|
|
|
tools
command
|
|
|
transcribe
command
|