v1

package
v0.0.0-...-b655c0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Transcriptions = "https://api.openai.com/v1/audio/transcriptions"
	Translations   = "https://api.openai.com/v1/audio/translations"
)
View Source
const (
	GPT4                    = "gpt-4"
	GPT40314                = "gpt-4-0314"
	GPT432K                 = "gpt-4-32k"
	GPT432K0314             = "gpt-4-32k-0314"
	GPT3Dot5Turbo0301       = "gpt-3.5-turbo-0301"
	GPT3Dot5Turbo           = "gpt-3.5-turbo"
	GPT3TextDavinci003      = "text-davinci-003"
	GPT3TextDavinci002      = "text-davinci-002"
	GPT3TextCurie001        = "text-curie-001"
	GPT3TextBabbage001      = "text-babbage-001"
	GPT3TextAda001          = "text-ada-001"
	GPT3TextDavinci001      = "text-davinci-001"
	GPT3DavinciInstructBeta = "davinci-instruct-beta"
	GPT3Davinci             = "davinci"
	GPT3CurieInstructBeta   = "curie-instruct-beta"
	GPT3Curie               = "curie"
	GPT3Ada                 = "ada"
	GPT3Babbage             = "babbage"
)
View Source
const (
	CodexCodeDavinci002 = "code-davinci-002"
	CodexCodeCushman001 = "code-cushman-001"
	CodexCodeDavinci001 = "code-davinci-001"
)
View Source
const (
	CreateImageSize256x256   = "256x256"
	CreateImageSize512x512   = "512x512"
	CreateImageSize1024x1024 = "1024x1024"
)
View Source
const (
	CreateImageResponseFormatURL     = "url"
	CreateImageResponseFormatB64JSON = "b64_json"
)
View Source
const (
	Files       = "https://api.openai.com/v1/files"
	UploadFile  = "https://api.openai.com/v1/files"
	File        = "https://api.openai.com/v1/files/%s"
	FileContent = "https://api.openai.com/v1/files/%s/content"
)
View Source
const (
	FineTunes      = "https://api.openai.com/v1/fine-tunes"
	FineTune       = "https://api.openai.com/v1/fine-tunes/%s"
	CancelFineTune = "https://api.openai.com/v1/fine-tunes/%s/cancel"
	FineTuneEvents = "https://api.openai.com/v1/fine-tunes/%s/events"
)
View Source
const (
	CreateImage           = "https://api.openai.com/v1/images/generations"
	CreateImageEdit       = "https://api.openai.com/v1/images/edits"
	CreateImageVariations = "https://api.openai.com/v1/images/variations"
)
View Source
const (
	Models = "https://api.openai.com/v1/models"
	Model  = "https://api.openai.com/v1/models/%s"
)
View Source
const (
	Answers = "https://api.openai.com/v1/answers"
)
View Source
const (
	ChatCompletion = "https://api.openai.com/v1/chat/completions"
)
View Source
const (
	Completions = "https://api.openai.com/v1/completions"
)
View Source
const (
	CreateEdits = "https://api.openai.com/v1/edits"
)
View Source
const (
	Embeddings = "https://api.openai.com/v1/embeddings"
)
View Source
const (
	Moderations = "https://api.openai.com/v1/moderations"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AnswersRequest

type AnswersRequest struct {
	Model     string `json:"model"`  // 用于生成答案的 GPT 模型的 ID,例如 "davinci" 或 "curie"
	Prompt    string `json:"prompt"` //  (必需) 要回答的问题。
	Documents []struct {
		Text     string `json:"text"` // 用于生成答案的文档文本
		Metadata struct {
			Name   string `json:"name"`
			Source string `json:"source"`
		} `json:"metadata"`
	} `json:"documents"` // 一个列表,其中包含用于生成答案的文档对象
}

type AnswersResponse

type AnswersResponse struct {
	Id      string `json:"id"`
	Object  string `json:"object"`
	Model   string `json:"model"`
	Created int    `json:"created"`
	Answers []struct {
		Document struct {
			Text     string `json:"text"`
			Metadata struct {
				Name   string `json:"name"`
				Source string `json:"source"`
			} `json:"metadata"`
		} `json:"document"`
		Text       string  `json:"text"`
		Confidence float64 `json:"confidence"`
	} `json:"answers"`
}

type CancelFineTuneResponse

type CancelFineTuneResponse 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 ChatGpt

type ChatGpt struct {
	Authorization string
	HasProxy      bool
	ProxyUrl      string
}

func Client

func Client(option ChatGptOption) *ChatGpt

func (*ChatGpt) Answers

func (chat *ChatGpt) Answers(ctx context.Context, req AnswersRequest) (response AnswersResponse, err error)

Answers 用于自动回答问题。 您可以提供一个问题和一些上下文信息,然后ChatGPT将自动回答该问题。 这个API非常适合于构建智能客服、问答系统和搜索引擎等应用程序。

func (*ChatGpt) CancelFineTune

func (chat *ChatGpt) CancelFineTune(ctx context.Context, id string) (response CancelFineTuneResponse, err error)

CancelFineTune Immediately cancel a fine-tune job.

func (*ChatGpt) Completions

func (chat *ChatGpt) Completions(ctx context.Context, req CompletionsRequest) (response CompletionsResponse, err error)

Completions 用于生成文本。 您可以提供一个起始文本(prompt),然后ChatGPT将自动根据这个文本生成接下来的文本。 您可以控制生成的文本长度、温度(即创作性)、频率和置信度等参数。

func (*ChatGpt) CreateChatCompletion

func (chat *ChatGpt) CreateChatCompletion(ctx context.Context, req CreateChatCompletionRequest) (response CreateChatCompletionResponse, err error)

func (*ChatGpt) CreateEdits

func (chat *ChatGpt) CreateEdits(ctx context.Context, req CreateEditsRequest) (response CreateEditsResponse, err error)

CreateEdits Creates a new edit for the provided input, instruction, and parameters.

func (*ChatGpt) CreateFineTunes

func (chat *ChatGpt) CreateFineTunes(ctx context.Context, req CreateFineTunesRequest) (response CreateFineTunesResponse, err error)

CreateFineTunes 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 (*ChatGpt) CreateImage

func (chat *ChatGpt) CreateImage(ctx context.Context, req CreateImageRequest) (response CreateImageResponse, err error)

CreateImage Creates an image given a prompt.

func (*ChatGpt) CreateImageEdit

func (chat *ChatGpt) CreateImageEdit(ctx context.Context, req CreateImageEditRequest) (response CreateImageEditResponse, err error)

CreateImageEdit Creates an edited or extended image given an original image and a prompt.

func (*ChatGpt) CreateImageVariations

func (chat *ChatGpt) CreateImageVariations(ctx context.Context, req CreateImageVariationsRequest) (response CreateImageVariationsResponse, err error)

CreateImageVariations Creates a variation of a given image.

func (*ChatGpt) CreateModerations

func (chat *ChatGpt) CreateModerations(ctx context.Context, req CreateModerationsRequest) (response CreateModerationsResponse, err error)

CreateModerations Classifies if text violates OpenAI's Content Policy

func (*ChatGpt) CreateTranscriptions

func (chat *ChatGpt) CreateTranscriptions(ctx context.Context, req CreateTranscriptionsRequest) (response CreateTranscriptionsResponse, err error)

func (*ChatGpt) CreateTranslations

func (chat *ChatGpt) CreateTranslations(ctx context.Context, req CreateTranslationsRequest) (response CreateTranslationsResponse, err error)

func (*ChatGpt) Delete

func (chat *ChatGpt) Delete(ctx context.Context, url string, data interface{}) ([]byte, error)

func (*ChatGpt) DeleteFile

func (chat *ChatGpt) DeleteFile(ctx context.Context, id string) (response DeleteFileResponse, err error)

func (*ChatGpt) DeleteModel

func (chat *ChatGpt) DeleteModel(ctx context.Context, model string) (response DeleteModelResponse, err error)

DeleteModel Delete a fine-tuned model. You must have the Owner role in your organization.

func (*ChatGpt) Embeddings

func (chat *ChatGpt) Embeddings(ctx context.Context, req EmbeddingsRequest) (response EmbeddingsResponse, err error)

Embeddings Creates an embedding vector representing the input text.

func (*ChatGpt) Files

func (chat *ChatGpt) Files() (ctx context.Context, response FilesResponse, err error)

Files are used to upload documents that can be used with features like Fine-tuning.

func (*ChatGpt) FineTune

func (chat *ChatGpt) FineTune(ctx context.Context, id string) (response FineTuneResponse, err error)

FineTune Gets info about the fine-tune job.

func (*ChatGpt) FineTuneEvents

func (chat *ChatGpt) FineTuneEvents(ctx context.Context, id string) (response FineTuneEventsResponse, err error)

func (*ChatGpt) FineTunes

func (chat *ChatGpt) FineTunes(ctx context.Context) (response FineTunesResponse, err error)

FineTunes List your organization's fine-tuning jobs

func (*ChatGpt) Get

func (chat *ChatGpt) Get(ctx context.Context, url string, data interface{}) ([]byte, error)

func (*ChatGpt) Model

func (chat *ChatGpt) Model(ctx context.Context, model string) (response ModelResponse, err error)

Model Retrieves a model instance, providing basic information about the model such as the owner and permissioning. param model The ID of the model to use for this request

func (*ChatGpt) Models

func (chat *ChatGpt) Models(ctx context.Context) (response ModelsResponse, err error)

Models Lists the currently available models, and provides basic information about each one such as the owner and availability.

func (*ChatGpt) Post

func (chat *ChatGpt) Post(ctx context.Context, url string, data interface{}) ([]byte, error)

func (*ChatGpt) Proxy

func (chat *ChatGpt) Proxy() *http.Transport

func (*ChatGpt) RetrieveFile

func (chat *ChatGpt) RetrieveFile(ctx context.Context, id string) (response FilesResponse, err error)

RetrieveFile Returns information about a specific file.

func (*ChatGpt) RetrieveFileContent

func (chat *ChatGpt) RetrieveFileContent(ctx context.Context, id string) ([]byte, error)

RetrieveFileContent Returns the contents of the specified file

func (*ChatGpt) UploadFile

func (chat *ChatGpt) UploadFile(ctx context.Context, req UploadFileRequest) (response UploadFileResponse, err error)

UploadFile Upload 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 us if you need to increase the storage limit.

type ChatGptOption

type ChatGptOption struct {
	SecretKey string // OpenAI AuthKey
	HasProxy  bool   // proxy http
	ProxyUrl  string
}

type ChatMessage

type ChatMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Choice

type Choice struct {
	Index        int         `json:"index"`
	Message      ChatMessage `json:"message"`
	FinishReason string      `json:"finish_reason"`
}

type CompletionsChoice

type CompletionsChoice struct {
	Text         string      `json:"text"`
	Index        int         `json:"index"`
	Logprobs     interface{} `json:"logprobs"`
	FinishReason string      `json:"finish_reason"`
}

type CompletionsRequest

type CompletionsRequest struct {
	Model            string                 `json:"model"`                       // 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.
	Prompt           string                 `json:"prompt"`                      // 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.
	Suffix           string                 `json:"suffix,omitempty"`            // The suffix that comes after a completion of inserted text.
	MaxTokens        int                    `json:"max_tokens"`                  // The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
	Temperature      float32                `json:"temperature"`                 // 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 top_p but not both.
	TopP             int                    `json:"top_p,omitempty"`             // 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 temperature but not both.
	N                int                    `json:"n,omitempty"`                 // 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 max_tokens and stop.
	Stream           bool                   `json:"stream,omitempty"`            // Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.
	Logprobs         interface{}            `json:"logprobs,omitempty"`          // logprobs integer Optional Defaults to null Include the log probabilities on the logprobs most likely tokens, as well the chosen tokens. For example, if logprobs is 5, the API will return a list of the 5 most likely tokens. The API will always return the logprob of the sampled token, so there may be up to logprobs+1 elements in the response. The maximum value for logprobs is 5. If you need more than this, please contact us through our Help center and describe your use case.
	Echo             bool                   `json:"echo,omitempty"`              // Echo back the prompt in addition to the completion
	Stop             string                 `json:"stop,omitempty"`              // Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
	PresencePenalty  float32                `json:"presence_penalty,omitempty"`  // presence_penalty number 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.
	FrequencyPenalty float32                `json:"frequency_penalty,omitempty"` // 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.
	BestOf           int                    `json:"best_of,omitempty"`           // best_of integer Optional Defaults to 1 Generates best_of completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed. When used with n, best_of controls the number of candidate completions and n specifies how many to return – best_of must be greater than 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 max_tokens and stop.
	LogitBias        map[string]interface{} `json:"logit_bias,omitempty"`        // 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 {"50256": -100} to prevent the <|endoftext|> token from being generated.
	User             string                 `json:"user,omitempty"`              // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse
}

type CompletionsResponse

type CompletionsResponse struct {
	Id      string              `json:"id"`
	Object  string              `json:"object"`
	Created int                 `json:"created"`
	Model   string              `json:"model"`
	Choices []CompletionsChoice `json:"choices"`
	Usage   Usage               `json:"usage"`
}

type CreateChatCompletionRequest

type CreateChatCompletionRequest struct {
	Model            string                 `json:"model"`                       // ID of the model to use. Currently, only gpt-3.5-turbo and gpt-3.5-turbo-0301 are supported.
	Messages         []ChatMessage          `json:"messages"`                    // The messages to generate chat completions for, in the chat format(https://platform.openai.com/docs/guides/chat/introduction).
	MaxTokens        int                    `json:"max_tokens,omitempty"`        // The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
	Temperature      float32                `json:"temperature,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 top_p but not both.
	TopP             int                    `json:"top_p,omitempty"`             // 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 temperature but not both.
	N                int                    `json:"n,omitempty"`                 // 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 max_tokens and stop.
	Stream           bool                   `json:"stream,omitempty"`            // Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.
	Stop             string                 `json:"stop,omitempty"`              // Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
	PresencePenalty  float32                `json:"presence_penalty,omitempty"`  // presence_penalty number 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.
	FrequencyPenalty float32                `json:"frequency_penalty,omitempty"` // 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.
	LogitBias        map[string]interface{} `json:"logit_bias,omitempty"`        // 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 {"50256": -100} to prevent the <|endoftext|> token from being generated.
	User             string                 `json:"user,omitempty"`              // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse
}

type CreateChatCompletionResponse

type CreateChatCompletionResponse struct {
	Id      string   `json:"id"`
	Object  string   `json:"object"`
	Created int      `json:"created"`
	Choices []Choice `json:"choices"`
	Usage   Usage    `json:"usage"`
}

type CreateEditsChoice

type CreateEditsChoice struct {
	Text  string `json:"text"`
	Index int    `json:"index"`
}

type CreateEditsRequest

type CreateEditsRequest struct {
	Model       string  `json:"model"`
	Input       string  `json:"input"`
	Instruction string  `json:"instruction"`
	N           int     `json:"n,omitempty"`
	Temperature float32 `json:"temperature,omitempty"`
	TopP        float32 `json:"top_p,omitempty"`
}

type CreateEditsResponse

type CreateEditsResponse struct {
	Object  string              `json:"object"`
	Created int                 `json:"created"`
	Choices []CreateEditsChoice `json:"choices"`
	Usage   Usage               `json:"usage"`
}

type CreateFineTunesRequest

type CreateFineTunesRequest struct {
	TrainingFile                 string        `json:"training_file"`
	ValidationFile               string        `json:"validation_file,omitempty"`
	Model                        string        `json:"model,omitempty"`
	NEpochs                      int           `json:"n_epochs,omitempty"`
	BatchSize                    int           `json:"batch_size,omitempty"`
	LearningRateMultiplier       float32       `json:"learning_rate_multiplier,omitempty"`
	PromptLossWeight             float32       `json:"prompt_loss_weight,omitempty"`
	ComputeClassificationMetrics bool          `json:"compute_classification_metrics,omitempty"`
	ClassificationNClasses       int           `json:"classification_n_classes,omitempty"`
	ClassificationPositiveClass  string        `json:"classification_positive_class,omitempty"`
	ClassificationBetas          []interface{} `json:"classification_betas,omitempty"`
	Suffix                       string        `json:"suffix,omitempty"`
}

type CreateFineTunesResponse

type CreateFineTunesResponse 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 CreateImageEditRequest

type CreateImageEditRequest struct {
	Image          *os.File `json:"image"`                     // 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
	Mask           *os.File `json:"mask,omitempty"`            // 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
	Prompt         string   `json:"prompt"`                    // A text description of the desired image(s). The maximum length is 1000 characters
	N              int      `json:"n,omitempty"`               // The number of images to generate. Must be between 1 and 10
	Size           string   `json:"size,omitempty"`            // The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024
	ResponseFormat string   `json:"response_format,omitempty"` // The format in which the generated images are returned. Must be one of url or b64_json
	User           string   `json:"user,omitempty"`            // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse
}

type CreateImageEditResponse

type CreateImageEditResponse struct {
	Created int `json:"created"`
	Data    []struct {
		Url string `json:"url"`
	} `json:"data"`
}

type CreateImageRequest

type CreateImageRequest struct {
	Prompt         string `json:"prompt"`                    // A text description of the desired image(s). The maximum length is 1000 characters
	N              int    `json:"n,omitempty"`               // The number of images to generate. Must be between 1 and 10
	Size           string `json:"size,omitempty"`            // The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024
	ResponseFormat string `json:"response_format,omitempty"` // The format in which the generated images are returned. Must be one of url or b64_json
	User           string `json:"user,omitempty"`            // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse
}

type CreateImageResponse

type CreateImageResponse struct {
	Created int `json:"created"`
	Data    []struct {
		Url string `json:"url"`
	} `json:"data"`
}

type CreateImageVariationsRequest

type CreateImageVariationsRequest struct {
	Image          *os.File `json:"image"`                     // 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
	Prompt         string   `json:"prompt"`                    // A text description of the desired image(s). The maximum length is 1000 characters
	N              int      `json:"n,omitempty"`               // The number of images to generate. Must be between 1 and 10
	Size           string   `json:"size,omitempty"`            // The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024
	ResponseFormat string   `json:"response_format,omitempty"` // The format in which the generated images are returned. Must be one of url or b64_json
	User           string   `json:"user,omitempty"`            // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse
}

type CreateImageVariationsResponse

type CreateImageVariationsResponse struct {
	Created int `json:"created"`
	Data    []struct {
		Url string `json:"url"`
	} `json:"data"`
}

type CreateModerationsRequest

type CreateModerationsRequest struct {
	Input string `json:"input"`
	Model string `json:"model,omitempty"`
}

type CreateModerationsResponse

type CreateModerationsResponse 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 CreateTranscriptionsRequest

type CreateTranscriptionsRequest struct {
	File           *os.File `json:"file"`                      // The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
	Model          string   `json:"model"`                     // ID of the model to use. Only whisper-1 is currently available.
	Prompt         string   `json:"prompt,omitempty"`          // An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language.
	ResponseFormat string   `json:"response_format,omitempty"` // The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
	Temperature    float32  `json:"temperature,omitempty"`     // 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 to automatically increase the temperature until certain thresholds are hit.
	Language       string   `json:"language,omitempty"`        // The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency.
}

type CreateTranscriptionsResponse

type CreateTranscriptionsResponse struct {
	Text string `json:"text"`
}

type CreateTranslationsRequest

type CreateTranslationsRequest struct {
	File           *os.File `json:"file"`                      // The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
	Model          string   `json:"model"`                     // ID of the model to use. Only whisper-1 is currently available.
	Prompt         string   `json:"prompt,omitempty"`          // An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English.
	ResponseFormat string   `json:"response_format,omitempty"` // The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
	Temperature    float32  `json:"temperature,omitempty"`     // 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 to automatically increase the temperature until certain thresholds are hit.
}

type CreateTranslationsResponse

type CreateTranslationsResponse struct {
	Text string `json:"text"`
}

type DeleteFileResponse

type DeleteFileResponse struct {
	Id      string `json:"id"`
	Object  string `json:"object"`
	Deleted bool   `json:"deleted"`
}

type DeleteModelResponse

type DeleteModelResponse struct {
	Id      string `json:"id"`
	Object  string `json:"object"`
	Deleted bool   `json:"deleted"`
}

type EmbeddingsData

type EmbeddingsData struct {
	Object    string    `json:"object"`
	Embedding []float64 `json:"embedding"`
	Index     int       `json:"index"`
}

type EmbeddingsRequest

type EmbeddingsRequest struct {
	Model string `json:"model"`          // 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.
	Input string `json:"input"`          // 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.
	User  string `json:"user,omitempty"` // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse
}

type EmbeddingsResponse

type EmbeddingsResponse struct {
	Object string           `json:"object"`
	Data   []EmbeddingsData `json:"data"`
	Model  string           `json:"model"`
	Usage  Usage            `json:"usage"`
}

type FilesResponse

type FilesResponse struct {
	Data []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:"data"`
	Object string `json:"object"`
}

type FineTuneEventsResponse

type FineTuneEventsResponse struct {
	Object string `json:"object"`
	Data   []struct {
		Object    string `json:"object"`
		CreatedAt int    `json:"created_at"`
		Level     string `json:"level"`
		Message   string `json:"message"`
	} `json:"data"`
}

type FineTuneResponse

type FineTuneResponse 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 FineTunesResponse

type FineTunesResponse 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    struct {
		} `json:"hyperparams"`
		OrganizationId  string        `json:"organization_id"`
		ResultFiles     []interface{} `json:"result_files"`
		Status          string        `json:"status"`
		ValidationFiles []interface{} `json:"validation_files"`
		TrainingFiles   []interface{} `json:"training_files"`
		UpdatedAt       int           `json:"updated_at"`
	} `json:"data"`
}

type ModelResponse

type ModelResponse struct {
	Id         string        `json:"id"`
	Object     string        `json:"object"`
	OwnedBy    string        `json:"owned_by"`
	Permission []interface{} `json:"permission"`
}

type ModelsResponse

type ModelsResponse struct {
	Data []struct {
		Id         string        `json:"id"`
		Object     string        `json:"object"`
		OwnedBy    string        `json:"owned_by"`
		Permission []interface{} `json:"permission"`
	} `json:"data"`
	Object string `json:"object"`
}

type RetrieveFileResponse

type RetrieveFileResponse 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"`
}

type UploadFileRequest

type UploadFileRequest struct {
	File    *os.File `json:"file"`    // If the purpose is set to "fine-tune", each line is a JSON record with "prompt" and "completion" fields representing your training examples.
	Purpose string   `json:"purpose"` // The intended purpose of the uploaded documents.  Use "fine-tune" for Fine-tuning. This allows us to validate the format of the uploaded file.
}

type UploadFileResponse

type UploadFileResponse 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"`
}

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL