Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Perplexity AI Search Tool to Marketplaces/Tools #2771

Merged

Conversation

AsharibAli
Copy link
Contributor

This pull request adds a new tool named perplexity_ai_search to the marketplaces/tools directory. The tool utilizes the Perplexity AI online model for conducting research. The tool is built using the Langchain framework and includes the necessary configurations and a function to interact with the Perplexity AI API.

Code Added:

{
    "name": "perplexity_ai_search",
    "framework": "Langchain",
    "description": "Useful when conducting research using Perplexity AI online model.",
    "color": "linear-gradient(rgb(155,190,84), rgb(176,69,245))",
    "iconSrc": "https://raw.githubusercontent.com/AsharibAli/project-images/main/perplexity-ai-icon.svg",
    "schema": "[{\"id\":1,\"property\":\"query\",\"description\":\"Query for research\",\"type\":\"string\",\"required\":true}]",
    "func": "const fetch = require('node-fetch');\nconst apiKey = 'YOUR_PERPLEXITY_API_KEY';  // Put Your Perplexity AI API key here\n\nconst query = $query;\n\nconst options = {\n\tmethod: 'POST',\n\theaders: {\n\t\t'Content-Type': 'application/json',\n\t\t'Authorization': 'Bearer <YOUR_PERPLEXITY_API_KEY>'\n\t},\n\tbody: JSON.stringify({\n\t\tmodel: 'llama-3-sonar-small-32k-online',  // Model\n\t\tmessages: [\n\t\t\t{\n\t\t\t\trole: 'system',\n\t\t\t\tcontent: 'You are a research assistant.'\n\t\t\t},\n\t\t\t{\n\t\t\t\trole: 'user',\n\t\t\t\tcontent: query\n\t\t\t}\n\t\t]\n\t})\n};\n\ntry {\n\tconst response = await fetch('https://api.perplexity.ai/chat/completions', options);\n\tconst data = await response.json();\n\treturn JSON.stringify(data);\n} catch (error) {\n\tconsole.error(error);\n\treturn 'Error occurred while fetching data from Perplexity AI';\n}\n\n// For more details: https://docs.perplexity.ai/docs/getting-started"
}

For more details about the Perplexity API: Perplexity API Getting Started Guide.

LeadUp Guru on Flowise Discord: Orignal Tool

@HenryHengZJ HenryHengZJ merged commit 9ea439d into FlowiseAI:main Jul 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants