Documentation ¶
Index ¶
- Variables
- type AbnormalReturn
- type BaseOpenAI
- type Function
- type Message
- type Method
- type Model
- type ModelName
- type OpenAI
- func NewCancelFineTune(baseOpenAI BaseOpenAI, fineTuneId string) OpenAI[RequestCancelFineTune, ResponseCancelFineTune]
- func NewChat(baseOpenAI BaseOpenAI) OpenAI[RequestChat, ResponseChat]
- func NewCompletions(baseOpenAI BaseOpenAI) OpenAI[RequestCompletions, ResponseCompletions]
- func NewCreateFineTune(baseOpenAI BaseOpenAI) OpenAI[RequestCreateFineTune, ResponseCreateFineTune]
- func NewCreateImage(baseOpenAI BaseOpenAI) OpenAI[RequestCreateImage, ResponseCreateImage]
- func NewCreateModeration(baseOpenAI BaseOpenAI) OpenAI[RequestCreateModeration, ResponseCreateModeration]
- func NewCreateVariationImage(baseOpenAI BaseOpenAI) OpenAI[RequestCreateVariationImage, ResponseCreateVariationImage]
- func NewDeleteFile(baseOpenAI BaseOpenAI, fileID string) OpenAI[RequestDeleteFile, ResponseDeleteFile]
- func NewDeleteFineTuneModel(baseOpenAI BaseOpenAI, modelId string) OpenAI[RequestDeleteFineTuneModel, ResponseDeleteFineTuneModel]
- func NewEditImage(baseOpenAI BaseOpenAI) OpenAI[RequestEditImage, ResponseEditImage]
- func NewEdits(baseOpenAI BaseOpenAI) OpenAI[RequestEdits, ResponseEdits]
- func NewEmbeddings(baseOpenAI BaseOpenAI) OpenAI[RequestEmbeddings, ResponseEmbeddings]
- func NewEngines(baseOpenAI BaseOpenAI) OpenAI[RequestEngines, ResponseEngines]
- func NewFiles(baseOpenAI BaseOpenAI) OpenAI[RequestFiles, ResponseFiles]
- func NewFineTunes(baseOpenAI BaseOpenAI) OpenAI[RequestFineTunes, ResponseFineTunes]
- func NewImageEdit(baseOpenAI BaseOpenAI) OpenAI[RequestImageEdit, ResponseImageEdit]
- func NewImageGenerations(baseOpenAI BaseOpenAI) OpenAI[RequestImageGenerations, ResponseImageGenerations]
- func NewImageVariation(baseOpenAI BaseOpenAI) OpenAI[RequestImageVariation, ResponseImageVariation]
- func NewListFineTuneEvents(baseOpenAI BaseOpenAI, fineTuneId string) OpenAI[RequestListFineTuneEvents, ResponseListFineTuneEvents]
- func NewModelList(baseOpenAI BaseOpenAI, modelID string) OpenAI[RequestModel, ResponseModel]
- func NewModels(baseOpenAI BaseOpenAI) OpenAI[RequestModels, ResponseModels]
- func NewRetrieveEngine(baseOpenAI BaseOpenAI, engineID string) OpenAI[RequestRetrieveEngine, ResponseRetrieveEngine]
- func NewRetrieveFile(baseOpenAI BaseOpenAI, fileID string) OpenAI[RequestRetrieveFile, ResponseRetrieveFile]
- func NewRetrieveFileContent(baseOpenAI BaseOpenAI, fileID string) OpenAI[RequestRetrieveFileContent, ResponseRetrieveFileContent]
- func NewRetrieveFineTune(baseOpenAI BaseOpenAI, fineTuneId string) OpenAI[RequestRetrieveFineTune, ResponseRetrieveFineTune]
- func NewTranscription(baseOpenAI BaseOpenAI, request RequestTranscription) OpenAI[RequestTranscription, ResponseTranscription]
- func NewTranslation(baseOpenAI BaseOpenAI) OpenAI[RequestTranslation, ResponseTranslation]
- func NewUploadFile(baseOpenAI BaseOpenAI) OpenAI[RequestUploadFile, ResponseUploadFile]
- type OpenAIWithStream
- type Option
- type RequestCancelFineTune
- type RequestChat
- type RequestCompletions
- type RequestCreateFineTune
- type RequestCreateImage
- type RequestCreateModeration
- type RequestCreateVariationImage
- type RequestDeleteFile
- type RequestDeleteFineTuneModel
- type RequestEditImage
- type RequestEdits
- type RequestEmbeddings
- type RequestEngines
- type RequestFiles
- type RequestFineTunes
- type RequestImageEdit
- type RequestImageGenerations
- type RequestImageVariation
- type RequestListFineTuneEvents
- type RequestModel
- type RequestModels
- type RequestRetrieveEngine
- type RequestRetrieveFile
- type RequestRetrieveFileContent
- type RequestRetrieveFineTune
- type RequestTranscription
- type RequestTranslation
- type RequestUploadFile
- type ResponseCancelFineTune
- type ResponseChat
- type ResponseChatWithStream
- type ResponseCompletions
- type ResponseCreateFineTune
- type ResponseCreateImage
- type ResponseCreateModeration
- type ResponseCreateVariationImage
- type ResponseDeleteFile
- type ResponseDeleteFineTuneModel
- type ResponseEditImage
- type ResponseEdits
- type ResponseEmbeddings
- type ResponseEngines
- type ResponseFiles
- type ResponseFineTunes
- type ResponseImageEdit
- type ResponseImageGenerations
- type ResponseImageVariation
- type ResponseListFineTuneEvents
- type ResponseModel
- type ResponseModels
- type ResponseRetrieveEngine
- type ResponseRetrieveFile
- type ResponseRetrieveFileContent
- type ResponseRetrieveFineTune
- type ResponseTranscription
- type ResponseTranslation
- type ResponseUploadFile
- type Role
- type Stream
- type StrongOrArray
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RoleSystem = Role("system") RoleUser = Role("user") RoleAssistant = Role("assistant") RoleFunction = Role("function") )
View Source
var ( Gpt4 = ModelName{Name: "gpt-4"} Gpt4_0613 = ModelName{Name: "gpt-4-0613"} Gpt4_32k = ModelName{Name: "gpt-4-32k"} Gpt4_32k_0613 = ModelName{Name: "gpt-4-32k-0613"} )
View Source
var ( GPT3p5Turbo = ModelName{Name: "gpt-3.5-turbo"} GPT3p5Turbo16k = ModelName{Name: "gpt-3.5-turbo-16k"} GPT3p5Turbo0613 = ModelName{Name: "gpt-3.5-turbo-0613"} GTP3p5Turbo16k0613 = ModelName{Name: "gpt-3.5-turbo-16k-0613"} TextDavinci003 = ModelName{Name: "text-davinci-003"} TextDavinci002 = ModelName{Name: "text-davinci-002"} CodeDavinci002 = ModelName{Name: "code-davinci-002"} )
View Source
var ( TextModerationLatest = ModelName{Name: "text-moderation-latest"} TextModerationStable = ModelName{Name: "text-moderation-stable"} )
The Moderation models are designed to check whether content complies with OpenAI's usage policies. The models provide classification capabilities that look for content in the following categories: hate, hate/threatening, self-harm, sexual, sexual/minors, violence, and violence/graphic. You can find out more in our moderation guide.
Moderation models take in an arbitrary sized input that is automatically broken up to fix the models specific context window.
MODEL DESCRIPTION text-moderation-latest Most capable moderation model. Accuracy will be slighlty higher than the stable model text-moderation-stable Almo
View Source
var ( TextCurie001 = ModelName{Name: "text-curie-001"} TextBabbage001 = ModelName{Name: "text-babbage-001"} TextAda001 = ModelName{Name: "text-ada-001"} Davinci = ModelName{Name: "davinci"} Curie = ModelName{Name: "curie"} Babbage = ModelName{Name: "babbage"} Ada = ModelName{Name: "ada"} )
View Source
var ( //CodeDavinci002 = ModelName{Name: "code-davinci-002"} CodeDavinci001 = ModelName{Name: "code-davinci-001"} CodeCushman002 = ModelName{Name: "code-cushman-002"} CodeCushman001 = ModelName{Name: "code-cushman-001"} )
View Source
var (
ErrorUnsupportedMethod = errors.New("unsupported method")
)
View Source
var (
TextEmbeddingAda002 = ModelName{Name: "text-embedding-ada-002"}
)
View Source
var (
Whisper = ModelName{Name: "whisper-1"}
)
Functions ¶
This section is empty.
Types ¶
type AbnormalReturn ¶
type AbnormalReturn map[string]interface{}
func (AbnormalReturn) Error ¶
func (a AbnormalReturn) Error() string
type BaseOpenAI ¶
type BaseOpenAI struct { APIKey string `json:"api_key"` Organization string `json:"organization"` // contains filtered or unexported fields }
func NewBaseOpenAI ¶
func NewBaseOpenAI(apiKey, organization string, options ...Option) BaseOpenAI
type Function ¶ added in v0.0.2
type Function struct { // string Required // The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. Name string `json:"name"` // string Optional // The description of what the function does. Description string `json:"description,omitempty"` // object Optional // The parameters the functions accepts, described as a JSON Schema object. See the guide https://platform.openai.com/docs/guides/gpt/function-calling for examples, and the JSON Schema reference https://json-schema.org/understanding-json-schema/ for documentation about the format. Parameters interface{} `json:"parameters,omitempty"` }
type Message ¶
type Message struct { // string Required // The role of the messages author. One of , , , or .system user assistant function Role Role `json:"role"` // string Optional // The contents of the message. is required for all messages except assistant messages with function calls.content Content string `json:"content,omitempty"` // string Optional // The name of the author of this message. is required if role is , and it should be the name of the function whose response is in the . May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.name function content Name string `json:"name,omitempty"` // object Optional // The name and arguments of a function that should be called, as generated by the model. FunctionCall interface{} `json:"function_call,omitempty"` }
type OpenAI ¶
type OpenAI[Request, Response any] struct { BaseOpenAI Method Method `json:"method"` TargetURL string `json:"target_url"` }
func NewCancelFineTune ¶
func NewCancelFineTune(baseOpenAI BaseOpenAI, fineTuneId string) OpenAI[RequestCancelFineTune, ResponseCancelFineTune]
func NewChat ¶
func NewChat(baseOpenAI BaseOpenAI) OpenAI[RequestChat, ResponseChat]
func NewCompletions ¶
func NewCompletions(baseOpenAI BaseOpenAI) OpenAI[RequestCompletions, ResponseCompletions]
func NewCreateFineTune ¶
func NewCreateFineTune(baseOpenAI BaseOpenAI) OpenAI[RequestCreateFineTune, ResponseCreateFineTune]
func NewCreateImage ¶
func NewCreateImage(baseOpenAI BaseOpenAI) OpenAI[RequestCreateImage, ResponseCreateImage]
func NewCreateModeration ¶
func NewCreateModeration(baseOpenAI BaseOpenAI) OpenAI[RequestCreateModeration, ResponseCreateModeration]
func NewCreateVariationImage ¶
func NewCreateVariationImage(baseOpenAI BaseOpenAI) OpenAI[RequestCreateVariationImage, ResponseCreateVariationImage]
func NewDeleteFile ¶
func NewDeleteFile(baseOpenAI BaseOpenAI, fileID string) OpenAI[RequestDeleteFile, ResponseDeleteFile]
func NewDeleteFineTuneModel ¶
func NewDeleteFineTuneModel(baseOpenAI BaseOpenAI, modelId string) OpenAI[RequestDeleteFineTuneModel, ResponseDeleteFineTuneModel]
func NewEditImage ¶
func NewEditImage(baseOpenAI BaseOpenAI) OpenAI[RequestEditImage, ResponseEditImage]
func NewEdits ¶
func NewEdits(baseOpenAI BaseOpenAI) OpenAI[RequestEdits, ResponseEdits]
func NewEmbeddings ¶
func NewEmbeddings(baseOpenAI BaseOpenAI) OpenAI[RequestEmbeddings, ResponseEmbeddings]
func NewEngines ¶
func NewEngines(baseOpenAI BaseOpenAI) OpenAI[RequestEngines, ResponseEngines]
func NewFiles ¶
func NewFiles(baseOpenAI BaseOpenAI) OpenAI[RequestFiles, ResponseFiles]
func NewFineTunes ¶
func NewFineTunes(baseOpenAI BaseOpenAI) OpenAI[RequestFineTunes, ResponseFineTunes]
func NewImageEdit ¶ added in v0.0.2
func NewImageEdit(baseOpenAI BaseOpenAI) OpenAI[RequestImageEdit, ResponseImageEdit]
func NewImageGenerations ¶ added in v0.0.2
func NewImageGenerations(baseOpenAI BaseOpenAI) OpenAI[RequestImageGenerations, ResponseImageGenerations]
func NewImageVariation ¶ added in v0.0.2
func NewImageVariation(baseOpenAI BaseOpenAI) OpenAI[RequestImageVariation, ResponseImageVariation]
func NewListFineTuneEvents ¶
func NewListFineTuneEvents(baseOpenAI BaseOpenAI, fineTuneId string) OpenAI[RequestListFineTuneEvents, ResponseListFineTuneEvents]
func NewModelList ¶
func NewModelList(baseOpenAI BaseOpenAI, modelID string) OpenAI[RequestModel, ResponseModel]
func NewModels ¶
func NewModels(baseOpenAI BaseOpenAI) OpenAI[RequestModels, ResponseModels]
func NewRetrieveEngine ¶
func NewRetrieveEngine(baseOpenAI BaseOpenAI, engineID string) OpenAI[RequestRetrieveEngine, ResponseRetrieveEngine]
func NewRetrieveFile ¶
func NewRetrieveFile(baseOpenAI BaseOpenAI, fileID string) OpenAI[RequestRetrieveFile, ResponseRetrieveFile]
func NewRetrieveFileContent ¶
func NewRetrieveFileContent(baseOpenAI BaseOpenAI, fileID string) OpenAI[RequestRetrieveFileContent, ResponseRetrieveFileContent]
func NewRetrieveFineTune ¶
func NewRetrieveFineTune(baseOpenAI BaseOpenAI, fineTuneId string) OpenAI[RequestRetrieveFineTune, ResponseRetrieveFineTune]
func NewTranscription ¶
func NewTranscription(baseOpenAI BaseOpenAI, request RequestTranscription) OpenAI[RequestTranscription, ResponseTranscription]
func NewTranslation ¶
func NewTranslation(baseOpenAI BaseOpenAI) OpenAI[RequestTranslation, ResponseTranslation]
func NewUploadFile ¶
func NewUploadFile(baseOpenAI BaseOpenAI) OpenAI[RequestUploadFile, ResponseUploadFile]
type OpenAIWithStream ¶ added in v0.0.1
type OpenAIWithStream[Request any, Response any] struct { BaseOpenAI Method Method `json:"method"` TargetURL string `json:"target_url"` }
func NewChatWithStream ¶ added in v0.0.1
func NewChatWithStream(baseOpenAI BaseOpenAI) OpenAIWithStream[RequestChat, ResponseChatWithStream]
func NewCompletionsWithStream ¶ added in v0.0.1
func NewCompletionsWithStream(baseOpenAI BaseOpenAI) OpenAIWithStream[RequestCompletions, ResponseCompletions]
func (OpenAIWithStream[Request, Response]) DoRequestByStream ¶ added in v0.0.1
func (o OpenAIWithStream[Request, Response]) DoRequestByStream(request Request) (*Stream[Response], error)
type RequestCancelFineTune ¶
type RequestCancelFineTune struct{}
type RequestChat ¶
type RequestChat struct { // string Required // ID of the model to use. See the model endpoint compatibility https://platform.openai.com/docs/models/model-endpoint-compatibility table for details on which models work with the Chat API. Model *string `json:"model"` // array Required // A list of messages comprising the conversation so far. Example Python code https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb. Messages []Message `json:"messages"` // array Optional // A list of functions the model may generate JSON inputs for. Functions []Function `json:"functions,omitempty"` // string or object Optional // Controls how the model responds to function calls. "none" means the model does not call a function, and responds to the end-user. "auto" means the model can pick between an end-user or calling a function. Specifying a particular function via forces the model to call that function. "none" is the default when no functions are present. "auto" is the default if functions are present.{"name":\ "my_function"} FunctionCall interface{} `json:"function_call,omitempty"` // number Optional Defaults to 1 // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. // // We generally recommend altering this or but not both.top_p Temperature float64 `json:"temperature,omitempty"` // number Optional Defaults to 1 // An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. // // We generally recommend altering this or but not both.temperature TopP float64 `json:"top_p,omitempty"` // integer Optional Defaults to 1 // How many chat completion choices to generate for each input message. N int `json:"n,omitempty"` // boolean Optional Defaults to false // If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format as they become available, with the stream terminated by a message. Example Python code.data: https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb [DONE] Stream bool `json:"stream,omitempty"` // string or array Optional Defaults to null // Up to 4 sequences where the API will stop generating further tokens. Stop StrongOrArray `json:"stop,omitempty"` // integer Optional Defaults to inf // The maximum number of tokens https://platform.openai.com/tokenizer to generate in the chat completion. // // The total length of input tokens and generated tokens is limited by the model's context length. Example Python code https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb for counting tokens. MaxTokens int `json:"max_tokens,omitempty"` // Optional Defaults to 0 // Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. // // See more information about frequency and presence penalties https://platform.openai.com/docs/api-reference/parameter-details. PresencePenalty float64 `json:"presence_penalty,omitempty"` // number Optional Defaults to 0 // Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. // // See more information about frequency and presence penalties https://platform.openai.com/docs/api-reference/parameter-details. FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` // map Optional Defaults to null // Modify the likelihood of specified tokens appearing in the completion. // // Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. LogitBias map[string]interface{} `json:"logit_bias,omitempty"` // string Optional // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids. User string `json:"user,omitempty"` }
type RequestCompletions ¶
type RequestCompletions struct { // string Required // ID of the model to use. You can use the List models https://platform.openai.com/docs/api-reference/models/list API to see all of your available models, or see our Model overview https://platform.openai.com/docs/models/overview for descriptions of them. Model *string `json:"model"` // string or array Optional Defaults to <|endoftext|> // The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays. // // Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document. Prompt StrongOrArray `json:"prompt,omitempty"` // string Optional Defaults to null // The suffix that comes after a completion of inserted text. Suffix string `json:"suffix,omitempty"` // integer Optional Defaults to 16 // The maximum number of tokens https://platform.openai.com/tokenizer to generate in the completion. // // The token count of your prompt plus cannot exceed the model's context length. Example Python code https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb for counting tokens.max_tokens MaxTokens int `json:"max_tokens,omitempty"` // number Optional Defaults to 1 // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. // // We generally recommend altering this or but not both.top_p Temperature float64 `json:"temperature,omitempty"` // number Optional Defaults to 1 // An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. // // We generally recommend altering this or but not both.temperature TopP float64 `json:"top_p,omitempty"` // integer Optional Defaults to 1 // How many completions to generate for each prompt. // // Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for and .max_tokens stop N int `json:"n,omitempty"` // boolean Optional Defaults to false // Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format as they become available, with the stream terminated by a message. Example Python code.data: https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb [DONE] Stream bool `json:"stream,omitempty"` // integer Optional Defaults to null // Include the log probabilities on the most likely tokens, as well the chosen tokens. For example, if is 5, the API will return a list of the 5 most likely tokens. The API will always return the of the sampled token, so there may be up to elements in the response.logprobslogprobslogproblogprobs+1 // // The maximum value for is 5.logprobs Logprobs int `json:"logprobs,omitempty"` // boolean Optional Defaults to false // Echo back the prompt in addition to the completion Echo bool `json:"echo,omitempty"` // string or array Optional Defaults to null // Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. Stop StrongOrArray `json:"stop,omitempty"` // Optional Defaults to 0 // Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. // // See more information about frequency and presence penalties https://platform.openai.com/docs/api-reference/parameter-details. PresencePenalty float64 `json:"presence_penalty,omitempty"` // number Optional Defaults to 0 // Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. // // See more information about frequency and presence penalties https://platform.openai.com/docs/api-reference/parameter-details. FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` // integer Optional Defaults to 1 // Generates completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed.best_of // //When used with , controls the number of candidate completions and specifies how many to return – must be greater than . n best_of n best_of n // //Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for and .max_tokens stop BestOf int `json:"best_of,omitempty"` // map Optional Defaults to null // Modify the likelihood of specified tokens appearing in the completion. // // Accepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this tokenizer tool (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. // // As an example, you can pass to prevent the <|endoftext|> token from being generated.{"50256": -100} LogitBias map[string]interface{} `json:"logit_bias,omitempty"` // string Optional // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids. User string `json:"user,omitempty"` }
type RequestCreateFineTune ¶
type RequestCreateFineTune struct { // string Required // The ID of an uploaded file that contains training data. // // See upload file https://platform.openai.com/docs/api-reference/files/upload for how to upload a file. // // Your dataset must be formatted as a JSONL file, where each training example is a JSON object with the keys "prompt" and "completion". Additionally, you must upload your file with the purpose .fine-tune // // See the fine-tuning guide https://platform.openai.com/docs/guides/fine-tuning/creating-training-data for more details. TrainingFile *string `json:"training_file"` // string Optional // The ID of an uploaded file that contains validation data. // // If you provide this file, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in the fine-tuning results file https://platform.openai.com/docs/guides/fine-tuning/analyzing-your-fine-tuned-model. Your train and validation data should be mutually exclusive. // // Your dataset must be formatted as a JSONL file, where each validation example is a JSON object with the keys "prompt" and "completion". Additionally, you must upload your file with the purpose .fine-tune // // See the fine-tuning https://platform.openai.com/docs/guides/fine-tuning/creating-training-data guide for more details. ValidationFile string `json:"validation_file,omitempty"` // string Optional Defaults to curie // The name of the base model to fine-tune. You can select one of "ada", "babbage", "curie", "davinci", or a fine-tuned model created after 2022-04-21. To learn more about these models, see the Models documentation. Model string `json:"model,omitempty"` // integer Optional Defaults to 4 // The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. NEpochs int `json:"n_epochs,omitempty"` // integer Optional Defaults to null // The batch size to use for training. The batch size is the number of training examples used to train a single forward and backward pass. // // By default, the batch size will be dynamically configured to be ~0.2% of the number of examples in the training set, capped at 256 - in general, we've found that larger batch sizes tend to work better for larger datasets. BatchSize float64 `json:"batch_size,omitempty"` // number Optional Defaults to null // The learning rate multiplier to use for training. The fine-tuning learning rate is the original learning rate used for pretraining multiplied by this value. // // By default, the learning rate multiplier is the 0.05, 0.1, or 0.2 depending on final (larger learning rates tend to perform better with larger batch sizes). We recommend experimenting with values in the range 0.02 to 0.2 to see what produces the best results.batch_size LearningRateMultiplier float64 `json:"learning_rate_multiplier,omitempty"` // number Optional Defaults to 0.01 // The weight to use for loss on the prompt tokens. This controls how much the model tries to learn to generate the prompt (as compared to the completion which always has a weight of 1.0), and can add a stabilizing effect to training when completions are short. // // If prompts are extremely long (relative to completions), it may make sense to reduce this weight so as to avoid over-prioritizing learning the prompt. PromptLossWeight float64 `json:"prompt_loss_weight,omitempty"` // boolean Optional Defaults to false // If set, we calculate classification-specific metrics such as accuracy and F-1 score using the validation set at the end of every epoch. These metrics can be viewed in the results file https://platform.openai.com/docs/guides/fine-tuning/analyzing-your-fine-tuned-model. // // In order to compute classification metrics, you must provide a . Additionally, you must specify for multiclass classification or for binary classification.validation_fileclassification_n_classesclassification_positive_class ComputeClassificationMetrics bool `json:"compute_classification_metrics,omitempty"` // integer Optional Defaults to null // The number of classes in a classification task. // // This parameter is required for multiclass classification. ClassificationNClasses int `json:"classification_n_classes,omitempty"` // string Optional Defaults to null // The positive class in binary classification. // // This parameter is needed to generate precision, recall, and F1 metrics when doing binary classification. ClassificationPositiveClass string `json:"classification_positive_class,omitempty"` // array Optional Defaults to null // If this is provided, we calculate F-beta scores at the specified beta values. The F-beta score is a generalization of F-1 score. This is only used for binary classification. // // With a beta of 1 (i.e. the F-1 score), precision and recall are given the same weight. A larger beta score puts more weight on recall and less on precision. A smaller beta score puts more weight on precision and less on recall. ClassificationBetas []byte `json:"classification_betas,omitempty"` // string Optional Defaults to null // A string of up to 40 characters that will be added to your fine-tuned model name. // // For example, a suffix of "custom-model-name" would produce a model name like ada:ft-your-org:custom-model-name-2022-02-15-04-21-04. Suffix string `json:"suffix,omitempty"` }
type RequestCreateImage ¶
type RequestCreateImage struct { // string Required // A text description of the desired image(s). The maximum length is 1000 characters. Prompt *string `json:"prompt"` // integer Optional Defaults to 1 // The number of images to generate. Must be between 1 and 10. N int `json:"n,omitempty"` // string Optional Defaults to 1024x1024 // The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024. Size string `json:"size,omitempty"` // string Optional Defaults to url // The format in which the generated images are returned. Must be one of url or b64_json. ResponseFormat string `json:"response_format,omitempty"` // string Optional // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more. https://platform.openai.com/docs/guides/safety-best-practices User string `json:"user,omitempty"` }
type RequestCreateModeration ¶
type RequestCreateModeration struct { // string or array Required // The input text to classify Input StrongOrArray `json:"input"` // string Optional Defaults to text-moderation-latest // Two content moderations models are available: and .text-moderation-stabletext-moderation-latest // //The default is which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use , we will provide advanced notice before updating the model. Accuracy of may be slightly lower than for .text-moderation-latest text-moderation-stable text-moderation-stable text-moderation-latest Model string `json:"model,omitempty"` }
type RequestCreateVariationImage ¶
type RequestCreateVariationImage struct { // string Required // The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. Image *string `json:"image"` // integer Optional Defaults to 1 // The number of images to generate. Must be between 1 and 10. N int `json:"n,omitempty"` // string Optional Defaults to 1024x1024 // The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024. Size string `json:"size,omitempty"` // string Optional Defaults to url // The format in which the generated images are returned. Must be one of url or b64_json. ResponseFormat string `json:"response_format,omitempty"` // string Optional // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more. https://platform.openai.com/docs/guides/safety-best-practices User string `json:"user,omitempty"` }
type RequestDeleteFile ¶
type RequestDeleteFile struct{}
type RequestDeleteFineTuneModel ¶
type RequestDeleteFineTuneModel struct{}
type RequestEditImage ¶
type RequestEditImage struct { // string Required // The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. Image *string `json:"image"` // string Optional // An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as image. Mask string `json:"mask,omitempty"` // string Required // A text description of the desired image(s). The maximum length is 1000 characters. Prompt *string `json:"prompt"` // integer Optional Defaults to 1 // The number of images to generate. Must be between 1 and 10. N int `json:"n,omitempty"` // string Optional Defaults to 1024x1024 // The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024. Size string `json:"size,omitempty"` // string Optional Defaults to url // The format in which the generated images are returned. Must be one of url or b64_json. ResponseFormat string `json:"response_format,omitempty"` // string Optional // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more. https://platform.openai.com/docs/guides/safety-best-practices User string `json:"user,omitempty"` }
type RequestEdits ¶
type RequestEdits struct { // string Required // ID of the model to use. You can use the or model with this endpoint.text-davinci-edit-001 code-davinci-edit-001 Model *string `json:"model"` // string Optional Defaults to ” // The input text to use as a starting point for the edit. Input string `json:"input,omitempty"` // string Required // The instruction that tells the model how to edit the prompt. Instruction *string `json:"instruction"` // integer Optional Defaults to 1 // How many edits to generate for the input and instruction. N int `json:"n,omitempty"` // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. // // We generally recommend altering this or but not both.top_p Temperature float64 `json:"temperature,omitempty"` // number Optional Defaults to 1 // An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. // // We generally recommend altering this or but not both.temperature TopP float64 `json:"top_p,omitempty"` }
type RequestEmbeddings ¶
type RequestEmbeddings struct { // string Required // ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them. https://platform.openai.com/docs/api-reference/models/list Model *string `json:"model"` // string or array Required // Input text to get embeddings for, encoded as a string or array of tokens. To get embeddings for multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed 8192 tokens in length. Input StrongOrArray `json:"input"` // string Optional // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more. https://platform.openai.com/docs/guides/safety-best-practices https://platform.openai.com/docs/api-reference/models/list User string `json:"user,omitempty"` }
type RequestEngines ¶
type RequestEngines struct{}
type RequestFiles ¶
type RequestFiles struct { }
type RequestFineTunes ¶
type RequestFineTunes struct{}
type RequestImageEdit ¶ added in v0.0.2
type RequestImageEdit struct { // string Required // The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. Image *string `json:"image"` // string Optional // An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as . image image Mask string `json:"mask,omitempty"` // string Required // A text description of the desired image(s). The maximum length is 1000 characters. Prompt *string `json:"prompt"` // integer Optional Defaults to 1 // The number of images to generate. Must be between 1 and 10. N int `json:"n,omitempty"` // string Optional Defaults to 1024x1024 // The size of the generated images. Must be one of , , or .256x256 512x512 1024x1024 Size string `json:"size,omitempty"` // string Optional Defaults to url // The format in which the generated images are returned. Must be one of or .url b64_json ResponseFormat string `json:"response_format,omitempty"` // string Optional // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids. User string `json:"user,omitempty"` }
type RequestImageGenerations ¶ added in v0.0.2
type RequestImageGenerations struct { // string Required // A text description of the desired image(s). The maximum length is 1000 characters. Prompt *string `json:"prompt"` // integer Optional Defaults to 1 // The number of images to generate. Must be between 1 and 10. N int `json:"n,omitempty"` // string Optional Defaults to 1024x1024 // The size of the generated images. Must be one of , , or .256x256 512x512 1024x1024 Size string `json:"size,omitempty"` // string Optional Defaults to url // The format in which the generated images are returned. Must be one of or .url b64_json ResponseFormat string `json:"response_format,omitempty"` // string Optional // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids. User string `json:"user,omitempty"` }
type RequestImageVariation ¶ added in v0.0.2
type RequestImageVariation struct { // string Required // The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. Image *string `json:"image"` // integer Optional Defaults to 1 // The number of images to generate. Must be between 1 and 10. N int `json:"n,omitempty"` // string Optional Defaults to 1024x1024 // The size of the generated images. Must be one of , , or .256x256 512x512 1024x1024 Size string `json:"size,omitempty"` // string Optional Defaults to url // The format in which the generated images are returned. Must be one of or .url b64_json ResponseFormat string `json:"response_format,omitempty"` // string Optional // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids. User string `json:"user,omitempty"` }
type RequestListFineTuneEvents ¶
type RequestListFineTuneEvents struct{}
type RequestModel ¶
type RequestModel struct { }
type RequestModels ¶
type RequestModels struct { }
type RequestRetrieveEngine ¶
type RequestRetrieveEngine struct{}
type RequestRetrieveFile ¶
type RequestRetrieveFile struct{}
type RequestRetrieveFileContent ¶
type RequestRetrieveFileContent struct{}
type RequestRetrieveFineTune ¶
type RequestRetrieveFineTune struct { // string Required // The ID of the fine-tune job FineTurnID string `json:"fine_turn_id"` }
type RequestTranscription ¶
type RequestTranscription struct { // string Required // The audio file object (not file name) to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. File *string `json:"file"` // string Required // ID of the model to use. Only is currently available.whisper-1 Model *string `json:"model"` // string Optional // An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. Prompt string `json:"prompt,omitempty"` // string Optional Defaults to json // The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. ResponseFormat string `json:"response_format,omitempty"` // number Optional Defaults to 0 // The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability https://en.wikipedia.org/wiki/Log_probability to automatically increase the temperature until certain thresholds are hit. Temperature float64 `json:"temperature,omitempty"` // string Optional // The language of the input audio. Supplying the input language in ISO-639-1 https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes format will improve accuracy and latency. Language string `json:"language,omitempty"` }
type RequestTranslation ¶
type RequestTranslation struct { // string Required // The audio file object (not file name) translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. File *string `json:"file"` // string Required // ID of the model to use. Only is currently available.whisper-1 Model *string `json:"model"` // string Optional // An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English. https://platform.openai.com/docs/guides/speech-to-text/prompting Prompt string `json:"prompt,omitempty"` // string Optional Defaults to json // The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. ResponseFormat string `json:"response_format,omitempty"` // number Optional Defaults to 0 // The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability https://en.wikipedia.org/wiki/Log_probability to automatically increase the temperature until certain thresholds are hit. Temperature float64 `json:"temperature,omitempty"` }
type RequestUploadFile ¶
type RequestUploadFile struct { // string Required // Name of the JSON Lines https://jsonlines.readthedocs.io/en/latest/ file to be uploaded. // // If the is set to "fine-tune", each line is a JSON record with "prompt" and "completion" fields representing your training examples https://jsonlines.readthedocs.io/en/latest/.purpose File *string `json:"file"` // string Required // The intended purpose of the uploaded documents. // // Use "fine-tune" for Fine-tuning https://platform.openai.com/docs/api-reference/fine-tunes. This allows us to validate the format of the uploaded file. Purpose *string `json:"purpose"` }
type ResponseCancelFineTune ¶
type ResponseCancelFineTune struct { Id string `json:"id"` Object string `json:"object"` Model string `json:"model"` CreatedAt int `json:"created_at"` Events []struct { } `json:"events"` FineTunedModel interface{} `json:"fine_tuned_model"` Hyperparams struct { } `json:"hyperparams"` OrganizationId string `json:"organization_id"` ResultFiles []interface{} `json:"result_files"` Status string `json:"status"` ValidationFiles []interface{} `json:"validation_files"` TrainingFiles []struct { Id string `json:"id"` Object string `json:"object"` Bytes int `json:"bytes"` CreatedAt int `json:"created_at"` Filename string `json:"filename"` Purpose string `json:"purpose"` } `json:"training_files"` UpdatedAt int `json:"updated_at"` }
type ResponseChat ¶
type ResponseChat struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` Choices []struct { Index int `json:"index"` Message struct { Role string `json:"role"` Content string `json:"content"` FunctionCall interface{} `json:"function_call,omitempty"` } `json:"message"` FinishReason string `json:"finish_reason"` } `json:"choices"` Usage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` } `json:"usage"` }
type ResponseChatWithStream ¶ added in v0.0.1
type ResponseChatWithStream struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` Model string `json:"model"` Choices []struct { Delta struct { Role string `json:"role"` Content string `json:"content"` } `json:"delta"` Index int `json:"index"` FinishReason interface{} `json:"finish_reason"` } `json:"choices"` }
type ResponseCompletions ¶
type ResponseCompletions struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` Model string `json:"model"` Choices []struct { Text string `json:"text"` Index int `json:"index"` Logprobs interface{} `json:"logprobs"` FinishReason string `json:"finish_reason"` } `json:"choices"` Usage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` } `json:"usage"` }
type ResponseCreateFineTune ¶
type ResponseCreateFineTune struct { Id string `json:"id"` Object string `json:"object"` Model string `json:"model"` CreatedAt int `json:"created_at"` Events []struct { Object string `json:"object"` CreatedAt int `json:"created_at"` Level string `json:"level"` Message string `json:"message"` } `json:"events"` FineTunedModel interface{} `json:"fine_tuned_model"` HyperParams struct { BatchSize int `json:"batch_size"` LearningRateMultiplier float64 `json:"learning_rate_multiplier"` NEpochs int `json:"n_epochs"` PromptLossWeight float64 `json:"prompt_loss_weight"` } `json:"hyperparams"` OrganizationId string `json:"organization_id"` ResultFiles []interface{} `json:"result_files"` Status string `json:"status"` ValidationFiles []interface{} `json:"validation_files"` TrainingFiles []struct { Id string `json:"id"` Object string `json:"object"` Bytes int `json:"bytes"` CreatedAt int `json:"created_at"` Filename string `json:"filename"` Purpose string `json:"purpose"` } `json:"training_files"` UpdatedAt int `json:"updated_at"` }
type ResponseCreateImage ¶
type ResponseCreateModeration ¶
type ResponseCreateModeration struct { Id string `json:"id"` Model string `json:"model"` Results []struct { Categories struct { Hate bool `json:"hate"` HateThreatening bool `json:"hate/threatening"` SelfHarm bool `json:"self-harm"` Sexual bool `json:"sexual"` SexualMinors bool `json:"sexual/minors"` Violence bool `json:"violence"` ViolenceGraphic bool `json:"violence/graphic"` } `json:"categories"` 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"` } `json:"category_scores"` Flagged bool `json:"flagged"` } `json:"results"` }
type ResponseDeleteFile ¶
type ResponseEditImage ¶
type ResponseEdits ¶
type ResponseEdits struct { Object string `json:"object"` Created int `json:"created"` Choices []struct { Text string `json:"text"` Index int `json:"index"` } `json:"choices"` Usage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` } `json:"usage"` }
type ResponseEmbeddings ¶
type ResponseEmbeddings struct { Object string `json:"object"` Data []struct { Object string `json:"object"` Embedding []interface{} `json:"embedding"` Index int `json:"index"` } `json:"data"` Model string `json:"model"` Usage struct { PromptTokens int `json:"prompt_tokens"` TotalTokens int `json:"total_tokens"` } `json:"usage"` }
type ResponseEngines ¶
type ResponseFiles ¶
type ResponseFineTunes ¶
type ResponseFineTunes struct { Object string `json:"object"` Data []struct { Id string `json:"id"` Object string `json:"object"` Model string `json:"model"` CreatedAt int `json:"created_at"` FineTunedModel interface{} `json:"fine_tuned_model"` Hyperparams map[string]interface{} `json:"hyperparams"` OrganizationId string `json:"organization_id"` ResultFiles []interface{} `json:"result_files"` Status string `json:"status"` ValidationFiles []interface{} `json:"validation_files"` TrainingFiles []map[string]interface{} `json:"training_files"` UpdatedAt int `json:"updated_at"` } `json:"data"` }
type ResponseImageEdit ¶ added in v0.0.2
type ResponseImageGenerations ¶ added in v0.0.2
type ResponseImageVariation ¶ added in v0.0.2
type ResponseModel ¶
type ResponseModels ¶
type ResponseRetrieveEngine ¶
type ResponseRetrieveFile ¶
type ResponseRetrieveFileContent ¶
type ResponseRetrieveFileContent struct { }
type ResponseRetrieveFineTune ¶
type ResponseRetrieveFineTune struct { Id string `json:"id"` Object string `json:"object"` Model string `json:"model"` CreatedAt int `json:"created_at"` Events []struct { Object string `json:"object"` CreatedAt int `json:"created_at"` Level string `json:"level"` Message string `json:"message"` } `json:"events"` FineTunedModel string `json:"fine_tuned_model"` Hyperparams struct { BatchSize int `json:"batch_size"` LearningRateMultiplier float64 `json:"learning_rate_multiplier"` NEpochs int `json:"n_epochs"` PromptLossWeight float64 `json:"prompt_loss_weight"` } `json:"hyperparams"` OrganizationId string `json:"organization_id"` ResultFiles []struct { Id string `json:"id"` Object string `json:"object"` Bytes int `json:"bytes"` CreatedAt int `json:"created_at"` Filename string `json:"filename"` Purpose string `json:"purpose"` } `json:"result_files"` Status string `json:"status"` ValidationFiles []interface{} `json:"validation_files"` TrainingFiles []struct { Id string `json:"id"` Object string `json:"object"` Bytes int `json:"bytes"` CreatedAt int `json:"created_at"` Filename string `json:"filename"` Purpose string `json:"purpose"` } `json:"training_files"` UpdatedAt int `json:"updated_at"` }
type ResponseTranscription ¶
type ResponseTranscription struct {
Text string `json:"text"`
}
type ResponseTranslation ¶
type ResponseTranslation struct {
Text string `json:"text"`
}
type ResponseUploadFile ¶
type Stream ¶ added in v0.0.1
type Stream[Response any] struct { // contains filtered or unexported fields }
type StrongOrArray ¶
type StrongOrArray interface {
RealValue() interface{} // MUST String or Array
}
Click to show internal directories.
Click to hide internal directories.