Documentation
¶
Index ¶
- type AnswerRequest
- type AnswerResponse
- type Choice
- type Client
- func (c *Client) Answers(ctx context.Context, request AnswerRequest) (response AnswerResponse, err error)
- func (c *Client) CreateCompletion(ctx context.Context, engineID string, request CompletionRequest) (response CompletionResponse, err error)
- func (c *Client) CreateFile(ctx context.Context, request FileRequest) (file File, err error)
- func (c *Client) DeleteFile(ctx context.Context, fileID string) (err error)
- func (c *Client) GetEngine(ctx context.Context, engineID string) (engine Engine, err error)
- func (c *Client) GetFile(ctx context.Context, fileID string) (file File, err error)
- func (c *Client) ListEngines(ctx context.Context) (engines EnginesList, err error)
- func (c *Client) ListFiles(ctx context.Context) (files FilesList, err error)
- func (c *Client) Search(ctx context.Context, engineID string, request SearchRequest) (response SearchResponse, err error)
- type CompletionRequest
- type CompletionResponse
- type Engine
- type EnginesList
- type ErrorResponse
- type File
- type FileRequest
- type FilesList
- type LogprobResult
- type SearchRequest
- type SearchResponse
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnswerRequest ¶
type AnswerRequest struct { Documents []*string `json:"documents,omitempty"` Examples [][]string `json:"examples"` ExamplesContext string `json:"examples_context"` Expand *bool `json:"expand,omitempty"` File *string `json:"file,omitempty"` LogProbs *int `json:"logprobs,omitempty"` MaxRerank *int `json:"max_rerank,omitempty"` MaxTokens *int `json:"max_tokens,omitempty"` Model string `json:"model"` N *int `json:"n,omitempty"` Question string `json:"question"` ReturnMetadata *bool `json:"return_metadata,omitempty"` ReturnPrompt *bool `json:"return_prompt,omitempty"` SearchModel *string `json:"search_model,omitempty"` Stop []*string `json:"stop,omitempty"` Temperature *float64 `json:"temperature,omitempty"` UserID *string `json:"user,omitempty"` }
type AnswerResponse ¶
type AnswerResponse struct { Answers []string `json:"answers"` Completion string `json:"completion"` Model string `json:"model"` Object string `json:"object"` Prompt *string `json:"prompt,omitempty"` SearchModel string `json:"search_model"` SelectedDocuments []struct { Document int `json:"document"` Metadata *string `json:"metadata,omitempty"` Score float64 `json:"score"` Text string `json:"text"` } `json:"selected_documents"` }
type Choice ¶
type Choice struct { Text string `json:"text"` Index int `json:"index"` FinishReason string `json:"finish_reason"` LogProbs LogprobResult `json:"logprobs"` }
Choice represents one of possible completions
type Client ¶
type Client struct { BaseURL string HTTPClient *http.Client // contains filtered or unexported fields }
Client is OpenAI GPT-3 API client
func NewOrgClient ¶
NewOrgClient creates new OpenAI API client for specified Organization ID
func (*Client) Answers ¶
func (c *Client) Answers(ctx context.Context, request AnswerRequest) (response AnswerResponse, err error)
Search — perform a semantic search api call over a list of documents.
func (*Client) CreateCompletion ¶
func (c *Client) CreateCompletion(ctx context.Context, engineID string, request CompletionRequest) (response CompletionResponse, err error)
CreateCompletion — API call to create a completion. This is the main endpoint of the API. Returns new text as well as, if requested, the probabilities over each alternative token at each position.
func (*Client) CreateFile ¶
CreateFile uploads a jsonl file to GPT3 FilePath can be either a local file path or a URL
func (*Client) DeleteFile ¶
DeleteFile deletes an existing file
func (*Client) GetEngine ¶
GetEngine Retrieves an engine instance, providing basic information about the engine such as the owner and availability.
func (*Client) GetFile ¶
GetFile Retrieves a file instance, providing basic information about the file such as the file name and purpose.
func (*Client) ListEngines ¶
func (c *Client) ListEngines(ctx context.Context) (engines EnginesList, err error)
ListEngines Lists the currently available engines, and provides basic information about each option such as the owner and availability.
func (*Client) ListFiles ¶
ListFiles Lists the currently available files, and provides basic information about each file such as the file name and purpose.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, engineID string, request SearchRequest) (response SearchResponse, err error)
Search — perform a semantic search api call over a list of documents.
type CompletionRequest ¶
type CompletionRequest struct { Prompt string `json:"prompt,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` N int `json:"n,omitempty"` LogProbs int `json:"logprobs,omitempty"` Model *string `json:"model,omitempty"` Echo bool `json:"echo,omitempty"` Stop []string `json:"stop,omitempty"` PresencePenalty float32 `json:"presence_penalty,omitempty"` FrequencyPenalty float32 `json:"frequency_penalty,omitempty"` BestOf int `json:"best_of,omitempty"` UserID *string `json:"user,omitempty"` }
CompletionRequest represents a request structure for completion API
type CompletionResponse ¶
type CompletionResponse struct { ID string `json:"id"` Object string `json:"object"` Created uint64 `json:"created"` Model string `json:"model"` Choices []Choice `json:"choices"` }
CompletionResponse represents a response structure for completion API
type Engine ¶
type Engine struct { ID string `json:"id"` Object string `json:"object"` Owner string `json:"owner"` Ready bool `json:"ready"` }
Engine struct represents engine from OpenAPI API
type EnginesList ¶
type EnginesList struct {
Engines []Engine `json:"data"`
}
EnginesList is a list of engines
type ErrorResponse ¶
type File ¶
type File struct { Bytes int `json:"bytes"` CreatedAt int `json:"created_at"` ID string `json:"id"` FileName string `json:"filename"` Object string `json:"object"` Owner string `json:"owner"` Purpose string `json:"purpose"` }
File struct represents an OpenAPI file
type FileRequest ¶
type FilesList ¶
type FilesList struct {
Files []File `json:"data"`
}
FilesList is a list of files that belong to the user or organization
type LogprobResult ¶
type LogprobResult struct { Tokens []string `json:"tokens"` TokenLogprobs []float32 `json:"token_logprobs"` TopLogprobs []map[string]float32 `json:"top_logprobs"` TextOffset []int `json:"text_offset"` }
LogprobResult represents logprob result of Choice
type SearchRequest ¶
type SearchRequest struct { Documents []*string `json:"documents,omitempty"` File *string `json:"file,omitempty"` MaxRerank *int `json:"max_rerank,omitempty"` Query string `json:"query"` ReturnMetadata *bool `json:"return_metadata,omitempty"` UserID *string `json:"user,omitempty"` }
SearchRequest represents a request structure for search API
type SearchResponse ¶
type SearchResponse struct {
SearchResults []SearchResult `json:"data"`
}
SearchResponse represents a response structure for search API