-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Issue #17031 #17036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Issue #17031 #17036
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
@jeevikasirwani is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughA new action module, "Chat with OpenAI Responses API," has been introduced. This module allows sending chat messages to the OpenAI Responses API, with configurable options for model selection, chat input, system instructions, tool integrations, response formatting, and support for multi-turn conversations. Dynamic property handling and validation are included. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ActionModule
participant OpenAIResponsesAPI
participant MCPServer (optional)
User->>ActionModule: Provide input, model, and options
ActionModule->>MCPServer: (If MCP tools enabled) Fetch available tools
ActionModule->>OpenAIResponsesAPI: Send chat request with parameters
OpenAIResponsesAPI-->>ActionModule: Return response and responseId
ActionModule-->>User: Export chat output and summary
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (2)
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs (2)
21-24
: Consider expanding model options.The current model selection is limited to only
gpt-4o
andgpt-4o-mini
. Consider including other models that support the Responses API to provide users with more flexibility.
114-125
: Optimize MCP server requests for better performance.The current implementation makes sequential requests to MCP servers. Consider making parallel requests to improve performance when multiple servers are configured.
async options({ mcpServers }) { if (!mcpServers?.length) return []; - const all = []; - for (let url of mcpServers) { - url = url.replace(/\/$/, ""); - try { - const { data } = await axios.get(`${url}/tools`, { - timeout: 5000, - validateStatus: (status) => status === 200, - }); - if (data?.tools && Array.isArray(data.tools)) { - for (const t of data.tools) { - if (t?.name && t?.id) { - all.push({ - label: t.name, - value: t.id, - }); - } - } - } - } catch (error) { - console.warn(`Failed to fetch tools from ${url}:`, error.message); - } - } + + const requests = mcpServers.map(async (url) => { + url = url.replace(/\/$/, ""); + try { + const { data } = await axios.get(`${url}/tools`, { + timeout: 5000, + validateStatus: (status) => status === 200, + }); + if (data?.tools && Array.isArray(data.tools)) { + return data.tools + .filter(t => t?.name && t?.id) + .map(t => ({ + label: t.name, + value: t.id, + })); + } + } catch (error) { + console.warn(`Failed to fetch tools from ${url}:`, error.message); + } + return []; + }); + + const results = await Promise.all(requests); + const all = results.flat(); return all; },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
components/quickbooks/package-lock.json
is excluded by!**/package-lock.json
components/smiirl/package-lock.json
is excluded by!**/package-lock.json
docs-v2/yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
helpers/package-lock.json
is excluded by!**/package-lock.json
packages/connect-react/examples/nextjs/package-lock.json
is excluded by!**/package-lock.json
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (1)
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
(1 hunks)
🔇 Additional comments (1)
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs (1)
8-8
:⚠️ Potential issueFix typo in the action key.
There's a typo in the key: "opeai" should be "openai".
- key: "openai-chat-using-responses-api", + key: "openai-chat-with-responses-api",Likely an incorrect or invalid review comment.
const response = await this.openai.responses({ | ||
$, | ||
data, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the OpenAI responses method exists.
Ensure that the this.openai.responses()
method is available in the OpenAI app module, as this appears to be a newer API endpoint.
🏁 Script executed:
#!/bin/bash
# Description: Verify if the responses method exists in the OpenAI app module
# Expected: Find the responses method implementation
# Search for the responses method in OpenAI related files
ast-grep --pattern 'responses($_) {
$$$
}'
# Also search for any mention of responses API
rg -A 5 "responses.*api|responses.*method"
Length of output: 6777
Missing responses
Method on OpenAI Client
We couldn’t locate a responses
method on this.openai
. The OpenAI app module does not currently expose this endpoint, so calling this.openai.responses()
will fail.
Please update accordingly:
- Confirm the correct client method name for the new Responses API (e.g.,
chat.completions
,chat.stream
, etc.). - If
responses
is intended, implement it in the OpenAI app module (components/openai
), wiring through to the actual API endpoint. - Otherwise, replace the call in
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
(around lines 186–189) with the appropriate existing method.
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 186 to 189, the call to this.openai.responses() is invalid because
the OpenAI client does not have a responses method. To fix this, verify the
correct existing method name for the intended API call (such as chat.completions
or chat.stream) and replace this.openai.responses() with that method. If the
responses method is required, implement it in the OpenAI app module under
components/openai by adding the appropriate API endpoint wiring before using it
here.
for (const id of this.mcpTools || []) { | ||
tools.push({ | ||
type: id, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add array validation for mcpTools.
The code assumes mcpTools
is an array without validation, which could cause runtime errors if the property is undefined or not an array.
- for (const id of this.mcpTools || []) {
+ for (const id of Array.isArray(this.mcpTools) ? this.mcpTools : []) {
tools.push({
type: id,
});
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
for (const id of this.mcpTools || []) { | |
tools.push({ | |
type: id, | |
}); | |
} | |
for (const id of Array.isArray(this.mcpTools) ? this.mcpTools : []) { | |
tools.push({ | |
type: id, | |
}); | |
} |
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 158 to 162, the code iterates over this.mcpTools assuming it is
always an array, which can cause runtime errors if it is undefined or not an
array. Add a validation check to confirm this.mcpTools is an array before the
loop, and only iterate if the check passes. This prevents errors by ensuring the
code handles cases where mcpTools is missing or not an array.
async options({ mcpServers }) { | ||
if (!mcpServers?.length) return []; | ||
const all = []; | ||
for (let url of mcpServers) { | ||
url = url.replace(/\/$/, ""); | ||
const { data } = await axios.get(`${url}/tools`); | ||
for (const t of data.tools) { | ||
all.push({ | ||
label: t.name, | ||
value: t.id, | ||
}); | ||
} | ||
} | ||
return all; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comprehensive error handling for MCP server requests.
The async options method lacks error handling for HTTP requests to MCP servers. If a server is unreachable or returns an error, this will cause the component to fail during property loading.
async options({ mcpServers }) {
if (!mcpServers?.length) return [];
const all = [];
for (let url of mcpServers) {
url = url.replace(/\/$/, "");
- const { data } = await axios.get(`${url}/tools`);
- for (const t of data.tools) {
- all.push({
- label: t.name,
- value: t.id,
- });
- }
+ try {
+ const { data } = await axios.get(`${url}/tools`, {
+ timeout: 5000,
+ validateStatus: (status) => status === 200,
+ });
+ if (data?.tools && Array.isArray(data.tools)) {
+ for (const t of data.tools) {
+ if (t?.name && t?.id) {
+ all.push({
+ label: t.name,
+ value: t.id,
+ });
+ }
+ }
+ }
+ } catch (error) {
+ console.warn(`Failed to fetch tools from ${url}:`, error.message);
+ // Continue with other servers instead of failing completely
+ }
}
return all;
},
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
async options({ mcpServers }) { | |
if (!mcpServers?.length) return []; | |
const all = []; | |
for (let url of mcpServers) { | |
url = url.replace(/\/$/, ""); | |
const { data } = await axios.get(`${url}/tools`); | |
for (const t of data.tools) { | |
all.push({ | |
label: t.name, | |
value: t.id, | |
}); | |
} | |
} | |
return all; | |
}, | |
async options({ mcpServers }) { | |
if (!mcpServers?.length) return []; | |
const all = []; | |
for (let url of mcpServers) { | |
url = url.replace(/\/$/, ""); | |
try { | |
const { data } = await axios.get(`${url}/tools`, { | |
timeout: 5000, | |
validateStatus: (status) => status === 200, | |
}); | |
if (data?.tools && Array.isArray(data.tools)) { | |
for (const t of data.tools) { | |
if (t?.name && t?.id) { | |
all.push({ | |
label: t.name, | |
value: t.id, | |
}); | |
} | |
} | |
} | |
} catch (error) { | |
console.warn(`Failed to fetch tools from ${url}:`, error.message); | |
// Continue with other servers instead of failing completely | |
} | |
} | |
return all; | |
}, |
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 112 to 126, the async options method does not handle errors from
axios.get calls to MCP servers, which can cause failures if a server is
unreachable or returns an error. Add try-catch blocks around the axios.get
request to catch any errors, log or handle them appropriately, and ensure the
method continues processing other servers without failing entirely. This will
make the property loading more robust against individual server issues.
try { | ||
data.text = { | ||
format: { | ||
type: this.responseFormat, | ||
...JSON.parse(this.jsonSchema), | ||
}, | ||
}; | ||
} catch { | ||
throw new Error("Invalid JSON format in the provided JSON Schema"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve JSON schema validation and error handling.
The current error handling for JSON parsing is too generic and doesn't provide helpful feedback to users.
try {
+ if (!this.jsonSchema || typeof this.jsonSchema !== 'string') {
+ throw new Error("JSON Schema is required when using json_schema response format");
+ }
+ const parsedSchema = JSON.parse(this.jsonSchema);
+ if (typeof parsedSchema !== 'object' || parsedSchema === null) {
+ throw new Error("JSON Schema must be a valid JSON object");
+ }
data.text = {
format: {
type: this.responseFormat,
- ...JSON.parse(this.jsonSchema),
+ ...parsedSchema,
},
};
- } catch {
- throw new Error("Invalid JSON format in the provided JSON Schema");
+ } catch (error) {
+ if (error instanceof SyntaxError) {
+ throw new Error(`Invalid JSON syntax in schema: ${error.message}`);
+ }
+ throw error;
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
try { | |
data.text = { | |
format: { | |
type: this.responseFormat, | |
...JSON.parse(this.jsonSchema), | |
}, | |
}; | |
} catch { | |
throw new Error("Invalid JSON format in the provided JSON Schema"); | |
} | |
try { | |
if (!this.jsonSchema || typeof this.jsonSchema !== 'string') { | |
throw new Error("JSON Schema is required when using json_schema response format"); | |
} | |
const parsedSchema = JSON.parse(this.jsonSchema); | |
if (typeof parsedSchema !== 'object' || parsedSchema === null) { | |
throw new Error("JSON Schema must be a valid JSON object"); | |
} | |
data.text = { | |
format: { | |
type: this.responseFormat, | |
...parsedSchema, | |
}, | |
}; | |
} catch (error) { | |
if (error instanceof SyntaxError) { | |
throw new Error(`Invalid JSON syntax in schema: ${error.message}`); | |
} | |
throw error; | |
} |
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 175 to 184, the catch block for JSON.parse is too generic and does
not provide detailed error feedback. Modify the catch block to capture the
specific error thrown by JSON.parse and include its message in the thrown Error,
so users receive more informative feedback about what went wrong with the JSON
schema parsing.
mcpServers: { | ||
type: "string[]", | ||
label: "MCP Server URLs", | ||
description: | ||
"Enter your MCP server base URLs. To set one up, visit https://mcp.pipedream.com/ and click “Create new server.", | ||
optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding URL validation for MCP servers.
User-provided MCP server URLs could potentially be used for SSRF attacks. Consider validating that URLs point to expected domains or implementing allowlists.
mcpServers: {
type: "string[]",
label: "MCP Server URLs",
description:
"Enter your MCP server base URLs. To set one up, visit https://mcp.pipedream.com/ and click "Create new server.",
optional: true,
+ validate: (urls) => {
+ if (!urls?.length) return true;
+ for (const url of urls) {
+ try {
+ const parsed = new URL(url);
+ if (!['http:', 'https:'].includes(parsed.protocol)) {
+ throw new Error(`Invalid protocol: ${parsed.protocol}`);
+ }
+ } catch (error) {
+ throw new Error(`Invalid URL "${url}": ${error.message}`);
+ }
+ }
+ return true;
+ },
},
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
mcpServers: { | |
type: "string[]", | |
label: "MCP Server URLs", | |
description: | |
"Enter your MCP server base URLs. To set one up, visit https://mcp.pipedream.com/ and click “Create new server.", | |
optional: true, | |
mcpServers: { | |
type: "string[]", | |
label: "MCP Server URLs", | |
description: | |
"Enter your MCP server base URLs. To set one up, visit https://mcp.pipedream.com/ and click “Create new server.", | |
optional: true, | |
validate: (urls) => { | |
if (!urls?.length) return true; | |
for (const url of urls) { | |
try { | |
const parsed = new URL(url); | |
if (!['http:', 'https:'].includes(parsed.protocol)) { | |
throw new Error(`Invalid protocol: ${parsed.protocol}`); | |
} | |
} catch (error) { | |
throw new Error(`Invalid URL \"${url}\": ${error.message}`); | |
} | |
} | |
return true; | |
}, | |
}, |
🤖 Prompt for AI Agents
In
components/openai/actions/chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
around lines 99 to 104, the MCP server URLs input lacks validation, which could
lead to SSRF vulnerabilities. Implement validation logic to ensure each URL is
well-formed and restrict URLs to a predefined allowlist of trusted domains or
patterns. This can be done by parsing each URL and checking its hostname against
the allowed domains before accepting them.
WHY
Add “Chat with OpenAI Responses API” action
This PR adds a new action that lets you call the OpenAI Responses API with both built-in tools and tools from MCP servers.
What’s changed
File: pipedream\components\openai\actions\chat-with-opeai-responses-api/chat-with-openai-responses-api.mjs
Props added
builtInTools: pick any of OpenAI’s tools (web search, file search, code interpreter)
mcpServers: enter one or more MCP server URLs (see https://mcp.pipedream.com/)
mcpTools: loads the list of tools from each MCP server URL for you to select
run() logic
Combines builtInTools and mcpTools into one tools array
Sends a single openai.responses.create() request with that array
Keeps existing features : Skip-step flag,JSON-schema output option,Shared methods from common.
Summary by CodeRabbit