Documentation ¶
Index ¶
- Constants
- Variables
- type Assistant
- type AssistantDeletionStatus
- type AssistantFile
- type AssistantFileDeletionStatus
- type AssistantFiles
- type Assistants
- type ChatCompletion
- type ChatCompletionChoice
- type ChatCompletionOptions
- func (o ChatCompletionOptions) SetFrequencyPenalty(frequencyPenalty float64) ChatCompletionOptions
- func (o ChatCompletionOptions) SetLogitBias(logitBias map[string]any) ChatCompletionOptions
- func (o ChatCompletionOptions) SetMaxTokens(maxTokens int) ChatCompletionOptions
- func (o ChatCompletionOptions) SetN(n int) ChatCompletionOptions
- func (o ChatCompletionOptions) SetPresencePenalty(presencePenalty float64) ChatCompletionOptions
- func (o ChatCompletionOptions) SetResponseFormat(format ChatCompletionResponseFormat) ChatCompletionOptions
- func (o ChatCompletionOptions) SetSeed(seed int64) ChatCompletionOptions
- func (o ChatCompletionOptions) SetStop(stop any) ChatCompletionOptions
- func (o ChatCompletionOptions) SetStream(cb callback) ChatCompletionOptions
- func (o ChatCompletionOptions) SetTemperature(temperature float64) ChatCompletionOptions
- func (o ChatCompletionOptions) SetToolChoice(choice ChatCompletionToolChoiceMode) ChatCompletionOptions
- func (o ChatCompletionOptions) SetToolChoiceWithName(name string) ChatCompletionOptions
- func (o ChatCompletionOptions) SetTools(tools []ChatCompletionTool) ChatCompletionOptions
- func (o ChatCompletionOptions) SetTopP(topP float64) ChatCompletionOptions
- func (o ChatCompletionOptions) SetUser(user string) ChatCompletionOptions
- type ChatCompletionResponseFormat
- type ChatCompletionResponseFormatType
- type ChatCompletionTool
- type ChatCompletionToolChoiceMode
- type ChatCompletionToolFunction
- type ChatMessage
- type ChatMessageContent
- type ChatMessageRole
- type ChatUserMessageContentTypes
- type Classification
- type Client
- func (c *Client) CancelFineTuningJob(fineTuningJobID string) (response FineTuningJob, err error)
- func (c *Client) CancelRun(threadID, runID string) (response Run, err error)
- func (c *Client) CreateAssistant(model string, options CreateAssistantOptions) (response Assistant, err error)
- func (c *Client) CreateAssistantFile(assistantID, fileID string) (response AssistantFile, err error)
- func (c *Client) CreateChatCompletion(model string, messages []ChatMessage, options ChatCompletionOptions) (response ChatCompletion, err error)
- func (c *Client) CreateCompletion(model string, options CompletionOptions) (response Completion, err error)
- func (c *Client) CreateEmbedding(model string, input any, options EmbeddingOptions) (response Embeddings, err error)
- func (c *Client) CreateFineTuningJob(trainingFileID, model string, options FineTuningJobOptions) (response FineTuningJob, err error)
- func (c *Client) CreateImage(prompt string, options ImageOptions) (response GeneratedImages, err error)
- func (c *Client) CreateImageEdit(image FileParam, prompt string, options ImageEditOptions) (response GeneratedImages, err error)
- func (c *Client) CreateImageVariation(image FileParam, options ImageVariationOptions) (response GeneratedImages, err error)
- func (c *Client) CreateMessage(threadID, role, content string, options CreateMessageOptions) (response Message, err error)
- func (c *Client) CreateModeration(input any, options ModerationOptions) (response Moderation, err error)
- func (c *Client) CreateRun(threadID, assistantID string, options CreateRunOptions) (response Run, err error)
- func (c *Client) CreateSpeech(model string, input string, voice SpeechVoice, options SpeechOptions) (audio []byte, err error)
- func (c *Client) CreateThread(options CreateThreadOptions) (response Thread, err error)
- func (c *Client) CreateThreadAndRun(assistantID string, options CreateThreadAndRunOptions) (response Run, err error)
- func (c *Client) CreateTranscription(file FileParam, model string, options TranscriptionOptions) (response Transcription, err error)
- func (c *Client) CreateTranslation(file FileParam, model string, options TranslationOptions) (response Translation, err error)
- func (c *Client) DeleteAssistant(assistantID string) (response AssistantDeletionStatus, err error)
- func (c *Client) DeleteAssistantFile(assistantID, fileID string) (response AssistantFileDeletionStatus, err error)
- func (c *Client) DeleteFile(fileID string) (response DeletedFile, err error)
- func (c *Client) DeleteFineTuneModel(model string) (response ModelDeletionStatus, err error)
- func (c *Client) DeleteThread(threadID string) (response ThreadDeletionStatus, err error)
- func (c *Client) ListAssistantFiles(assistantID string, options ListAssistantFilesOptions) (response AssistantFiles, err error)
- func (c *Client) ListAssistants(options ListAssistantsOptions) (response Assistants, err error)
- func (c *Client) ListFiles() (response Files, err error)
- func (c *Client) ListFineTuningJobEvents(fineTuningJobID string, options FineTuningJobEventsOptions) (response FineTuningJobEvents, err error)
- func (c *Client) ListFineTuningJobs(options FineTuningJobsOptions) (response FineTuningJobs, err error)
- func (c *Client) ListMessageFiles(threadID, messageID string, options ListMessageFilesOptions) (response MessageFiles, err error)
- func (c *Client) ListMessages(threadID string, options ListMessagesOptions) (response Messages, err error)
- func (c *Client) ListModels() (response ModelsList, err error)
- func (c *Client) ListRunSteps(threadID, runID string, options ListRunStepsOptions) (response RunSteps, err error)
- func (c *Client) ListRuns(threadID string, options ListRunsOptions) (response Runs, err error)
- func (c *Client) ModifyAssistant(assistantID string, options ModifyAssistantOptions) (response Assistant, err error)
- func (c *Client) ModifyMessage(threadID, messageID string, options ModifyMessageOptions) (response Message, err error)
- func (c *Client) ModifyRun(threadID, runID string, options ModifyRunOptions) (response Run, err error)
- func (c *Client) ModifyThread(threadID string, options ModifyThreadOptions) (response Thread, err error)
- func (c *Client) RetrieveAssistant(assistantID string) (response Assistant, err error)
- func (c *Client) RetrieveAssistantFile(assistantID, fileID string) (response AssistantFile, err error)
- func (c *Client) RetrieveFile(fileID string) (response RetrievedFile, err error)
- func (c *Client) RetrieveFileContent(fileID string) (response []byte, err error)
- func (c *Client) RetrieveFineTuningJob(fineTuningJobID string) (response FineTuningJob, err error)
- func (c *Client) RetrieveMessage(threadID, messageID string) (response Message, err error)
- func (c *Client) RetrieveMessageFile(threadID, messageID, fileID string) (response MessageFile, err error)
- func (c *Client) RetrieveModel(id string) (response Model, err error)
- func (c *Client) RetrieveRun(threadID, runID string) (response Run, err error)
- func (c *Client) RetrieveRunStep(threadID, runID, stepID string) (response RunStep, err error)
- func (c *Client) RetrieveThread(threadID string) (response Thread, err error)
- func (c *Client) SetBaseURL(baseURL string) *Client
- func (c *Client) SetBetaHeader(beta string) *Client
- func (c *Client) SubmitToolOutputs(threadID, runID string, toolOutputs []ToolOutput) (response Run, err error)
- func (c *Client) UploadFile(file FileParam, purpose string) (response UploadedFile, err error)
- type CommonResponse
- type Completion
- type CompletionChoice
- type CompletionOptions
- func (o CompletionOptions) SetBestOf(bestOf int) CompletionOptions
- func (o CompletionOptions) SetEcho(echo bool) CompletionOptions
- func (o CompletionOptions) SetFrequencyPenalty(frequencyPenalty float64) CompletionOptions
- func (o CompletionOptions) SetLogProbabilities(logprobs int) CompletionOptions
- func (o CompletionOptions) SetLogitBias(logitBias map[string]any) CompletionOptions
- func (o CompletionOptions) SetMaxTokens(maxTokens int) CompletionOptions
- func (o CompletionOptions) SetN(n int) CompletionOptions
- func (o CompletionOptions) SetPresencePenalty(presencePenalty float64) CompletionOptions
- func (o CompletionOptions) SetPrompt(prompt any) CompletionOptions
- func (o CompletionOptions) SetStop(stop any) CompletionOptions
- func (o CompletionOptions) SetStream(stream bool) CompletionOptions
- func (o CompletionOptions) SetSuffix(suffix string) CompletionOptions
- func (o CompletionOptions) SetTemperature(temperature float64) CompletionOptions
- func (o CompletionOptions) SetTopP(topP float64) CompletionOptions
- func (o CompletionOptions) SetUser(user string) CompletionOptions
- type CreateAssistantOptions
- func (o CreateAssistantOptions) SetDescription(description string) CreateAssistantOptions
- func (o CreateAssistantOptions) SetFileIDs(fileIDs []string) CreateAssistantOptions
- func (o CreateAssistantOptions) SetInstructions(instructions string) CreateAssistantOptions
- func (o CreateAssistantOptions) SetMetadata(metadata map[string]string) CreateAssistantOptions
- func (o CreateAssistantOptions) SetName(name string) CreateAssistantOptions
- func (o CreateAssistantOptions) SetTools(tools []Tool) CreateAssistantOptions
- type CreateMessageOptions
- type CreateRunOptions
- type CreateThreadAndRunOptions
- func (o CreateThreadAndRunOptions) SetInstructions(instructions string) CreateThreadAndRunOptions
- func (o CreateThreadAndRunOptions) SetMetadata(metadata map[string]string) CreateThreadAndRunOptions
- func (o CreateThreadAndRunOptions) SetModel(model string) CreateThreadAndRunOptions
- func (o CreateThreadAndRunOptions) SetThread(thread RunnableThread) CreateThreadAndRunOptions
- func (o CreateThreadAndRunOptions) SetTools(tools []Tool) CreateThreadAndRunOptions
- type CreateThreadOptions
- type DeletedFile
- type Embedding
- type EmbeddingEncodingFormat
- type EmbeddingOptions
- type Embeddings
- type Error
- type File
- type FileParam
- type Files
- type FineTuningHyperparameters
- type FineTuningJob
- type FineTuningJobEvent
- type FineTuningJobEvents
- type FineTuningJobEventsOptions
- type FineTuningJobOptions
- type FineTuningJobStatus
- type FineTuningJobs
- type FineTuningJobsOptions
- type GeneratedImages
- type ImageEditOptions
- func (o ImageEditOptions) SetMask(mask FileParam) ImageEditOptions
- func (o ImageEditOptions) SetModel(model string) ImageEditOptions
- func (o ImageEditOptions) SetN(n int) ImageEditOptions
- func (o ImageEditOptions) SetResponseFormat(responseFormat ImageResponseFormat) ImageEditOptions
- func (o ImageEditOptions) SetSize(size ImageSize) ImageEditOptions
- func (o ImageEditOptions) SetUser(user string) ImageEditOptions
- type ImageOptions
- func (o ImageOptions) SetModel(model string) ImageOptions
- func (o ImageOptions) SetN(n int) ImageOptions
- func (o ImageOptions) SetQuality(quality string) ImageOptions
- func (o ImageOptions) SetResponseFormat(responseFormat ImageResponseFormat) ImageOptions
- func (o ImageOptions) SetSize(size ImageSize) ImageOptions
- func (o ImageOptions) SetStyle(style ImageStyle) ImageOptions
- func (o ImageOptions) SetUser(user string) ImageOptions
- type ImageResponseFormat
- type ImageSize
- type ImageStyle
- type ImageVariationOptions
- func (o ImageVariationOptions) SetModel(model string) ImageVariationOptions
- func (o ImageVariationOptions) SetN(n int) ImageVariationOptions
- func (o ImageVariationOptions) SetResponseFormat(responseFormat ImageResponseFormat) ImageVariationOptions
- func (o ImageVariationOptions) SetSize(size ImageSize) ImageVariationOptions
- func (o ImageVariationOptions) SetUser(user string) ImageVariationOptions
- type ListAssistantFilesOptions
- func (o ListAssistantFilesOptions) SetAfter(after string) ListAssistantFilesOptions
- func (o ListAssistantFilesOptions) SetBefore(before string) ListAssistantFilesOptions
- func (o ListAssistantFilesOptions) SetLimit(limit int) ListAssistantFilesOptions
- func (o ListAssistantFilesOptions) SetOrder(order string) ListAssistantFilesOptions
- type ListAssistantsOptions
- func (o ListAssistantsOptions) SetAfter(after string) ListAssistantsOptions
- func (o ListAssistantsOptions) SetBefore(before string) ListAssistantsOptions
- func (o ListAssistantsOptions) SetLimit(limit int) ListAssistantsOptions
- func (o ListAssistantsOptions) SetOrder(order string) ListAssistantsOptions
- type ListMessageFilesOptions
- func (o ListMessageFilesOptions) SetAfter(after string) ListMessageFilesOptions
- func (o ListMessageFilesOptions) SetBefore(before string) ListMessageFilesOptions
- func (o ListMessageFilesOptions) SetLimit(limit int) ListMessageFilesOptions
- func (o ListMessageFilesOptions) SetOrder(order string) ListMessageFilesOptions
- type ListMessagesOptions
- type ListRunStepsOptions
- type ListRunsOptions
- type Message
- type MessageContent
- type MessageContentImageFile
- type MessageContentText
- type MessageContentTextAnnotation
- type MessageContentTextAnnotationFileCitation
- type MessageContentTextAnnotationFilePath
- type MessageContentTextAnnotationType
- type MessageContentType
- type MessageFile
- type MessageFiles
- type Messages
- type Model
- type ModelDeletionStatus
- type ModelsList
- type Moderation
- type ModerationOptions
- type ModifyAssistantOptions
- func (o ModifyAssistantOptions) SetDescription(description string) ModifyAssistantOptions
- func (o ModifyAssistantOptions) SetFileIDs(fileIDs []string) ModifyAssistantOptions
- func (o ModifyAssistantOptions) SetInstructions(instructions string) ModifyAssistantOptions
- func (o ModifyAssistantOptions) SetMetadata(metadata map[string]string) ModifyAssistantOptions
- func (o ModifyAssistantOptions) SetModel(model string) ModifyAssistantOptions
- func (o ModifyAssistantOptions) SetName(name string) ModifyAssistantOptions
- func (o ModifyAssistantOptions) SetTools(tools []Tool) ModifyAssistantOptions
- type ModifyMessageOptions
- type ModifyRunOptions
- type ModifyThreadOptions
- type Permission
- type RetrievedFile
- type Run
- type RunAction
- type RunError
- type RunErrorCode
- type RunStatus
- type RunStep
- type RunStepDetails
- type RunStepDetailsMessageCreation
- type RunStepDetailsToolCall
- type RunStepDetailsToolCallCodeInterpreter
- type RunStepDetailsToolCallFunction
- type RunStepDetailsToolCallRetrieval
- type RunStepStatus
- type RunStepType
- type RunSteps
- type RunnableThread
- type RunnableThreadMessage
- type Runs
- type SpeechOptions
- type SpeechResponseFormat
- type SpeechVoice
- type Thread
- type ThreadDeletionStatus
- type ThreadMessage
- type Tool
- type ToolCall
- type ToolCallCodeInterpreterOutput
- type ToolCallCodeInterpreterOutputImage
- type ToolCallCodeInterpreterOutputType
- type ToolCallFunction
- type ToolFunction
- type ToolFunctionParameters
- func (p ToolFunctionParameters) AddArrayPropertyWithDescription(name, elemType, description string) ToolFunctionParameters
- func (p ToolFunctionParameters) AddPropertyWithDescription(name, typ3, description string) ToolFunctionParameters
- func (p ToolFunctionParameters) AddPropertyWithEnums(name, typ3, description string, enums []string) ToolFunctionParameters
- func (p ToolFunctionParameters) SetRequiredParameters(names []string) ToolFunctionParameters
- type ToolOutput
- type ToolType
- type Transcription
- type TranscriptionOptions
- func (o TranscriptionOptions) SetLanguage(language string) TranscriptionOptions
- func (o TranscriptionOptions) SetPrompt(prompt string) TranscriptionOptions
- func (o TranscriptionOptions) SetResponseFormat(responseFormat TranscriptionResponseFormat) TranscriptionOptions
- func (o TranscriptionOptions) SetTemperature(temperature float64) TranscriptionOptions
- type TranscriptionResponseFormat
- type Translation
- type TranslationOptions
- type TranslationResponseFormat
- type UploadedFile
- type Usage
Constants ¶
Variables ¶
var ( StreamData = []byte("data: ") StreamDone = []byte("[DONE]") )
Functions ¶
This section is empty.
Types ¶
type Assistant ¶
type Assistant struct { CommonResponse ID string `json:"id"` CreatedAt int `json:"created_at"` Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` Model string `json:"model"` Instructions *string `json:"instructions,omitempty"` Tools []Tool `json:"tools"` FileIDs []string `json:"file_ids"` Metadata map[string]string `json:"metadata"` }
Assistant struct for assistant object
https://platform.openai.com/docs/api-reference/assistants/object
type AssistantDeletionStatus ¶
type AssistantDeletionStatus struct { CommonResponse ID string `json:"id"` Deleted bool `json:"deleted"` }
AssistantDeletionStatus struct for API response
type AssistantFile ¶
type AssistantFile struct { CommonResponse ID string `json:"id"` CreatedAt int `json:"created_at"` AssistantID string `json:"assistant_id"` }
AssistantFile struct for attached files of assistants
https://platform.openai.com/docs/api-reference/assistants/file-object
type AssistantFileDeletionStatus ¶
type AssistantFileDeletionStatus struct { CommonResponse ID string `json:"id"` Deleted bool `json:"deleted"` }
AssistantFileDeletionStatus struct for API response
type AssistantFiles ¶
type AssistantFiles struct { CommonResponse Data []AssistantFile `json:"data"` FirstID string `json:"first_id"` LastID string `json:"last_id"` HasMore bool `json:"has_more"` }
AssistantFiless struct for API response
type Assistants ¶
type Assistants struct { CommonResponse Data []Assistant `json:"data"` FirstID string `json:"first_id"` LastID string `json:"last_id"` HasMore bool `json:"has_more"` }
Assistants struct for API response
type ChatCompletion ¶
type ChatCompletion struct { CommonResponse ID string `json:"id"` Created int64 `json:"created"` Choices []ChatCompletionChoice `json:"choices"` Usage Usage `json:"usage"` }
ChatCompletion struct for chat completion response
type ChatCompletionChoice ¶
type ChatCompletionChoice struct { Index int `json:"index"` Message ChatMessage `json:"message"` FinishReason string `json:"finish_reason"` Delta ChatMessage `json:"delta"` // Only appears in stream response }
ChatCompletionChoice struct for chat completion response
type ChatCompletionOptions ¶
ChatCompletionOptions for creating chat completions
func (ChatCompletionOptions) SetFrequencyPenalty ¶
func (o ChatCompletionOptions) SetFrequencyPenalty(frequencyPenalty float64) ChatCompletionOptions
SetFrequencyPenalty sets the `frequency_penalty` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-frequency_penalty
func (ChatCompletionOptions) SetLogitBias ¶
func (o ChatCompletionOptions) SetLogitBias(logitBias map[string]any) ChatCompletionOptions
SetLogitBias sets the `logit_bias` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-logit_bias
func (ChatCompletionOptions) SetMaxTokens ¶
func (o ChatCompletionOptions) SetMaxTokens(maxTokens int) ChatCompletionOptions
SetMaxTokens sets the `max_tokens` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-max_tokens
func (ChatCompletionOptions) SetN ¶
func (o ChatCompletionOptions) SetN(n int) ChatCompletionOptions
SetN sets the `n` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-n
func (ChatCompletionOptions) SetPresencePenalty ¶
func (o ChatCompletionOptions) SetPresencePenalty(presencePenalty float64) ChatCompletionOptions
SetPresencePenalty sets the `presence_penalty` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-presence_penalty
func (ChatCompletionOptions) SetResponseFormat ¶
func (o ChatCompletionOptions) SetResponseFormat(format ChatCompletionResponseFormat) ChatCompletionOptions
SetResponseFormat sets the `response_format` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format
func (ChatCompletionOptions) SetSeed ¶
func (o ChatCompletionOptions) SetSeed(seed int64) ChatCompletionOptions
SetSeed sets the `seed` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat-create-seed
func (ChatCompletionOptions) SetStop ¶
func (o ChatCompletionOptions) SetStop(stop any) ChatCompletionOptions
SetStop sets the `stop` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-stop
func (ChatCompletionOptions) SetStream ¶
func (o ChatCompletionOptions) SetStream(cb callback) ChatCompletionOptions
SetStream sets the `stream` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-stream
func (ChatCompletionOptions) SetTemperature ¶
func (o ChatCompletionOptions) SetTemperature(temperature float64) ChatCompletionOptions
SetTemperature sets the `temperature` parameter of chat completion request.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature
func (ChatCompletionOptions) SetToolChoice ¶
func (o ChatCompletionOptions) SetToolChoice(choice ChatCompletionToolChoiceMode) ChatCompletionOptions
SetToolChoice sets the `tool_choice` parameter of chat completion request.
https://platform.openai.com/docs/api-reference/chat/create#chat-create-tool_choice
func (ChatCompletionOptions) SetToolChoiceWithName ¶
func (o ChatCompletionOptions) SetToolChoiceWithName(name string) ChatCompletionOptions
SetToolChoiceWithName sets the `tool_choice` parameter of chat completion request with given function name.
https://platform.openai.com/docs/api-reference/chat/create#chat-create-tool_choice
func (ChatCompletionOptions) SetTools ¶
func (o ChatCompletionOptions) SetTools(tools []ChatCompletionTool) ChatCompletionOptions
SetTools sets the `tools` parameter of chat completion request.
https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools
func (ChatCompletionOptions) SetTopP ¶
func (o ChatCompletionOptions) SetTopP(topP float64) ChatCompletionOptions
SetTopP sets the `top_p` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-top_p
func (ChatCompletionOptions) SetUser ¶
func (o ChatCompletionOptions) SetUser(user string) ChatCompletionOptions
SetUser sets the `user` parameter of chat completions.
https://platform.openai.com/docs/api-reference/chat/create#chat/create-user
type ChatCompletionResponseFormat ¶
type ChatCompletionResponseFormat struct {
Type ChatCompletionResponseFormatType `json:"type,omitempty"`
}
ChatCompletionResponseFormat struct for chat completion request
type ChatCompletionResponseFormatType ¶
type ChatCompletionResponseFormatType string
ChatCompletionResponseFormatType type for constants
const ( ChatCompletionResponseFormatTypeText ChatCompletionResponseFormatType = "text" ChatCompletionResponseFormatTypeJSONObject ChatCompletionResponseFormatType = "json_object" )
ChatCompletionResponseFormatType constants
type ChatCompletionTool ¶
type ChatCompletionTool struct { Type string `json:"type"` // == 'function' Function ChatCompletionToolFunction `json:"function"` }
ChatCompletionTool struct for chat completion function
https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools
func NewChatCompletionTool ¶
func NewChatCompletionTool(name, description string, parameters ToolFunctionParameters) ChatCompletionTool
NewChatCompletionTool returns a ChatCompletionTool.
type ChatCompletionToolChoiceMode ¶
type ChatCompletionToolChoiceMode string
ChatCompletionToolChoiceMode type
https://platform.openai.com/docs/api-reference/chat/create#chat-create-tool_choice
const ( ChatCompletionToolChoiceNone ChatCompletionToolChoiceMode = "none" ChatCompletionToolChoiceAuto ChatCompletionToolChoiceMode = "auto" )
ChatCompletionToolChoiceMode constants
type ChatCompletionToolFunction ¶
type ChatCompletionToolFunction struct { Name string `json:"name"` Description *string `json:"description,omitempty"` Parameters ToolFunctionParameters `json:"parameters"` }
ChatCompletionToolFunction struct
type ChatMessage ¶
type ChatMessage struct { Role ChatMessageRole `json:"role"` Content any `json:"content,omitempty"` // NOTE: string | []ChatMessageContent // for function call ToolCalls []ToolCall `json:"tool_calls,omitempty"` // when role == 'assistant' ToolCallID *string `json:"tool_call_id,omitempty"` // when role == 'tool' }
ChatMessage struct for chat completion
https://platform.openai.com/docs/guides/chat/introduction
func NewChatAssistantMessage ¶
func NewChatAssistantMessage(message string) ChatMessage
NewChatAssistantMessage returns a new ChatMessage with assistant role.
func NewChatSystemMessage ¶
func NewChatSystemMessage(message string) ChatMessage
NewChatSystemMessage returns a new ChatMessage with system role.
func NewChatToolMessage ¶
func NewChatToolMessage(toolCallID, content string) ChatMessage
NewChatToolMessage returns a new ChatMesssage with tool role.
func NewChatUserMessage ¶
func NewChatUserMessage[T ChatUserMessageContentTypes](contents T) ChatMessage
NewChatUserMessage returns a new ChatMessage with user role.
func (ChatMessage) ContentArray ¶
func (m ChatMessage) ContentArray() ([]ChatMessageContent, error)
ContentArray tries to return the `content` value as a content array.
func (ChatMessage) ContentString ¶
func (m ChatMessage) ContentString() (string, error)
ContentString tries to return the `content` value as a string.
type ChatMessageContent ¶
type ChatMessageContent struct { Type string `json:"type"` Text *string `json:"text,omitempty"` ImageURL any `json:"image_url,omitempty"` }
ChatMessageContent struct
func NewChatMessageContentWithBytes ¶
func NewChatMessageContentWithBytes(bytes []byte) ChatMessageContent
NewChatMessageContentWithBytes returns a ChatMessageContent struct with given `bytes`.
func NewChatMessageContentWithFileParam ¶
func NewChatMessageContentWithFileParam(file FileParam) ChatMessageContent
NewChatMessageContentWithFileParam returns a ChatMessageContent struct with given `file`.
func NewChatMessageContentWithImageURL ¶
func NewChatMessageContentWithImageURL(url string) ChatMessageContent
NewChatMessageContentWithImageURL returns a ChatMessageContent struct with given `url`.
func NewChatMessageContentWithText ¶
func NewChatMessageContentWithText(text string) ChatMessageContent
NewChatMessageContentWithText returns a ChatMessageContent struct with given `text`.
type ChatMessageRole ¶
type ChatMessageRole string
ChatMessageRole type for constants
const ( ChatMessageRoleSystem ChatMessageRole = "system" ChatMessageRoleUser ChatMessageRole = "user" ChatMessageRoleAssistant ChatMessageRole = "assistant" ChatMessageRoleTool ChatMessageRole = "tool" )
type ChatUserMessageContentTypes ¶
type ChatUserMessageContentTypes interface { string | []ChatMessageContent }
ChatUserMessageContentTypes interface for type constraints in `NewChatUserMessage`
type Classification ¶
type Classification struct { Categories map[string]bool `json:"categories"` CategoryScores map[string]float64 `json:"category_scores"` Flagged bool `json:"flagged"` }
Classification struct for Moderation strcut
type Client ¶
type Client struct { APIKey string `json:"api_key"` OrganizationID string `json:"organization_id"` Verbose bool // contains filtered or unexported fields }
Client struct which holds its API key, Organization ID, and HTTP client.
func (*Client) CancelFineTuningJob ¶
func (c *Client) CancelFineTuningJob(fineTuningJobID string) (response FineTuningJob, err error)
CancelFineTuningJob cancels a fine-tuning job.
https://platform.openai.com/docs/api-reference/fine-tuning/cancel
func (*Client) CancelRun ¶
CancelRun cancels a run with given `threadID` and `runID`.
This can be called when
run.Status == RunStatusInProgress.
https://platform.openai.com/docs/api-reference/runs/cancelRun
func (*Client) CreateAssistant ¶
func (c *Client) CreateAssistant(model string, options CreateAssistantOptions) (response Assistant, err error)
CreateAssistant creates an assitant with given `model` and `options`.
https://platform.openai.com/docs/api-reference/assistants/createAssistant
func (*Client) CreateAssistantFile ¶
func (c *Client) CreateAssistantFile(assistantID, fileID string) (response AssistantFile, err error)
CreateAssistantFile creates an assistant file by attaching given `fileID` to an assistant with `assistantID`.
https://platform.openai.com/docs/api-reference/assistants/createAssistantFile
func (*Client) CreateChatCompletion ¶
func (c *Client) CreateChatCompletion(model string, messages []ChatMessage, options ChatCompletionOptions) (response ChatCompletion, err error)
CreateChatCompletion creates a completion for chat messages.
func (*Client) CreateCompletion ¶
func (c *Client) CreateCompletion(model string, options CompletionOptions) (response Completion, err error)
CreateCompletion creates a completion.
https://platform.openai.com/docs/api-reference/completions/create
func (*Client) CreateEmbedding ¶
func (c *Client) CreateEmbedding(model string, input any, options EmbeddingOptions) (response Embeddings, err error)
CreateEmbedding creates an embedding with given input.
https://platform.openai.com/docs/api-reference/embeddings/create
func (*Client) CreateFineTuningJob ¶
func (c *Client) CreateFineTuningJob(trainingFileID, model string, options FineTuningJobOptions) (response FineTuningJob, err error)
CreateFineTuningJob creates a job that fine-tunes a specified model from given data
https://platform.openai.com/docs/api-reference/fine-tuning/create
func (*Client) CreateImage ¶
func (c *Client) CreateImage(prompt string, options ImageOptions) (response GeneratedImages, err error)
CreateImage creates an image with given prompt.
https://platform.openai.com/docs/api-reference/images/create
func (*Client) CreateImageEdit ¶
func (c *Client) CreateImageEdit(image FileParam, prompt string, options ImageEditOptions) (response GeneratedImages, err error)
CreateImageEdit creates an edited or extended image with given file and prompt.
https://platform.openai.com/docs/api-reference/images/create-edit
func (*Client) CreateImageVariation ¶
func (c *Client) CreateImageVariation(image FileParam, options ImageVariationOptions) (response GeneratedImages, err error)
CreateImageVariation creates a variation of a given image.
https://platform.openai.com/docs/api-reference/images/create-variation
func (*Client) CreateMessage ¶
func (c *Client) CreateMessage(threadID, role, content string, options CreateMessageOptions) (response Message, err error)
CreateMessage creates a message with given `threadID`, `role`, `content`, and `options`.
https://platform.openai.com/docs/api-reference/messages/createMessage
func (*Client) CreateModeration ¶
func (c *Client) CreateModeration(input any, options ModerationOptions) (response Moderation, err error)
CreateModeration classifies given text.
https://platform.openai.com/docs/api-reference/moderations/create
func (*Client) CreateRun ¶
func (c *Client) CreateRun(threadID, assistantID string, options CreateRunOptions) (response Run, err error)
CreateRun creates a run with given `threadID`, `assistantID`, and `options`.
https://platform.openai.com/docs/api-reference/runs/createRun
func (*Client) CreateSpeech ¶
func (c *Client) CreateSpeech(model string, input string, voice SpeechVoice, options SpeechOptions) (audio []byte, err error)
CreateSpeech generates audio from the input text.
https://platform.openai.com/docs/api-reference/audio/createSpeech
func (*Client) CreateThread ¶
func (c *Client) CreateThread(options CreateThreadOptions) (response Thread, err error)
CreateThread creates a thread with given `options`.
https://platform.openai.com/docs/api-reference/threads/createThread
func (*Client) CreateThreadAndRun ¶
func (c *Client) CreateThreadAndRun(assistantID string, options CreateThreadAndRunOptions) (response Run, err error)
CreateThreadAndRun creates a thread and runs it with given `assistantID` and `options`.
https://platform.openai.com/docs/api-reference/runs/createThreadAndRun
func (*Client) CreateTranscription ¶
func (c *Client) CreateTranscription(file FileParam, model string, options TranscriptionOptions) (response Transcription, err error)
CreateTranscription transcribes given audio file into the input language.
func (*Client) CreateTranslation ¶
func (c *Client) CreateTranslation(file FileParam, model string, options TranslationOptions) (response Translation, err error)
CreateTranslation translates given audio file into English.
func (*Client) DeleteAssistant ¶
func (c *Client) DeleteAssistant(assistantID string) (response AssistantDeletionStatus, err error)
DeleteAssistant deletes an assistant with given `assistantID`.
https://platform.openai.com/docs/api-reference/assistants/deleteAssistant
func (*Client) DeleteAssistantFile ¶
func (c *Client) DeleteAssistantFile(assistantID, fileID string) (response AssistantFileDeletionStatus, err error)
DeleteAssistantFile deletes an assistant file by given `assistantID` and `fileID`.
https://platform.openai.com/docs/api-reference/assistants/deleteAssistantFile
func (*Client) DeleteFile ¶
func (c *Client) DeleteFile(fileID string) (response DeletedFile, err error)
DeleteFile deletes given file.
func (*Client) DeleteFineTuneModel ¶
func (c *Client) DeleteFineTuneModel(model string) (response ModelDeletionStatus, err error)
DeleteFineTuneModel deletes a fine-tuned model.
https://platform.openai.com/docs/api-reference/models/delete
func (*Client) DeleteThread ¶
func (c *Client) DeleteThread(threadID string) (response ThreadDeletionStatus, err error)
DeleteThread deletes a thread with given `threadID`.
https://platform.openai.com/docs/api-reference/threads/deleteThread
func (*Client) ListAssistantFiles ¶
func (c *Client) ListAssistantFiles(assistantID string, options ListAssistantFilesOptions) (response AssistantFiles, err error)
ListAssistantFiles lists all assistant files with given `assistantID` and `options`.
https://platform.openai.com/docs/api-reference/assistants/listAssistantFiles
func (*Client) ListAssistants ¶
func (c *Client) ListAssistants(options ListAssistantsOptions) (response Assistants, err error)
ListAssistants lists all assistants with given `options`.
https://platform.openai.com/docs/api-reference/assistants/getAssistants
func (*Client) ListFiles ¶
ListFiles returns a list of files that belong to the requested organization id.
func (*Client) ListFineTuningJobEvents ¶
func (c *Client) ListFineTuningJobEvents(fineTuningJobID string, options FineTuningJobEventsOptions) (response FineTuningJobEvents, err error)
ListFineTuningJobEvents lists status updates for a given fine-tuning job.
https://platform.openai.com/docs/api-reference/fine-tuning/list-events
func (*Client) ListFineTuningJobs ¶
func (c *Client) ListFineTuningJobs(options FineTuningJobsOptions) (response FineTuningJobs, err error)
ListFineTuningJobs lists your organization's fine-tuning jobs.
https://platform.openai.com/docs/api-reference/fine-tuning/list
func (*Client) ListMessageFiles ¶
func (c *Client) ListMessageFiles(threadID, messageID string, options ListMessageFilesOptions) (response MessageFiles, err error)
ListMessageFiles fetches message files with given `threadID`, `mesageID`, and `options`.
https://platform.openai.com/docs/api-reference/messages/listMessageFiles
func (*Client) ListMessages ¶
func (c *Client) ListMessages(threadID string, options ListMessagesOptions) (response Messages, err error)
ListMessages fetches messages with given `threadID`, and `options`.
https://platform.openai.com/docs/api-reference/messages/listMessages
func (*Client) ListModels ¶
func (c *Client) ListModels() (response ModelsList, err error)
ListModels lists currently available models.
func (*Client) ListRunSteps ¶
func (c *Client) ListRunSteps(threadID, runID string, options ListRunStepsOptions) (response RunSteps, err error)
ListRunSteps fetches run steps with given `threadID`, `runID` and `options`.
https://platform.openai.com/docs/api-reference/runs/listRunSteps
func (*Client) ListRuns ¶
func (c *Client) ListRuns(threadID string, options ListRunsOptions) (response Runs, err error)
ListRuns fetches runs with given `threadID` and `options`.
https://platform.openai.com/docs/api-reference/runs/listRuns
func (*Client) ModifyAssistant ¶
func (c *Client) ModifyAssistant(assistantID string, options ModifyAssistantOptions) (response Assistant, err error)
ModifyAssistant modifies an assistant with given `assistantID` and `options`.
https://platform.openai.com/docs/api-reference/assistants/modifyAssistant
func (*Client) ModifyMessage ¶
func (c *Client) ModifyMessage(threadID, messageID string, options ModifyMessageOptions) (response Message, err error)
ModifyMessage modifies a message with given `threadID`, `messageID`, and `options`.
https://platform.openai.com/docs/api-reference/messages/modifyMessage
func (*Client) ModifyRun ¶
func (c *Client) ModifyRun(threadID, runID string, options ModifyRunOptions) (response Run, err error)
ModifyRun modifies a run with given `threadID`, `runID`, and `options`.
https://platform.openai.com/docs/api-reference/runs/modifyRun
func (*Client) ModifyThread ¶
func (c *Client) ModifyThread(threadID string, options ModifyThreadOptions) (response Thread, err error)
ModifyThread modifies a thread with given `threadID` and `options`.
https://platform.openai.com/docs/api-reference/threads/modifyThread
func (*Client) RetrieveAssistant ¶
RetrieveAssistant retrieves an assistant with given `assistantID`.
https://platform.openai.com/docs/api-reference/assistants/getAssistant
func (*Client) RetrieveAssistantFile ¶
func (c *Client) RetrieveAssistantFile(assistantID, fileID string) (response AssistantFile, err error)
RetrieveAssistantFile retrieves an assistant file by given `assistantID` and `fileID`.
https://platform.openai.com/docs/api-reference/assistants/getAssistantFile
func (*Client) RetrieveFile ¶
func (c *Client) RetrieveFile(fileID string) (response RetrievedFile, err error)
RetrieveFile returns the information of given file.
https://platform.openai.com/docs/api-reference/files/retrieve
func (*Client) RetrieveFileContent ¶
RetrieveFileContent returns the content of given file.
https://platform.openai.com/docs/api-reference/files/retrieve-content
func (*Client) RetrieveFineTuningJob ¶
func (c *Client) RetrieveFineTuningJob(fineTuningJobID string) (response FineTuningJob, err error)
RetrieveFineTuningJob retrieves a fine-tuning job.
https://platform.openai.com/docs/api-reference/fine-tuning/retrieve
func (*Client) RetrieveMessage ¶
RetrieveMessage retrieves a message with given `threadID` and `messageID`.
https://platform.openai.com/docs/api-reference/messages/getMessage
func (*Client) RetrieveMessageFile ¶
func (c *Client) RetrieveMessageFile(threadID, messageID, fileID string) (response MessageFile, err error)
RetrieveMessageFile retrieves a message file with given `threadID`, `messageID`, and `fileID`.
https://platform.openai.com/docs/api-reference/messages/getMessageFile
func (*Client) RetrieveModel ¶
RetrieveModel retrieves a model instance.
https://platform.openai.com/docs/api-reference/models/retrieve
func (*Client) RetrieveRun ¶
RetrieveRun retrieves a run with given `threadID` and `runID`.
func (*Client) RetrieveRunStep ¶
RetrieveRunStep retrieves a run step with given `threadID`, `runID` and `stepID`.
https://platform.openai.com/docs/api-reference/runs/getRunStep
func (*Client) RetrieveThread ¶
RetrieveThread retrieves the thread with given `threadID`.
https://platform.openai.com/docs/api-reference/threads/getThread
func (*Client) SetBaseURL ¶ added in v0.4.7
func (*Client) SetBetaHeader ¶
SetBetaHeader sets the beta HTTP header for beta features.
func (*Client) SubmitToolOutputs ¶
func (c *Client) SubmitToolOutputs(threadID, runID string, toolOutputs []ToolOutput) (response Run, err error)
SubmitToolOutputs submits tool outputs with given `threadID` and `runID`.
This can be called when
run.Status == RunStatusRequiresAction && run.RequiredAction.Type == "submit_tool_outputs".
https://platform.openai.com/docs/api-reference/runs/submitToolOutputs
func (*Client) UploadFile ¶
func (c *Client) UploadFile(file FileParam, purpose string) (response UploadedFile, err error)
UploadFile uploads given file.
type CommonResponse ¶
type CommonResponse struct { Object *string `json:"object,omitempty"` Error *Error `json:"error,omitempty"` }
CommonResponse struct for responses with common properties
type Completion ¶
type Completion struct { CommonResponse ID string `json:"id"` Created int64 `json:"created"` Model string `json:"model"` Choices []CompletionChoice `json:"choices"` Usage Usage `json:"usage"` }
Completion struct for response
type CompletionChoice ¶
type CompletionChoice struct { Text string `json:"text"` Index int `json:"index"` Logprobs *int `json:"logprobs,omitempty"` FinishReason string `json:"finish_reason"` }
CompletionChoice struct for completion response
type CompletionOptions ¶
CompletionOptions for creating completions
func (CompletionOptions) SetBestOf ¶
func (o CompletionOptions) SetBestOf(bestOf int) CompletionOptions
SetBestOf sets the `best_of` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-best_of
func (CompletionOptions) SetEcho ¶
func (o CompletionOptions) SetEcho(echo bool) CompletionOptions
SetEcho sets the `echo` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-echo
func (CompletionOptions) SetFrequencyPenalty ¶
func (o CompletionOptions) SetFrequencyPenalty(frequencyPenalty float64) CompletionOptions
SetFrequencyPenalty sets the `frequency_penalty` parameter of completion request.
func (CompletionOptions) SetLogProbabilities ¶
func (o CompletionOptions) SetLogProbabilities(logprobs int) CompletionOptions
SetLogProbabilities sets the `logprobs` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-logprobs
func (CompletionOptions) SetLogitBias ¶
func (o CompletionOptions) SetLogitBias(logitBias map[string]any) CompletionOptions
SetLogitBias sets the `logit_bias` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-logit_bias
func (CompletionOptions) SetMaxTokens ¶
func (o CompletionOptions) SetMaxTokens(maxTokens int) CompletionOptions
SetMaxTokens sets the `max_tokens` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-max_tokens
func (CompletionOptions) SetN ¶
func (o CompletionOptions) SetN(n int) CompletionOptions
SetN sets the `n` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-n
func (CompletionOptions) SetPresencePenalty ¶
func (o CompletionOptions) SetPresencePenalty(presencePenalty float64) CompletionOptions
SetPresencePenalty sets the `presence_penalty` parameter of completion request.
func (CompletionOptions) SetPrompt ¶
func (o CompletionOptions) SetPrompt(prompt any) CompletionOptions
SetPrompt sets the `prompt` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-prompt
func (CompletionOptions) SetStop ¶
func (o CompletionOptions) SetStop(stop any) CompletionOptions
SetStop sets the `stop` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-stop
func (CompletionOptions) SetStream ¶
func (o CompletionOptions) SetStream(stream bool) CompletionOptions
SetStream sets the `stream` parameter of completion request.
NOTE: (not implemented) https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format
https://platform.openai.com/docs/api-reference/completions/create#completions/create-stream
func (CompletionOptions) SetSuffix ¶
func (o CompletionOptions) SetSuffix(suffix string) CompletionOptions
SetSuffix sets the `suffix` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-suffix
func (CompletionOptions) SetTemperature ¶
func (o CompletionOptions) SetTemperature(temperature float64) CompletionOptions
SetTemperature sets the `temperature` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-temperature
func (CompletionOptions) SetTopP ¶
func (o CompletionOptions) SetTopP(topP float64) CompletionOptions
SetTopP sets the `top_p` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-top_p
func (CompletionOptions) SetUser ¶
func (o CompletionOptions) SetUser(user string) CompletionOptions
SetUser sets the `user` parameter of completion request.
https://platform.openai.com/docs/api-reference/completions/create#completions/create-user
type CreateAssistantOptions ¶
CreateAssistantOptions for creating assistant
func (CreateAssistantOptions) SetDescription ¶
func (o CreateAssistantOptions) SetDescription(description string) CreateAssistantOptions
SetDescription sets the `description` parameter of assistant creation.
func (CreateAssistantOptions) SetFileIDs ¶
func (o CreateAssistantOptions) SetFileIDs(fileIDs []string) CreateAssistantOptions
SetFileIDs sets the `file_ids` parameter of assistant creation.
func (CreateAssistantOptions) SetInstructions ¶
func (o CreateAssistantOptions) SetInstructions(instructions string) CreateAssistantOptions
SetInstructions sets the `instructions` parameter of assistant creation.
func (CreateAssistantOptions) SetMetadata ¶
func (o CreateAssistantOptions) SetMetadata(metadata map[string]string) CreateAssistantOptions
SetMetadata sets the `metadata` parameter of assistant creation.
func (CreateAssistantOptions) SetName ¶
func (o CreateAssistantOptions) SetName(name string) CreateAssistantOptions
SetName sets the `name` parameter of assistant creation.
func (CreateAssistantOptions) SetTools ¶
func (o CreateAssistantOptions) SetTools(tools []Tool) CreateAssistantOptions
SetTools sets the `tools` parameter of assistant creation.
type CreateMessageOptions ¶
CreateMessageOptions for creating message
func (CreateMessageOptions) SetFileIDs ¶
func (o CreateMessageOptions) SetFileIDs(fileIDs []string) CreateMessageOptions
SetFileIDs sets the `file_ids` parameter of CreateMessageOptions.
func (CreateMessageOptions) SetMetadata ¶
func (o CreateMessageOptions) SetMetadata(metadata map[string]string) CreateMessageOptions
SetMetadata sets the `metadata` parameter of CreateMessageOptions.
type CreateRunOptions ¶
CreateRunOptions for creating run
func (CreateRunOptions) SetInstructions ¶
func (o CreateRunOptions) SetInstructions(instructions string) CreateRunOptions
SetInstructions sets the `instructions` parameter of CreateRunOptions.
https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-instructions
func (CreateRunOptions) SetMetadata ¶
func (o CreateRunOptions) SetMetadata(metadata map[string]string) CreateRunOptions
SetMetadata sets the `metadata` parameter of CreateRunOptions.
https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-metadata
func (CreateRunOptions) SetModel ¶
func (o CreateRunOptions) SetModel(model string) CreateRunOptions
SetModel sets the `model` parameter of CreateRunOptions.
https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-model
func (CreateRunOptions) SetTools ¶
func (o CreateRunOptions) SetTools(tools []Tool) CreateRunOptions
SetTools sets the `tools` parameter of CreateRunOptions.
https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-tools
type CreateThreadAndRunOptions ¶
CreateThreadAndRunOptions for creating thread and running it
func (CreateThreadAndRunOptions) SetInstructions ¶
func (o CreateThreadAndRunOptions) SetInstructions(instructions string) CreateThreadAndRunOptions
SetInstructions sets the `instructions` parameter of CreateThreadAndRunOptions.
func (CreateThreadAndRunOptions) SetMetadata ¶
func (o CreateThreadAndRunOptions) SetMetadata(metadata map[string]string) CreateThreadAndRunOptions
SetMetadata sets the `metadata` parameter of CreateThreadAndRunOptions.
func (CreateThreadAndRunOptions) SetModel ¶
func (o CreateThreadAndRunOptions) SetModel(model string) CreateThreadAndRunOptions
SetModel sets the `model` parameter of CreateThreadAndRunOptions.
https://platform.openai.com/docs/api-reference/runs/createThreadAndRun#runs-createthreadandrun-model
func (CreateThreadAndRunOptions) SetThread ¶
func (o CreateThreadAndRunOptions) SetThread(thread RunnableThread) CreateThreadAndRunOptions
SetThread sets the `thread` parameter of CreateThreadAndRunOptions.
func (CreateThreadAndRunOptions) SetTools ¶
func (o CreateThreadAndRunOptions) SetTools(tools []Tool) CreateThreadAndRunOptions
SetTools sets the `tools` parameter of CreateThreadAndRunOptions.
https://platform.openai.com/docs/api-reference/runs/createThreadAndRun#runs-createthreadandrun-tools
type CreateThreadOptions ¶
CreateThreadOptions for creating thread
func (CreateThreadOptions) SetMessages ¶
func (o CreateThreadOptions) SetMessages(messages []ThreadMessage) CreateThreadOptions
SetMessages sets the `messages` parameter of CreateThreadOptions.
https://platform.openai.com/docs/api-reference/threads/createThread#threads-createthread-messages
func (CreateThreadOptions) SetMetadata ¶
func (o CreateThreadOptions) SetMetadata(metadata map[string]string) CreateThreadOptions
SetMetadata sets the `metadata` parameter of CreateThreadOptions.
https://platform.openai.com/docs/api-reference/threads/createThread#threads-createthread-metadata
type DeletedFile ¶
type DeletedFile struct { CommonResponse ID string `json:"id"` Deleted bool `json:"deleted"` }
DeletedFile struct for response
type Embedding ¶
type Embedding struct { Object string `json:"object"` Embedding []float64 `json:"embedding"` Index int `json:"index"` }
Embedding struct for Embeddings struct
type EmbeddingEncodingFormat ¶
type EmbeddingEncodingFormat string
EmbeddingEncodingFormat type for constants
const ( EmbeddingEncodingFormatFloat EmbeddingEncodingFormat = "float" EmbeddingEncodingFormatBase64 EmbeddingEncodingFormat = "base64" )
type EmbeddingOptions ¶
EmbeddingOptions for creating embedding
func (EmbeddingOptions) SetEncodingFormat ¶
func (o EmbeddingOptions) SetEncodingFormat(format EmbeddingEncodingFormat) EmbeddingOptions
SetEncodingFormat sets the `encoding_format` parameter of create embedding request.
https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-encoding_format
func (EmbeddingOptions) SetUser ¶
func (o EmbeddingOptions) SetUser(user string) EmbeddingOptions
SetUser sets the `user` parameter of create embedding request.
https://platform.openai.com/docs/api-reference/embeddings/create#embeddings/create-user
type Embeddings ¶
type Embeddings struct { CommonResponse Data []Embedding `json:"data"` Model string `json:"model"` Usage struct { PromptTokens int `json:"prompt_tokens"` TotalTokens int `json:"total_tokens"` } `json:"usage"` }
Embeddings struct for response
type Error ¶
type Error struct { Message string `json:"message"` Type string `json:"type"` Param any `json:"param,omitempty"` Code *string `json:"code,omitempty"` }
Error struct for response error property
type File ¶
type File struct { CommonResponse ID string `json:"id"` Bytes int `json:"bytes"` CreatedAt int64 `json:"created_at"` Filename string `json:"filename"` Purpose string `json:"purpose"` }
File struct for file items
type FileParam ¶
type FileParam struct {
// contains filtered or unexported fields
}
FileParam struct for multipart requests
func NewFileParamFromBytes ¶
NewFileParamFromBytes returns a new FileParam with given bytes
func NewFileParamFromFilepath ¶
NewFileParamFromFilepath returns a new FileParam with bytes read from given filepath
type Files ¶
type Files struct { CommonResponse Data []File `json:"data"` }
Files struct for response
type FineTuningHyperparameters ¶
type FineTuningHyperparameters struct {
NEpochs any `json:"n_epochs"` // string("Auto") or int
}
FineTuningHyperparameters struct
type FineTuningJob ¶
type FineTuningJob struct { CommonResponse ID string `json:"id"` CreatedAt int64 `json:"created_at"` FinishedAt int64 `json:"finished_at"` Model string `json:"model"` FineTunedModel *string `json:"fine_tuned_model,omitempty"` OrganizationID string `json:"organization_id"` Status FineTuningJobStatus `json:"status"` Hyperparameters FineTuningHyperparameters `json:"hyperparameters"` TrainingFile string `json:"training_file"` ValidationFile *string `json:"validation_file,omitempty"` ResultFiles []string `json:"result_files"` TrainedTokens int `json:"trained_tokens"` }
FineTuningJob struct
type FineTuningJobEvent ¶
type FineTuningJobEvent struct { CommonResponse ID string `json:"id"` CreatedAt int `json:"created_at"` Level string `json:"level"` Message string `json:"message"` Data any `json:"data,omitempty"` Type string `json:"type"` }
FineTuningJobEvent struct
type FineTuningJobEvents ¶
type FineTuningJobEvents struct { CommonResponse Data []FineTuningJobEvent `json:"data"` HasMore bool `json:"has_more"` }
FineTuningJobEvents struct
type FineTuningJobEventsOptions ¶
FineTuningJobEventsOptions for listing fine-tuning job events
func (FineTuningJobEventsOptions) SetAfter ¶
func (o FineTuningJobEventsOptions) SetAfter(fineTuningJobEventID string) FineTuningJobEventsOptions
SetAfter sets the `after` parameter of fine-tuning events request.
https://platform.openai.com/docs/api-reference/fine-tuning/list-events#after
func (FineTuningJobEventsOptions) SetLimit ¶
func (o FineTuningJobEventsOptions) SetLimit(limit int) FineTuningJobEventsOptions
SetLimit sets the `limit` parameter of fine-tuning events request.
https://platform.openai.com/docs/api-reference/fine-tuning/list-events#limit
type FineTuningJobOptions ¶
FineTuningJobOptions for retrieving fine-tuning jobs
func (FineTuningJobOptions) SetHyperparameters ¶
func (o FineTuningJobOptions) SetHyperparameters(hyperparameters FineTuningHyperparameters) FineTuningJobOptions
SetHyperparameters sets the `hyperparameters` parameter of fine-tuning job request.
https://platform.openai.com/docs/api-reference/fine-tuning/create#model
func (FineTuningJobOptions) SetSuffix ¶
func (o FineTuningJobOptions) SetSuffix(suffix string) FineTuningJobOptions
SetSuffix sets the `suffix` parameter of fine-tuning job request.
https://platform.openai.com/docs/api-reference/fine-tuning/create#suffix
func (FineTuningJobOptions) SetValidationFile ¶
func (o FineTuningJobOptions) SetValidationFile(validationFileID string) FineTuningJobOptions
SetValidationFile sets the `validation_file` parameter of fine-tuning job request.
https://platform.openai.com/docs/api-reference/fine-tuning/create#validation_file
type FineTuningJobStatus ¶
type FineTuningJobStatus string
FineTuningJobStatus type
const ( FineTuningJobStatusCreated FineTuningJobStatus = "created" FineTuningJobStatusPending FineTuningJobStatus = "pending" FineTuningJobStatusRunning FineTuningJobStatus = "running" FineTuningJobStatusSucceeded FineTuningJobStatus = "succeeded" FineTuningJobStatusFailed FineTuningJobStatus = "failed" FineTuningJobStatusCancelled FineTuningJobStatus = "cancelled" )
FineTuningJobStatus constants
type FineTuningJobs ¶
type FineTuningJobs struct { CommonResponse Data []FineTuningJob `json:"data"` HasMore bool `json:"has_more"` }
FineTuningJobs struct
type FineTuningJobsOptions ¶
FineTuningJobsOptions for listing fine-tuning jobs
func (FineTuningJobsOptions) SetAfter ¶
func (o FineTuningJobsOptions) SetAfter(after string) FineTuningJobsOptions
SetAfter sets the `after` parameter of fine-tuning jobs listing request.
https://platform.openai.com/docs/api-reference/fine-tuning/list#fine-tuning-list-after
func (FineTuningJobsOptions) SetLimit ¶
func (o FineTuningJobsOptions) SetLimit(limit int) FineTuningJobsOptions
SetLimit sets the `limit` parameter of fine-tuning jobs listing request.
https://platform.openai.com/docs/api-reference/fine-tuning/list#fine-tuning-list-limit
type GeneratedImages ¶
type GeneratedImages struct { CommonResponse Created int64 `json:"created"` Data []struct { URL *string `json:"url,omitempty"` Base64JSON *string `json:"b64_json,omitempty"` } `json:"data"` }
GeneratedImages struct for image creation responses
type ImageEditOptions ¶
ImageEditOptions for creating image edits
func (ImageEditOptions) SetMask ¶
func (o ImageEditOptions) SetMask(mask FileParam) ImageEditOptions
SetMask sets the `mask` parameter of image edit request.
https://platform.openai.com/docs/api-reference/images/create-edit#images/create-edit-mask
func (ImageEditOptions) SetModel ¶
func (o ImageEditOptions) SetModel(model string) ImageEditOptions
SetModel sets the `model` parameter of image edit request.
NOTE: only `dall-e-2` is supported at this time.
https://platform.openai.com/docs/api-reference/images/createEdit#images-createedit-model
func (ImageEditOptions) SetN ¶
func (o ImageEditOptions) SetN(n int) ImageEditOptions
SetN sets the `n` parameter of image edit request.
https://platform.openai.com/docs/api-reference/images/create-edit#images/create-edit-n
func (ImageEditOptions) SetResponseFormat ¶
func (o ImageEditOptions) SetResponseFormat(responseFormat ImageResponseFormat) ImageEditOptions
SetResponseFormat sets the `response_format` parameter of image edit request.
https://platform.openai.com/docs/api-reference/images/create-edit#images/create-edit-response_format
func (ImageEditOptions) SetSize ¶
func (o ImageEditOptions) SetSize(size ImageSize) ImageEditOptions
SetSize sets the `size` parameter of image edit request.
https://platform.openai.com/docs/api-reference/images/create-edit#images/create-edit-size
func (ImageEditOptions) SetUser ¶
func (o ImageEditOptions) SetUser(user string) ImageEditOptions
SetUser sets the `user` parameter of image edit request.
https://platform.openai.com/docs/api-reference/images/create-edit#images/create-edit-user
type ImageOptions ¶
ImageOptions for creating images
func (ImageOptions) SetModel ¶
func (o ImageOptions) SetModel(model string) ImageOptions
SetModel sets the `model` parameter of image generation request.
https://platform.openai.com/docs/api-reference/images/create#images-create-model
func (ImageOptions) SetN ¶
func (o ImageOptions) SetN(n int) ImageOptions
SetN sets the `n` parameter of image generation request.
NOTE: only 1 supported for model: `dall-e-3`
https://platform.openai.com/docs/api-reference/images/create#images/create-n
func (ImageOptions) SetQuality ¶
func (o ImageOptions) SetQuality(quality string) ImageOptions
SetQuality sets the `quality` parameter of image generation request.
NOTE: 'hd' supported only for model: `dall-e-3`
https://platform.openai.com/docs/api-reference/images/create#images-create-quality
func (ImageOptions) SetResponseFormat ¶
func (o ImageOptions) SetResponseFormat(responseFormat ImageResponseFormat) ImageOptions
SetResponseFormat sets the `response_format` parameter of image generation request.
https://platform.openai.com/docs/api-reference/images/create#images/create-response_format
func (ImageOptions) SetSize ¶
func (o ImageOptions) SetSize(size ImageSize) ImageOptions
SetSize sets the `size` parameter of image generation request.
https://platform.openai.com/docs/api-reference/images/create#images/create-size
func (ImageOptions) SetStyle ¶
func (o ImageOptions) SetStyle(style ImageStyle) ImageOptions
SetStyle set the `style` parameter of image generation request.
NOTE: supported only for model: `dall-e-3`
https://platform.openai.com/docs/api-reference/images/create#images-create-style
func (ImageOptions) SetUser ¶
func (o ImageOptions) SetUser(user string) ImageOptions
SetUser sets the `user` parameter of image generation request.
https://platform.openai.com/docs/api-reference/images/create#images/create-user
type ImageResponseFormat ¶
type ImageResponseFormat string
ImageResponseFormat type for constants
const ( IamgeResponseFormatURL ImageResponseFormat = "url" IamgeResponseFormatBase64JSON ImageResponseFormat = "b64_json" )
type ImageSize ¶
type ImageSize string
ImageSize type for constants
const ( // for Dall-E-2 ImageSize256x256_DallE2 ImageSize = "256x256" ImageSize512x512_DallE2 ImageSize = "512x512" ImageSize1024x1024_DallE2 ImageSize = "1024x1024" // for Dall-E-3 ImageSize1024x1024_DallE3 ImageSize = "1024x1024" ImageSize1792x1024_DallE3 ImageSize = "1792x1024" ImageSize1024x1792_DallE3 ImageSize = "1024x1792" )
type ImageStyle ¶
type ImageStyle string
ImageStyle type for constants
const ( ImageStyleVivid ImageStyle = "vivid" ImageStyleNatural ImageStyle = "natural" )
type ImageVariationOptions ¶
ImageVariationOptions for creating image variations
func (ImageVariationOptions) SetModel ¶
func (o ImageVariationOptions) SetModel(model string) ImageVariationOptions
SetModel sets the `model` parameter of image variation request.
NOTE: only `dall-e-2` is supported at this time.
https://platform.openai.com/docs/api-reference/images/createVariation#images-createvariation-model
func (ImageVariationOptions) SetN ¶
func (o ImageVariationOptions) SetN(n int) ImageVariationOptions
SetN sets the `n` parameter of image variation request.
https://platform.openai.com/docs/api-reference/images/create-variation#images/create-variation-n
func (ImageVariationOptions) SetResponseFormat ¶
func (o ImageVariationOptions) SetResponseFormat(responseFormat ImageResponseFormat) ImageVariationOptions
SetResponseFormat sets the `response_format` parameter of image variation request.
func (ImageVariationOptions) SetSize ¶
func (o ImageVariationOptions) SetSize(size ImageSize) ImageVariationOptions
SetSize sets the `size` parameter of image variation request.
https://platform.openai.com/docs/api-reference/images/create-variation#images/create-variation-size
func (ImageVariationOptions) SetUser ¶
func (o ImageVariationOptions) SetUser(user string) ImageVariationOptions
SetUser sets the `user` parameter of image variation request.
https://platform.openai.com/docs/api-reference/images/create-variation#images/create-variation-user
type ListAssistantFilesOptions ¶
ListAssistantFilesOptions for listing assistant files
func (ListAssistantFilesOptions) SetAfter ¶
func (o ListAssistantFilesOptions) SetAfter(after string) ListAssistantFilesOptions
SetAfter sets the `after` parameter of assistant files' listing request.
func (ListAssistantFilesOptions) SetBefore ¶
func (o ListAssistantFilesOptions) SetBefore(before string) ListAssistantFilesOptions
SetBefore sets the `before` parameter of assistant files' listing request.
func (ListAssistantFilesOptions) SetLimit ¶
func (o ListAssistantFilesOptions) SetLimit(limit int) ListAssistantFilesOptions
SetLimit sets the `limit` parameter of assistant files' listing request.
func (ListAssistantFilesOptions) SetOrder ¶
func (o ListAssistantFilesOptions) SetOrder(order string) ListAssistantFilesOptions
SetOrder sets the `order` parameter of assistant files' listing request.
`order` can be one of 'asc' or 'desc'. (default: 'desc')
type ListAssistantsOptions ¶
ListAssistantsOptions for listing assistants
func (ListAssistantsOptions) SetAfter ¶
func (o ListAssistantsOptions) SetAfter(after string) ListAssistantsOptions
SetAfter sets the `after` parameter of assistants' listing request.
func (ListAssistantsOptions) SetBefore ¶
func (o ListAssistantsOptions) SetBefore(before string) ListAssistantsOptions
SetBefore sets the `before` parameter of assistants' listing request.
func (ListAssistantsOptions) SetLimit ¶
func (o ListAssistantsOptions) SetLimit(limit int) ListAssistantsOptions
SetLimit sets the `limit` parameter of assistants' listing request.
func (ListAssistantsOptions) SetOrder ¶
func (o ListAssistantsOptions) SetOrder(order string) ListAssistantsOptions
SetOrder sets the `order` parameter of assistants' listing request.
`order` can be one of 'asc' or 'desc'. (default: 'desc')
type ListMessageFilesOptions ¶
ListMessageFilesOptions for listing message files
func (ListMessageFilesOptions) SetAfter ¶
func (o ListMessageFilesOptions) SetAfter(after string) ListMessageFilesOptions
SetAfter sets the `after` parameter of message files' listing request.
func (ListMessageFilesOptions) SetBefore ¶
func (o ListMessageFilesOptions) SetBefore(before string) ListMessageFilesOptions
SetBefore sets the `before` parameter of messages' listing request.
func (ListMessageFilesOptions) SetLimit ¶
func (o ListMessageFilesOptions) SetLimit(limit int) ListMessageFilesOptions
SetLimit sets the `limit` parameter of message files' listing request.
func (ListMessageFilesOptions) SetOrder ¶
func (o ListMessageFilesOptions) SetOrder(order string) ListMessageFilesOptions
SetOrder sets the `order` parameter of message files' listing request.
`order` can be one of 'asc' or 'desc'. (default: 'desc')
type ListMessagesOptions ¶
ListMessagesOptions for listing messages
func (ListMessagesOptions) SetAfter ¶
func (o ListMessagesOptions) SetAfter(after string) ListMessagesOptions
SetAfter sets the `after` parameter of messages' listing request.
https://platform.openai.com/docs/api-reference/messages/listMessages#messages-listmessages-after
func (ListMessagesOptions) SetBefore ¶
func (o ListMessagesOptions) SetBefore(before string) ListMessagesOptions
SetBefore sets the `before` parameter of messages' listing request.
https://platform.openai.com/docs/api-reference/messages/listMessages#messages-listmessages-before
func (ListMessagesOptions) SetLimit ¶
func (o ListMessagesOptions) SetLimit(limit int) ListMessagesOptions
SetLimit sets the `limit` parameter of messages' listing request.
https://platform.openai.com/docs/api-reference/messages/listMessages#messages-listmessages-limit
func (ListMessagesOptions) SetOrder ¶
func (o ListMessagesOptions) SetOrder(order string) ListMessagesOptions
SetOrder sets the `order` parameter of messages' listing request.
`order` can be one of 'asc' or 'desc'. (default: 'desc')
https://platform.openai.com/docs/api-reference/messages/listMessages#messages-listmessages-order
type ListRunStepsOptions ¶
ListRunStepsOptions type for listing run steps
func (ListRunStepsOptions) SetAfter ¶
func (o ListRunStepsOptions) SetAfter(after string) ListRunStepsOptions
SetAfter sets the `after` parameter of run steps' listing request.
https://platform.openai.com/docs/api-reference/runs/listRunSteps#runs-listrunsteps-after
func (ListRunStepsOptions) SetBefore ¶
func (o ListRunStepsOptions) SetBefore(before string) ListRunStepsOptions
SetBefore sets the `before` parameter of run steps' listing request.
https://platform.openai.com/docs/api-reference/runs/listRunSteps#runs-listrunsteps-before
func (ListRunStepsOptions) SetLimit ¶
func (o ListRunStepsOptions) SetLimit(limit int) ListRunStepsOptions
SetLimit sets the `limit` parameter of run steps' listing request.
https://platform.openai.com/docs/api-reference/runs/listRunSteps#runs-listrunsteps-limit
func (ListRunStepsOptions) SetOrder ¶
func (o ListRunStepsOptions) SetOrder(order string) ListRunStepsOptions
SetOrder sets the `order` parameter of run steps' listing request.
`order` can be one of 'asc' or 'desc'. (default: 'desc')
https://platform.openai.com/docs/api-reference/runs/listRunSteps#runs-listrunsteps-order
type ListRunsOptions ¶
ListRunsOptions for listing runs
func (ListRunsOptions) SetAfter ¶
func (o ListRunsOptions) SetAfter(after string) ListRunsOptions
SetAfter sets the `after` parameter of messages' listing request.
https://platform.openai.com/docs/api-reference/runs/listRuns#runs-listruns-after
func (ListRunsOptions) SetBefore ¶
func (o ListRunsOptions) SetBefore(before string) ListRunsOptions
SetBefore sets the `before` parameter of messages' listing request.
https://platform.openai.com/docs/api-reference/runs/listRuns#runs-listruns-before
func (ListRunsOptions) SetLimit ¶
func (o ListRunsOptions) SetLimit(limit int) ListRunsOptions
SetLimit sets the `limit` parameter of messages' listing request.
https://platform.openai.com/docs/api-reference/runs/listRuns#runs-listruns-limit
func (ListRunsOptions) SetOrder ¶
func (o ListRunsOptions) SetOrder(order string) ListRunsOptions
SetOrder sets the `order` parameter of messages' listing request.
`order` can be one of 'asc' or 'desc'. (default: 'desc')
https://platform.openai.com/docs/api-reference/runs/listRuns#runs-listruns-order
type Message ¶
type Message struct { CommonResponse ID string `json:"id"` CreatedAt int `json:"created_at"` ThreadID string `json:"thread_id"` Role string `json:"role"` // 'user' | 'assistant' Content []MessageContent `json:"content"` AssistantID *string `json:"assistant_id,omitempty"` RunID *string `json:"run_id,omitempty"` FileIDs []string `json:"file_ids"` Metadata map[string]string `json:"metadata"` }
https://platform.openai.com/docs/api-reference/messages/object
type MessageContent ¶
type MessageContent struct { Type MessageContentType `json:"type"` ImageFile *MessageContentImageFile `json:"image_file,omitempty"` // Type == 'image_file' Text *MessageContentText `json:"text,omitempty"` // Type == 'text' }
MessageContent struct for Message
type MessageContentImageFile ¶
type MessageContentImageFile struct {
FileID string `json:"file_id"`
}
MessageContentImageFile struct for MessageContent
type MessageContentText ¶
type MessageContentText struct { Value string `json:"value"` Annotations []MessageContentTextAnnotation `json:"annotations"` }
MessageContentText struct for MessageContent
type MessageContentTextAnnotation ¶
type MessageContentTextAnnotation struct { Type MessageContentTextAnnotationType `json:"type"` Text string `json:"text"` FileCitation *MessageContentTextAnnotationFileCitation `json:"file_citation,omitempty"` FilePath *MessageContentTextAnnotationFilePath `json:"file_path,omitempty"` StartIndex int `json:"start_index"` EndIndex int `json:"end_index"` }
MessageContentTextAnntation struct for MessageContentText
type MessageContentTextAnnotationFileCitation ¶
type MessageContentTextAnnotationFileCitation struct { FileID string `json:"file_id"` Quote string `json:"quote"` }
MessageContentTextAnnotationFileCitation struct
type MessageContentTextAnnotationFilePath ¶
type MessageContentTextAnnotationFilePath struct {
FileID string `json:"file_id"`
}
MessageContentTextAnnotationFilePath struct
type MessageContentTextAnnotationType ¶
type MessageContentTextAnnotationType string
MessageContentTextAnnotationType type for constants
const ( MessageContentTextAnnotationTypeFileCitation MessageContentTextAnnotationType = "file_citation" MessageContentTextAnnotationTypeFilePath MessageContentTextAnnotationType = "file_path" )
MessageContentTextAnnotationType constants
type MessageContentType ¶
type MessageContentType string
MessageContentType type for constants
const ( MessageContentTypeImageFile MessageContentType = "image_file" MessageContentTypeText MessageContentType = "text" )
MessageContentType constants
type MessageFile ¶
type MessageFile struct { CommonResponse ID string `json:"id"` CreatedAt int `json:"created_at"` MessageID string `json:"message_id"` }
https://platform.openai.com/docs/api-reference/messages/file-object
type MessageFiles ¶
type MessageFiles struct { CommonResponse Data []MessageFile `json:"data"` FirstID string `json:"first_id"` LastID string `json:"last_id"` HasMore bool `json:"has_more"` }
MessageFiles struct for API response
type Messages ¶
type Messages struct { CommonResponse Data []Message `json:"data"` FirstID string `json:"first_id"` LastID string `json:"last_id"` HasMore bool `json:"has_more"` }
Messages struct for API response
type Model ¶
type Model struct { CommonResponse ID string `json:"id"` Created int64 `json:"created"` OwnedBy string `json:"owned_by"` Permission []Permission `json:"permission"` Root string `json:"root"` Parent *string `json:"parent,omitempty"` }
Model struct
type ModelDeletionStatus ¶
type ModelDeletionStatus struct { CommonResponse ID string `json:"id"` Deleted bool `json:"deleted"` }
ModelDeletionStatus struct for API response
type ModelsList ¶
type ModelsList struct { CommonResponse Data []Model `json:"data"` }
ModelList struct for API response
type Moderation ¶
type Moderation struct { CommonResponse ID string `json:"id"` Model string `json:"model"` Results []Classification `json:"results"` }
Moderation struct for response
type ModerationOptions ¶
ModerationOptions for creating moderation
func (ModerationOptions) SetModel ¶
func (o ModerationOptions) SetModel(model string) ModerationOptions
SetModel sets the `model` parameter of moderation request.
https://platform.openai.com/docs/api-reference/moderations/create#moderations/create-model
type ModifyAssistantOptions ¶
ModifyAssistantOptions for modifying assistant
func (ModifyAssistantOptions) SetDescription ¶
func (o ModifyAssistantOptions) SetDescription(description string) ModifyAssistantOptions
SetDescription sets the `description` parameter of assistant modification.
func (ModifyAssistantOptions) SetFileIDs ¶
func (o ModifyAssistantOptions) SetFileIDs(fileIDs []string) ModifyAssistantOptions
SetFileIDs sets the `file_ids` parameter of assistant modification.
func (ModifyAssistantOptions) SetInstructions ¶
func (o ModifyAssistantOptions) SetInstructions(instructions string) ModifyAssistantOptions
SetInstructions sets the `instructions` parameter of assistant modification.
func (ModifyAssistantOptions) SetMetadata ¶
func (o ModifyAssistantOptions) SetMetadata(metadata map[string]string) ModifyAssistantOptions
SetMetadata sets the `metadata` parameter of assistant modification.
func (ModifyAssistantOptions) SetModel ¶
func (o ModifyAssistantOptions) SetModel(model string) ModifyAssistantOptions
SetModel sets the `model` parameter of assistant modification.
func (ModifyAssistantOptions) SetName ¶
func (o ModifyAssistantOptions) SetName(name string) ModifyAssistantOptions
SetName sets the `name` parameter of assistant modification.
func (ModifyAssistantOptions) SetTools ¶
func (o ModifyAssistantOptions) SetTools(tools []Tool) ModifyAssistantOptions
SetTools sets the `tools` parameter of assistant modification.
type ModifyMessageOptions ¶
ModifyMessageOptions for modifying message
func (ModifyMessageOptions) SetMetadata ¶
func (o ModifyMessageOptions) SetMetadata(metadata map[string]string) ModifyMessageOptions
SetMetadata sets the `metadata` parameter of ModifyMessageOptions.
type ModifyRunOptions ¶
ModifyRunOptions for modifying run
func (ModifyRunOptions) SetMetadata ¶
func (o ModifyRunOptions) SetMetadata(metadata map[string]string) ModifyRunOptions
SetMetadata sets the `metadata` parameter of ModifyRunOptions.
https://platform.openai.com/docs/api-reference/runs/modifyRun#runs-modifyrun-metadata
type ModifyThreadOptions ¶
ModifyThreadOptions for modifying thread
func (ModifyThreadOptions) SetMetadata ¶
func (o ModifyThreadOptions) SetMetadata(metadata map[string]string) ModifyThreadOptions
SetMetadata sets the `metadata` parameter of ModifyThreadOptions.
https://platform.openai.com/docs/api-reference/threads/modifyThread#threads-modifythread-metadata
type Permission ¶
type Permission struct { ID string `json:"id"` Object string `json:"object"` Created int64 `json:"created"` AllowCreateEngine bool `json:"allow_create_engine"` AllowSampling bool `json:"allow_sampling"` AllowLogProbs bool `json:"allow_logprobs"` AllowSearchIndices bool `json:"allow_search_indices"` AllowView bool `json:"allow_view"` AllowFineTuning bool `json:"allow_fine_tuning"` Organization string `json:"organization"` Group *string `json:"group,omitempty"` IsBlocking bool `json:"is_blocking"` }
Permission struct
type Run ¶
type Run struct { CommonResponse ID string `json:"id"` CreatedAt int `json:"created_at"` ThreadID string `json:"thread_id"` AssistantID string `json:"assistant_id"` Status RunStatus `json:"status"` RequiredAction *RunAction `json:"required_action,omitempty"` LastError *RunError `json:"last_error,omitempty"` ExpiresAt int `json:"expires_at"` StartedAt *int `json:"started_at,omitempty"` CancelledAt *int `json:"cancelled_at,omitempty"` FailedAt *int `json:"failed_at,omitempty"` CompletedAt *int `json:"completed_at,omitempty"` Model string `json:"model"` Instructions string `json:"instructions"` Tools []Tool `json:"tools"` FileIDs []string `json:"file_ids"` Metadata map[string]string `json:"metadata"` }
type RunAction ¶
type RunAction struct { Type string `json:"type"` // == 'submit_tool_outputs' SubmitToolOutputs struct { ToolCalls []ToolCall `json:"tool_calls"` } `json:"submit_tool_outputs"` }
RunAction struct for Run struct
type RunError ¶
type RunError struct { Code RunErrorCode `json:"code"` Message string `json:"message"` }
RunError struct for Run struct
type RunErrorCode ¶
type RunErrorCode string
RunErrorCode type for constants
const ( RunErrorCodeServerError RunErrorCode = "server_error" RunErrorRateLimitExceeded RunErrorCode = "rate_limit_exceeded" )
RunErrorCode constants
type RunStatus ¶
type RunStatus string
RunStatus type for constants
const ( RunStatusQueued RunStatus = "queued" RunStatusInProgress RunStatus = "in_progress" RunStatusRequiresAction RunStatus = "requires_action" RunStatusCanceling RunStatus = "cancelling" RunStatusCanceled RunStatus = "cancelled" RunStatusFailed RunStatus = "failed" RunStatusCompleted RunStatus = "completed" RunStatusExpired RunStatus = "expired" )
RunStatus constants
type RunStep ¶
type RunStep struct { CommonResponse ID string `json:"id"` CreatedAt int `json:"created_at"` AssistantID string `json:"assistant_id"` ThreadID string `json:"thread_id"` RunID string `json:"run_id"` Type RunStepType `json:"type"` Status RunStepStatus `json:"status"` StepDetails RunStepDetails `json:"step_details"` LastError *RunError `json:"last_error,omitempty"` ExpiredAt *int `json:"expired_at,omitempty"` CancelledAt *int `json:"cancelled_at,omitempty"` FailedAt *int `json:"failed_at,omitempty"` CompletedAt *int `json:"completed_at,omitempty"` Metadata map[string]string `json:"metadata"` }
https://platform.openai.com/docs/api-reference/runs/step-object
type RunStepDetails ¶
type RunStepDetails struct { Type RunStepType `json:"type"` MessageCreation *RunStepDetailsMessageCreation `json:"message_creation,omitempty"` // Type == RunStepTypeMessageCreation ToolCalls []RunStepDetailsToolCall `json:"tool_calls,omitempty"` // Type == RunStepTypeToolCalls }
RunStepDetails struct for RunStepObject struct
type RunStepDetailsMessageCreation ¶
type RunStepDetailsMessageCreation struct {
MessageID string `json:"message_id"`
}
RunStepDetailsMessageCreation struct for RunStepDetails struct
type RunStepDetailsToolCall ¶
type RunStepDetailsToolCall struct { ID string `json:"id"` Type ToolType `json:"type"` CodeInterpreter *RunStepDetailsToolCallCodeInterpreter `json:"code_interpreter,omitempty"` // Type == ToolTypeCodeInterpreter Retrieval *RunStepDetailsToolCallRetrieval `json:"retrieval,omitempty"` // Type -== ToolTypeRetrieval Function *RunStepDetailsToolCallFunction `json:"function,omitempty"` // Type == ToolTypeFunction }
RunStepDetailsToolCall struct for RunStepDetails struct
type RunStepDetailsToolCallCodeInterpreter ¶
type RunStepDetailsToolCallCodeInterpreter struct { Input string `json:"input"` Outputs []ToolCallCodeInterpreterOutput `json:"outputs"` }
RunStepDetailsToolCallCodeInterpreter struct for RunStepDetailsToolCall struct
type RunStepDetailsToolCallFunction ¶
type RunStepDetailsToolCallFunction struct { Name string `json:"name"` Arguments string `json:"arguments"` Output *string `json:"output,omitempty"` }
RunStepDetailsToolCallsFunction struct for RunStepDetailsToolCall struct
type RunStepDetailsToolCallRetrieval ¶
type RunStepDetailsToolCallRetrieval struct{}
RunStepDetailsToolCallRetrieval struct for RunStepDetailsToolCall struct (empty object for now)
type RunStepStatus ¶
type RunStepStatus string
RunStepStatus type for constants
const ( RunStepStatusInProgress RunStepStatus = "in_progress" RunStepStatusCancelled RunStepStatus = "cancelled" RunStepStatusFailed RunStepStatus = "failed" RunStepStatusCompleted RunStepStatus = "completed" RunStepStatusExpired RunStepStatus = "expired" )
RunStepStatus constants
type RunStepType ¶
type RunStepType string
RunStepType type for constants
const ( RunStepTypeMessageCreation RunStepType = "message_creation" RunStepTypeToolCalls RunStepType = "tool_calls" )
RunStepType constants
type RunSteps ¶
type RunSteps struct { CommonResponse Data []RunStep `json:"data"` FirstID string `json:"first_id"` LastID string `json:"last_id"` HasMore bool `json:"has_more"` }
RunSteps struct for API response
type RunnableThread ¶
type RunnableThread struct { Messages []RunnableThreadMessage `json:"messages,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` }
RunnableThread struct for CreateThreadAndRunOptions
type RunnableThreadMessage ¶
type RunnableThreadMessage struct { Role string `json:"role"` // == 'user' Content string `json:"content"` FileIDs []string `json:"file_ids,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` }
RunnableThreadMessage struct for RunnableThread struct
type Runs ¶
type Runs struct { CommonResponse Data []Run `json:"data"` FirstID string `json:"first_id"` LastID string `json:"last_id"` HasMore bool `json:"has_more"` }
Runs struct for API response
type SpeechOptions ¶
SpeechOptions for creating speech
func (SpeechOptions) SetResponseFormat ¶
func (o SpeechOptions) SetResponseFormat(format SpeechResponseFormat) SpeechOptions
SetResponseFormat sets the `response_format` parameter of speech request.
func (SpeechOptions) SetSpeed ¶
func (o SpeechOptions) SetSpeed(speed float32) SpeechOptions
SetSpeed sets the `speed` parameter of speech request.
type SpeechResponseFormat ¶
type SpeechResponseFormat string
SpeechResponseFormat type for constants
const ( SpeechResponseFormatMP3 SpeechResponseFormat = "mp3" SpeechResponseFormatOpus SpeechResponseFormat = "opus" SpeechResponseFormatAAC SpeechResponseFormat = "aac" SpeechResponseFormatFLAC SpeechResponseFormat = "flac" )
type SpeechVoice ¶
type SpeechVoice string
SpeechVoice type for constants
const ( SpeechVoiceAlloy SpeechVoice = "alloy" SpeechVoiceEcho SpeechVoice = "echo" SpeechVoiceFable SpeechVoice = "fable" SpeechVoiceOnyx SpeechVoice = "onyx" SpeechVoiceNova SpeechVoice = "nova" SpeechVoiceShimmer SpeechVoice = "shimmer" )
type Thread ¶
type Thread struct { CommonResponse ID string `json:"id"` CreatedAt int `json:"created_at"` Metadata map[string]string `json:"metadata"` }
Thread struct
https://platform.openai.com/docs/api-reference/threads/object
type ThreadDeletionStatus ¶
type ThreadDeletionStatus struct { CommonResponse ID string `json:"id"` Deleted bool `json:"deleted"` }
ThreadDeletionStatus for API response
type ThreadMessage ¶
type ThreadMessage struct { Role string `json:"role"` // == 'user' Content string `json:"content"` FileIDs []string `json:"file_ids,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` }
ThreadMessage struct for Thread
func NewThreadMessage ¶
func NewThreadMessage(content string) ThreadMessage
NewThreadMessage returns a new ThreadMessage with given `content`.
func (ThreadMessage) SetFileIDs ¶
func (m ThreadMessage) SetFileIDs(fileIDs []string) ThreadMessage
SetFileIDs sets the `file_ids` value of ThreadMessage and return it.
func (ThreadMessage) SetMetadata ¶
func (m ThreadMessage) SetMetadata(metadata map[string]string) ThreadMessage
SetMetadata sets the `metadata` value of ThreadMessage and return it.
type Tool ¶
type Tool struct { Type ToolType `json:"type"` Function *ToolFunction `json:"function,omitempty"` }
Tool struct for assistant object
https://platform.openai.com/docs/api-reference/assistants/object#assistants/object-tools
func NewCodeInterpreterTool ¶
func NewCodeInterpreterTool() Tool
NewCodeInterpreterTool returns a tool with type: 'code_interpreter'.
func NewFunctionTool ¶
func NewFunctionTool(fn ToolFunction) Tool
NewFunctionTool returns a tool with type: 'function'.
func NewRetrievalTool ¶
func NewRetrievalTool() Tool
NewRetrievalTool returns a tool with type: 'retrieval'.
type ToolCall ¶
type ToolCall struct { // Index is not nil only in chat completion chunk object Index *int `json:"index,omitempty"` ID string `json:"id"` Type string `json:"type"` // == 'function' Function ToolCallFunction `json:"function"` }
ToolCall struct
func (ToolCall) ArgumentsInto ¶
ArgumentsInto parses the generated arguments into a given interface
type ToolCallCodeInterpreterOutput ¶
type ToolCallCodeInterpreterOutput struct { Type ToolCallCodeInterpreterOutputType `json:"type"` Logs *string `json:"logs,omitempty"` // Type == ToolCallCodeInterpreterOutputTypeLogs Image *ToolCallCodeInterpreterOutputImage `json:"image,omitempty"` // Type == ToolCallCodeInterpreterOutputTypeImage }
ToolCallCodeInterpreterOutput struct for RunStepDetailsToolCallCodeInterpreter struct
type ToolCallCodeInterpreterOutputImage ¶
type ToolCallCodeInterpreterOutputImage struct {
FileID string `json:"file_id"`
}
ToolCallCodeInterpreterOutputImage struct for ToolCallCodeInterpreterOutput struct
type ToolCallCodeInterpreterOutputType ¶
type ToolCallCodeInterpreterOutputType string
ToolCallCodeInterpreterOutputType type for constants
const ( ToolCallCodeInterpreterOutputTypeLogs ToolCallCodeInterpreterOutputType = "logs" ToolCallCodeInterpreterOutputTypeImage ToolCallCodeInterpreterOutputType = "image" )
ToolCallCodeInterpreterOutputType constants
type ToolCallFunction ¶
ToolCallFunction struct for ToolCall
type ToolFunction ¶
type ToolFunction struct { Name string `json:"name"` Description string `json:"description"` Parameters ToolFunctionParameters `json:"parameters"` }
ToolFunction struct for Tool struct
type ToolFunctionParameters ¶
ToolFunctionParameters type
func NewToolFunctionParameters ¶
func NewToolFunctionParameters() ToolFunctionParameters
NewToolFunctionParameters returns an empty ToolFunctionParameters.
func (ToolFunctionParameters) AddArrayPropertyWithDescription ¶
func (p ToolFunctionParameters) AddArrayPropertyWithDescription(name, elemType, description string) ToolFunctionParameters
AddArrayPropertyWithDescription adds/overwrites an array property in chat completion function parameters with a description.
func (ToolFunctionParameters) AddPropertyWithDescription ¶
func (p ToolFunctionParameters) AddPropertyWithDescription(name, typ3, description string) ToolFunctionParameters
AddPropertyWithDescription adds/overwrites a property in chat completion function parameters with a description.
func (ToolFunctionParameters) AddPropertyWithEnums ¶
func (p ToolFunctionParameters) AddPropertyWithEnums(name, typ3, description string, enums []string) ToolFunctionParameters
AddPropertyWithEnums adds/overwrites a property in chat completion function parameters with enums.
func (ToolFunctionParameters) SetRequiredParameters ¶
func (p ToolFunctionParameters) SetRequiredParameters(names []string) ToolFunctionParameters
SetRequiredParameters sets/overwrites required parameter names for chat completion function parameters.
type ToolOutput ¶
type ToolOutput struct { ToolCallID *string `json:"tool_call_id,omitempty"` Output *string `json:"output,omitempty"` }
ToolOutput struct for API request
type Transcription ¶
type Transcription struct { CommonResponse JSON *string `json:"json,omitempty"` Text *string `json:"text,omitempty"` SRT *string `json:"srt,omitempty"` VerboseJSON *string `json:"verbose_json,omitempty"` VTT *string `json:"vtt,omitempty"` }
Transcription struct for response
type TranscriptionOptions ¶
TranscriptionOptions for creating transcription
func (TranscriptionOptions) SetLanguage ¶
func (o TranscriptionOptions) SetLanguage(language string) TranscriptionOptions
SetLanguage sets the `language` parameter of transcription request.
https://platform.openai.com/docs/api-reference/audio/create#audio/create-language
func (TranscriptionOptions) SetPrompt ¶
func (o TranscriptionOptions) SetPrompt(prompt string) TranscriptionOptions
SetPrompt sets the `prompt` parameter of transcription request.
https://platform.openai.com/docs/api-reference/audio/create#audio/create-prompt
func (TranscriptionOptions) SetResponseFormat ¶
func (o TranscriptionOptions) SetResponseFormat(responseFormat TranscriptionResponseFormat) TranscriptionOptions
SetResponseFormat sets the `response_format` parameter of transcription request.
https://platform.openai.com/docs/api-reference/audio/create#audio/create-response_format
func (TranscriptionOptions) SetTemperature ¶
func (o TranscriptionOptions) SetTemperature(temperature float64) TranscriptionOptions
SetTemperature sets the `temperature` parameter of transcription request.
https://platform.openai.com/docs/api-reference/audio/create#audio/create-temperature
type TranscriptionResponseFormat ¶
type TranscriptionResponseFormat string
TranscriptionResponseFormat type for constants
const ( TranscriptionResponseFormatJSON TranscriptionResponseFormat = "json" TranscriptionResponseFormatText TranscriptionResponseFormat = "text" TranscriptionResponseFormatSRT TranscriptionResponseFormat = "srt" TranscriptionResponseFormatVerboseJSON TranscriptionResponseFormat = "verbose_json" TranscriptionResponseFormatVTT TranscriptionResponseFormat = "vtt" )
type TranslationOptions ¶
TranslationOptions for creating transcription
func (TranslationOptions) SetPrompt ¶
func (o TranslationOptions) SetPrompt(prompt string) TranslationOptions
SetPrompt sets the `prompt` parameter of translation request.
https://platform.openai.com/docs/api-reference/audio/create#audio/create-prompt
func (TranslationOptions) SetResponseFormat ¶
func (o TranslationOptions) SetResponseFormat(responseFormat TranslationResponseFormat) TranslationOptions
SetResponseFormat sets the `response_format` parameter of translation request.
https://platform.openai.com/docs/api-reference/audio/create#audio/create-response_format
func (TranslationOptions) SetTemperature ¶
func (o TranslationOptions) SetTemperature(temperature float64) TranslationOptions
SetTemperature sets the `temperature` parameter of translation request.
https://platform.openai.com/docs/api-reference/audio/create#audio/create-temperature
type TranslationResponseFormat ¶
type TranslationResponseFormat TranscriptionResponseFormat
TransclationResponseFormat type for constants