From 33ed485631c96919a60452aacea8e50795b93f1a Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Tue, 14 Oct 2025 13:25:17 -0400 Subject: [PATCH 1/3] chat-completions-advanced --- .../chat-completions-advanced.mjs | 185 ++++++++++++++++++ .../chat-completions/chat-completions.mjs | 4 +- components/perplexity/package.json | 2 +- 3 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 components/perplexity/actions/chat-completions-advanced/chat-completions-advanced.mjs diff --git a/components/perplexity/actions/chat-completions-advanced/chat-completions-advanced.mjs b/components/perplexity/actions/chat-completions-advanced/chat-completions-advanced.mjs new file mode 100644 index 0000000000000..fe1295f45debd --- /dev/null +++ b/components/perplexity/actions/chat-completions-advanced/chat-completions-advanced.mjs @@ -0,0 +1,185 @@ +import app from "../../perplexity.app.mjs"; + +export default { + key: "perplexity-chat-completions-advanced", + name: "Chat Completions (Advanced)", + description: "Generates a model's response for the given chat conversation with multi-message support and Perplexity search controls. Docs: https://docs.perplexity.ai/api-reference/chat-completions-post", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + model: { + propDefinition: [ + app, + "model", + ], + }, + messages: { + type: "string[]", + label: "Messages (JSON strings or UI collection)", + description: "Array of message objects: [{ role: 'system'|'user'|'assistant', content: '...' }, ...]. If provided, 'role' and 'content' are ignored.", + optional: true, + }, + system: { + type: "string", + label: "System", + description: "Optional system prompt injected as the first message", + optional: true, + }, + role: { + propDefinition: [ + app, + "role", + ], + optional: true, + }, + content: { + propDefinition: [ + app, + "content", + ], + optional: true, + }, + temperature: { + type: "string", + label: "Temperature", + description: "Sampling temperature. Higher values = more diverse output.", + optional: true, + }, + topP: { + type: "string", + label: "Top-p", + description: "Nucleus sampling probability mass. Use either temperature or top_p.", + optional: true, + }, + maxTokens: { + type: "integer", + label: "Max Output Tokens", + description: "Cap response length (Sonar Pro practical max output ~8k).", + optional: true, + }, + stream: { + type: "boolean", + label: "Stream", + description: "Enable server-side streaming. This action will still buffer and return the final text.", + optional: true, + default: false, + }, + searchDomainFilter: { + type: "string[]", + label: "Search Domain Filter", + description: "Limit web search to these domains (e.g., ['sec.gov','ft.com'])", + optional: true, + }, + searchRecencyFilter: { + type: "string", + label: "Search Recency Filter", + description: "Prefer recent sources (e.g., 'day', 'week', 'month', 'year')", + optional: true, + }, + topK: { + type: "integer", + label: "Top K", + description: "Restrict number of retrieved items considered", + optional: true, + }, + returnImages: { + type: "boolean", + label: "Return Images", + description: "Ask API to include images when applicable", + optional: true, + default: false, + }, + returnRelatedQuestions: { + type: "boolean", + label: "Return Related Questions", + description: "Ask API to include related questions in response", + optional: true, + default: false, + }, + }, + + async run({ $ }) { + // Build messages array + let messages = []; + const provided = this.messages && this.messages.length > 0; + + if (provided) { + // Accept messages as array of either objects or JSON strings + messages = this.messages.map((m) => + typeof m === "string" + ? JSON.parse(m) + : m); + } else { + if (!this.content) { + throw new Error("Either provide `messages` or `content`."); + } + // Back-compat single-turn + if (this.system) { + messages.push({ + role: "system", + content: this.system, + }); + } + messages.push({ + role: this.role || "user", + content: this.content, + }); + } + + const data = { + model: this.model, + messages, + // Generation knobs + ...(this.temperature != null && { + temperature: +this.temperature, + }), + ...(this.topP != null && { + top_p: +this.topP, + }), + ...(this.maxTokens != null && { + max_tokens: this.maxTokens, + }), + ...(this.stream != null && { + stream: this.stream, + }), + // Perplexity search controls + ...(this.searchDomainFilter && { + search_domain_filter: this.searchDomainFilter, + }), + ...(this.searchRecencyFilter && { + search_recency_filter: this.searchRecencyFilter, + }), + ...(this.topK != null && { + top_k: this.topK, + }), + ...(this.returnImages != null && { + return_images: this.returnImages, + }), + ...(this.returnRelatedQuestions != null && { + return_related_questions: this.returnRelatedQuestions, + }), + }; + + const response = await this.app.chatCompletions({ + $, + data, + }); + + $.export( + "$summary", + `Perplexity ${this.model} responded${ + this.stream + ? " (streaming buffered)" + : "" + }`, + ); + + return response; + }, +}; diff --git a/components/perplexity/actions/chat-completions/chat-completions.mjs b/components/perplexity/actions/chat-completions/chat-completions.mjs index 8bb4654cf2928..10ae7eae4ea1d 100644 --- a/components/perplexity/actions/chat-completions/chat-completions.mjs +++ b/components/perplexity/actions/chat-completions/chat-completions.mjs @@ -3,8 +3,8 @@ import app from "../../perplexity.app.mjs"; export default { key: "perplexity-chat-completions", name: "Chat Completions", - description: "Generates a model's response for the given chat conversation. [See the documentation](https://docs.perplexity.ai/reference/post_chat_completions)", - version: "0.0.6", + description: "Generates a model's response for the given chat conversation. [See the documentation](https://docs.perplexity.ai/api-reference/chat-completions-post)", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/perplexity/package.json b/components/perplexity/package.json index 4b680ddcf5819..9bfb67becc30c 100644 --- a/components/perplexity/package.json +++ b/components/perplexity/package.json @@ -13,6 +13,6 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.6.5" + "@pipedream/platform": "^3.1.0" } } From 1c2d0a5499bfb2ae43d83b0ea2d6fcf8477e710f Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Tue, 14 Oct 2025 13:39:05 -0400 Subject: [PATCH 2/3] pnpm-lock.yaml --- pnpm-lock.yaml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 931f07d548291..78a1063f18c09 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1367,8 +1367,7 @@ importers: components/azure_api_for_fhir: {} - components/azure_cosmos_db: - specifiers: {} + components/azure_cosmos_db: {} components/azure_devops: dependencies: @@ -1673,8 +1672,7 @@ importers: components/billsby: {} - components/binalyze_air: - specifiers: {} + components/binalyze_air: {} components/bingx: dependencies: @@ -6064,8 +6062,7 @@ importers: specifier: ^8.8.0 version: 8.9.0 - components/google_perspective: - specifiers: {} + components/google_perspective: {} components/google_photos: dependencies: @@ -10587,8 +10584,8 @@ importers: components/perplexity: dependencies: '@pipedream/platform': - specifier: ^1.6.5 - version: 1.6.6 + specifier: ^3.1.0 + version: 3.1.0 components/perry_github_test: {} @@ -31322,22 +31319,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net supports-color@10.0.0: resolution: {integrity: sha512-HRVVSbCCMbj7/kdWF9Q+bbckjBHLtHMEoJWlkmYzzdwhYMkjkOwubLM6t7NbWKjgKamGDrWL1++KrjUO1t9oAQ==} From ede64b48629e42c3f031da47ffecc96d845cb92b Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Tue, 14 Oct 2025 13:50:37 -0400 Subject: [PATCH 3/3] package version --- components/perplexity/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/perplexity/package.json b/components/perplexity/package.json index 9bfb67becc30c..162b628d64c1a 100644 --- a/components/perplexity/package.json +++ b/components/perplexity/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/perplexity", - "version": "0.1.4", + "version": "0.2.0", "description": "Pipedream Perplexity Components", "main": "perplexity.app.mjs", "keywords": [