Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(perplexity-ai): let AI agents run agent responses, web search, skills and batches (#17047)

Kishan Parmarfbb0448cbdb7
diff --git a/bun.lock b/bun.lock
index f1d59d02339..078e03d7094 100644
--- a/bun.lock
+++ b/bun.lock
@@ -7098,12 +7098,13 @@
},
"packages/pieces/community/perplexity-ai": {
"name": "@activepieces/piece-perplexity-ai",
- "version": "0.5.0",
+ "version": "0.6.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
"@activepieces/pieces-common": "workspace:*",
"@activepieces/pieces-framework": "workspace:*",
+ "form-data": "4.0.6",
"zod": "4.3.6",
},
"devDependencies": {
diff --git a/packages/pieces/community/perplexity-ai/package.json b/packages/pieces/community/perplexity-ai/package.json
index fed4a64ffc4..e01a83eb958 100644
--- a/packages/pieces/community/perplexity-ai/package.json
+++ b/packages/pieces/community/perplexity-ai/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-perplexity-ai",
- "version": "0.5.0",
+ "version": "0.6.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
@@ -14,7 +14,8 @@
"@activepieces/pieces-framework": "workspace:*",
"zod": "4.3.6",
"@activepieces/core-piece-types": "workspace:*",
- "@activepieces/core-utils": "workspace:*"
+ "@activepieces/core-utils": "workspace:*",
+ "form-data": "4.0.6"
},
"devDependencies": {
"tslib": "2.6.2",
diff --git a/packages/pieces/community/perplexity-ai/src/index.ts b/packages/pieces/community/perplexity-ai/src/index.ts
index 9d91a36566a..9f4012a4999 100644
--- a/packages/pieces/community/perplexity-ai/src/index.ts
+++ b/packages/pieces/community/perplexity-ai/src/index.ts
@@ -1,7 +1,8 @@
-import { createPiece, PieceAuth } from '@activepieces/pieces-framework';
+import { createPiece } from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/pieces-framework';
-import { createChatCompletionAction } from './lib/actions/create-chat-completion.action';
+import { createChatCompletionAction } from './lib/actions/create-chat-completion';
import { perplexityAiAuth } from './lib/auth';
+import { perplexityAiAiActions } from './lib/actions/ai';
export const perplexityAi = createPiece({
displayName: 'Perplexity AI',
@@ -10,7 +11,7 @@ export const perplexityAi = createPiece({
logoUrl: 'https://cdn.activepieces.com/pieces/perplexity-ai.png',
categories: [PieceCategory.ARTIFICIAL_INTELLIGENCE],
description: 'AI powered search engine',
- authors: ['kishanprmr','AbdulTheActivePiecer'],
- actions: [createChatCompletionAction],
+ authors: ['kishanprmr', 'AbdulTheActivePiecer'],
+ actions: [createChatCompletionAction, ...perplexityAiAiActions],
triggers: [],
});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/cancel-agent-response.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/cancel-agent-response.ts
new file mode 100644
index 00000000000..22d67d0bdf4
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/cancel-agent-response.ts
@@ -0,0 +1,39 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiCancelAgentResponseOutputSchema } from '../../../output-schemas';
+
+export const cancelAgentResponseAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_cancel_agent_response',
+ outputSchema: perplexityAiCancelAgentResponseOutputSchema,
+ displayName: 'Cancel Agent Response',
+ description: 'Request cancellation of a running Agent API response.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Asks Perplexity to stop a queued or running Agent API response, typically a background one from Create Agent Response. Returns status "cancelling" at once; the run stops shortly after, so poll Get Agent Response for the final status. Work already done is still billed.',
+ idempotent: true,
+ },
+ props: {
+ responseId: Property.ShortText({
+ displayName: 'Response ID',
+ description: 'Response id ("resp_..."), from Create Agent Response.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await perplexityAiClient.request<{
+ response_id: string;
+ status: string;
+ }>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/v1/agent/${encodeURIComponent(
+ context.propsValue.responseId
+ )}/cancel`,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/create-agent-response.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/create-agent-response.ts
new file mode 100644
index 00000000000..c576590e99e
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/create-agent-response.ts
@@ -0,0 +1,194 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import type { PerplexityAiAgentResponse } from '../../../common/types';
+import { perplexityAiCreateAgentResponseOutputSchema } from '../../../output-schemas';
+
+const REASONING_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
+
+export const createAgentResponseAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_create_agent_response',
+ outputSchema: perplexityAiCreateAgentResponseOutputSchema,
+ displayName: 'Create Agent Response',
+ description:
+ 'Generate a response with the Perplexity Agent API, optionally using web search and other tools.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Runs one Agent API request: a model (or fallback chain, or a preset effort level) answers the input, calling any tools given (web_search, fetch_url, finance_search and others) and returns the completed response with its id, output items and token usage. Set at least one of Model, Models or Effort; use List Models for model ids. Anthropic models need Max Output Tokens. With Background set, it returns at once with status "queued": poll it with Get Agent Response and stop it with Cancel Agent Response. Pass a completed response id as Previous Response ID to continue a conversation. Not idempotent: every call runs and bills a new response.',
+ idempotent: false,
+ },
+ props: {
+ input: Property.LongText({
+ displayName: 'Input',
+ description: 'The question or task for the model.',
+ required: true,
+ }),
+ model: Property.ShortText({
+ displayName: 'Model',
+ description:
+ 'Model id in provider/model form, e.g. "openai/gpt-6-luna" or "perplexity/sonar". Use List Models for the available ids. Set this, Models or Effort.',
+ required: false,
+ }),
+ models: Property.Array({
+ displayName: 'Models',
+ description:
+ 'Fallback chain of up to 5 model ids, tried in order until one succeeds. Takes precedence over Model.',
+ required: false,
+ }),
+ effort: Property.ShortText({
+ displayName: 'Effort',
+ description:
+ 'Preset effort level that picks the model, system prompt and search settings, e.g. "fast", "low", "medium" or "high", optionally pinned as "name@<version>". Cannot be combined with Profile.',
+ required: false,
+ }),
+ profile: Property.ShortText({
+ displayName: 'Profile',
+ description:
+ 'Saved, versioned configuration to run with. Cannot be combined with Effort.',
+ required: false,
+ }),
+ instructions: Property.LongText({
+ displayName: 'Instructions',
+ description: 'System instructions for the model.',
+ required: false,
+ }),
+ tools: Property.Json({
+ displayName: 'Tools',
+ description:
+ 'Array of tools the model may call, each an object with a "type": web_search, image_search, finance_search, people_search, fetch_url, function, sandbox, mcp or connector, e.g. [{"type":"web_search"}]. Each tool call is billed. Omit for no tools.',
+ required: false,
+ }),
+ toolChoice: Property.Json({
+ displayName: 'Tool Choice',
+ description:
+ 'Tool choice strategy, e.g. {"type":"image_search"} to force image search.',
+ required: false,
+ }),
+ skills: Property.Json({
+ displayName: 'Skills',
+ description:
+ 'Array of skills available to the model, e.g. [{"type":"custom","name":"<skill name>"}] for a skill from List Skills. Selecting any skill enables the billed sandbox tool.',
+ required: false,
+ }),
+ previousResponseId: Property.ShortText({
+ displayName: 'Previous Response ID',
+ description:
+ 'Id of a completed response from this action or Get Agent Response, to continue that conversation.',
+ required: false,
+ }),
+ maxOutputTokens: Property.Number({
+ displayName: 'Max Output Tokens',
+ description:
+ 'Maximum tokens to generate. Required for anthropic/* models.',
+ required: false,
+ }),
+ maxSteps: Property.Number({
+ displayName: 'Max Steps',
+ description:
+ "Maximum research loop steps. Defaults to 1 for a direct model, or the effort level's own value.",
+ required: false,
+ }),
+ reasoningEffort: Property.StaticDropdown({
+ displayName: 'Reasoning Effort',
+ description:
+ 'How much the model reasons before answering, for models that support it.',
+ required: false,
+ options: {
+ disabled: false,
+ options: REASONING_EFFORTS.map((value) => ({ label: value, value })),
+ },
+ }),
+ responseFormat: Property.Json({
+ displayName: 'Response Format',
+ description:
+ 'Desired output format, e.g. {"type":"json_schema","json_schema":{"name":"answer","schema":{...}}}.',
+ required: false,
+ }),
+ languagePreference: Property.ShortText({
+ displayName: 'Language',
+ description: 'ISO 639-1 code of the language to answer in, e.g. "en".',
+ required: false,
+ }),
+ temperature: Property.Number({
+ displayName: 'Temperature',
+ description: 'Sampling temperature.',
+ required: false,
+ }),
+ topP: Property.Number({
+ displayName: 'Top P',
+ description: 'Nucleus sampling parameter.',
+ required: false,
+ }),
+ background: Property.StaticDropdown({
+ displayName: 'Background',
+ description:
+ '"true" returns at once with status "queued"; poll with Get Agent Response. Defaults to "false", which waits for the answer.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'true', value: 'true' },
+ { label: 'false', value: 'false' },
+ ],
+ },
+ }),
+ store: Property.StaticDropdown({
+ displayName: 'Store',
+ description:
+ '"false" hides the response from Get Agent Response. Defaults to "true".',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'true', value: 'true' },
+ { label: 'false', value: 'false' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ return await perplexityAiClient.request<PerplexityAiAgentResponse>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/v1/agent',
+ body: {
+ input: p.input,
+ model: p.model,
+ models: p.models && p.models.length > 0 ? p.models : undefined,
+ effort: p.effort,
+ profile: p.profile,
+ instructions: p.instructions,
+ tools: p.tools,
+ tool_choice: p.toolChoice,
+ skills: p.skills,
+ previous_response_id: p.previousResponseId,
+ max_output_tokens: p.maxOutputTokens,
+ max_steps: p.maxSteps,
+ reasoning:
+ p.reasoningEffort === undefined
+ ? undefined
+ : { effort: p.reasoningEffort },
+ response_format: p.responseFormat,
+ language_preference: p.languagePreference,
+ temperature: p.temperature,
+ top_p: p.topP,
+ background: toBoolean({ value: p.background }),
+ store: toBoolean({ value: p.store }),
+ stream: false,
+ },
+ });
+ },
+});
+
+function toBoolean({
+ value,
+}: {
+ value: string | undefined;
+}): boolean | undefined {
+ return value === undefined ? undefined : value === 'true';
+}
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/download-agent-response-file.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/download-agent-response-file.ts
new file mode 100644
index 00000000000..f37af2ebd20
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/download-agent-response-file.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiDownloadAgentResponseFileOutputSchema } from '../../../output-schemas';
+
+export const downloadAgentResponseFileAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_download_agent_response_file',
+ outputSchema: perplexityAiDownloadAgentResponseFileOutputSchema,
+ displayName: 'Download Agent Response File',
+ description: 'Download a file an Agent API response produced.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Downloads one file an Agent API response delivered with the share_file tool and returns it as a file reference. Get the file id and name from List Agent Response Files.',
+ idempotent: true,
+ },
+ props: {
+ responseId: Property.ShortText({
+ displayName: 'Response ID',
+ description: 'Response id ("resp_..."), from Create Agent Response.',
+ required: true,
+ }),
+ fileId: Property.ShortText({
+ displayName: 'File ID',
+ description: 'File id from List Agent Response Files.',
+ required: true,
+ }),
+ fileName: Property.ShortText({
+ displayName: 'File Name',
+ description:
+ 'Name to save the file as, e.g. the filename from List Agent Response Files. Defaults to the file id.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { responseId, fileId, fileName } = context.propsValue;
+ const data = await perplexityAiClient.download({
+ auth: context.auth,
+ path: `/v1/agent/${encodeURIComponent(
+ responseId
+ )}/files/${encodeURIComponent(fileId)}/content`,
+ });
+ const name = fileName ?? fileId;
+ const file = await context.files.write({ fileName: name, data });
+ return { file, file_name: name, size: data.length };
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/get-agent-response.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/get-agent-response.ts
new file mode 100644
index 00000000000..c39ff6e58ec
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/get-agent-response.ts
@@ -0,0 +1,35 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import type { PerplexityAiAgentResponse } from '../../../common/types';
+import { perplexityAiCreateAgentResponseOutputSchema } from '../../../output-schemas';
+
+export const getAgentResponseAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_get_agent_response',
+ outputSchema: perplexityAiCreateAgentResponseOutputSchema,
+ displayName: 'Get Agent Response',
+ description: 'Retrieve an Agent API response by its id.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Reads one Agent API response once, with its status (queued, in_progress, completed, failed, incomplete or cancelled), output items and usage. Use it to poll a background response from Create Agent Response until the status is terminal; it never waits itself. Responses created with Store "false" are not retrievable.',
+ idempotent: true,
+ },
+ props: {
+ responseId: Property.ShortText({
+ displayName: 'Response ID',
+ description: 'Response id ("resp_..."), from Create Agent Response.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await perplexityAiClient.request<PerplexityAiAgentResponse>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/v1/agent/${encodeURIComponent(context.propsValue.responseId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/list-agent-response-files.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/list-agent-response-files.ts
new file mode 100644
index 00000000000..78a213c4c99
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/list-agent-response-files.ts
@@ -0,0 +1,37 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import type { PerplexityAiList } from '../../../common/types';
+import { perplexityAiListAgentResponseFilesOutputSchema } from '../../../output-schemas';
+
+export const listAgentResponseFilesAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_list_agent_response_files',
+ outputSchema: perplexityAiListAgentResponseFilesOutputSchema,
+ displayName: 'List Agent Response Files',
+ description: 'List the files an Agent API response produced.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the files an Agent API response delivered from its sandbox with the share_file tool, with each file id, name and size. Use the file id with Download Agent Response File. Responses that used no sandbox have none.',
+ idempotent: true,
+ },
+ props: {
+ responseId: Property.ShortText({
+ displayName: 'Response ID',
+ description: 'Response id ("resp_..."), from Create Agent Response.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await perplexityAiClient.request<PerplexityAiList<unknown>>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/v1/agent/${encodeURIComponent(
+ context.propsValue.responseId
+ )}/files`,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/list-models.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/list-models.ts
new file mode 100644
index 00000000000..9b89e5137d8
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/agent/list-models.ts
@@ -0,0 +1,29 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import type { PerplexityAiList } from '../../../common/types';
+import { perplexityAiListModelsOutputSchema } from '../../../output-schemas';
+
+export const listModelsAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_list_models',
+ outputSchema: perplexityAiListModelsOutputSchema,
+ displayName: 'List Models',
+ description: 'List the models available to the Agent API.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the model ids (provider/model form, e.g. "openai/gpt-6-luna") that Create Agent Response accepts in Model and Models. For Orchestrator models and their prices use List Orchestrator Models.',
+ idempotent: true,
+ },
+ props: {},
+ async run(context) {
+ return await perplexityAiClient.request<PerplexityAiList<unknown>>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/v1/models',
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/cancel-batch.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/cancel-batch.ts
new file mode 100644
index 00000000000..e2731d80a82
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/cancel-batch.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiCancelBatchOutputSchema } from '../../../output-schemas';
+
+export const cancelBatchAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_cancel_batch',
+ outputSchema: perplexityAiCancelBatchOutputSchema,
+ displayName: 'Cancel Batch',
+ description: 'Cancel a running batch.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Moves a batch to "cancelling"; it becomes "cancelled" once running lines stop. Lines already completed stay in the output file and are billed. Cancelling an already cancelled batch returns it unchanged.',
+ idempotent: true,
+ },
+ props: {
+ batchId: Property.ShortText({
+ displayName: 'Batch ID',
+ description: 'Batch id ("batch_..."), from Create Batch or List Batches.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/v1/batches/${encodeURIComponent(
+ context.propsValue.batchId
+ )}/cancel`,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/create-batch.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/create-batch.ts
new file mode 100644
index 00000000000..29772314f3c
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/create-batch.ts
@@ -0,0 +1,50 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiCreateBatchOutputSchema } from '../../../output-schemas';
+
+export const createBatchAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_create_batch',
+ outputSchema: perplexityAiCreateBatchOutputSchema,
+ displayName: 'Create Batch',
+ description: 'Start a batch over an uploaded JSONL file.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Starts a batch that runs every request line of a file from Upload Batch File as Agent API responses within 24 hours. Returns the batch id with status "validating"; poll Get Batch for progress and its output_file_id. Every completed line is billed. Set Idempotency Key to make a retry with the same inputs return the same batch instead of starting another; reusing a key with different inputs fails.',
+ idempotent: false,
+ },
+ props: {
+ inputFileId: Property.ShortText({
+ displayName: 'Input File ID',
+ description: 'File id ("file_...") from Upload Batch File.',
+ required: true,
+ }),
+ metadata: Property.Json({
+ displayName: 'Metadata',
+ description: 'Up to 16 string key-value pairs.',
+ required: false,
+ }),
+ idempotencyKey: Property.ShortText({
+ displayName: 'Idempotency Key',
+ description: 'Unique key; repeating it returns the original batch.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { inputFileId, metadata, idempotencyKey } = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/v1/batches',
+ headers:
+ idempotencyKey === undefined
+ ? undefined
+ : { 'Idempotency-Key': idempotencyKey },
+ body: { input_file_id: inputFileId, endpoint: '/v1/responses', metadata },
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/delete-file.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/delete-file.ts
new file mode 100644
index 00000000000..5a47f865239
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/delete-file.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiDeleteFileOutputSchema } from '../../../output-schemas';
+
+export const deleteFileAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_delete_file',
+ outputSchema: perplexityAiDeleteFileOutputSchema,
+ displayName: 'Delete Batch File',
+ description: 'Permanently delete a batch file.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a batch file; it cannot be restored. Batches already created from it are not affected.',
+ idempotent: true,
+ },
+ props: {
+ fileId: Property.ShortText({
+ displayName: 'File ID',
+ description: 'File id ("file_..."), from List Batch Files.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/v1/files/${encodeURIComponent(context.propsValue.fileId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/download-file-content.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/download-file-content.ts
new file mode 100644
index 00000000000..996cf0ce7f0
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/download-file-content.ts
@@ -0,0 +1,41 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiDownloadAgentResponseFileOutputSchema } from '../../../output-schemas';
+
+export const downloadFileContentAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_download_file_content',
+ outputSchema: perplexityAiDownloadAgentResponseFileOutputSchema,
+ displayName: 'Download Batch File Content',
+ description: 'Download a batch input, output or error file.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ "Downloads a batch file, typically a finished batch's output_file_id or error_file_id from Get Batch, and returns it as a file reference. Output files are JSONL, one result per input line.",
+ idempotent: true,
+ },
+ props: {
+ fileId: Property.ShortText({
+ displayName: 'File ID',
+ description: 'File id ("file_..."), from Get Batch or List Batch Files.',
+ required: true,
+ }),
+ fileName: Property.ShortText({
+ displayName: 'File Name',
+ description: 'Name to save the file as. Defaults to "<file id>.jsonl".',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { fileId, fileName } = context.propsValue;
+ const data = await perplexityAiClient.download({
+ auth: context.auth,
+ path: `/v1/files/${encodeURIComponent(fileId)}/content`,
+ });
+ const name = fileName ?? `${fileId}.jsonl`;
+ const file = await context.files.write({ fileName: name, data });
+ return { file, file_name: name, size: data.length };
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/get-batch.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/get-batch.ts
new file mode 100644
index 00000000000..8545af165e5
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/get-batch.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiGetBatchOutputSchema } from '../../../output-schemas';
+
+export const getBatchAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_get_batch',
+ outputSchema: perplexityAiGetBatchOutputSchema,
+ displayName: 'Get Batch',
+ description: "Get a batch's status and results file.",
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Reads one batch once: status, request counts and, when done, output_file_id and error_file_id for Download Batch File Content. Use it to poll a batch from Create Batch; it never waits itself.',
+ idempotent: true,
+ },
+ props: {
+ batchId: Property.ShortText({
+ displayName: 'Batch ID',
+ description: 'Batch id ("batch_..."), from Create Batch or List Batches.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/v1/batches/${encodeURIComponent(context.propsValue.batchId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/get-file.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/get-file.ts
new file mode 100644
index 00000000000..bc70d65d94e
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/get-file.ts
@@ -0,0 +1,35 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiGetFileOutputSchema } from '../../../output-schemas';
+
+export const getFileAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_get_file',
+ outputSchema: perplexityAiGetFileOutputSchema,
+ displayName: 'Get Batch File',
+ description: "Get a batch file's metadata.",
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ "Reads one batch file's metadata: name, purpose, size and expiry. Use Download Batch File Content for its content.",
+ idempotent: true,
+ },
+ props: {
+ fileId: Property.ShortText({
+ displayName: 'File ID',
+ description:
+ 'File id ("file_..."), from Upload Batch File, List Batch Files or a batch\'s output_file_id.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/v1/files/${encodeURIComponent(context.propsValue.fileId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/list-batches.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/list-batches.ts
new file mode 100644
index 00000000000..2bd1c782aca
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/list-batches.ts
@@ -0,0 +1,47 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiUtils } from '../../../common/utils';
+import { perplexityAiListBatchesOutputSchema } from '../../../output-schemas';
+
+export const listBatchesAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_list_batches',
+ outputSchema: perplexityAiListBatchesOutputSchema,
+ displayName: 'List Batches',
+ description: 'List your batches, newest first.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ "Lists the organization's batches, newest first, with each batch id, status and request counts. For the next page pass last_id as After ID.",
+ idempotent: true,
+ },
+ props: {
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Batches to return. Defaults to 20.',
+ required: false,
+ }),
+ afterId: Property.ShortText({
+ displayName: 'After ID',
+ description: 'last_id from the previous page.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { limit, afterId } = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/v1/batches',
+ query: perplexityAiUtils.toQuery({
+ params: {
+ limit: perplexityAiUtils.clampLimit({ limit, max: 100 }),
+ after_id: afterId,
+ },
+ }),
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/list-files.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/list-files.ts
new file mode 100644
index 00000000000..d6dcfc5377e
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/list-files.ts
@@ -0,0 +1,74 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiUtils } from '../../../common/utils';
+import { perplexityAiListFilesOutputSchema } from '../../../output-schemas';
+
+export const listFilesAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_list_files',
+ outputSchema: perplexityAiListFilesOutputSchema,
+ displayName: 'List Batch Files',
+ description: 'List batch input, output and error files.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ "Lists the organization's batch files, uploads and the output and error files batches write, with each file id, name, purpose and size. For the next page pass last_id as After ID. Deleted and expired files are not listed.",
+ idempotent: true,
+ },
+ props: {
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Files to return. Defaults to 20.',
+ required: false,
+ }),
+ afterId: Property.ShortText({
+ displayName: 'After ID',
+ description: 'last_id from the previous page.',
+ required: false,
+ }),
+ order: Property.StaticDropdown({
+ displayName: 'Order',
+ description: '"desc" for newest first or "asc".',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'desc', value: 'desc' },
+ { label: 'asc', value: 'asc' },
+ ],
+ },
+ }),
+ purpose: Property.StaticDropdown({
+ displayName: 'Purpose',
+ description:
+ '"batch" for uploads or "batch_output" for files batches wrote.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'batch', value: 'batch' },
+ { label: 'batch_output', value: 'batch_output' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ const { limit, afterId, order, purpose } = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/v1/files',
+ query: perplexityAiUtils.toQuery({
+ params: {
+ limit: perplexityAiUtils.clampLimit({ limit, max: 100 }),
+ after_id: afterId,
+ order,
+ purpose,
+ },
+ }),
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/upload-file.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/upload-file.ts
new file mode 100644
index 00000000000..47135af0460
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/batches/upload-file.ts
@@ -0,0 +1,41 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import FormData from 'form-data';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiGetFileOutputSchema } from '../../../output-schemas';
+
+export const uploadFileAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_upload_file',
+ outputSchema: perplexityAiGetFileOutputSchema,
+ displayName: 'Upload Batch File',
+ description: 'Upload a JSONL file as batch input.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Uploads a JSONL file of up to 50,000 request lines and 200 MB as batch input; every line is validated first. Returns the file id to pass to Create Batch. Files expire after 30 days. Not idempotent: each call stores another file.',
+ idempotent: false,
+ },
+ props: {
+ file: Property.File({
+ displayName: 'File',
+ description:
+ 'JSONL file, one request per line: {"custom_id":"1","method":"POST","url":"/v1/responses","body":{"model":"openai/gpt-6-luna","input":"..."}}.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { file } = context.propsValue;
+ const form = new FormData();
+ form.append('purpose', 'batch');
+ form.append('file', file.data, { filename: file.filename });
+ return await perplexityAiClient.upload<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/v1/files',
+ form,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/decisions/evaluate-decisions.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/decisions/evaluate-decisions.ts
new file mode 100644
index 00000000000..2b697083d4a
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/decisions/evaluate-decisions.ts
@@ -0,0 +1,74 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiEvaluateDecisionsOutputSchema } from '../../../output-schemas';
+
+const MODELS = [
+ 'pplx-decider-flash-v1.2',
+ 'pplx-decider-v1.2',
+ 'pplx-decider-flash-latest',
+ 'pplx-decider-latest',
+];
+
+export const evaluateDecisionsAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_evaluate_decisions',
+ outputSchema: perplexityAiEvaluateDecisionsOutputSchema,
+ displayName: 'Evaluate Decisions',
+ description:
+ 'Answer named yes/no, choice and score questions about some content.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Answers 1-128 named questions about one piece of content in a single call: "noul" (yes/no), "choice" (pick an option) and "score" (pick a level) questions, each returned under its own name with probabilities. Pick it for classification, moderation or grading; use Create Agent Response for open-ended answers. Set exactly one of Content Text or Content JSON; content plus any one question must fit in 256K tokens.',
+ idempotent: true,
+ },
+ props: {
+ model: Property.StaticDropdown({
+ displayName: 'Model',
+ description:
+ '"pplx-decider-flash-v1.2" (cheaper) or "pplx-decider-v1.2" (more accurate), or a -latest alias.',
+ required: true,
+ defaultValue: 'pplx-decider-flash-v1.2',
+ options: {
+ disabled: false,
+ options: MODELS.map((value) => ({ label: value, value })),
+ },
+ }),
+ stateText: Property.LongText({
+ displayName: 'Content Text',
+ description:
+ 'The text every question refers to. Set this or Content JSON.',
+ required: false,
+ }),
+ state: Property.Json({
+ displayName: 'Content JSON',
+ description:
+ 'The content every question refers to as an object or array; may hold OpenAI-style image_url parts with base64 data URLs. Set this or Content Text.',
+ required: false,
+ }),
+ questions: Property.Json({
+ displayName: 'Questions',
+ description:
+ 'Object of questions keyed by a name you choose, e.g. {"defect":{"type":"noul","instructions":"Does the review report a defect?"},"sentiment":{"type":"choice","instructions":"Overall sentiment?","criteria":{"positive":null,"negative":null}},"severity":{"type":"score","instructions":"How severe?","criteria":["none","minor","major"]}}.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { model, stateText, state, questions } = context.propsValue;
+ const hasJson = state !== undefined && state !== null;
+ if ((stateText === undefined) === !hasJson) {
+ throw new Error(
+ 'Set exactly one of Content Text (stateText) or Content JSON (state).'
+ );
+ }
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/v1/decisions',
+ body: { model, state: hasJson ? state : stateText, questions },
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/embeddings/create-contextualized-embeddings.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/embeddings/create-contextualized-embeddings.ts
new file mode 100644
index 00000000000..21157227b56
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/embeddings/create-contextualized-embeddings.ts
@@ -0,0 +1,72 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiCreateContextualizedEmbeddingsOutputSchema } from '../../../output-schemas';
+
+const MODELS = ['pplx-embed-context-v1-0.6b', 'pplx-embed-context-v1-4b'];
+const ENCODING_FORMATS = ['base64_int8', 'base64_binary'];
+
+export const createContextualizedEmbeddingsAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_create_contextualized_embeddings',
+ outputSchema: perplexityAiCreateContextualizedEmbeddingsOutputSchema,
+ displayName: 'Create Contextualized Embeddings',
+ description: 'Generate document-aware embeddings for chunks of documents.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Embeds document chunks so chunks of the same document share context, which improves retrieval over plain Create Embeddings. Input is an array of documents, each an array of chunk strings in order; returns base64-encoded vectors grouped the same way, plus token usage.',
+ idempotent: true,
+ },
+ props: {
+ input: Property.Json({
+ displayName: 'Documents',
+ description:
+ 'Array of documents, each an array of chunk strings in reading order, e.g. [["chunk 1","chunk 2"],["other doc chunk"]]. Up to 512 documents.',
+ required: true,
+ }),
+ model: Property.StaticDropdown({
+ displayName: 'Model',
+ description:
+ '"pplx-embed-context-v1-0.6b" (1024 dimensions, cheaper) or "pplx-embed-context-v1-4b" (2560 dimensions).',
+ required: true,
+ defaultValue: 'pplx-embed-context-v1-0.6b',
+ options: {
+ disabled: false,
+ options: MODELS.map((value) => ({ label: value, value })),
+ },
+ }),
+ dimensions: Property.Number({
+ displayName: 'Dimensions',
+ description:
+ 'Output dimensions, 128 up to the model maximum (1024 or 2560). Defaults to the maximum.',
+ required: false,
+ }),
+ encodingFormat: Property.StaticDropdown({
+ displayName: 'Encoding Format',
+ description:
+ '"base64_int8" (default) or "base64_binary" (1 bit per dimension).',
+ required: false,
+ options: {
+ disabled: false,
+ options: ENCODING_FORMATS.map((value) => ({ label: value, value })),
+ },
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/v1/contextualizedembeddings',
+ body: {
+ input: p.input,
+ model: p.model,
+ dimensions: p.dimensions,
+ encoding_format: p.encodingFormat,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/embeddings/create-embeddings.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/embeddings/create-embeddings.ts
new file mode 100644
index 00000000000..c117944a00c
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/embeddings/create-embeddings.ts
@@ -0,0 +1,72 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiCreateEmbeddingsOutputSchema } from '../../../output-schemas';
+
+const MODELS = ['pplx-embed-v1-0.6b', 'pplx-embed-v1-4b'];
+const ENCODING_FORMATS = ['base64_int8', 'base64_binary'];
+
+export const createEmbeddingsAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_create_embeddings',
+ outputSchema: perplexityAiCreateEmbeddingsOutputSchema,
+ displayName: 'Create Embeddings',
+ description: 'Generate vector embeddings for independent texts.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Embeds up to 512 independent texts (queries, sentences, documents) and returns one base64-encoded vector per text, in input order, plus token usage. For chunks of the same document that should share context, use Create Contextualized Embeddings. Empty strings are rejected.',
+ idempotent: true,
+ },
+ props: {
+ input: Property.Array({
+ displayName: 'Texts',
+ description:
+ 'Texts to embed, up to 512, each up to 32K tokens and 120K tokens in total.',
+ required: true,
+ }),
+ model: Property.StaticDropdown({
+ displayName: 'Model',
+ description:
+ '"pplx-embed-v1-0.6b" (1024 dimensions, cheaper) or "pplx-embed-v1-4b" (2560 dimensions).',
+ required: true,
+ defaultValue: 'pplx-embed-v1-0.6b',
+ options: {
+ disabled: false,
+ options: MODELS.map((value) => ({ label: value, value })),
+ },
+ }),
+ dimensions: Property.Number({
+ displayName: 'Dimensions',
+ description:
+ 'Output dimensions, 128 up to the model maximum (1024 or 2560). Defaults to the maximum.',
+ required: false,
+ }),
+ encodingFormat: Property.StaticDropdown({
+ displayName: 'Encoding Format',
+ description:
+ '"base64_int8" (default) or "base64_binary" (1 bit per dimension).',
+ required: false,
+ options: {
+ disabled: false,
+ options: ENCODING_FORMATS.map((value) => ({ label: value, value })),
+ },
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/v1/embeddings',
+ body: {
+ input: p.input,
+ model: p.model,
+ dimensions: p.dimensions,
+ encoding_format: p.encodingFormat,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/index.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/index.ts
new file mode 100644
index 00000000000..6f5b33abc66
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/index.ts
@@ -0,0 +1,55 @@
+import { cancelAgentResponseAction } from './agent/cancel-agent-response';
+import { createAgentResponseAction } from './agent/create-agent-response';
+import { downloadAgentResponseFileAction } from './agent/download-agent-response-file';
+import { getAgentResponseAction } from './agent/get-agent-response';
+import { listAgentResponseFilesAction } from './agent/list-agent-response-files';
+import { listModelsAction } from './agent/list-models';
+import { cancelBatchAction } from './batches/cancel-batch';
+import { createBatchAction } from './batches/create-batch';
+import { deleteFileAction } from './batches/delete-file';
+import { downloadFileContentAction } from './batches/download-file-content';
+import { getBatchAction } from './batches/get-batch';
+import { getFileAction } from './batches/get-file';
+import { listBatchesAction } from './batches/list-batches';
+import { listFilesAction } from './batches/list-files';
+import { uploadFileAction } from './batches/upload-file';
+import { evaluateDecisionsAction } from './decisions/evaluate-decisions';
+import { createContextualizedEmbeddingsAction } from './embeddings/create-contextualized-embeddings';
+import { createEmbeddingsAction } from './embeddings/create-embeddings';
+import { searchWebAction } from './search/search-web';
+import { createSkillAction } from './skills/create-skill';
+import { deleteSkillAction } from './skills/delete-skill';
+import { getSkillAction } from './skills/get-skill';
+import { getSkillDownloadUrlAction } from './skills/get-skill-download-url';
+import { listSkillRevisionsAction } from './skills/list-skill-revisions';
+import { listSkillsAction } from './skills/list-skills';
+import { updateSkillAction } from './skills/update-skill';
+
+export const perplexityAiAiActions = [
+ cancelAgentResponseAction,
+ createAgentResponseAction,
+ downloadAgentResponseFileAction,
+ getAgentResponseAction,
+ listAgentResponseFilesAction,
+ listModelsAction,
+ searchWebAction,
+ createContextualizedEmbeddingsAction,
+ createEmbeddingsAction,
+ evaluateDecisionsAction,
+ createSkillAction,
+ deleteSkillAction,
+ getSkillAction,
+ getSkillDownloadUrlAction,
+ listSkillRevisionsAction,
+ listSkillsAction,
+ updateSkillAction,
+ cancelBatchAction,
+ createBatchAction,
+ deleteFileAction,
+ downloadFileContentAction,
+ getBatchAction,
+ getFileAction,
+ listBatchesAction,
+ listFilesAction,
+ uploadFileAction,
+];
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/search/search-web.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/search/search-web.ts
new file mode 100644
index 00000000000..eb7881b4aab
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/search/search-web.ts
@@ -0,0 +1,135 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiSearchWebOutputSchema } from '../../../output-schemas';
+
+const SEARCH_TYPES = ['web', 'fast', 'people'];
+const RECENCY_FILTERS = ['hour', 'day', 'week', 'month', 'year'];
+
+export const searchWebAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_search_web',
+ outputSchema: perplexityAiSearchWebOutputSchema,
+ displayName: 'Search the Web',
+ description:
+ 'Get ranked web search results with page content from Perplexity.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Runs a Perplexity web search and returns raw ranked results (title, url, snippet, dates) with extracted page content, without an AI-written answer. Pick it when you need sources to read yourself; use Create Agent Response or Ask AI for a written, cited answer. Up to 5 queries in one call are billed as one request; dates are MM/DD/YYYY.',
+ idempotent: true,
+ },
+ props: {
+ query: Property.Array({
+ displayName: 'Queries',
+ description: 'One to five search queries.',
+ required: true,
+ }),
+ searchType: Property.StaticDropdown({
+ displayName: 'Search Type',
+ description:
+ '"web" (default), "fast" for lower latency and cost, or "people" for people search.',
+ required: false,
+ options: {
+ disabled: false,
+ options: SEARCH_TYPES.map((value) => ({ label: value, value })),
+ },
+ }),
+ maxResults: Property.Number({
+ displayName: 'Max Results',
+ description:
+ 'Results to return, 1-20 for web search and up to 50 for people search. Defaults to 10.',
+ required: false,
+ }),
+ maxTokens: Property.Number({
+ displayName: 'Max Tokens',
+ description: 'Maximum page content tokens returned across all results.',
+ required: false,
+ }),
+ maxTokensPerPage: Property.Number({
+ displayName: 'Max Tokens Per Page',
+ description: 'Maximum content tokens extracted from each result page.',
+ required: false,
+ }),
+ country: Property.ShortText({
+ displayName: 'Country',
+ description:
+ 'ISO 3166-1 alpha-2 country code to localize results, e.g. "US".',
+ required: false,
+ }),
+ searchLanguageFilter: Property.Array({
+ displayName: 'Languages',
+ description: 'ISO 639-1 language codes to limit results to, e.g. "en".',
+ required: false,
+ }),
+ searchDomainFilter: Property.Array({
+ displayName: 'Domains',
+ description:
+ 'Up to 20 domains to limit results to, e.g. "wikipedia.org".',
+ required: false,
+ }),
+ searchRecencyFilter: Property.StaticDropdown({
+ displayName: 'Recency',
+ description:
+ 'Only results published within the last hour, day, week, month or year.',
+ required: false,
+ options: {
+ disabled: false,
+ options: RECENCY_FILTERS.map((value) => ({ label: value, value })),
+ },
+ }),
+ searchAfterDateFilter: Property.ShortText({
+ displayName: 'Published After',
+ description: 'Only results published after this date, MM/DD/YYYY.',
+ required: false,
+ }),
+ searchBeforeDateFilter: Property.ShortText({
+ displayName: 'Published Before',
+ description: 'Only results published before this date, MM/DD/YYYY.',
+ required: false,
+ }),
+ lastUpdatedAfterFilter: Property.ShortText({
+ displayName: 'Updated After',
+ description: 'Only results updated after this date, MM/DD/YYYY.',
+ required: false,
+ }),
+ lastUpdatedBeforeFilter: Property.ShortText({
+ displayName: 'Updated Before',
+ description: 'Only results updated before this date, MM/DD/YYYY.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/search',
+ body: {
+ query: p.query,
+ search_type: p.searchType,
+ max_results: p.maxResults,
+ max_tokens: p.maxTokens,
+ max_tokens_per_page: p.maxTokensPerPage,
+ country: p.country,
+ search_language_filter: nonEmpty({ items: p.searchLanguageFilter }),
+ search_domain_filter: nonEmpty({ items: p.searchDomainFilter }),
+ search_recency_filter: p.searchRecencyFilter,
+ search_after_date_filter: p.searchAfterDateFilter,
+ search_before_date_filter: p.searchBeforeDateFilter,
+ last_updated_after_filter: p.lastUpdatedAfterFilter,
+ last_updated_before_filter: p.lastUpdatedBeforeFilter,
+ },
+ });
+ },
+});
+
+function nonEmpty({
+ items,
+}: {
+ items: unknown[] | undefined;
+}): unknown[] | undefined {
+ return items && items.length > 0 ? items : undefined;
+}
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/create-skill.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/create-skill.ts
new file mode 100644
index 00000000000..f9230eb2f78
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/create-skill.ts
@@ -0,0 +1,39 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import FormData from 'form-data';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiCreateSkillOutputSchema } from '../../../output-schemas';
+
+export const createSkillAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_create_skill',
+ outputSchema: perplexityAiCreateSkillOutputSchema,
+ displayName: 'Create Skill',
+ description: 'Create a skill from a zip bundle containing SKILL.md.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ "Creates a custom skill in the project from a zip bundle; the bundle's SKILL.md supplies the name and description. Returns the skill id and revision, needed by Update Skill and Delete Skill. Not idempotent: each call creates another skill, and a duplicate name fails with 409.",
+ idempotent: false,
+ },
+ props: {
+ file: Property.File({
+ displayName: 'Bundle',
+ description: 'Zip file containing SKILL.md.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { file } = context.propsValue;
+ const form = new FormData();
+ form.append('file', file.data, { filename: file.filename });
+ return await perplexityAiClient.upload<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/v1/skills',
+ form,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/delete-skill.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/delete-skill.ts
new file mode 100644
index 00000000000..1b17a6c8476
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/delete-skill.ts
@@ -0,0 +1,45 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiUtils } from '../../../common/utils';
+import { perplexityAiDeleteSkillOutputSchema } from '../../../output-schemas';
+
+export const deleteSkillAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_delete_skill',
+ outputSchema: perplexityAiDeleteSkillOutputSchema,
+ displayName: 'Delete Skill',
+ description: 'Permanently delete a skill.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a skill and all its revisions; it cannot be restored. Expected Revision must be the current revision (from Get Skill), else it fails with 409 so a newer update is never deleted by mistake.',
+ idempotent: false,
+ },
+ props: {
+ skillId: Property.ShortText({
+ displayName: 'Skill ID',
+ description: 'Skill id from List Skills or Create Skill.',
+ required: true,
+ }),
+ expectedRevision: Property.ShortText({
+ displayName: 'Expected Revision',
+ description: "The skill's current revision, from Get Skill.",
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { skillId, expectedRevision } = context.propsValue;
+ await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/v1/skills/${encodeURIComponent(skillId)}`,
+ query: perplexityAiUtils.toQuery({
+ params: { expected_revision: expectedRevision },
+ }),
+ });
+ return { deleted: true, skill_id: skillId };
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/get-skill-download-url.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/get-skill-download-url.ts
new file mode 100644
index 00000000000..0280ffbbc71
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/get-skill-download-url.ts
@@ -0,0 +1,43 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiUtils } from '../../../common/utils';
+import { perplexityAiGetSkillDownloadUrlOutputSchema } from '../../../output-schemas';
+
+export const getSkillDownloadUrlAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_get_skill_download_url',
+ outputSchema: perplexityAiGetSkillDownloadUrlOutputSchema,
+ displayName: 'Get Skill Download URL',
+ description: 'Get a short-lived URL to download a skill bundle.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ "Returns a short-lived URL to download a skill's zip bundle, at the active revision or a given one. It does not fetch the bundle.",
+ idempotent: true,
+ },
+ props: {
+ skillId: Property.ShortText({
+ displayName: 'Skill ID',
+ description: 'Skill id from List Skills or Create Skill.',
+ required: true,
+ }),
+ revision: Property.ShortText({
+ displayName: 'Revision',
+ description:
+ 'Revision token from List Skill Revisions. Defaults to the active revision.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { skillId, revision } = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/v1/skills/${encodeURIComponent(skillId)}/download`,
+ query: perplexityAiUtils.toQuery({ params: { revision } }),
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/get-skill.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/get-skill.ts
new file mode 100644
index 00000000000..30a80424306
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/get-skill.ts
@@ -0,0 +1,43 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiUtils } from '../../../common/utils';
+import { perplexityAiCreateSkillOutputSchema } from '../../../output-schemas';
+
+export const getSkillAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_get_skill',
+ outputSchema: perplexityAiCreateSkillOutputSchema,
+ displayName: 'Get Skill',
+ description: "Get a skill's metadata.",
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ "Reads one skill's metadata, at the active revision or at a given one; latest_revision always names the newest. Use its revision as Expected Revision in Update Skill or Delete Skill.",
+ idempotent: true,
+ },
+ props: {
+ skillId: Property.ShortText({
+ displayName: 'Skill ID',
+ description: 'Skill id from List Skills or Create Skill.',
+ required: true,
+ }),
+ revision: Property.ShortText({
+ displayName: 'Revision',
+ description:
+ 'Revision token from List Skill Revisions. Defaults to the active revision.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { skillId, revision } = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/v1/skills/${encodeURIComponent(skillId)}`,
+ query: perplexityAiUtils.toQuery({ params: { revision } }),
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/list-skill-revisions.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/list-skill-revisions.ts
new file mode 100644
index 00000000000..dd52707f7ef
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/list-skill-revisions.ts
@@ -0,0 +1,52 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiUtils } from '../../../common/utils';
+import { perplexityAiListSkillRevisionsOutputSchema } from '../../../output-schemas';
+
+export const listSkillRevisionsAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_list_skill_revisions',
+ outputSchema: perplexityAiListSkillRevisionsOutputSchema,
+ displayName: 'List Skill Revisions',
+ description: 'List the revisions of a skill.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ "Lists a skill's revisions, newest first, with each revision token and creation time. Pass next_page_token back as Page Token for the next page; pass a revision to Get Skill or Get Skill Download URL.",
+ idempotent: true,
+ },
+ props: {
+ skillId: Property.ShortText({
+ displayName: 'Skill ID',
+ description: 'Skill id from List Skills or Create Skill.',
+ required: true,
+ }),
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Revisions to return, 1-200. Defaults to 20.',
+ required: false,
+ }),
+ pageToken: Property.ShortText({
+ displayName: 'Page Token',
+ description: 'next_page_token from the previous page.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { skillId, limit, pageToken } = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/v1/skills/${encodeURIComponent(skillId)}/revisions`,
+ query: perplexityAiUtils.toQuery({
+ params: {
+ limit: perplexityAiUtils.clampLimit({ limit, max: 200 }),
+ page_token: pageToken,
+ },
+ }),
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/list-skills.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/list-skills.ts
new file mode 100644
index 00000000000..0988caf8bdb
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/list-skills.ts
@@ -0,0 +1,47 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiUtils } from '../../../common/utils';
+import { perplexityAiListSkillsOutputSchema } from '../../../output-schemas';
+
+export const listSkillsAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_list_skills',
+ outputSchema: perplexityAiListSkillsOutputSchema,
+ displayName: 'List Skills',
+ description: 'List the skills in your Perplexity project.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ "Lists custom skills in the API key's project, newest first, with each skill id, name and revision. Pass next_page_token back as Page Token for the next page. Use a skill name in Create Agent Response Skills.",
+ idempotent: true,
+ },
+ props: {
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Skills to return, 1-200. Defaults to 20.',
+ required: false,
+ }),
+ pageToken: Property.ShortText({
+ displayName: 'Page Token',
+ description: 'next_page_token from the previous page.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { limit, pageToken } = context.propsValue;
+ return await perplexityAiClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/v1/skills',
+ query: perplexityAiUtils.toQuery({
+ params: {
+ limit: perplexityAiUtils.clampLimit({ limit, max: 200 }),
+ page_token: pageToken,
+ },
+ }),
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/update-skill.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/update-skill.ts
new file mode 100644
index 00000000000..6317f0bec67
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/ai/skills/update-skill.ts
@@ -0,0 +1,50 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import FormData from 'form-data';
+import { perplexityAiAuth } from '../../../auth';
+import { perplexityAiClient } from '../../../common/client';
+import { perplexityAiUpdateSkillOutputSchema } from '../../../output-schemas';
+
+export const updateSkillAction = createAction({
+ auth: perplexityAiAuth,
+ name: 'perplexity_ai_update_skill',
+ outputSchema: perplexityAiUpdateSkillOutputSchema,
+ displayName: 'Update Skill',
+ description: 'Upload a new zip bundle as a revision of a skill.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ "Uploads a new zip bundle as the next revision of an existing skill; name and description are re-read from its SKILL.md. Expected Revision must be the skill's current revision (from Get Skill), else it fails with 409 instead of overwriting a newer change. Not idempotent: each call adds a revision.",
+ idempotent: false,
+ },
+ props: {
+ skillId: Property.ShortText({
+ displayName: 'Skill ID',
+ description: 'Skill id from List Skills or Create Skill.',
+ required: true,
+ }),
+ expectedRevision: Property.ShortText({
+ displayName: 'Expected Revision',
+ description: "The skill's current revision, from Get Skill.",
+ required: true,
+ }),
+ file: Property.File({
+ displayName: 'Bundle',
+ description: 'Zip file containing SKILL.md.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { skillId, expectedRevision, file } = context.propsValue;
+ const form = new FormData();
+ form.append('file', file.data, { filename: file.filename });
+ return await perplexityAiClient.upload<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/v1/skills/${encodeURIComponent(skillId)}`,
+ query: { expected_revision: expectedRevision },
+ form,
+ });
+ },
+});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/actions/create-chat-completion.action.ts b/packages/pieces/community/perplexity-ai/src/lib/actions/create-chat-completion.ts
similarity index 74%
rename from packages/pieces/community/perplexity-ai/src/lib/actions/create-chat-completion.action.ts
rename to packages/pieces/community/perplexity-ai/src/lib/actions/create-chat-completion.ts
index 9fed75a4c9b..5039083d933 100644
--- a/packages/pieces/community/perplexity-ai/src/lib/actions/create-chat-completion.action.ts
+++ b/packages/pieces/community/perplexity-ai/src/lib/actions/create-chat-completion.ts
@@ -5,23 +5,23 @@ import {
Property,
} from '@activepieces/pieces-framework';
-import {
- AuthenticationType,
- httpClient,
- HttpMethod,
-} from '@activepieces/pieces-common';
+import { HttpMethod, propsValidation } from '@activepieces/pieces-common';
import * as z from 'zod/mini'
-import { propsValidation } from '@activepieces/pieces-common';
+import { perplexityAiClient } from '../common/client';
+import type { PerplexityAiChatCompletion, PerplexityAiMessage } from '../common/types';
+import { askAiOutputSchema } from '../output-schemas';
+
export const createChatCompletionAction = createAction({
audience: 'both',
auth: perplexityAiAuth,
name: 'ask-ai',
+ outputSchema: askAiOutputSchema,
classification: 'READ',
displayName: 'Ask AI',
description:
'Ask a question and get an answer sourced from the live web.',
- aiMetadata: { description: 'Sends a question to a Perplexity Sonar model, which answers from a live web search with source citations rather than model memory alone, choosing between the plain sonar models for fast grounded answers and the sonar-reasoning models for step-by-step reasoning. It is the only action in this piece; pick it when the reply must reflect current web content, and prefer a general LLM vendor piece such as OpenAI or Google Gemini when no web lookup is needed. Runs stateless - earlier turns must be supplied in the optional roles array, which alternates user and assistant after any system message; requires a model and a question, and is not idempotent: each call runs a new search and produces a fresh completion.', idempotent: false },
+ aiMetadata: { description: 'Sends a question to a Perplexity Sonar model, which answers from a live web search with source citations rather than model memory alone, choosing between the plain sonar models for fast grounded answers and the sonar-reasoning models for step-by-step reasoning. Pick it for a quick cited answer; use Create Agent Response to choose any catalogued model or tools, and Search the Web for raw results without an answer. Runs stateless - earlier turns must be supplied in the optional roles array, which alternates user and assistant after any system message; requires a model and a question, and is not idempotent: each call runs a new search and produces a fresh completion.', idempotent: false },
propertyGroups: [
{ key: 'settings', display: 'section', label: 'Settings', icon: 'sliders', props: ['model', 'max_tokens'] },
{ key: 'message', display: 'section', label: 'Message', icon: 'text', props: ['prompt'] },
@@ -44,10 +44,6 @@ export const createChatCompletionAction = createAction({
label:'Sonar Pro',
value:'sonar-pro'
},
- {
- label:'Sonar Reasoning',
- value:'sonar-reasoning'
- },
{
label:'Sonar Reasoning Pro',
value:'sonar-reasoning-pro'
@@ -116,10 +112,10 @@ export const createChatCompletionAction = createAction({
});
const maxTokens = context.propsValue.max_tokens;
- const rolesArray = context.propsValue.roles
- ? (context.propsValue.roles as any)
- : [];
- const roles = rolesArray.map((item: any) => {
+ const rolesArray = z
+ .array(z.object({ role: z.string(), content: z.unknown() }))
+ .parse(context.propsValue.roles ? context.propsValue.roles : []);
+ const roles: PerplexityAiMessage[] = rolesArray.map((item) => {
const rolesEnum = ['system', 'user', 'assistant'];
if (!rolesEnum.includes(item.role)) {
throw new Error(
@@ -135,16 +131,10 @@ export const createChatCompletionAction = createAction({
roles.push({ role: 'user', content: context.propsValue.prompt });
- const response = await httpClient.sendRequest({
+ const response = await perplexityAiClient.request<PerplexityAiChatCompletion>({
+ auth: context.auth,
method: HttpMethod.POST,
- url: 'https://api.perplexity.ai/chat/completions',
- authentication: {
- type: AuthenticationType.BEARER_TOKEN,
- token: context.auth.secret_text,
- },
- headers: {
- 'Content-Type': 'application/json',
- },
+ path: '/chat/completions',
body: {
model: context.propsValue.model,
messages: roles,
@@ -156,14 +146,9 @@ export const createChatCompletionAction = createAction({
},
});
- if (response.status === 200) {
-
- return {
- result:response.body.choices[0].message.content,
- citations:response.body.citations
- }
- }
-
- return response.body;
+ return {
+ result: response.choices[0].message.content,
+ citations: response.citations,
+ };
},
});
diff --git a/packages/pieces/community/perplexity-ai/src/lib/common/client.ts b/packages/pieces/community/perplexity-ai/src/lib/common/client.ts
new file mode 100644
index 00000000000..808e1c59155
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/common/client.ts
@@ -0,0 +1,90 @@
+import {
+ AuthenticationType,
+ HttpMethod,
+ httpClient,
+ QueryParams,
+} from '@activepieces/pieces-common';
+import FormData from 'form-data';
+import type { PerplexityAiAuthValue } from './types';
+
+function baseUrl(): string {
+ return 'https://api.perplexity.ai';
+}
+
+async function request<T>({
+ auth,
+ method,
+ path,
+ query,
+ body,
+ headers,
+}: RequestParams & { auth: PerplexityAiAuthValue }): Promise<T> {
+ const response = await httpClient.sendRequest<T>({
+ method,
+ url: `${baseUrl()}${path}`,
+ authentication: {
+ type: AuthenticationType.BEARER_TOKEN,
+ token: auth.secret_text,
+ },
+ headers: { 'Content-Type': 'application/json', ...headers },
+ queryParams: query,
+ body,
+ });
+ return response.body;
+}
+
+async function upload<T>({
+ auth,
+ method,
+ path,
+ query,
+ form,
+}: UploadParams & { auth: PerplexityAiAuthValue }): Promise<T> {
+ const response = await httpClient.sendRequest<T>({
+ method,
+ url: `${baseUrl()}${path}`,
+ authentication: {
+ type: AuthenticationType.BEARER_TOKEN,
+ token: auth.secret_text,
+ },
+ headers: form.getHeaders(),
+ queryParams: query,
+ body: form,
+ });
+ return response.body;
+}
+
+async function download({
+ auth,
+ path,
+}: DownloadParams & { auth: PerplexityAiAuthValue }): Promise<Buffer> {
+ const response = await httpClient.sendRequest<ArrayBuffer>({
+ method: HttpMethod.GET,
+ url: `${baseUrl()}${path}`,
+ authentication: {
+ type: AuthenticationType.BEARER_TOKEN,
+ token: auth.secret_text,
+ },
+ responseType: 'arraybuffer',
+ });
+ return Buffer.from(response.body);
+}
+
+export const perplexityAiClient = { baseUrl, request, upload, download };
+
+type RequestParams = {
+ method: HttpMethod;
+ path: string;
+ query?: QueryParams;
+ body?: unknown;
+ headers?: Record<string, string>;
+};
+
+type UploadParams = {
+ method: HttpMethod;
+ path: string;
+ query?: QueryParams;
+ form: FormData;
+};
+
+type DownloadParams = { path: string };
diff --git a/packages/pieces/community/perplexity-ai/src/lib/common/types.ts b/packages/pieces/community/perplexity-ai/src/lib/common/types.ts
new file mode 100644
index 00000000000..62b50213ea3
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/common/types.ts
@@ -0,0 +1,33 @@
+import type { AppConnectionType } from '@activepieces/pieces-framework';
+
+export type PerplexityAiAuthValue = {
+ type: AppConnectionType.SECRET_TEXT;
+ secret_text: string;
+};
+
+export type PerplexityAiMessage = { role: string; content: unknown };
+
+export type PerplexityAiChatCompletion = {
+ choices: { message: { content: string } }[];
+ citations?: string[];
+};
+
+export type PerplexityAiAgentResponse = {
+ id: string;
+ object: 'response';
+ created_at: number;
+ model: string;
+ status:
+ | 'completed'
+ | 'failed'
+ | 'incomplete'
+ | 'in_progress'
+ | 'queued'
+ | 'cancelled';
+ output: unknown[];
+ effort?: string;
+ error?: unknown;
+ usage?: unknown;
+};
+
+export type PerplexityAiList<T> = { object: string; data: T[] };
diff --git a/packages/pieces/community/perplexity-ai/src/lib/common/utils.ts b/packages/pieces/community/perplexity-ai/src/lib/common/utils.ts
new file mode 100644
index 00000000000..e5acc0dff5d
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/common/utils.ts
@@ -0,0 +1,27 @@
+function toQuery({
+ params,
+}: {
+ params: Record<string, string | number | undefined>;
+}): Record<string, string> {
+ return Object.fromEntries(
+ Object.entries(params)
+ .filter(
+ (entry): entry is [string, string | number] => entry[1] !== undefined
+ )
+ .map(([key, value]) => [key, String(value)])
+ );
+}
+
+function clampLimit({
+ limit,
+ max,
+}: {
+ limit: number | undefined;
+ max: number;
+}): number {
+ return Math.min(Math.max(limit ?? DEFAULT_LIMIT, 1), max);
+}
+
+export const perplexityAiUtils = { toQuery, clampLimit };
+
+const DEFAULT_LIMIT = 20;
diff --git a/packages/pieces/community/perplexity-ai/src/lib/output-schemas.ts b/packages/pieces/community/perplexity-ai/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..c0666362c21
--- /dev/null
+++ b/packages/pieces/community/perplexity-ai/src/lib/output-schemas.ts
@@ -0,0 +1,585 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const tokenUsageFields: OutputSchema['fields'] = [
+ { key: 'input_tokens', label: 'Input Tokens', format: 'number' },
+ {
+ key: 'input_tokens_details',
+ label: 'Input Token Details',
+ children: [
+ { key: 'cached_tokens', label: 'Cached Tokens', format: 'number' },
+ ],
+ },
+ { key: 'output_tokens', label: 'Output Tokens', format: 'number' },
+ {
+ key: 'output_tokens_details',
+ label: 'Output Token Details',
+ children: [
+ { key: 'reasoning_tokens', label: 'Reasoning Tokens', format: 'number' },
+ ],
+ },
+ { key: 'total_tokens', label: 'Total Tokens', format: 'number' },
+];
+
+const batchFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Batch ID' },
+ { key: 'object', label: 'Object Type' },
+ { key: 'status', label: 'Status' },
+ { key: 'endpoint', label: 'Endpoint' },
+ { key: 'input_file_id', label: 'Input File ID' },
+ { key: 'output_file_id', label: 'Output File ID' },
+ { key: 'error_file_id', label: 'Error File ID' },
+ { key: 'completion_window', label: 'Completion Window' },
+ {
+ key: 'request_counts',
+ label: 'Request Counts',
+ children: [
+ { key: 'total', label: 'Total', format: 'number' },
+ { key: 'completed', label: 'Completed', format: 'number' },
+ { key: 'failed', label: 'Failed', format: 'number' },
+ ],
+ },
+ { key: 'errors', label: 'Errors' },
+ { key: 'metadata', label: 'Metadata', dynamicKey: true },
+ { key: 'usage', label: 'Usage', children: tokenUsageFields },
+ { key: 'created_at', label: 'Created At (Unix Seconds)', format: 'number' },
+ {
+ key: 'in_progress_at',
+ label: 'In Progress At (Unix Seconds)',
+ format: 'number',
+ },
+ {
+ key: 'finalizing_at',
+ label: 'Finalizing At (Unix Seconds)',
+ format: 'number',
+ },
+ {
+ key: 'completed_at',
+ label: 'Completed At (Unix Seconds)',
+ format: 'number',
+ },
+ { key: 'failed_at', label: 'Failed At (Unix Seconds)', format: 'number' },
+ {
+ key: 'cancelling_at',
+ label: 'Cancelling At (Unix Seconds)',
+ format: 'number',
+ },
+ {
+ key: 'cancelled_at',
+ label: 'Cancelled At (Unix Seconds)',
+ format: 'number',
+ },
+ { key: 'expires_at', label: 'Expires At (Unix Seconds)', format: 'number' },
+ { key: 'expired_at', label: 'Expired At (Unix Seconds)', format: 'number' },
+];
+
+const batchFileFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'File ID' },
+ { key: 'object', label: 'Object Type' },
+ { key: 'filename', label: 'File Name' },
+ { key: 'purpose', label: 'Purpose' },
+ { key: 'bytes', label: 'Size', format: 'filesize' },
+ { key: 'created_at', label: 'Created At (Unix Seconds)', format: 'number' },
+ { key: 'expires_at', label: 'Expires At (Unix Seconds)', format: 'number' },
+];
+
+const pageFields: OutputSchema['fields'] = [
+ { key: 'first_id', label: 'First ID' },
+ { key: 'last_id', label: 'Last ID' },
+ { key: 'has_more', label: 'Has More', format: 'boolean' },
+ { key: 'object', label: 'Object Type' },
+];
+
+const skillFields: OutputSchema['fields'] = [
+ { key: 'skill_id', label: 'Skill ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'revision', label: 'Revision' },
+ { key: 'latest_revision', label: 'Latest Revision' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+];
+
+const searchResultFields: OutputSchema['fields'] = [
+ { key: 'title', label: 'Title' },
+ { key: 'url', label: 'URL', format: 'url' },
+ { key: 'snippet', label: 'Snippet' },
+ { key: 'date', label: 'Published', format: 'date' },
+ { key: 'last_updated', label: 'Last Updated', format: 'date' },
+];
+
+const embeddingUsageFields: OutputSchema['fields'] = [
+ { key: 'prompt_tokens', label: 'Prompt Tokens', format: 'number' },
+ { key: 'total_tokens', label: 'Total Tokens', format: 'number' },
+ {
+ key: 'cost',
+ label: 'Cost',
+ children: [
+ {
+ key: 'input_cost',
+ label: 'Input Cost',
+ format: 'currency',
+ currency: 'USD',
+ },
+ {
+ key: 'total_cost',
+ label: 'Total Cost',
+ format: 'currency',
+ currency: 'USD',
+ },
+ { key: 'currency', label: 'Currency' },
+ ],
+ },
+];
+
+const embeddingFields: OutputSchema['fields'] = [
+ { key: 'index', label: 'Index', format: 'number' },
+ { key: 'embedding', label: 'Embedding (Base64)' },
+ { key: 'object', label: 'Object Type' },
+];
+
+const savedFileFields: OutputSchema['fields'] = [
+ { key: 'file', label: 'File', format: 'url' },
+ { key: 'file_name', label: 'File Name' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+];
+
+export const askAiOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'result', label: 'Answer' },
+ { key: 'citations', label: 'Citations' },
+ ],
+};
+
+export const perplexityAiCancelAgentResponseOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'response_id', label: 'Response ID' },
+ { key: 'status', label: 'Status' },
+ ],
+};
+
+export const perplexityAiCancelBatchOutputSchema: OutputSchema = {
+ fields: batchFields,
+};
+
+export const perplexityAiCreateAgentResponseOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Response ID' },
+ { key: 'object', label: 'Object Type' },
+ { key: 'status', label: 'Status' },
+ { key: 'model', label: 'Model' },
+ {
+ key: 'output',
+ label: 'Output',
+ labelKey: 'type',
+ listItems: [
+ { key: 'type', label: 'Type' },
+ { key: 'id', label: 'Item ID' },
+ { key: 'role', label: 'Role' },
+ { key: 'status', label: 'Status' },
+ {
+ key: 'content',
+ label: 'Content',
+ labelKey: 'type',
+ listItems: [
+ { key: 'type', label: 'Type' },
+ { key: 'text', label: 'Text' },
+ { key: 'annotations', label: 'Annotations' },
+ ],
+ },
+ { key: 'queries', label: 'Search Queries' },
+ {
+ key: 'results',
+ label: 'Search Results',
+ labelKey: 'title',
+ listItems: searchResultFields,
+ },
+ ],
+ },
+ { key: 'error', label: 'Error' },
+ { key: 'incomplete_details', label: 'Incomplete Details' },
+ { key: 'background', label: 'Background', format: 'boolean' },
+ { key: 'store', label: 'Stored', format: 'boolean' },
+ { key: 'previous_response_id', label: 'Previous Response ID' },
+ { key: 'instructions', label: 'Instructions' },
+ { key: 'max_output_tokens', label: 'Max Output Tokens', format: 'number' },
+ { key: 'max_tool_calls', label: 'Max Tool Calls', format: 'number' },
+ {
+ key: 'tools',
+ label: 'Tools',
+ labelKey: 'type',
+ listItems: [{ key: 'type', label: 'Type' }],
+ },
+ { key: 'tool_choice', label: 'Tool Choice' },
+ {
+ key: 'parallel_tool_calls',
+ label: 'Parallel Tool Calls',
+ format: 'boolean',
+ },
+ { key: 'reasoning', label: 'Reasoning' },
+ {
+ key: 'text',
+ label: 'Text Format',
+ children: [
+ {
+ key: 'format',
+ label: 'Format',
+ children: [{ key: 'type', label: 'Type' }],
+ },
+ ],
+ },
+ { key: 'temperature', label: 'Temperature', format: 'number' },
+ { key: 'top_p', label: 'Top P', format: 'number' },
+ { key: 'top_logprobs', label: 'Top Logprobs', format: 'number' },
+ { key: 'frequency_penalty', label: 'Frequency Penalty', format: 'number' },
+ { key: 'presence_penalty', label: 'Presence Penalty', format: 'number' },
+ { key: 'truncation', label: 'Truncation' },
+ { key: 'service_tier', label: 'Service Tier' },
+ { key: 'prompt_cache_key', label: 'Prompt Cache Key' },
+ { key: 'safety_identifier', label: 'Safety Identifier' },
+ { key: 'user', label: 'User' },
+ { key: 'metadata', label: 'Metadata', dynamicKey: true },
+ {
+ key: 'usage',
+ label: 'Usage',
+ children: [
+ { key: 'input_tokens', label: 'Input Tokens', format: 'number' },
+ {
+ key: 'input_tokens_details',
+ label: 'Input Token Details',
+ children: [
+ { key: 'cached_tokens', label: 'Cached Tokens', format: 'number' },
+ {
+ key: 'cache_read_input_tokens',
+ label: 'Cache Read Tokens',
+ format: 'number',
+ },
+ {
+ key: 'cache_creation_input_tokens',
+ label: 'Cache Write Tokens',
+ format: 'number',
+ },
+ ],
+ },
+ { key: 'output_tokens', label: 'Output Tokens', format: 'number' },
+ {
+ key: 'output_tokens_details',
+ label: 'Output Token Details',
+ children: [
+ {
+ key: 'reasoning_tokens',
+ label: 'Reasoning Tokens',
+ format: 'number',
+ },
+ ],
+ },
+ { key: 'total_tokens', label: 'Total Tokens', format: 'number' },
+ {
+ key: 'cost',
+ label: 'Cost',
+ children: [
+ {
+ key: 'total_cost',
+ label: 'Total Cost',
+ format: 'currency',
+ currency: 'USD',
+ },
+ {
+ key: 'input_cost',
+ label: 'Input Cost',
+ format: 'currency',
+ currency: 'USD',
+ },
+ {
+ key: 'output_cost',
+ label: 'Output Cost',
+ format: 'currency',
+ currency: 'USD',
+ },
+ {
+ key: 'cache_creation_cost',
+ label: 'Cache Write Cost',
+ format: 'currency',
+ currency: 'USD',
+ },
+ {
+ key: 'tool_calls_cost',
+ label: 'Tool Calls Cost',
+ format: 'currency',
+ currency: 'USD',
+ },
+ {
+ key: 'tool_calls_cost_details',
+ label: 'Tool Calls Cost by Tool',
+ dynamicKey: true,
+ },
+ { key: 'currency', label: 'Currency' },
+ ],
+ },
+ {
+ key: 'tool_calls_details',
+ label: 'Tool Calls by Tool',
+ dynamicKey: true,
+ children: [
+ { key: 'invocation', label: 'Calls', format: 'number' },
+ {
+ key: 'cost_usd',
+ label: 'Cost',
+ format: 'currency',
+ currency: 'USD',
+ },
+ ],
+ },
+ ],
+ },
+ { key: 'created_at', label: 'Created At (Unix Seconds)', format: 'number' },
+ {
+ key: 'completed_at',
+ label: 'Completed At (Unix Seconds)',
+ format: 'number',
+ },
+ ],
+};
+
+export const perplexityAiCreateBatchOutputSchema: OutputSchema = {
+ fields: batchFields,
+};
+
+export const perplexityAiCreateContextualizedEmbeddingsOutputSchema: OutputSchema =
+ {
+ fields: [
+ {
+ key: 'data',
+ label: 'Documents',
+ listItems: [
+ { key: 'index', label: 'Document Index', format: 'number' },
+ {
+ key: 'data',
+ label: 'Chunk Embeddings',
+ listItems: embeddingFields,
+ },
+ { key: 'object', label: 'Object Type' },
+ ],
+ },
+ { key: 'model', label: 'Model' },
+ { key: 'object', label: 'Object Type' },
+ { key: 'usage', label: 'Usage', children: embeddingUsageFields },
+ ],
+ };
+
+export const perplexityAiCreateEmbeddingsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Embeddings', listItems: embeddingFields },
+ { key: 'model', label: 'Model' },
+ { key: 'object', label: 'Object Type' },
+ { key: 'usage', label: 'Usage', children: embeddingUsageFields },
+ ],
+};
+
+export const perplexityAiCreateSkillOutputSchema: OutputSchema = {
+ fields: skillFields,
+};
+
+export const perplexityAiDeleteFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'File ID' },
+ { key: 'deleted', label: 'Deleted', format: 'boolean' },
+ { key: 'object', label: 'Object Type' },
+ ],
+};
+
+export const perplexityAiDeleteSkillOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'skill_id', label: 'Skill ID' },
+ { key: 'deleted', label: 'Deleted', format: 'boolean' },
+ ],
+};
+
+export const perplexityAiDownloadAgentResponseFileOutputSchema: OutputSchema = {
+ fields: savedFileFields,
+};
+
+export const perplexityAiEvaluateDecisionsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'answers',
+ label: 'Answers',
+ dynamicKey: true,
+ labelKey: 'type',
+ children: [
+ { key: 'type', label: 'Question Type' },
+ { key: 'noul', label: 'Probability of Yes', format: 'number' },
+ { key: 'choice', label: 'Choice' },
+ { key: 'score', label: 'Score', format: 'number' },
+ { key: 'confidence', label: 'Confidence', format: 'number' },
+ { key: 'probabilities', label: 'Probabilities', dynamicKey: true },
+ { key: 'legend', label: 'Score Levels', dynamicKey: true },
+ ],
+ },
+ { key: 'model', label: 'Model' },
+ {
+ key: 'usage',
+ label: 'Usage',
+ children: [
+ { key: 'input_tokens', label: 'Input Tokens', format: 'number' },
+ { key: 'output_tokens', label: 'Output Tokens', format: 'number' },
+ ],
+ },
+ ],
+};
+
+export const perplexityAiGetBatchOutputSchema: OutputSchema = {
+ fields: batchFields,
+};
+
+export const perplexityAiGetFileOutputSchema: OutputSchema = {
+ fields: batchFileFields,
+};
+
+export const perplexityAiGetSkillDownloadUrlOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'download_url', label: 'Download URL', format: 'url' },
+ { key: 'name', label: 'Name' },
+ { key: 'revision', label: 'Revision' },
+ ],
+};
+
+export const perplexityAiListAgentResponseFilesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'data',
+ label: 'Files',
+ labelKey: 'filename',
+ listItems: [
+ { key: 'id', label: 'File ID' },
+ { key: 'filename', label: 'File Name' },
+ { key: 'bytes', label: 'Size', format: 'filesize' },
+ { key: 'object', label: 'Object Type' },
+ {
+ key: 'created_at',
+ label: 'Created At (Unix Seconds)',
+ format: 'number',
+ },
+ ],
+ },
+ { key: 'object', label: 'Object Type' },
+ ],
+};
+
+export const perplexityAiListBatchesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Batches', labelKey: 'id', listItems: batchFields },
+ ...pageFields,
+ ],
+};
+
+export const perplexityAiListFilesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'data',
+ label: 'Files',
+ labelKey: 'filename',
+ listItems: batchFileFields,
+ },
+ ...pageFields,
+ ],
+};
+
+export const perplexityAiListModelsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'data',
+ label: 'Models',
+ labelKey: 'id',
+ listItems: [
+ { key: 'id', label: 'Model ID' },
+ { key: 'owned_by', label: 'Provider' },
+ { key: 'object', label: 'Object Type' },
+ { key: 'created', label: 'Created (Unix Seconds)', format: 'number' },
+ {
+ key: 'pricing',
+ label: 'Pricing',
+ children: [
+ {
+ key: 'input',
+ label: 'Input per 1M Tokens',
+ format: 'currency',
+ currency: 'USD',
+ },
+ {
+ key: 'output',
+ label: 'Output per 1M Tokens',
+ format: 'currency',
+ currency: 'USD',
+ },
+ {
+ key: 'cache_read',
+ label: 'Cache Read per 1M Tokens',
+ format: 'currency',
+ currency: 'USD',
+ },
+ {
+ key: 'cache_write',
+ label: 'Cache Write per 1M Tokens',
+ format: 'currency',
+ currency: 'USD',
+ },
+ { key: 'unit', label: 'Unit' },
+ ],
+ },
+ ],
+ },
+ { key: 'object', label: 'Object Type' },
+ ],
+};
+
+export const perplexityAiListSkillRevisionsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'revisions',
+ label: 'Revisions',
+ labelKey: 'revision',
+ listItems: [
+ { key: 'revision', label: 'Revision' },
+ { key: 'name', label: 'Name' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ ],
+ },
+ { key: 'next_page_token', label: 'Next Page Token' },
+ ],
+};
+
+export const perplexityAiListSkillsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'skills',
+ label: 'Skills',
+ labelKey: 'name',
+ listItems: [
+ { key: 'skill_id', label: 'Skill ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'revision', label: 'Revision' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+ ],
+ },
+ { key: 'next_page_token', label: 'Next Page Token' },
+ ],
+};
+
+export const perplexityAiSearchWebOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Search ID' },
+ {
+ key: 'results',
+ label: 'Results',
+ labelKey: 'title',
+ listItems: searchResultFields,
+ },
+ ],
+};
+
+export const perplexityAiUpdateSkillOutputSchema: OutputSchema = {
+ fields: [
+ ...skillFields,
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+ ],
+};
diff --git a/packages/pieces/community/perplexity-ai/test/ask-ai.test.ts b/packages/pieces/community/perplexity-ai/test/ask-ai.test.ts
index da6c37f67c3..2a5c30e52a5 100644
--- a/packages/pieces/community/perplexity-ai/test/ask-ai.test.ts
+++ b/packages/pieces/community/perplexity-ai/test/ask-ai.test.ts
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { createChatCompletionAction } from '../src/lib/actions/create-chat-completion.action';
+import { createChatCompletionAction } from '../src/lib/actions/create-chat-completion';
const sendRequest = vi.fn();