Documentation ¶
Index ¶
- Constants
- type Client
- type CompletionRequest
- type CompletionResponse
- func (cr CompletionResponse) Choices() map[string]any
- func (cr CompletionResponse) Created() time.Time
- func (cr CompletionResponse) Id() string
- func (cr CompletionResponse) Model() string
- func (cr CompletionResponse) Object() string
- func (cr CompletionResponse) Text() string
- func (cr CompletionResponse) Usage() map[string]any
- type ImageRequest
- type ImageResponse
Constants ¶
const ( COMPLETIONS_URL = "https://api.openai.com/v1/completions" IMAGE_URL = "https://api.openai.com/v1/images" EDITS_URL = "https://api.openai.com/v1/edits" MODELS_URL = "https://api.openai.com/v1/models" EMBEDDINGS_URL = "https://api.openai.com/v1/embeddings" FILES_URL = "https://api.openai.com/v1/files" FINETUNES_URL = "https://api.openai.com/v1/finetunes" MODERATIONS_URL = "https://api.openai.com/v1/moderations" TEXT_GPT_35_TURBO = "gpt-3.5-turbo" TEXT_DAVINCI_003 = "text-davinci-003" TEXT_DAVINCI_002 = "text-davinci-002" TEXT_CURIE_001 = "text-curie-001" TEXT_BABBAGE_001 = "text-babbage-001" TEXT_ADA_001 = "text-ada-001" CODE_DAVINCI_002 = "code-davinci-002" CODE_CUSHMAN_001 = "code-cushman-001" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func (*Client) Complete ¶
func (c *Client) Complete(request CompletionRequest) (response CompletionResponse, err error)
func (*Client) GenerateImage ¶
func (c *Client) GenerateImage(request ImageRequest) (response ImageResponse, err error)
type CompletionRequest ¶
CompletionRequest is the request to send to the OpenAI API for completion The 2 required fields are prompt and model You should also set the user to the actual end-user that is sending the request
func (CompletionRequest) SetModel ¶
func (c CompletionRequest) SetModel(model string)
func (CompletionRequest) SetPrompt ¶
func (c CompletionRequest) SetPrompt(prompt string)
func (CompletionRequest) SetUser ¶
func (c CompletionRequest) SetUser(user string)
User is unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse. You should set the user to the actual end-user that is sending the request OpenAI has since changed their policy to not require a user
type CompletionResponse ¶
func (CompletionResponse) Choices ¶
func (cr CompletionResponse) Choices() map[string]any
func (CompletionResponse) Created ¶
func (cr CompletionResponse) Created() time.Time
func (CompletionResponse) Id ¶
func (cr CompletionResponse) Id() string
func (CompletionResponse) Model ¶
func (cr CompletionResponse) Model() string
func (CompletionResponse) Object ¶
func (cr CompletionResponse) Object() string
func (CompletionResponse) Text ¶
func (cr CompletionResponse) Text() string
func (CompletionResponse) Usage ¶
func (cr CompletionResponse) Usage() map[string]any
type ImageRequest ¶
ImageRequest is the request to send to the OpenAI API for image generation The only required field is the prompt You should also set the user to the actual end-user that is sending the request
func (ImageRequest) SetFormat ¶
func (c ImageRequest) SetFormat(format string)
func (ImageRequest) SetN ¶
func (c ImageRequest) SetN(n string)
func (ImageRequest) SetPrompt ¶
func (c ImageRequest) SetPrompt(prompt string)
func (ImageRequest) SetSize ¶
func (c ImageRequest) SetSize(size string)
func (ImageRequest) SetUser ¶
func (c ImageRequest) SetUser(user string)
User is unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse. You should set the user to the actual end-user that is sending the request
type ImageResponse ¶
func (ImageResponse) Created ¶
func (cr ImageResponse) Created() time.Time
func (ImageResponse) ImageBase64 ¶
func (cr ImageResponse) ImageBase64() string
func (ImageResponse) URL ¶
func (cr ImageResponse) URL() string