Documentation
¶
Index ¶
- type Api
- type AudioAPI
- type AudioTranscriptionRequest
- type AudioTranscriptionResponse
- type Categories
- type CategoryScores
- type ChatAPI
- type ChatCompletion
- type ChatRequest
- type Choice
- type Completion
- type CompletionRequest
- type CompletionsAPI
- type ContentModerationInput
- type DeleteModelResponse
- type EditRequest
- type EditedChoice
- type EditedInput
- type EditedUsage
- type EditsAPI
- type Embed
- type EmbedUse
- type EmbeddingRequest
- type EmbeddingResponse
- type EmbeddingsAPI
- type EnginesAPI
- type File
- type FileAPI
- func (f *FileAPI) DeleteFile(ctx context.Context, id string) (*FileDeleteResponse, *Response, error)
- func (f *FileAPI) List(ctx context.Context) (*FileList, *Response, error)
- func (f *FileAPI) RetrieveFile(ctx context.Context, id string) (*File, *Response, error)
- func (f *FileAPI) RetrieveFileContent(ctx context.Context, id string) (*Response, error)
- func (f *FileAPI) UploadFile(ctx context.Context, fuReq *FileUploadRequest) (*File, *Response, error)
- type FileDeleteResponse
- type FileList
- type FileUploadRequest
- type FineTune
- type FineTuneEvent
- type FineTuneEventList
- type FineTuneInfo
- type FineTuneList
- type FineTuneRequest
- type FineTunesAPI
- func (ft *FineTunesAPI) CancelFineTune(ctx context.Context, id string) (*FineTuneInfo, *Response, error)
- func (ft *FineTunesAPI) CreateFineTune(ctx context.Context, ftReq *FineTuneRequest) (*FineTune, *Response, error)
- func (ft *FineTunesAPI) Delete(ctx context.Context, model string) (*DeleteModelResponse, *Response, error)
- func (ft *FineTunesAPI) List(ctx context.Context) (*FineTuneList, *Response, error)
- func (ft *FineTunesAPI) ListFineTuneEvents(ctx context.Context, id string) (*FineTuneEventList, *Response, error)
- func (ft *FineTunesAPI) RetrieveFineTune(ctx context.Context, id string) (*FineTuneInfo, *Response, error)
- type HyperParams
- type Hyperparams
- type ImageData
- type ImageEditRequest
- type ImageRequest
- type ImageResponse
- type ImagesAPI
- func (i *ImagesAPI) CreateImage(ctx context.Context, imgReq *ImageRequest) (*ImageResponse, *Response, error)
- func (i *ImagesAPI) CreateImageEdit(ctx context.Context, imgEditReq *ImageEditRequest) (*ImageResponse, *Response, error)
- func (i *ImagesAPI) CreateImageVariation(ctx context.Context, imgReq *ImageRequest) (*ImageResponse, *Response, error)
- type Message
- type Model
- type ModelList
- type ModelsAPI
- type ModerationsAPI
- type OpenAIClient
- type Response
- type Results
- type TextChoice
- type TextModerationResponse
- type TextUsage
- type TrainingFile
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudioAPI ¶
type AudioAPI Api
func (*AudioAPI) CreateEnglishTranslation ¶
func (a *AudioAPI) CreateEnglishTranslation(ctx context.Context, aTReq *AudioTranscriptionRequest) (*AudioTranscriptionResponse, *Response, error)
CreateTranslation translates audio into into English.
func (*AudioAPI) CreateTranscription ¶
func (a *AudioAPI) CreateTranscription(ctx context.Context, aTReq *AudioTranscriptionRequest) (*AudioTranscriptionResponse, *Response, error)
CreateTranscription transcribes audio into the input language.
type AudioTranscriptionRequest ¶
type AudioTranscriptionRequest struct {
File string `json:"file" required:"true"`
Model string `json:"model" required:"true"`
Prompt string `json:"prompt,omitempty"`
ResponseFormat string `json:"response_format,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
Language string `json:"language,omitempty"`
}
type AudioTranscriptionResponse ¶
type AudioTranscriptionResponse struct {
Text string `json:"text"`
}
type Categories ¶
type CategoryScores ¶
type CategoryScores struct {
Hate float64 `json:"hate"`
HateThreatening float64 `json:"hate/threatening"`
SelfHarm float64 `json:"self-harm"`
Sexual float64 `json:"sexual"`
SexualMinors float64 `json:"sexual/minors"`
Violence float64 `json:"violence"`
ViolenceGraphic float64 `json:"violence/graphic"`
}
type ChatAPI ¶
type ChatAPI Api
func (*ChatAPI) CreateChatCompletion ¶
func (c *ChatAPI) CreateChatCompletion(ctx context.Context, chatReq *ChatRequest) (*ChatCompletion, *Response, error)
CreateChatCompletion creates a completion for the chat message
type ChatCompletion ¶
type ChatRequest ¶
type ChatRequest struct {
Model string `json:"model" binding:"required"`
Messages []string `json:"messages" binding:"required"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
N int `json:"n,omitempty"`
Stream bool `json:"stream,omitempty"`
Stop interface{} `json:"stop,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
PresencePenalty float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
LogitBias map[string]float64 `json:"logit_bias,omitempty"`
User string `json:"user,omitempty"`
}
type Completion ¶
type CompletionRequest ¶
type CompletionRequest struct {
Model string `json:"model" binding:"required"`
Prompt interface{} `json:"prompt,omitempty"`
Suffix string `json:"suffix,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
N int `json:"n,omitempty"`
Stream bool `json:"stream,omitempty"`
Logprobs int `json:"logprobs,omitempty"`
Echo bool `json:"echo,omitempty"`
Stop interface{} `json:"stop,omitempty"`
PresencePenalty float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
BestOf int `json:"best_of,omitempty"`
LogitBias interface{} `json:"logit_bias,omitempty"`
User string `json:"user,omitempty"`
}
type CompletionsAPI ¶
type CompletionsAPI Api
func (*CompletionsAPI) CreateCompletion ¶
func (c *CompletionsAPI) CreateCompletion(ctx context.Context, completionReq *CompletionRequest) (*Completion, *Response, error)
CreateCompletion creates a completion for the provided prompt and parameters
type ContentModerationInput ¶
type DeleteModelResponse ¶
type EditRequest ¶
type EditRequest struct {
Model string `json:"model" binding:"required"`
Input string `json:"input,omitempty"`
Instruction string `json:"instruction" binding:"required"`
N int `json:"n,omitempty" default:"1"`
Temperature float64 `json:"temperature,omitempty" default:"1"`
TopP float64 `json:"top_p,omitempty" default:"1"`
}
type EditedChoice ¶
type EditedInput ¶
type EditedInput struct {
Object string `json:"object"`
Created int64 `json:"created"`
Choices []EditedChoice `json:"choices"`
Usage EditedUsage `json:"usage"`
}
type EditedUsage ¶
type EditsAPI ¶
type EditsAPI Api
func (*EditsAPI) CreateEdit ¶
func (e *EditsAPI) CreateEdit(ctx context.Context, editReq *EditRequest) (*EditedInput, *Response, error)
CreateEdit creates a new edit for the provided input, instruction, and parameters.
type EmbeddingRequest ¶
type EmbeddingResponse ¶
type EmbeddingsAPI ¶
type EmbeddingsAPI Api
func (*EmbeddingsAPI) CreateEmbeddings ¶
func (em *EmbeddingsAPI) CreateEmbeddings(ctx context.Context, embReq *EmbeddingRequest) (*EmbeddingResponse, *Response, error)
CreateEmbeddings creates an embedding vector representing the input text
type EnginesAPI ¶
type EnginesAPI Api
The Engines endpoints are deprecated. Please use their replacement, Models, instead.
type FileAPI ¶
type FileAPI Api
func (*FileAPI) DeleteFile ¶
func (f *FileAPI) DeleteFile(ctx context.Context, id string) (*FileDeleteResponse, *Response, error)
DeleteFile deletes file
func (*FileAPI) RetrieveFile ¶
RetrieveFile returns information about a specific file.
func (*FileAPI) RetrieveFileContent ¶
RetrieveFileContent returns the contents of the specified file.
func (*FileAPI) UploadFile ¶
func (f *FileAPI) UploadFile(ctx context.Context, fuReq *FileUploadRequest) (*File, *Response, error)
UploadFile uploads a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact https://help.openai.com/ if you need to increase the storage limit.
type FileDeleteResponse ¶
type FileUploadRequest ¶
type FileUploadRequest struct {
// Name of the JSON Lines file to be uploaded.
// If the purpose is set to "fine-tune",
// each line is a JSON record with "prompt" and "completion" fields representing your training examples (https://platform.openai.com/docs/guides/fine-tuning/prepare-training-data).
File string `json:"file"`
// The intended purpose of the uploaded documents.
// Use "fine-tune" for Fine-tuning. This allows us to validate the format of the uploaded file.
Purpose string `json:"purpose"`
}
type FineTune ¶
type FineTune struct {
ID string `json:"id"`
Object string `json:"object"`
Model string `json:"model"`
CreatedAt int64 `json:"created_at"`
Events []FineTuneEvent `json:"events"`
FineTunedModel interface{} `json:"fine_tuned_model"`
Hyperparams Hyperparams `json:"hyperparams"`
OrganizationID string `json:"organization_id"`
ResultFiles []interface{} `json:"result_files"`
Status string `json:"status"`
ValidationFiles []interface{} `json:"validation_files"`
TrainingFiles []TrainingFile `json:"training_files"`
UpdatedAt int64 `json:"updated_at"`
}
type FineTuneEvent ¶
type FineTuneEventList ¶
type FineTuneEventList struct {
Object string `json:"object"`
Data []FineTuneEvent `json:"data"`
}
type FineTuneInfo ¶
type FineTuneInfo struct {
ID string `json:"id"`
Object string `json:"object"`
Model string `json:"model"`
CreatedAt int64 `json:"created_at"`
Events []FineTuneEvent `json:"events"`
FineTunedModel string `json:"fine_tuned_model"`
Hyperparams HyperParams `json:"hyperparams"`
OrganizationID string `json:"organization_id"`
ResultFiles []File `json:"result_files"`
Status string `json:"status"`
ValidationFiles []File `json:"validation_files"`
TrainingFiles []File `json:"training_files"`
UpdatedAt int64 `json:"updated_at"`
}
type FineTuneList ¶
type FineTuneRequest ¶
type FineTuneRequest struct {
TrainingFile string `json:"training_file" validate:"required"`
ValidationFile string `json:"validation_file"`
Model string `json:"model,omitempty"`
NumEpochs int `json:"n_epochs,omitempty"`
BatchSize *int `json:"batch_size,omitempty"`
LearningRateMultiplier *float64 `json:"learning_rate_multiplier,omitempty"`
PromptLossWeight *float64 `json:"prompt_loss_weight,omitempty"`
ComputeClassificationMetrics bool `json:"compute_classification_metrics,omitempty"`
ClassificationNumClasses *int `json:"classification_n_classes,omitempty"`
ClassificationPositiveClass string `json:"classification_positive_class,omitempty"`
ClassificationBetas []float64 `json:"classification_betas,omitempty"`
Suffix string `json:"suffix,omitempty"`
}
type FineTunesAPI ¶
type FineTunesAPI Api
func (*FineTunesAPI) CancelFineTune ¶
func (ft *FineTunesAPI) CancelFineTune(ctx context.Context, id string) (*FineTuneInfo, *Response, error)
CancelFineTune immediately cancel a fine-tune job.
func (*FineTunesAPI) CreateFineTune ¶
func (ft *FineTunesAPI) CreateFineTune(ctx context.Context, ftReq *FineTuneRequest) (*FineTune, *Response, error)
CreateFineTune creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
func (*FineTunesAPI) Delete ¶
func (ft *FineTunesAPI) Delete(ctx context.Context, model string) (*DeleteModelResponse, *Response, error)
Delete a fine-tuned model. You must have the Owner role in your organization.
func (*FineTunesAPI) List ¶
func (ft *FineTunesAPI) List(ctx context.Context) (*FineTuneList, *Response, error)
List your organization's fine-tuning jobs
func (*FineTunesAPI) ListFineTuneEvents ¶
func (ft *FineTunesAPI) ListFineTuneEvents(ctx context.Context, id string) (*FineTuneEventList, *Response, error)
ListFineTuneEvents gets fine-grained status updates for a fine-tune job.
func (*FineTunesAPI) RetrieveFineTune ¶
func (ft *FineTunesAPI) RetrieveFineTune(ctx context.Context, id string) (*FineTuneInfo, *Response, error)
RetrieveFineTune gets info about the fine-tune job.
type HyperParams ¶
type Hyperparams ¶
type ImageEditRequest ¶
type ImageEditRequest struct {
Image string `json:"image" binding:"required"`
Mask string `json:"mask,omitempty"`
Prompt string `json:"prompt" binding:"required"`
N int `json:"n,omitempty" default:"1"`
Size string `json:"size,omitempty" default:"1024x1024"`
ResponseFormat string `json:"response_format,omitempty" default:"url"`
User string `json:"user,omitempty"`
}
type ImageRequest ¶
type ImageResponse ¶
type ImagesAPI ¶
type ImagesAPI Api
func (*ImagesAPI) CreateImage ¶
func (i *ImagesAPI) CreateImage(ctx context.Context, imgReq *ImageRequest) (*ImageResponse, *Response, error)
CreateImage creates an image given a prompt.
func (*ImagesAPI) CreateImageEdit ¶
func (i *ImagesAPI) CreateImageEdit(ctx context.Context, imgEditReq *ImageEditRequest) (*ImageResponse, *Response, error)
CreateImageEdit creates an edited or extended image given an original image and a prompt.
func (*ImagesAPI) CreateImageVariation ¶
func (i *ImagesAPI) CreateImageVariation(ctx context.Context, imgReq *ImageRequest) (*ImageResponse, *Response, error)
CreateImageVariation creates a variation of a given image.
type ModelsAPI ¶
type ModelsAPI Api
type ModerationsAPI ¶
type ModerationsAPI Api
func (*ModerationsAPI) CreateModeration ¶
func (m *ModerationsAPI) CreateModeration(ctx context.Context, cmReq *ContentModerationInput) (*TextModerationResponse, *Response, error)
type OpenAIClient ¶
type OpenAIClient struct {
BaseURL *url.URL
Completions *CompletionsAPI
Models *ModelsAPI
Chat *ChatAPI
Images *ImagesAPI
Embeddings *EmbeddingsAPI
Audio *AudioAPI
File *FileAPI
FineTunes *FineTunesAPI
Moderations *ModerationsAPI
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(httpClient *http.Client) *OpenAIClient
func (*OpenAIClient) NewRequest ¶
func (oapiClient *OpenAIClient) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
type Results ¶
type Results struct {
Categories Categories `json:"categories"`
CategoryScores CategoryScores `json:"category_scores"`
Flagged bool `json:"flagged"`
}