@agentek/tools
Version:
Blockchain tools for AI agents
60 lines • 2.28 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAskPerplexitySearchTool = createAskPerplexitySearchTool;
const zod_1 = __importDefault(require("zod"));
const client_js_1 = require("../client.js");
function createAskPerplexitySearchTool(perplexityApiKey) {
return (0, client_js_1.createTool)({
name: "askPerplexitySearch",
description: "Ask perplexity search",
supportedChains: [],
parameters: zod_1.default.object({
searchString: zod_1.default.string(),
}),
execute: async (_client, args) => {
const options = {
method: "POST",
headers: {
Authorization: `Bearer ${perplexityApiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "sonar",
messages: [
{
role: "system",
content: "Be precise and concise.",
},
{
role: "user",
content: args.searchString,
},
],
temperature: 0.2,
top_p: 0.9,
search_domain_filter: [],
return_images: false,
return_related_questions: false,
search_recency_filter: "month",
top_k: 0,
stream: false,
presence_penalty: 0,
frequency_penalty: 1,
response_format: null,
}),
};
try {
const response = await fetch("https://api.perplexity.ai/chat/completions", options);
const result = await response.json();
return result;
}
catch (err) {
throw new Error(`Perplexity API Error: ${err}`);
}
},
});
}
//# sourceMappingURL=tools.js.map