Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions components/burstyai/actions/run-workflow/run-workflow.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import burstyai from "../../burstyai.app.mjs";

export default {
key: "burstyai-run-workflow",
name: "Run Workflow",
description: "Triggers an AI workflow on BurstyAI. [See the documentation](https://burstyai.readme.io/reference)",
version: "0.0.1",
type: "action",
props: {
burstyai,
workflow: {
type: "string",
label: "Workflow ID",
description: "The ID of the specific workflow to run. When viewing the workflow in BurstyAI, the ID is the last part of the URL. Example: `65e1cd00141fdc000195cb88`",
},
params: {
type: "object",
label: "Parameters",
description: "Optional parameters for the workflow",
optional: true,
},
waitForCompletion: {
type: "boolean",
label: "Wait For Completion",
description: "Set to `true` to poll the API in 3-second intervals until the workflow is completed",
optional: true,
},
},
async run({ $ }) {
let response = await this.burstyai.triggerWorkflow({
$,
workflow: this.workflow,
data: {
params: this.params || {},
},
});

const jobId = response;

if (this.waitForCompletion) {
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
while (response?.jobStatus !== "END" && response?.jobStatus !== "ERROR") {
response = await this.burstyai.getWorkflowExecutionResult({
$,
jobId,
});
await timer(3000);
}
}

if (response?.status === "END") {
$.export("$summary", `Successfully triggered workflow ${this.workflow}`);
}

return response;
},
};
41 changes: 36 additions & 5 deletions components/burstyai/burstyai.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "burstyai",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://app.burstyai.com/burstyai";
},
_makeRequest(opts = {}) {
const {
$ = this,
path,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: `${this._baseUrl()}${path}`,
headers: {
Authorization: `Bearer ${this.$auth.api_key}`,
},
});
},
triggerWorkflow({
workflow, ...args
}) {
return this._makeRequest({
method: "POST",
path: `/aiflows/${workflow}/async_run`,
...args,
});
},
getWorkflowExecutionResult({
jobId, ...args
}) {
return this._makeRequest({
path: `/aiflowjobs/${jobId}/result`,
...args,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/burstyai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/burstyai",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream BurstyAI Components",
"main": "burstyai.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
2 changes: 1 addition & 1 deletion components/franconnect/franconnect.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading