UNPKG

daggerai

Version:

A simple and powerful Typescript based agent framework to help businesses thrive in the AI Agent revolution.

40 lines 1.65 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PerplexityTool = void 0; const openai_1 = __importDefault(require("openai")); const zod_1 = require("zod"); class PerplexityTool { code = 'perplexity'; name = 'Perplexity Search'; description = 'Use this tool when you have questions about any subject that could be searched on the internet.'; schema = zod_1.z.object({ query: zod_1.z.string(), }); async execute(input) { const api = new openai_1.default({ apiKey: process.env.PERPLEXITY_API_KEY, baseURL: 'https://api.perplexity.ai', }); const response = await api.chat.completions.create({ model: 'llama-3-8b-instruct', messages: [ { role: 'system', content: 'You are an artificial intelligence assistant and you need to responde to the user query in a helpful, detailed way, using a language that is easy to understand to another AI. DO NOT add any preamble. DO NOT add greetings. DO NOT add redundant explantions. You just respond to the user query.', }, { role: 'user', content: input.query, }, ], }); return { text: response.choices[0]?.message.content || 'No response from the model.', }; } } exports.PerplexityTool = PerplexityTool; //# sourceMappingURL=perplexity.js.map