-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fixes #17048: GitHub actions for retrieving commits #17052
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||||||||||||||||||||||||||
name: Retrieve Commits | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
on: | ||||||||||||||||||||||||||||||
workflow_dispatch: | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
jobs: | ||||||||||||||||||||||||||||||
fetch-commits: | ||||||||||||||||||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
- name: Checkout repository | ||||||||||||||||||||||||||||||
uses: actions/checkout@v3 | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
- name: List commits | ||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||
gh api \ | ||||||||||||||||||||||||||||||
-H "Accept: application/vnd.github+json" \ | ||||||||||||||||||||||||||||||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||||||||||||||||||||||||||||||
/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/commits?per_page=30 \ | ||||||||||||||||||||||||||||||
> commits.json | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
- name: Get specific commit | ||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||
gh api \ | ||||||||||||||||||||||||||||||
-H "Accept: application/vnd.github+json" \ | ||||||||||||||||||||||||||||||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||||||||||||||||||||||||||||||
/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/commits/${{ github.sha }} \ | ||||||||||||||||||||||||||||||
> commit.json | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
- name: Upload commit data | ||||||||||||||||||||||||||||||
uses: actions/upload-artifact@v3 | ||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||
name: commit-data | ||||||||||||||||||||||||||||||
path: | | ||||||||||||||||||||||||||||||
commits.json | ||||||||||||||||||||||||||||||
commit.json | ||||||||||||||||||||||||||||||
Comment on lines
+33
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update to latest upload-artifact action version and fix formatting The workflow is using an outdated version of the upload-artifact action and has formatting issues. - name: Upload commit data
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: commit-data
path: |
commits.json
- commit.json
+ commit.json 📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.7)34-34: the runner of "actions/upload-artifact@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) 🪛 YAMLlint (1.37.1)[error] 39-39: no new line character at the end of file (new-line-at-end-of-file) [error] 39-39: trailing spaces (trailing-spaces) 🤖 Prompt for AI Agents
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question here isn't better to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jcortes Absolutely! You're correct that Version v4 offers several improvements:
The upgrade is straightforward and maintains the same API, so it's definitely the recommended approach for this workflow. 🐰💡 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is the solution to this issue #17031 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
import openai from "../../openai.app.mjs"; | ||
import common from "../common/common.mjs"; | ||
import constants from "../../common/constants.mjs"; | ||
import axios from "axios"; | ||
|
||
export default { | ||
...common, | ||
key: "openai-chat-using-responses-api", | ||
name: "Chat with OpenAI Responses API", | ||
version: "0.0.1", | ||
description: | ||
"Send a chat via the Responses API, mixing built-in tools and MCP servers.", | ||
type: "action", | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
props: { | ||
openai, | ||
modelId: { | ||
type: "string", | ||
label: "Model", | ||
description: "Model used to generate the response", | ||
default: "gpt-4o", | ||
options: [ | ||
"gpt-4o", | ||
"gpt-4o-mini", | ||
], | ||
}, | ||
input: { | ||
type: "string", | ||
label: "Chat Input", | ||
description: "Text input to the model used to generate a response", | ||
}, | ||
instructions: { | ||
type: "string", | ||
label: "Instructions", | ||
description: | ||
"Inserts a system (or developer) message as the first item in the model's context", | ||
optional: true, | ||
}, | ||
previousResponseId: { | ||
type: "string", | ||
label: "Previous Response ID", | ||
description: | ||
"The unique ID of the previous response to the model. Use this to create multi-turn conversations", | ||
optional: true, | ||
}, | ||
truncation: { | ||
type: "string", | ||
label: "Truncation", | ||
description: | ||
"Specifies the truncation mode for the response if it exceeds the context window", | ||
default: "auto", | ||
options: [ | ||
"auto", | ||
"disabled", | ||
], | ||
optional: true, | ||
}, | ||
responseFormat: { | ||
type: "string", | ||
label: "Response Format", | ||
description: | ||
"- **text**: Returns unstructured text output.\n- **json_schema**: Enforces a specific structure using a JSON schema.", | ||
options: [ | ||
"text", | ||
"json_schema", | ||
], | ||
default: "text", | ||
optional: true, | ||
reloadProps: true, | ||
}, | ||
skipThisStep: { | ||
type: "boolean", | ||
label: "Skip This Step", | ||
description: | ||
"Pass in a boolean custom expression to skip execution at runtime", | ||
default: false, | ||
optional: true, | ||
}, | ||
builtInTools: { | ||
type: "string[]", | ||
label: "Built-In Tools", | ||
description: | ||
"Which of OpenAI’s first-party tools to enable (web search, file search, code interpreter).", | ||
options: [ | ||
{ | ||
label: "Web Search", | ||
value: "web_search_preview", | ||
}, | ||
{ | ||
label: "File Search", | ||
value: "file_search", | ||
}, | ||
{ | ||
label: "Code Interpreter", | ||
value: "code_interpreter", | ||
}, | ||
], | ||
default: [], | ||
}, | ||
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, | ||
}, | ||
mcpTools: { | ||
type: "string[]", | ||
label: "MCP Tools to Enable", | ||
description: | ||
"Select which tools from your MCP servers to include in the chat.", | ||
optional: true, | ||
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; | ||
}, | ||
Comment on lines
+106
to
+126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please create a propDefinition for this one in import { axios } from "@pipedream/platform"; |
||
}, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
additionalProps() { | ||
const props = {}; | ||
if ( | ||
this.responseFormat === | ||
constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value | ||
) { | ||
props.jsonSchema = { | ||
type: "string", | ||
label: "JSON Schema", | ||
description: | ||
"Define the schema that the model's output must adhere to.", | ||
}; | ||
} | ||
return props; | ||
}, | ||
methods: { | ||
...common.methods, | ||
}, | ||
async run({ $ }) { | ||
if (this.skipThisStep) { | ||
$.export("$summary", "Step execution skipped"); | ||
return; | ||
} | ||
const tools = []; | ||
for (const id of this.builtInTools) { | ||
tools.push({ | ||
type: id, | ||
}); | ||
} | ||
for (const id of this.mcpTools || []) { | ||
tools.push({ | ||
type: id, | ||
}); | ||
} | ||
const data = { | ||
model: this.modelId, | ||
input: this.input, | ||
instructions: this.instructions, | ||
previous_response_id: this.previousResponseId, | ||
truncation: this.truncation, | ||
tools, | ||
}; | ||
if ( | ||
this.responseFormat === | ||
constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value | ||
) { | ||
try { | ||
data.text = { | ||
format: { | ||
type: this.responseFormat, | ||
...JSON.parse(this.jsonSchema), | ||
}, | ||
}; | ||
} catch { | ||
throw new Error("Invalid JSON format in the provided JSON Schema"); | ||
} | ||
} | ||
Comment on lines
+171
to
+185
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainFix response format property name and improve error handling The response format configuration appears to use an incorrect property name, and the JSON parsing error message could be more helpful. if (
this.responseFormat ===
constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value
) {
try {
- data.text = {
+ data.response_format = {
format: {
type: this.responseFormat,
...JSON.parse(this.jsonSchema),
},
};
- } catch {
- throw new Error("Invalid JSON format in the provided JSON Schema");
+ } catch (error) {
+ throw new Error(`Invalid JSON Schema: ${error.message}. Please ensure your schema is valid JSON.`);
}
} Please verify the correct property name for the OpenAI Responses API by checking the API documentation: 🌐 Web query:
💡 Result: In OpenAI's API, the property used to specify the response format is Fix response format property and enhance JSON parsing error The API expects a top-level • File: Proposed diff: if (
this.responseFormat ===
constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value
) {
try {
- data.text = {
+ data.format = {
type: this.responseFormat,
- ...JSON.parse(this.jsonSchema),
+ ...JSON.parse(this.jsonSchema),
};
- } catch {
- throw new Error("Invalid JSON format in the provided JSON Schema");
+ } catch (error) {
+ throw new Error(`Invalid JSON Schema: ${error.message}. Please ensure your schema is valid JSON.`);
}
}
🤖 Prompt for AI Agents
|
||
const response = await this.openai.responses({ | ||
$, | ||
data, | ||
}); | ||
if (response) { | ||
$.export("$summary", `Chat sent (id: ${response.id})`); | ||
$.export("chat_responses", response.output); | ||
} | ||
return response; | ||
}, | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.
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
Update to latest checkout action version
The workflow is using an outdated version of the checkout action. Please update to v4 for improved security and compatibility.
📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.7)
13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents
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.
is not better to use
actions/checkout@v4
here?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.
@jcortes Yes, absolutely!
actions/checkout@v4
is definitely better than v3. As the actionlint tool flagged, v3 is too old to run on current GitHub Actions runners, and v4 provides improved security and compatibility.The suggestion to update to v4 is spot on - it's a straightforward upgrade that will ensure the workflow continues to work properly on GitHub's infrastructure.
🐰✨