MCPcopy Create free account
hub / github.com/dariubs/goAI / newPerplexityProvider

Function newPerplexityProvider

perplexity.go:25–40  ·  view source on GitHub ↗

newPerplexityProvider creates a new Perplexity provider

(model string, opts Options)

Source from the content-addressed store, hash-verified

23
24// newPerplexityProvider creates a new Perplexity provider
25func newPerplexityProvider(model string, opts Options) (Provider, error) {
26 if opts.APIKey == "" {
27 return nil, fmt.Errorf("%w: perplexity", ErrNoAPIKey)
28 }
29
30 endpoint := opts.Endpoint
31 if endpoint == "" {
32 endpoint = "https://api.perplexity.ai/chat/completions"
33 }
34
35 return &perplexityProvider{
36 apiKey: opts.APIKey,
37 modelID: model,
38 apiEndpoint: endpoint,
39 }, nil
40}
41
42// chat sends a prompt to Perplexity and returns the response
43func (p *perplexityProvider) chat(ctx context.Context, prompt string, opts Options) (*Response, error) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected