Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultModel = "sonar-pro"
DefaultModel is the default model for the Perplexity API.
View Source
const DefaultTimeout = 30 * time.Second
DefaultTimeout is the default timeout for the Perplexity API.
View Source
const DefaultURL = "https://api.perplexity.ai/chat/completions"
DefaultURL is the default endpoint for the Perplexity API.
Variables ¶
View Source
var Transformer = func(e Event) (*prompts.ChatCompletionResponse, error) { resp := &prompts.ChatCompletionResponse{} if err := json.Unmarshal(e.Data, &resp); err != nil { return nil, err } return resp, nil }
Transformer is a function that transforms an event into a response.
Functions ¶
Types ¶
type Event ¶
type Event struct { // Type is the type of the event. Type string `json:"type"` // Data is the data of the event. Data []byte `json:"data"` }
Event is the structure of the event received from the server.
type Opts ¶
type Opts struct { // BaseURL is the base URL. BaseURL string `json:"base_url"` // ApiKey is the API key. ApiKey string `json:"api_key"` // Timeout is the timeout. Timeout time.Duration `json:"timeout"` // Client is the HTTP client. Client *http.Client `json:"-"` }
Opts ...
type Perplexity ¶
type Perplexity struct {
// contains filtered or unexported fields
}
Perplexity is a chat model.
func (*Perplexity) SendCompletionRequest ¶
func (p *Perplexity) SendCompletionRequest(ctx context.Context, req *prompts.ChatCompletionRequest) (*prompts.ChatCompletionResponse, error)
SendCompletionRequest sends a completion request to the Perplexity API.
func (*Perplexity) SendStreamCompletionRequest ¶
func (p *Perplexity) SendStreamCompletionRequest(ctx context.Context, req *prompts.ChatCompletionRequest, cb ...func(res *prompts.ChatCompletionResponse) error) error
SendStreamCompletionRequest sends a streamed completion request to the Perplexity API. nolint:gocyclo
Click to show internal directories.
Click to hide internal directories.