Documentation
¶
Index ¶
- Constants
- type Choice
- type Client
- func (s *Client) CreateCompletion(messages []Message) (*CompletionResponse, error)
- func (s *Client) GetHTTPTimeout() time.Duration
- func (s *Client) GetModel() string
- func (s *Client) SetEndpoint(endpoint string)
- func (s *Client) SetHTTPClient(httpClient *http.Client)
- func (s *Client) SetHTTPTimeout(timeout time.Duration)
- func (s *Client) SetModuleLlama31SonarHuge128kOnline()
- func (s *Client) SetModuleLlama31SonarLarge128kOnline()
- func (s *Client) SetModuleLlama31SonarSmall128kOnline()
- type CompletionRequest
- type CompletionResponse
- type Message
- type Usage
Constants ¶
const DefaultEndpoint = "https://api.perplexity.ai/chat/completions"
const DefautTimeout = 10 * time.Second
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Choice ¶
type Choice struct { Index int `json:"index"` FinishReason string `json:"finish_reason"` Message Message `json:"message"` Delta Message `json:"delta"` }
Choice is a choice object for the Perplexity API.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for the Perplexity API.
func NewClient ¶
NewClient creates a new Perplexity API client. The apiKey is the API key to use for authentication. The default model is llama-3-sonar-small-32k-online.
func (*Client) CreateCompletion ¶
func (s *Client) CreateCompletion(messages []Message) (*CompletionResponse, error)
CreateCompletion sends simple text to the Perplexity API and retrieve the response.
func (*Client) GetHTTPTimeout ¶ added in v0.2.0
GetHTTPTimeout sets the HTTP timeout.
func (*Client) SetEndpoint ¶
SetEndpoint sets the API endpoint.
func (*Client) SetHTTPClient ¶
SetHTTPClient sets the HTTP client.
func (*Client) SetHTTPTimeout ¶ added in v0.2.0
SetHTTPTimeout sets the HTTP timeout.
func (*Client) SetModuleLlama31SonarHuge128kOnline ¶ added in v1.1.0
func (s *Client) SetModuleLlama31SonarHuge128kOnline()
SetModuleLlama31SonarHuge128kChat sets the model to llama-3.1-sonar-huge-128k-online.
func (*Client) SetModuleLlama31SonarLarge128kOnline ¶ added in v1.0.0
func (s *Client) SetModuleLlama31SonarLarge128kOnline()
SetModuleLlama31SonarLarge128kChat sets the model to llama-3.1-sonar-large-128k-online.
func (*Client) SetModuleLlama31SonarSmall128kOnline ¶ added in v1.0.0
func (s *Client) SetModuleLlama31SonarSmall128kOnline()
SetModuleLlama31SonarSmall128kOnline sets the model to llama-3.1-sonar-small-128k-online.
type CompletionRequest ¶
CompletionRequest is a request object for the Perplexity API.
type CompletionResponse ¶
type CompletionResponse struct { ID string `json:"id"` Model string `json:"model"` Created int `json:"created"` Usage Usage `json:"usage"` Object string `json:"object"` Choices []Choice `json:"choices"` }
CompletionResponse is a response object for the Perplexity API.
func (*CompletionResponse) GetLastContent ¶
func (r *CompletionResponse) GetLastContent() string
func (*CompletionResponse) String ¶
func (r *CompletionResponse) String() string