@taskmagic/apps-image-router 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/package.json +48 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +33 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-image.d.ts +7 -0
- package/src/lib/actions/create-image.js +122 -0
- package/src/lib/actions/create-image.js.map +1 -0
- package/src/lib/actions/image-to-image.d.ts +9 -0
- package/src/lib/actions/image-to-image.js +179 -0
- package/src/lib/actions/image-to-image.js.map +1 -0
- package/src/lib/common/auth.d.ts +1 -0
- package/src/lib/common/auth.js +48 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +10 -0
- package/src/lib/common/client.js +27 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/props.d.ts +1 -0
- package/src/lib/common/props.js +142 -0
- package/src/lib/common/props.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taskmagic/apps-image-router",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@anthropic-ai/sdk": "0.33.1",
|
|
6
|
+
"@sinclair/typebox": "0.34.11",
|
|
7
|
+
"axios": "1.17.0",
|
|
8
|
+
"axios-retry": "4.4.1",
|
|
9
|
+
"deepmerge-ts": "7.1.0",
|
|
10
|
+
"form-data": "4.0.5",
|
|
11
|
+
"mime-types": "2.1.35",
|
|
12
|
+
"nanoid": "3.3.8",
|
|
13
|
+
"openai": "4.67.1",
|
|
14
|
+
"replicate": "0.34.1",
|
|
15
|
+
"semver": "7.6.0",
|
|
16
|
+
"zod": "3.25.76",
|
|
17
|
+
"@taskmagic/pieces-common": "0.4.4",
|
|
18
|
+
"@taskmagic/pieces-framework": "0.7.46",
|
|
19
|
+
"@taskmagic/shared": "0.10.171",
|
|
20
|
+
"tslib": "1.14.1"
|
|
21
|
+
},
|
|
22
|
+
"overrides": {
|
|
23
|
+
"cross-spawn": "7.0.6",
|
|
24
|
+
"elliptic": "^6.6.1",
|
|
25
|
+
"fast-xml-parser": "^4.4.1",
|
|
26
|
+
"protobufjs": "^7.5.5",
|
|
27
|
+
"tmp": "^0.2.4",
|
|
28
|
+
"koa": "^2.16.4",
|
|
29
|
+
"picomatch": "^4.0.4",
|
|
30
|
+
"langsmith": "^0.6.0",
|
|
31
|
+
"serialize-javascript": "^6.0.2",
|
|
32
|
+
"elevenlabs": {
|
|
33
|
+
"form-data": "^4.0.4"
|
|
34
|
+
},
|
|
35
|
+
"@tryfabric/martian": {
|
|
36
|
+
"@notionhq/client": "$@notionhq/client"
|
|
37
|
+
},
|
|
38
|
+
"vite": {
|
|
39
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"resolutions": {
|
|
43
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
44
|
+
},
|
|
45
|
+
"types": "./src/index.d.ts",
|
|
46
|
+
"main": "./src/index.js",
|
|
47
|
+
"type": "commonjs"
|
|
48
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const imageRouter: import("@taskmagic/pieces-framework").Piece<import("@taskmagic/pieces-framework").SecretTextProperty<true>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageRouter = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
5
|
+
const shared_1 = require("@taskmagic/shared");
|
|
6
|
+
const auth_1 = require("./lib/common/auth");
|
|
7
|
+
const create_image_1 = require("./lib/actions/create-image");
|
|
8
|
+
const image_to_image_1 = require("./lib/actions/image-to-image");
|
|
9
|
+
exports.imageRouter = (0, pieces_framework_1.createPiece)({
|
|
10
|
+
displayName: 'ImageRouter',
|
|
11
|
+
auth: auth_1.imageRouterAuth,
|
|
12
|
+
minimumSupportedRelease: '0.30.0',
|
|
13
|
+
categories: [shared_1.PieceCategory.ARTIFICIAL_INTELLIGENCE],
|
|
14
|
+
description: 'Generate images with any model available on ImageRouter.',
|
|
15
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/image-router.png',
|
|
16
|
+
authors: ['onyedikachi-david'],
|
|
17
|
+
ai: {
|
|
18
|
+
description: 'Generate and edit images with any AI model on ImageRouter: create images from a text prompt or transform existing images with optional masks.',
|
|
19
|
+
keywords: [
|
|
20
|
+
'image generation',
|
|
21
|
+
'text to image',
|
|
22
|
+
'image to image',
|
|
23
|
+
'ai image',
|
|
24
|
+
'generate image',
|
|
25
|
+
'edit image',
|
|
26
|
+
'inpainting',
|
|
27
|
+
'imagerouter',
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
actions: [create_image_1.createImage, image_to_image_1.imageToImage],
|
|
31
|
+
triggers: [],
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/image-router/src/index.ts"],"names":[],"mappings":";;;AAAA,kEAA0D;AAC1D,8CAAkD;AAClD,4CAAoD;AACpD,6DAAyD;AACzD,iEAA4D;AAE/C,QAAA,WAAW,GAAG,IAAA,8BAAW,EAAC;IACrC,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,sBAAe;IACrB,uBAAuB,EAAE,QAAQ;IACjC,UAAU,EAAE,CAAC,sBAAa,CAAC,uBAAuB,CAAC;IACnD,WAAW,EAAE,0DAA0D;IACvE,OAAO,EAAE,sDAAsD;IAC/D,OAAO,EAAE,CAAC,mBAAmB,CAAC;IAC9B,EAAE,EAAE;QACF,WAAW,EACT,+IAA+I;QACjJ,QAAQ,EAAE;YACR,kBAAkB;YAClB,eAAe;YACf,gBAAgB;YAChB,UAAU;YACV,gBAAgB;YAChB,YAAY;YACZ,YAAY;YACZ,aAAa;SACd;KACF;IACD,OAAO,EAAE,CAAC,0BAAW,EAAE,6BAAY,CAAC;IACpC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const createImage: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
prompt: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
model: import("@taskmagic/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
quality: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
5
|
+
size: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
responseFormat: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createImage = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const shared_1 = require("@taskmagic/shared");
|
|
8
|
+
const auth_1 = require("../common/auth");
|
|
9
|
+
const client_1 = require("../common/client");
|
|
10
|
+
const props_1 = require("../common/props");
|
|
11
|
+
const node_crypto_1 = require("node:crypto");
|
|
12
|
+
exports.createImage = (0, pieces_framework_1.createAction)({
|
|
13
|
+
auth: auth_1.imageRouterAuth,
|
|
14
|
+
name: 'createImage',
|
|
15
|
+
displayName: 'Create Image',
|
|
16
|
+
description: 'Generate an image from a text prompt using any available model',
|
|
17
|
+
props: {
|
|
18
|
+
prompt: pieces_framework_1.Property.ShortText({
|
|
19
|
+
displayName: 'Prompt',
|
|
20
|
+
description: 'Text prompt describing the image you want to generate',
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
model: props_1.modelDropdown,
|
|
24
|
+
quality: pieces_framework_1.Property.StaticDropdown({
|
|
25
|
+
displayName: 'Quality',
|
|
26
|
+
description: 'Image quality (not all models support this)',
|
|
27
|
+
required: false,
|
|
28
|
+
defaultValue: 'auto',
|
|
29
|
+
options: {
|
|
30
|
+
options: [
|
|
31
|
+
{ label: 'Auto', value: 'auto' },
|
|
32
|
+
{ label: 'Low', value: 'low' },
|
|
33
|
+
{ label: 'Medium', value: 'medium' },
|
|
34
|
+
{ label: 'High', value: 'high' },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
size: pieces_framework_1.Property.ShortText({
|
|
39
|
+
displayName: 'Size',
|
|
40
|
+
description: 'Image size (e.g., 1024x1024). Use "auto" for default size.',
|
|
41
|
+
required: false,
|
|
42
|
+
defaultValue: 'auto',
|
|
43
|
+
}),
|
|
44
|
+
responseFormat: pieces_framework_1.Property.StaticDropdown({
|
|
45
|
+
displayName: 'Response Format',
|
|
46
|
+
description: 'How to receive the generated image',
|
|
47
|
+
required: false,
|
|
48
|
+
defaultValue: 'url',
|
|
49
|
+
options: {
|
|
50
|
+
options: [
|
|
51
|
+
{ label: 'URL (saved in logs)', value: 'url' },
|
|
52
|
+
{ label: 'Base64 JSON (saved in logs)', value: 'b64_json' },
|
|
53
|
+
{ label: 'Base64 Ephemeral (not saved)', value: 'b64_ephemeral' },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
run(context) {
|
|
59
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const { prompt, model, quality, size, responseFormat } = context.propsValue;
|
|
61
|
+
const body = {
|
|
62
|
+
prompt,
|
|
63
|
+
model,
|
|
64
|
+
};
|
|
65
|
+
if (quality && quality !== 'auto') {
|
|
66
|
+
body['quality'] = quality;
|
|
67
|
+
}
|
|
68
|
+
if (size && size !== 'auto') {
|
|
69
|
+
body['size'] = size;
|
|
70
|
+
}
|
|
71
|
+
if (responseFormat && responseFormat !== 'url') {
|
|
72
|
+
body['response_format'] = responseFormat;
|
|
73
|
+
}
|
|
74
|
+
const response = yield (0, client_1.imageRouterApiCall)({
|
|
75
|
+
apiKey: context.auth,
|
|
76
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
77
|
+
resourceUri: '/v1/openai/images/generations',
|
|
78
|
+
body,
|
|
79
|
+
});
|
|
80
|
+
const images = response.data || [];
|
|
81
|
+
if (images.length === 0) {
|
|
82
|
+
return response;
|
|
83
|
+
}
|
|
84
|
+
const savedImages = yield Promise.all(images.map((img, index) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
var _a;
|
|
86
|
+
let imageBuffer;
|
|
87
|
+
let fileName;
|
|
88
|
+
if (img.b64_json) {
|
|
89
|
+
imageBuffer = Buffer.from(img.b64_json, 'base64');
|
|
90
|
+
fileName = `${(0, node_crypto_1.randomBytes)(8).toString('hex')}-${(0, shared_1.kebabCase)(prompt).slice(0, 40)}-${index + 1}.png`;
|
|
91
|
+
}
|
|
92
|
+
else if (img.url) {
|
|
93
|
+
const downloadResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
94
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
95
|
+
url: img.url,
|
|
96
|
+
responseType: 'arraybuffer',
|
|
97
|
+
});
|
|
98
|
+
imageBuffer = Buffer.from(downloadResponse.body);
|
|
99
|
+
const urlExtension = ((_a = img.url.split('.').pop()) === null || _a === void 0 ? void 0 : _a.split('?')[0]) || 'png';
|
|
100
|
+
fileName = `${(0, node_crypto_1.randomBytes)(8).toString('hex')}-${(0, shared_1.kebabCase)(prompt).slice(0, 40)}-${index + 1}.${urlExtension}`;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
throw new Error(`Image ${index + 1} has no URL or base64 data`);
|
|
104
|
+
}
|
|
105
|
+
const fileUrl = yield context.files.write({
|
|
106
|
+
fileName,
|
|
107
|
+
data: imageBuffer,
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
index: index + 1,
|
|
111
|
+
url: img.url || null,
|
|
112
|
+
b64_json: img.b64_json || null,
|
|
113
|
+
revised_prompt: img.revised_prompt || prompt,
|
|
114
|
+
savedFile: fileUrl,
|
|
115
|
+
fileName,
|
|
116
|
+
};
|
|
117
|
+
})));
|
|
118
|
+
return Object.assign(Object.assign({}, response), { images: savedImages });
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=create-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-image.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/image-router/src/lib/actions/create-image.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAAkE;AAClE,8CAA8C;AAC9C,yCAAiD;AACjD,6CAAsD;AACtD,2CAAgD;AAChD,6CAA0C;AAE7B,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,gEAAgE;IAC7E,KAAK,EAAE;QACL,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,qBAAa;QACpB,OAAO,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC/B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,MAAM;YACpB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;oBAChC,EAAE,KAAK,EAAE,K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AAG,CAAA,MAAA,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,0CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,KAAI,KAAK,CAAC;oBACtE,QAAQ,GAAG,GAAG,IAAA,yBAAW,EAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAA,kBAAS,EAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,YAAY,EAAE,CAAC;gBAChH,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,GAAG,CAAC,4BAA4B,CAAC,CAAC;gBAClE,CAAC;gBAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;oBACxC,QAAQ;oBACR,IAAI,EAAE,WAAW;iBAClB,CAAC,CAAC;gBAEH,OAAO;oBACL,KAAK,EAAE,KAAK,GAAG,CAAC;oBAChB,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,IAAI;oBACpB,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,IAAI;oBAC9B,cAAc,EAAE,GAAG,CAAC,cAAc,IAAI,MAAM;oBAC5C,SAAS,EAAE,OAAO;oBAClB,QAAQ;iBACT,CAAC;YACJ,CAAC,CAAA,CAAC,CACH,CAAC;YAEF,uCACK,QAAQ,KACX,MAAM,EAAE,WAAW,IACnB;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const imageToImage: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
prompt: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
model: import("@taskmagic/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
images: import("@taskmagic/pieces-framework").ArrayProperty<true>;
|
|
5
|
+
masks: import("@taskmagic/pieces-framework").ArrayProperty<true> | import("@taskmagic/pieces-framework").ArrayProperty<false>;
|
|
6
|
+
quality: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
7
|
+
size: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
responseFormat: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageToImage = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const shared_1 = require("@taskmagic/shared");
|
|
8
|
+
const auth_1 = require("../common/auth");
|
|
9
|
+
const props_1 = require("../common/props");
|
|
10
|
+
const client_1 = require("../common/client");
|
|
11
|
+
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
12
|
+
const node_crypto_1 = require("node:crypto");
|
|
13
|
+
exports.imageToImage = (0, pieces_framework_1.createAction)({
|
|
14
|
+
auth: auth_1.imageRouterAuth,
|
|
15
|
+
name: 'imageToImage',
|
|
16
|
+
displayName: 'Image to Image',
|
|
17
|
+
description: 'Generate or edit images using input image(s) with optional mask',
|
|
18
|
+
props: {
|
|
19
|
+
prompt: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: 'Prompt',
|
|
21
|
+
description: 'Text prompt describing the image transformation',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
model: props_1.modelDropdown,
|
|
25
|
+
images: pieces_framework_1.Property.Array({
|
|
26
|
+
displayName: 'Input Images',
|
|
27
|
+
description: 'Input image(s) for editing (up to 16 images)',
|
|
28
|
+
required: true,
|
|
29
|
+
properties: {
|
|
30
|
+
image: pieces_framework_1.Property.File({
|
|
31
|
+
displayName: 'Image',
|
|
32
|
+
description: 'Input image file',
|
|
33
|
+
required: true,
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
masks: pieces_framework_1.Property.Array({
|
|
38
|
+
displayName: 'Masks',
|
|
39
|
+
description: 'Mask file(s) to specify areas to edit (some models require this)',
|
|
40
|
+
required: false,
|
|
41
|
+
properties: {
|
|
42
|
+
mask: pieces_framework_1.Property.File({
|
|
43
|
+
displayName: 'Mask',
|
|
44
|
+
description: 'Mask image file',
|
|
45
|
+
required: true,
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
quality: pieces_framework_1.Property.StaticDropdown({
|
|
50
|
+
displayName: 'Quality',
|
|
51
|
+
description: 'Image quality (not all models support this)',
|
|
52
|
+
required: false,
|
|
53
|
+
defaultValue: 'auto',
|
|
54
|
+
options: {
|
|
55
|
+
options: [
|
|
56
|
+
{ label: 'Auto', value: 'auto' },
|
|
57
|
+
{ label: 'Low', value: 'low' },
|
|
58
|
+
{ label: 'Medium', value: 'medium' },
|
|
59
|
+
{ label: 'High', value: 'high' },
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
size: pieces_framework_1.Property.ShortText({
|
|
64
|
+
displayName: 'Size',
|
|
65
|
+
description: 'Image size (e.g., 1024x1024). Use "auto" for default size.',
|
|
66
|
+
required: false,
|
|
67
|
+
defaultValue: 'auto',
|
|
68
|
+
}),
|
|
69
|
+
responseFormat: pieces_framework_1.Property.StaticDropdown({
|
|
70
|
+
displayName: 'Response Format',
|
|
71
|
+
description: 'How to receive the generated image',
|
|
72
|
+
required: false,
|
|
73
|
+
defaultValue: 'url',
|
|
74
|
+
options: {
|
|
75
|
+
options: [
|
|
76
|
+
{ label: 'URL (saved in logs)', value: 'url' },
|
|
77
|
+
{ label: 'Base64 JSON (saved in logs)', value: 'b64_json' },
|
|
78
|
+
{ label: 'Base64 Ephemeral (not saved)', value: 'b64_ephemeral' },
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
run(context) {
|
|
84
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
var _a, _b, _c;
|
|
86
|
+
const { prompt, model, images: inputImages, masks, quality, size, responseFormat } = context.propsValue;
|
|
87
|
+
const imageItems = (_a = inputImages) !== null && _a !== void 0 ? _a : [];
|
|
88
|
+
const maskItems = (_b = masks) !== null && _b !== void 0 ? _b : [];
|
|
89
|
+
if (!imageItems || imageItems.length === 0) {
|
|
90
|
+
throw new Error('At least one input image is required');
|
|
91
|
+
}
|
|
92
|
+
if (imageItems.length > 16) {
|
|
93
|
+
throw new Error('Maximum 16 images allowed');
|
|
94
|
+
}
|
|
95
|
+
const formData = new form_data_1.default();
|
|
96
|
+
formData.append('prompt', prompt);
|
|
97
|
+
formData.append('model', model);
|
|
98
|
+
for (const imageItem of imageItems) {
|
|
99
|
+
if (imageItem.image) {
|
|
100
|
+
formData.append('image[]', Buffer.from(imageItem.image.data), imageItem.image.filename);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (maskItems && maskItems.length > 0) {
|
|
104
|
+
for (const maskItem of maskItems) {
|
|
105
|
+
if (maskItem.mask) {
|
|
106
|
+
formData.append('mask[]', Buffer.from(maskItem.mask.data), maskItem.mask.filename);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (quality && quality !== 'auto') {
|
|
111
|
+
formData.append('quality', quality);
|
|
112
|
+
}
|
|
113
|
+
if (size && size !== 'auto') {
|
|
114
|
+
formData.append('size', size);
|
|
115
|
+
}
|
|
116
|
+
if (responseFormat && responseFormat !== 'url') {
|
|
117
|
+
formData.append('response_format', responseFormat);
|
|
118
|
+
}
|
|
119
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
120
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
121
|
+
url: `${client_1.BASE_URL}/v1/openai/images/edits`,
|
|
122
|
+
authentication: {
|
|
123
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
124
|
+
token: context.auth,
|
|
125
|
+
},
|
|
126
|
+
headers: Object.assign({}, formData.getHeaders()),
|
|
127
|
+
body: formData,
|
|
128
|
+
});
|
|
129
|
+
if (response.status >= 400) {
|
|
130
|
+
const errorBody = response.body;
|
|
131
|
+
const errorMessage = ((_c = errorBody === null || errorBody === void 0 ? void 0 : errorBody.error) === null || _c === void 0 ? void 0 : _c.message) ||
|
|
132
|
+
(errorBody === null || errorBody === void 0 ? void 0 : errorBody.message) ||
|
|
133
|
+
`ImageRouter API error: ${response.status}`;
|
|
134
|
+
throw new Error(errorMessage);
|
|
135
|
+
}
|
|
136
|
+
const responseBody = response.body;
|
|
137
|
+
const generatedImages = responseBody.data || [];
|
|
138
|
+
if (generatedImages.length === 0) {
|
|
139
|
+
return responseBody;
|
|
140
|
+
}
|
|
141
|
+
const savedImages = yield Promise.all(generatedImages.map((img, index) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
var _a;
|
|
143
|
+
let imageBuffer;
|
|
144
|
+
let fileName;
|
|
145
|
+
if (img.b64_json) {
|
|
146
|
+
imageBuffer = Buffer.from(img.b64_json, 'base64');
|
|
147
|
+
fileName = `${(0, node_crypto_1.randomBytes)(8).toString('hex')}-${(0, shared_1.kebabCase)(prompt).slice(0, 40)}-${index + 1}.png`;
|
|
148
|
+
}
|
|
149
|
+
else if (img.url) {
|
|
150
|
+
const downloadResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
151
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
152
|
+
url: img.url,
|
|
153
|
+
responseType: 'arraybuffer',
|
|
154
|
+
});
|
|
155
|
+
imageBuffer = Buffer.from(downloadResponse.body);
|
|
156
|
+
const urlExtension = ((_a = img.url.split('.').pop()) === null || _a === void 0 ? void 0 : _a.split('?')[0]) || 'png';
|
|
157
|
+
fileName = `${(0, node_crypto_1.randomBytes)(8).toString('hex')}-${(0, shared_1.kebabCase)(prompt).slice(0, 40)}-${index + 1}.${urlExtension}`;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
throw new Error(`Image ${index + 1} has no URL or base64 data`);
|
|
161
|
+
}
|
|
162
|
+
const fileUrl = yield context.files.write({
|
|
163
|
+
fileName,
|
|
164
|
+
data: imageBuffer,
|
|
165
|
+
});
|
|
166
|
+
return {
|
|
167
|
+
index: index + 1,
|
|
168
|
+
url: img.url || null,
|
|
169
|
+
b64_json: img.b64_json || null,
|
|
170
|
+
revised_prompt: img.revised_prompt || prompt,
|
|
171
|
+
savedFile: fileUrl,
|
|
172
|
+
fileName,
|
|
173
|
+
};
|
|
174
|
+
})));
|
|
175
|
+
return Object.assign(Object.assign({}, responseBody), { images: savedImages });
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=image-to-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-to-image.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/image-router/src/lib/actions/image-to-image.ts"],"names":[],"mappings":";;;;AAAA,kEAA6E;AAC7E,4DAAsF;AACtF,8CAA8C;AAC9C,yCAAiD;AACjD,2CAAgD;AAChD,6CAA4C;AAC5C,kEAAiC;AACjC,6CAA0C;AAU7B,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,iEAAiE;IAC9E,KAAK,EAAE;QACL,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,iDAAiD;YAC9D,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,qBAAa;QACpB,MAAM,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACrB,WAAW,EAAE,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AAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;oBACjD,MAAM,YAAY,GAAG,CAAA,MAAA,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,0CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,KAAI,KAAK,CAAC;oBACtE,QAAQ,GAAG,GAAG,IAAA,yBAAW,EAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAA,kBAAS,EAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,YAAY,EAAE,CAAC;gBAChH,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,GAAG,CAAC,4BAA4B,CAAC,CAAC;gBAClE,CAAC;gBAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;oBACxC,QAAQ;oBACR,IAAI,EAAE,WAAW;iBAClB,CAAC,CAAC;gBAEH,OAAO;oBACL,KAAK,EAAE,KAAK,GAAG,CAAC;oBAChB,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,IAAI;oBACpB,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,IAAI;oBAC9B,cAAc,EAAE,GAAG,CAAC,cAAc,IAAI,MAAM;oBAC5C,SAAS,EAAE,OAAO;oBAClB,QAAQ;iBACT,CAAC;YACJ,CAAC,CAAA,CACF,CACF,CAAC;YAEF,uCACK,YAAY,KACf,MAAM,EAAE,WAAW,IACnB;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const imageRouterAuth: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageRouterAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const client_1 = require("./client");
|
|
8
|
+
exports.imageRouterAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
9
|
+
displayName: 'API Key',
|
|
10
|
+
description: 'Your ImageRouter API key. You can get your API key from the [ImageRouter API Keys page](https://imagerouter.io/api-keys).',
|
|
11
|
+
required: true,
|
|
12
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
13
|
+
try {
|
|
14
|
+
yield (0, client_1.imageRouterApiCall)({
|
|
15
|
+
apiKey: auth,
|
|
16
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
17
|
+
resourceUri: '/v1/openai/images/generations',
|
|
18
|
+
body: {
|
|
19
|
+
prompt: 'test',
|
|
20
|
+
model: 'test/test',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
valid: true,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
29
|
+
if (message.includes('401') || message.includes('403')) {
|
|
30
|
+
return {
|
|
31
|
+
valid: false,
|
|
32
|
+
error: 'Invalid API key. Please check your API key and try again.',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (message.includes('429')) {
|
|
36
|
+
return {
|
|
37
|
+
valid: false,
|
|
38
|
+
error: 'Rate limit exceeded. Please wait a moment and try again.',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
valid: false,
|
|
43
|
+
error: `Authentication failed: ${message}. Please verify your API key is correct.`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/image-router/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,kEAAwD;AACxD,4DAAsD;AACtD,qCAA8C;AAEjC,QAAA,eAAe,GAAG,4BAAS,CAAC,UAAU,CAAC;IAClD,WAAW,EAAE,SAAS;IACtB,WAAW,EACT,2HAA2H;IAC7H,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,IAAA,2BAAkB,EAAC;gBACvB,MAAM,EAAE,IAAc;gBACtB,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,WAAW,EAAE,+BAA+B;gBAC5C,IAAI,EAAE;oBACJ,MAAM,EAAE,MAAM;oBACd,KAAK,EAAE,WAAW;iBACnB;aACF,CAAC,CAAC;YAEH,OAAO;gBACL,KAAK,EAAE,IAAI;aACZ,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAEvE,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvD,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,2DAA2D;iBACnE,CAAC;YACJ,CAAC;YAED,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,0DAA0D;iBAClE,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,0BAA0B,OAAO,0CAA0C;aACnF,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HttpMethod, HttpMessageBody } from '@taskmagic/pieces-common';
|
|
2
|
+
export declare const BASE_URL = "https://api.imagerouter.io";
|
|
3
|
+
export type ImageRouterApiCallParams = {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
method: HttpMethod;
|
|
6
|
+
resourceUri: string;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
export declare function imageRouterApiCall<T extends HttpMessageBody>({ apiKey, method, resourceUri, body, headers, }: ImageRouterApiCallParams): Promise<T>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BASE_URL = void 0;
|
|
4
|
+
exports.imageRouterApiCall = imageRouterApiCall;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
exports.BASE_URL = 'https://api.imagerouter.io';
|
|
8
|
+
function imageRouterApiCall(_a) {
|
|
9
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, method, resourceUri, body, headers = {}, }) {
|
|
10
|
+
var _b;
|
|
11
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
12
|
+
method,
|
|
13
|
+
url: `${exports.BASE_URL}${resourceUri}`,
|
|
14
|
+
headers: Object.assign({ 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, headers),
|
|
15
|
+
body,
|
|
16
|
+
});
|
|
17
|
+
if (response.status >= 400) {
|
|
18
|
+
const errorBody = response.body;
|
|
19
|
+
const errorMessage = ((_b = errorBody === null || errorBody === void 0 ? void 0 : errorBody.error) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
20
|
+
(errorBody === null || errorBody === void 0 ? void 0 : errorBody.message) ||
|
|
21
|
+
`ImageRouter API error: ${response.status}`;
|
|
22
|
+
throw new Error(errorMessage);
|
|
23
|
+
}
|
|
24
|
+
return response.body;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/image-router/src/lib/common/client.ts"],"names":[],"mappings":";;;AAYA,gDA4BC;;AAxCD,4DAAmF;AAEtE,QAAA,QAAQ,GAAG,4BAA4B,CAAC;AAUrD,SAAsB,kBAAkB;iEAA4B,EAClE,MAAM,EACN,MAAM,EACN,WAAW,EACX,IAAI,EACJ,OAAO,GAAG,EAAE,GACa;;QACzB,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAI;YAC/C,MAAM;YACN,GAAG,EAAE,GAAG,gBAAQ,GAAG,WAAW,EAAE;YAChC,OAAO,kBACL,eAAe,EAAE,UAAU,MAAM,EAAE,EACnC,cAAc,EAAE,kBAAkB,IAC/B,OAAO,CACX;YACD,IAAI;SACL,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;YAC3B,MAAM,SAAS,GAAG,QAAQ,CAAC,IAA0D,CAAC;YACtF,MAAM,YAAY,GAChB,CAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,0CAAE,OAAO;iBACzB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CAAA;gBAClB,0BAA0B,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const modelDropdown: import("@taskmagic/pieces-framework").DropdownProperty<string, true>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modelDropdown = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const client_1 = require("./client");
|
|
8
|
+
exports.modelDropdown = pieces_framework_1.Property.Dropdown({
|
|
9
|
+
displayName: 'Model',
|
|
10
|
+
description: 'Select an image generation model',
|
|
11
|
+
required: true,
|
|
12
|
+
refreshers: [],
|
|
13
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
14
|
+
if (!auth) {
|
|
15
|
+
return {
|
|
16
|
+
disabled: true,
|
|
17
|
+
placeholder: 'Please connect your account first',
|
|
18
|
+
options: [],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const response = yield (0, client_1.imageRouterApiCall)({
|
|
23
|
+
apiKey: auth,
|
|
24
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
25
|
+
resourceUri: '/v1/models?type=image',
|
|
26
|
+
});
|
|
27
|
+
let models = [];
|
|
28
|
+
if (response && typeof response === 'object') {
|
|
29
|
+
const keys = Object.keys(response);
|
|
30
|
+
if (keys.length > 0 && typeof response[keys[0]] === 'object') {
|
|
31
|
+
models = keys.map((modelId) => {
|
|
32
|
+
var _a, _b, _c, _d, _e;
|
|
33
|
+
const modelData = response[modelId];
|
|
34
|
+
const provider = ((_b = (_a = modelData.providers) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) ||
|
|
35
|
+
((_d = (_c = modelData.providers) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.name) ||
|
|
36
|
+
'';
|
|
37
|
+
const modelName = modelId.split('/').pop() || modelId;
|
|
38
|
+
const isFree = modelId.includes(':free') ||
|
|
39
|
+
((_e = modelData.providers) === null || _e === void 0 ? void 0 : _e.some((p) => {
|
|
40
|
+
var _a, _b, _c;
|
|
41
|
+
return ((_a = p.pricing) === null || _a === void 0 ? void 0 : _a.value) === 0 ||
|
|
42
|
+
(((_b = p.pricing) === null || _b === void 0 ? void 0 : _b.type) === 'fixed' && ((_c = p.pricing) === null || _c === void 0 ? void 0 : _c.value) === 0);
|
|
43
|
+
})) ||
|
|
44
|
+
false;
|
|
45
|
+
const nameLower = modelName.toLowerCase();
|
|
46
|
+
const isFast = nameLower.includes('fast') ||
|
|
47
|
+
nameLower.includes('turbo') ||
|
|
48
|
+
nameLower.includes('schnell') ||
|
|
49
|
+
nameLower.includes('flash') ||
|
|
50
|
+
nameLower.includes('lightning') ||
|
|
51
|
+
nameLower.includes('mini');
|
|
52
|
+
const isPremium = nameLower.includes('pro') ||
|
|
53
|
+
nameLower.includes('ultra') ||
|
|
54
|
+
nameLower.includes('max') ||
|
|
55
|
+
nameLower.includes('quality');
|
|
56
|
+
let category = '';
|
|
57
|
+
if (isFree) {
|
|
58
|
+
category = 'Free';
|
|
59
|
+
}
|
|
60
|
+
else if (isFast) {
|
|
61
|
+
category = 'Fast';
|
|
62
|
+
}
|
|
63
|
+
else if (isPremium) {
|
|
64
|
+
category = 'Premium';
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
category = 'Standard';
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
id: modelId,
|
|
71
|
+
name: modelName,
|
|
72
|
+
provider,
|
|
73
|
+
category,
|
|
74
|
+
isFree,
|
|
75
|
+
isFast,
|
|
76
|
+
isPremium,
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else if (Array.isArray(response)) {
|
|
81
|
+
models = response;
|
|
82
|
+
}
|
|
83
|
+
else if (Array.isArray(response.data)) {
|
|
84
|
+
models = response.data;
|
|
85
|
+
}
|
|
86
|
+
else if (Array.isArray(response.models)) {
|
|
87
|
+
models = response.models;
|
|
88
|
+
}
|
|
89
|
+
else if (Array.isArray(response.items)) {
|
|
90
|
+
models = response.items;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (models.length === 0) {
|
|
94
|
+
return {
|
|
95
|
+
disabled: true,
|
|
96
|
+
placeholder: 'No models found',
|
|
97
|
+
options: [],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const sortedModels = models.sort((a, b) => {
|
|
101
|
+
if (a.isFree && !b.isFree)
|
|
102
|
+
return -1;
|
|
103
|
+
if (!a.isFree && b.isFree)
|
|
104
|
+
return 1;
|
|
105
|
+
if (a.isFast && !b.isFast)
|
|
106
|
+
return -1;
|
|
107
|
+
if (!a.isFast && b.isFast)
|
|
108
|
+
return 1;
|
|
109
|
+
if (a.isPremium && !b.isPremium)
|
|
110
|
+
return -1;
|
|
111
|
+
if (!a.isPremium && b.isPremium)
|
|
112
|
+
return 1;
|
|
113
|
+
return a.name.localeCompare(b.name);
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
disabled: false,
|
|
117
|
+
options: sortedModels.map((model) => {
|
|
118
|
+
const modelId = model.id || '';
|
|
119
|
+
const modelName = model.name || modelId.split('/').pop() || modelId;
|
|
120
|
+
const provider = model.provider || '';
|
|
121
|
+
const category = model.category || '';
|
|
122
|
+
const label = provider
|
|
123
|
+
? `[${category}] ${modelName} (${provider})`
|
|
124
|
+
: `[${category}] ${modelName}`;
|
|
125
|
+
return {
|
|
126
|
+
label,
|
|
127
|
+
value: modelId,
|
|
128
|
+
};
|
|
129
|
+
}),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
134
|
+
return {
|
|
135
|
+
disabled: true,
|
|
136
|
+
placeholder: `Failed to load models: ${message}`,
|
|
137
|
+
options: [],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}),
|
|
141
|
+
});
|
|
142
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/image-router/src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,kEAAuD;AACvD,4DAAsD;AACtD,qCAA8C;AAYjC,QAAA,aAAa,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAC7C,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,kCAAkC;IAC/C,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,mCAAmC;gBAChD,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAkB,EAAsB;gBAC7D,MAAM,EAAE,IAAc;gBACtB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,uBAAuB;aACrC,CAAC,CAAC;YAEH,IAAI,MAAM,GAAkB,EAAE,CAAC;YAE/B,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACnC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;oBAC7D,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;;wBAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;wBACpC,MAAM,QAAQ,GACZ,CAAA,MAAA,MAAA,SAAS,CAAC,SAAS,0CAAG,CAAC,CAAC,0CAAE,EAAE;6BAC5B,MAAA,MAAA,SAAS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