Skip to content

belabdesmd/genkitx-perplexity-sonar

Repository files navigation

Firebase Genkit + Anthropic AI

Firebase Genkit <> Sonar AI Plugin

Perplexity's Sonar API Community Plugin for Google Firebase Genkit

npm version NPM Downloads GitHub Org's stars GitHub License Static Badge
GitHub Issues or Pull Requests GitHub Issues or Pull Requests GitHub commit activity

genkitx-perplexity-sonar is a community plugin for using Perplexity's Sonar API and all its supported models with Firebase Genkit.

This Genkit plugin allows to use Perplexity's Sonar API models through their official APIs.

Supported models

The plugin supports the most recent Sonar models: sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro, and sonar-deep-research.

Installation

Install the plugin in your project with your favorite package manager:

  • npm install
  • yarn add

Usage

Initialize

import { genkit } from 'genkit';
import { perplexitySonar, sonar } from '';

const ai = genkit({
  plugins: [perplexitySonar({ apiKey: process.env.PERPLEXITY_SONAR_API_KEY })],
});

Basic examples

The simplest way to generate text is by using the generate method:

const response = await ai.generate({
  model: sonar, // model imported from 
  prompt: 'Tell me a joke.',
});

console.log(response.text);

Configurations

You can check the official documentations Here for more details about the API.

const response = await ai.generate({
    model: sonar, // model imported from 
    prompt: 'Tell me a joke.',
    config: {
        // check https://docs.perplexity.ai/guides/search-domain-filters for more details
        allowed_search_domain_filter: ["https://www.domain1.com", "domain2.com"], // allowed domain names, https:// and www are removed automatically
        denied_search_domain_filter: ["domain3.con", "domain4.com"], // denied list, it will automatically add - before the domain name
        // check https://docs.perplexity.ai/guides/date-range-filter-guide for more details
        search_before_date_filter: new Date(),
        search_after_date_filter: new Date(),
        search_recency_filter: "month",
        // check https://docs.perplexity.ai/guides/search-context-size-guide for more details
        search_context_size: "low",
        // check https://docs.perplexity.ai/guides/user-location-filter-guide for more etails
        user_location: {
            country: "DZ",
            latitude: 12.2,
            longitude: 12.2,
        },
        // other configurarions
        results_with_images: false,
        results_with_related_questions: false,
    }
});

Contributing

Want to contribute to the project? That's awesome! Head over to our Contribution Guidelines.

Need support?

Note

This repository depends on Google's Firebase Genkit. For issues and questions related to Genkit, please refer to instructions available in Genkit's repository.

Reach out by opening a discussion on Github Discussions.

License

This project is licensed under the Apache 2.0 License.

About

genkitx-perplexity-sonar is a community plugin for using Perplexity's Sonar API and all its supported models with Firebase Genkit.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors