newPerplexityProvider creates a new Perplexity provider
(model string, opts Options)
| 23 | |
| 24 | // newPerplexityProvider creates a new Perplexity provider |
| 25 | func 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 |
| 43 | func (p *perplexityProvider) chat(ctx context.Context, prompt string, opts Options) (*Response, error) { |
nothing calls this directly
no outgoing calls
no test coverage detected