Skip to content

Commit 1e68e23

Browse files
committed
Runware: new action component
1 parent 6da9785 commit 1e68e23

File tree

5 files changed

+379
-7
lines changed

5 files changed

+379
-7
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
import { v4 as uuid } from "uuid";
2+
import app from "../../runware.app.mjs";
3+
4+
export default {
5+
key: "runware-request-task",
6+
name: "Request Task",
7+
description: "Request one task to be processed by the Runware API. [See the documentation](https://docs.runware.ai/en/image-inference/api-reference).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
taskType: {
13+
propDefinition: [
14+
app,
15+
"taskType",
16+
],
17+
},
18+
outputType: {
19+
propDefinition: [
20+
app,
21+
"outputType",
22+
],
23+
},
24+
outputFormat: {
25+
propDefinition: [
26+
app,
27+
"outputFormat",
28+
],
29+
},
30+
uploadEndpoint: {
31+
propDefinition: [
32+
app,
33+
"uploadEndpoint",
34+
],
35+
},
36+
checkNSFW: {
37+
propDefinition: [
38+
app,
39+
"checkNSFW",
40+
],
41+
},
42+
includeCost: {
43+
propDefinition: [
44+
app,
45+
"includeCost",
46+
],
47+
},
48+
positivePrompt: {
49+
propDefinition: [
50+
app,
51+
"positivePrompt",
52+
],
53+
},
54+
negativePrompt: {
55+
propDefinition: [
56+
app,
57+
"negativePrompt",
58+
],
59+
},
60+
seedImage: {
61+
propDefinition: [
62+
app,
63+
"seedImage",
64+
],
65+
},
66+
maskImage: {
67+
propDefinition: [
68+
app,
69+
"maskImage",
70+
],
71+
},
72+
strength: {
73+
propDefinition: [
74+
app,
75+
"strength",
76+
],
77+
},
78+
height: {
79+
propDefinition: [
80+
app,
81+
"height",
82+
],
83+
},
84+
width: {
85+
propDefinition: [
86+
app,
87+
"width",
88+
],
89+
},
90+
model: {
91+
propDefinition: [
92+
app,
93+
"model",
94+
],
95+
},
96+
steps: {
97+
propDefinition: [
98+
app,
99+
"steps",
100+
],
101+
},
102+
scheduler: {
103+
propDefinition: [
104+
app,
105+
"scheduler",
106+
],
107+
},
108+
seed: {
109+
propDefinition: [
110+
app,
111+
"seed",
112+
],
113+
},
114+
numberResults: {
115+
propDefinition: [
116+
app,
117+
"numberResults",
118+
],
119+
},
120+
},
121+
methods: {
122+
requestTask(args = {}) {
123+
return this.app.post(args);
124+
},
125+
},
126+
async run({ $ }) {
127+
const {
128+
requestTask,
129+
taskType,
130+
outputType,
131+
outputFormat,
132+
uploadEndpoint,
133+
checkNSFW,
134+
includeCost,
135+
positivePrompt,
136+
negativePrompt,
137+
seedImage,
138+
maskImage,
139+
strength,
140+
height,
141+
width,
142+
model,
143+
steps,
144+
scheduler,
145+
seed,
146+
numberResults,
147+
} = this;
148+
149+
const response = await requestTask({
150+
$,
151+
data: [
152+
{
153+
taskUUID: uuid(),
154+
taskType,
155+
outputType,
156+
outputFormat,
157+
uploadEndpoint,
158+
checkNSFW,
159+
includeCost,
160+
positivePrompt,
161+
negativePrompt,
162+
seedImage,
163+
maskImage,
164+
strength,
165+
height,
166+
width,
167+
model,
168+
steps,
169+
scheduler,
170+
seed,
171+
numberResults,
172+
},
173+
],
174+
});
175+
176+
$.export("$summary", `Successfully requested task with UUID \`${response.data[0].taskUUID}\`.`);
177+
return response;
178+
},
179+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const BASE_URL = "https://api.runware.ai";
2+
const VERSION_PATH = "/v1";
3+
4+
const TASK_TYPE = {
5+
IMAGE_INFERENCE: {
6+
value: "imageInference",
7+
label: "Image Inference",
8+
},
9+
IMAGE_CONTROL_NET_PREPROCESS: {
10+
value: "imageControlNetPreProcess",
11+
label: "Image Control Net Preprocess",
12+
},
13+
IMAGE_UPSCALE: {
14+
value: "imageUpscale",
15+
label: "Image Upscale",
16+
},
17+
IMAGE_BACKGROUND_REMOVAL: {
18+
value: "imageBackgroundRemoval",
19+
label: "Image Background Removal",
20+
},
21+
IMAGE_CAPTION: {
22+
value: "imageCaption",
23+
label: "Image Caption",
24+
},
25+
PROMPT_ENHANCE: {
26+
value: "promptEnhance",
27+
label: "Prompt Enhance",
28+
},
29+
};
30+
31+
export default {
32+
BASE_URL,
33+
VERSION_PATH,
34+
TASK_TYPE,
35+
};

components/runware/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/runware",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Runware Components",
55
"main": "runware.app.mjs",
66
"keywords": [
@@ -11,5 +11,9 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "3.0.3",
17+
"uuid": "^10.0.0"
1418
}
15-
}
19+
}

0 commit comments

Comments
 (0)