Skip to content

Commit 2b7246a

Browse files
authored
New Components - letzai (#16567)
* letzai init * [Components] letzai #16541 Sources - New Image - New Image Edit Actions - Create New Image - Get Image Information - Create Image Edit * update pnpm * remove quriiri file
1 parent c7830a2 commit 2b7246a

File tree

13 files changed

+1258
-8
lines changed

13 files changed

+1258
-8
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import { parseObject } from "../../common/utils.mjs";
3+
import letzai from "../../letzai.app.mjs";
4+
5+
export default {
6+
key: "letzai-create-image-edit",
7+
name: "Create Image Edit",
8+
description: "Creates an image edit task that modifies an existing image using inpainting or outpainting in LetzAI. [See the documentation](https://api.letz.ai/doc#/image-edit/image_edit_create)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
letzai,
13+
mode: {
14+
propDefinition: [
15+
letzai,
16+
"mode",
17+
],
18+
reloadProps: true,
19+
},
20+
originalImageCompletionId: {
21+
propDefinition: [
22+
letzai,
23+
"originalImageCompletionId",
24+
],
25+
optional: true,
26+
},
27+
imageUrl: {
28+
propDefinition: [
29+
letzai,
30+
"imageUrl",
31+
],
32+
optional: true,
33+
},
34+
prompt: {
35+
propDefinition: [
36+
letzai,
37+
"promptEdit",
38+
],
39+
optional: true,
40+
},
41+
mask: {
42+
propDefinition: [
43+
letzai,
44+
"mask",
45+
],
46+
optional: true,
47+
},
48+
width: {
49+
propDefinition: [
50+
letzai,
51+
"width",
52+
],
53+
optional: true,
54+
},
55+
height: {
56+
propDefinition: [
57+
letzai,
58+
"height",
59+
],
60+
optional: true,
61+
},
62+
imageCompletionsCount: {
63+
propDefinition: [
64+
letzai,
65+
"imageCompletionsCount",
66+
],
67+
optional: true,
68+
},
69+
settings: {
70+
propDefinition: [
71+
letzai,
72+
"settings",
73+
],
74+
optional: true,
75+
},
76+
webhookUrl: {
77+
propDefinition: [
78+
letzai,
79+
"webhookUrl",
80+
],
81+
optional: true,
82+
},
83+
},
84+
async additionalProps(props) {
85+
if (this.mode === "in") {
86+
props.mask.optional = false;
87+
}
88+
return {};
89+
},
90+
async run({ $ }) {
91+
if (!this.originalImageCompletionId && !this.imageUrl) {
92+
throw new ConfigurationError("Please provide either an original image completion ID or an image URL.");
93+
}
94+
95+
const {
96+
letzai,
97+
settings,
98+
...data
99+
} = this;
100+
101+
const response = await letzai.createImageEditTask({
102+
$,
103+
data: {
104+
...data,
105+
settings: settings && parseObject(settings),
106+
},
107+
});
108+
$.export("$summary", `Image edit task created successfully with request ID: ${response.id}`);
109+
return response;
110+
},
111+
};
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import letzai from "../../letzai.app.mjs";
2+
3+
export default {
4+
key: "letzai-create-new-image",
5+
name: "Create New Image",
6+
description: "Creates a new image generation task from a text prompt in LetzAI. [See the documentation](https://api.letz.ai/doc#/images/images_create)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
letzai,
11+
info: {
12+
type: "alert",
13+
alertType: "info",
14+
content: "**Note:** You can monitor the generation status using the Action \"Get Image Information\".",
15+
},
16+
prompt: {
17+
propDefinition: [
18+
letzai,
19+
"prompt",
20+
],
21+
},
22+
width: {
23+
propDefinition: [
24+
letzai,
25+
"width",
26+
],
27+
optional: true,
28+
},
29+
height: {
30+
propDefinition: [
31+
letzai,
32+
"height",
33+
],
34+
optional: true,
35+
},
36+
quality: {
37+
propDefinition: [
38+
letzai,
39+
"quality",
40+
],
41+
optional: true,
42+
},
43+
creativity: {
44+
propDefinition: [
45+
letzai,
46+
"creativity",
47+
],
48+
optional: true,
49+
},
50+
hasWatermark: {
51+
propDefinition: [
52+
letzai,
53+
"hasWatermark",
54+
],
55+
optional: true,
56+
},
57+
systemVersion: {
58+
propDefinition: [
59+
letzai,
60+
"systemVersion",
61+
],
62+
optional: true,
63+
},
64+
mode: {
65+
propDefinition: [
66+
letzai,
67+
"generationMode",
68+
],
69+
optional: true,
70+
},
71+
},
72+
async run({ $ }) {
73+
const {
74+
letzai,
75+
...data
76+
} = this;
77+
78+
const response = await letzai.createImage({
79+
$,
80+
data,
81+
});
82+
$.export("$summary", `Created image with ID: ${response.id}`);
83+
return response;
84+
},
85+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import letzai from "../../letzai.app.mjs";
2+
3+
export default {
4+
key: "letzai-get-image-information",
5+
name: "Get Image Information",
6+
description: "Retrieves information about a specific image by ID. [See the documentation](https://api.letz.ai/doc#/images/images_get)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
letzai,
11+
imageId: {
12+
propDefinition: [
13+
letzai,
14+
"imageId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.letzai.retrieveImageInfo({
20+
$,
21+
imageId: this.imageId,
22+
});
23+
$.export("$summary", `Successfully retrieved information for image ID: ${this.imageId}`);
24+
return response;
25+
},
26+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export const LIMIT = 50;
2+
3+
export const GENERATION_MODE_OPTIONS = [
4+
{
5+
label: "Default",
6+
value: "default",
7+
},
8+
{
9+
label: "Sigma",
10+
value: "sigma",
11+
},
12+
];
13+
14+
export const SYSTEM_VERSION_OPTIONS = [
15+
{
16+
label: "Version 2",
17+
value: 2,
18+
},
19+
{
20+
label: "Version 3",
21+
value: 3,
22+
},
23+
];
24+
25+
export const MODE_OPTIONS = [
26+
{
27+
label: "Inpainting",
28+
value: "in",
29+
},
30+
{
31+
label: "Outpainting",
32+
value: "out",
33+
},
34+
];

components/letzai/common/utils.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

0 commit comments

Comments
 (0)