Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Call(ctx context.Context, method string, url string, body io.Reader) (response *http.Response, err error)
- func (c *Client) CreateChatCompletions(ctx context.Context, r CreateChatCompletionsRequest) (response CreateChatCompletionsResponse, err error)
- func (c *Client) CreateChatCompletionsRaw(ctx context.Context, r CreateChatCompletionsRequest) ([]byte, error)
- func (c *Client) CreateEdits(ctx context.Context, r CreateEditsRequest) (response CreateEditsResponse, err error)
- func (c *Client) CreateEditsRaw(ctx context.Context, r CreateEditsRequest) ([]byte, error)
- func (c *Client) CreateEmbeddings(ctx context.Context, r CreateEmbeddingsRequest) (response CreateEmbeddingsResponse, err error)
- func (c *Client) CreateEmbeddingsRaw(ctx context.Context, r CreateEmbeddingsRequest) ([]byte, error)
- func (c *Client) CreateImages(ctx context.Context, r CreateImagesRequest) (response CreateImagesResponse, err error)
- func (c *Client) CreateImagesEdits(ctx context.Context, r CreateImagesEditsRequest) (response CreateImagesEditsResponse, err error)
- func (c *Client) CreateImagesEditsRaw(ctx context.Context, r CreateImagesEditsRequest) ([]byte, error)
- func (c *Client) CreateImagesRaw(ctx context.Context, r CreateImagesRequest) ([]byte, error)
- func (c *Client) CreateImagesVariations(ctx context.Context, r CreateImagesVariationsRequest) (response CreateImagesVariationsResponse, err error)
- func (c *Client) CreateImagesVariationsRaw(ctx context.Context, r CreateImagesVariationsRequest) ([]byte, error)
- func (c *Client) CreateModerations(ctx context.Context, r CreateModerationsRequest) (response CreateModerationsResponse, err error)
- func (c *Client) CreateModerationsRaw(ctx context.Context, r CreateModerationsRequest) ([]byte, error)
- func (c *Client) CreateTranscriptions(ctx context.Context, r CreateTranscriptionsRequest) (response CreateTranscriptionsResponse, err error)
- func (c *Client) CreateTranscriptionsRaw(ctx context.Context, r CreateTranscriptionsRequest) ([]byte, error)
- func (c *Client) CreateTranslations(ctx context.Context, r CreateTranslationsRequest) (response CreateTranslationsResponse, err error)
- func (c *Client) CreateTranslationsRaw(ctx context.Context, r CreateTranslationsRequest) ([]byte, error)
- func (c *Client) Get(ctx context.Context, url string, input any) (response []byte, err error)
- func (c *Client) ListModels(ctx context.Context) (response ListModelsResponse, err error)
- func (c *Client) ListModelsRaw(ctx context.Context) ([]byte, error)
- func (c *Client) Post(ctx context.Context, url string, input any) (response []byte, err error)
- func (c *Client) RetrieveModel(ctx context.Context, id string) (response RetrieveModelResponse, err error)
- func (c *Client) RetrieveModelRaw(ctx context.Context, id string) ([]byte, error)
- type ClientInterface
- type CompletionFunciton
- type CreateChatCompletionsChoice
- type CreateChatCompletionsRequest
- type CreateChatCompletionsResponse
- type CreateChatCompletionsUsave
- type CreateEditsChoice
- type CreateEditsRequest
- type CreateEditsResponse
- type CreateEditsUsage
- type CreateEmbeddingsData
- type CreateEmbeddingsRequest
- type CreateEmbeddingsResponse
- type CreateEmbeddingsUsage
- type CreateImagesData
- type CreateImagesEditsData
- type CreateImagesEditsRequest
- type CreateImagesEditsResponse
- type CreateImagesRequest
- type CreateImagesResponse
- type CreateImagesVariationsData
- type CreateImagesVariationsRequest
- type CreateImagesVariationsResponse
- type CreateModerationsCategories
- type CreateModerationsCategoriesScores
- type CreateModerationsRequest
- type CreateModerationsResponse
- type CreateModerationsResult
- type CreateTranscriptionsRequest
- type CreateTranscriptionsResponse
- type CreateTranslationsRequest
- type CreateTranslationsResponse
- type Error
- type FunctionCall
- type ListModelsData
- type ListModelsResponse
- type Message
- type ResponseFormat
- type RetrieveModelResponse
- type StrArray
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrStrArrayUnsupportedType = errors.New("unsupported type, must be string or []string")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Organization string // contains filtered or unexported fields }
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, method string, url string, body io.Reader) (response *http.Response, err error)
Call makes a request
func (*Client) CreateChatCompletions ¶ added in v1.0.0
func (c *Client) CreateChatCompletions(ctx context.Context, r CreateChatCompletionsRequest) (response CreateChatCompletionsResponse, err error)
func (*Client) CreateChatCompletionsRaw ¶ added in v1.0.0
func (*Client) CreateEdits ¶
func (c *Client) CreateEdits(ctx context.Context, r CreateEditsRequest) (response CreateEditsResponse, err error)
func (*Client) CreateEditsRaw ¶
func (*Client) CreateEmbeddings ¶
func (c *Client) CreateEmbeddings(ctx context.Context, r CreateEmbeddingsRequest) (response CreateEmbeddingsResponse, err error)
func (*Client) CreateEmbeddingsRaw ¶
func (*Client) CreateImages ¶
func (c *Client) CreateImages(ctx context.Context, r CreateImagesRequest) (response CreateImagesResponse, err error)
func (*Client) CreateImagesEdits ¶
func (c *Client) CreateImagesEdits(ctx context.Context, r CreateImagesEditsRequest) (response CreateImagesEditsResponse, err error)
func (*Client) CreateImagesEditsRaw ¶
func (*Client) CreateImagesRaw ¶
func (*Client) CreateImagesVariations ¶
func (c *Client) CreateImagesVariations(ctx context.Context, r CreateImagesVariationsRequest) (response CreateImagesVariationsResponse, err error)
func (*Client) CreateImagesVariationsRaw ¶
func (*Client) CreateModerations ¶
func (c *Client) CreateModerations(ctx context.Context, r CreateModerationsRequest) (response CreateModerationsResponse, err error)
func (*Client) CreateModerationsRaw ¶
func (*Client) CreateTranscriptions ¶
func (c *Client) CreateTranscriptions(ctx context.Context, r CreateTranscriptionsRequest) (response CreateTranscriptionsResponse, err error)
func (*Client) CreateTranscriptionsRaw ¶
func (*Client) CreateTranslations ¶
func (c *Client) CreateTranslations(ctx context.Context, r CreateTranslationsRequest) (response CreateTranslationsResponse, err error)
func (*Client) CreateTranslationsRaw ¶
func (*Client) ListModels ¶ added in v0.3.0
func (c *Client) ListModels(ctx context.Context) (response ListModelsResponse, err error)
func (*Client) ListModelsRaw ¶ added in v0.3.0
func (*Client) RetrieveModel ¶ added in v0.3.0
type ClientInterface ¶
type ClientInterface interface { // ListModels Lists the currently available models, and provides basic information about each one such as the owner and availability. ListModels(ctx context.Context) (response ListModelsResponse, err error) // RetrieveModel Retrieves a model instance, providing basic information about the model such as the owner and permissioning. RetrieveModel(ctx context.Context, id string) (response RetrieveModelResponse, err error) // CreateChatCompletions Creates a completion for the provided prompt and parameters CreateChatCompletions(ctx context.Context, r CreateChatCompletionsRequest) (response CreateChatCompletionsResponse, err error) // CreateEdits Creates a new edit for the provided input, instruction, and parameters. CreateEdits(ctx context.Context, r CreateEditsRequest) (response CreateEditsResponse, err error) // CreateImages Creates an image given a prompt. CreateImages(ctx context.Context, r CreateImagesRequest) (response CreateImagesResponse, err error) // CreateImagesEdits Creates an edited or extended image given an original image and a prompt. CreateImagesEdits(ctx context.Context, r CreateImagesEditsRequest) (response CreateImagesEditsResponse, err error) // CreateImagesVariations Creates a variation of a given image. CreateImagesVariations(ctx context.Context, r CreateImagesVariationsRequest) (response CreateImagesVariationsResponse, err error) // CreateEmbeddings Creates an embedding vector representing the input text. CreateEmbeddings(ctx context.Context, r CreateEmbeddingsRequest) (response CreateEmbeddingsResponse, err error) // CreateTranscriptions Transcribes audio into the input language. CreateTranscriptions(ctx context.Context, r CreateTranscriptionsRequest) (response CreateTranscriptionsResponse, err error) // CreateTranslations Translates audio into into English. CreateTranslations(ctx context.Context, r CreateTranslationsRequest) (response CreateTranslationsResponse, err error) // CreateModerations Classifies if text violates OpenAI's Content Policy CreateModerations(ctx context.Context, r CreateModerationsRequest) (response CreateModerationsResponse, err error) }
ClientInterface is the interface for the OpenAI API client. Documentation at https://platform.openai.com/docs/api-reference/introduction
type CompletionFunciton ¶ added in v1.0.0
type CreateChatCompletionsChoice ¶ added in v1.0.0
type CreateChatCompletionsRequest ¶ added in v1.0.0
type CreateChatCompletionsRequest struct { Model string `json:"model,omitempty"` Messages []Message `json:"messages,omitempty"` Functions []CompletionFunciton `json:"functions,omitempty"` FunctionCall *string `json:"function_call,omitempty"` Temperature float64 `json:"temperature,omitempty"` TopP float64 `json:"top_p,omitempty"` N int `json:"n,omitempty"` Stream bool `json:"stream,omitempty"` Stop StrArray `json:"stop,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` PresencePenalty float64 `json:"presence_penalty,omitempty"` FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` LogitBias map[string]string `json:"logit_bias,omitempty"` User string `json:"user,omitempty"` ResponseFormat ResponseFormat `json:"response_format,omitempty"` Seed int `json:"seed,omitempty"` }
type CreateChatCompletionsResponse ¶ added in v1.0.0
type CreateChatCompletionsResponse struct { ID string `json:"id,omitempty"` Object string `json:"object,omitempty"` Created int `json:"created,omitempty"` Model string `json:"model,omitempty"` Choices []CreateChatCompletionsChoice `json:"choices,omitempty"` Usage CreateChatCompletionsUsave `json:"usage,omitempty"` SystemFingerprint string `json:"system_fingerprint,omitempty"` }
type CreateChatCompletionsUsave ¶ added in v1.0.0
type CreateEditsChoice ¶ added in v1.0.0
type CreateEditsRequest ¶
type CreateEditsResponse ¶
type CreateEditsResponse struct { Object string `json:"object,omitempty"` Created int `json:"created,omitempty"` Choices []CreateEditsChoice `json:"choices,omitempty"` Usage CreateEditsUsage `json:"usage,omitempty"` }
type CreateEditsUsage ¶ added in v1.0.0
type CreateEmbeddingsData ¶ added in v1.0.0
type CreateEmbeddingsRequest ¶
type CreateEmbeddingsResponse ¶
type CreateEmbeddingsResponse struct { Object string `json:"object,omitempty"` Data []CreateEmbeddingsData `json:"data,omitempty"` Model string `json:"model,omitempty"` Usage CreateEmbeddingsUsage `json:"usage,omitempty"` Error *Error `json:"error"` }
type CreateEmbeddingsUsage ¶ added in v1.0.0
type CreateImagesData ¶ added in v1.0.0
type CreateImagesData struct {
URL string `json:"url,omitempty"`
}
type CreateImagesEditsData ¶ added in v1.0.0
type CreateImagesEditsData struct {
URL string `json:"url,omitempty"`
}
type CreateImagesEditsRequest ¶
type CreateImagesEditsRequest struct { Image string `json:"image,omitempty"` Mask string `json:"mask,omitempty"` Prompt string `json:"prompt,omitempty"` N int `json:"n,omitempty"` Size string `json:"size,omitempty"` ResponseFormat string `json:"response_format,omitempty"` User string `json:"user,omitempty"` }
type CreateImagesEditsResponse ¶
type CreateImagesEditsResponse struct { Created int `json:"created,omitempty"` Data []CreateImagesEditsData `json:"data,omitempty"` }
type CreateImagesRequest ¶
type CreateImagesResponse ¶
type CreateImagesResponse struct { Created int `json:"created,omitempty"` Data []CreateImagesData `json:"data,omitempty"` }
type CreateImagesVariationsData ¶ added in v1.0.0
type CreateImagesVariationsData struct {
URL string `json:"url,omitempty"`
}
type CreateImagesVariationsResponse ¶
type CreateImagesVariationsResponse struct { Created int `json:"created,omitempty"` Data []CreateImagesVariationsData `json:"data,omitempty"` }
type CreateModerationsCategories ¶ added in v1.0.0
type CreateModerationsCategories struct { Hate bool `json:"hate,omitempty"` HateThreatening bool `json:"hate/threatening,omitempty"` SelfHarm bool `json:"self-harm,omitempty"` Sexual bool `json:"sexual,omitempty"` SexualMinors bool `json:"sexual/minors,omitempty"` Violence bool `json:"violence,omitempty"` ViolenceGraphic bool `json:"violence/graphic,omitempty"` }
type CreateModerationsCategoriesScores ¶ added in v1.0.0
type CreateModerationsCategoriesScores struct { Hate float64 `json:"hate,omitempty"` HateThreatening float64 `json:"hate/threatening,omitempty"` SelfHarm float64 `json:"self-harm,omitempty"` Sexual float64 `json:"sexual,omitempty"` SexualMinors float64 `json:"sexual/minors,omitempty"` Violence float64 `json:"violence,omitempty"` ViolenceGraphic float64 `json:"violence/graphic,omitempty"` }
type CreateModerationsResponse ¶
type CreateModerationsResponse struct { ID string `json:"id,omitempty"` Model string `json:"model,omitempty"` Results []CreateModerationsResult `json:"results,omitempty"` }
type CreateModerationsResult ¶ added in v1.0.0
type CreateModerationsResult struct { Categories CreateModerationsCategories `json:"categories,omitempty"` CategoryScores CreateModerationsCategoriesScores `json:"category_scores,omitempty"` Flagged bool `json:"flagged,omitempty"` }
type CreateTranscriptionsRequest ¶
type CreateTranscriptionsRequest struct { File string `json:"file,omitempty"` Model string `json:"model,omitempty"` Prompt string `json:"prompt,omitempty"` ResponseFormat string `json:"response_format,omitempty"` Temperature float64 `json:"temperature,omitempty"` Language string `json:"language,omitempty"` }
type CreateTranscriptionsResponse ¶
type CreateTranscriptionsResponse struct {
Text string `json:"text,omitempty"`
}
type CreateTranslationsResponse ¶
type CreateTranslationsResponse struct {
Text string `json:"text,omitempty"`
}
type Error ¶
type Error struct { Message string `json:"message,omitempty"` Type string `json:"type,omitempty"` Param interface{} `json:"param,omitempty"` Code interface{} `json:"code,omitempty"` }
Error is the error standard response from the API
type FunctionCall ¶ added in v1.0.0
type ListModelsData ¶ added in v1.0.0
type ListModelsResponse ¶ added in v0.3.0
type ListModelsResponse struct { Data []ListModelsData `json:"data,omitempty"` Object string `json:"object,omitempty"` }
type Message ¶
type Message struct { Role string `json:"role,omitempty"` Content string `json:"content,omitempty"` FunctionCall *FunctionCall `json:"function_call,omitempty"` }
Message is the message struct for the chat and completions endpoint
type ResponseFormat ¶ added in v1.1.0
type ResponseFormat struct {
Type string `json:"type"`
}
type RetrieveModelResponse ¶ added in v0.3.0
Source Files ¶
Click to show internal directories.
Click to hide internal directories.