@acedatacloud/piece-gpt-image 0.1.8 → 0.1.9
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
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Create a GPT Image task and retrieve the **same task ID** through Ace Data Cloud. The Piece provides **Create GPT Image task**, **Edit a GPT Image**, and **Get GPT Image task**. Submission returns an ID; the image is ready only after the lookup reports `succeeded`.
|
|
4
4
|
|
|
5
|
-
**Distribution:** Install `@acedatacloud/piece-gpt-image` (this source targets `0.1.
|
|
5
|
+
**Distribution:** Install `@acedatacloud/piece-gpt-image` (this source targets `0.1.9`; check npm for the published version) as a custom Piece in your Activepieces instance. A public npm package does not automatically enter the shared Activepieces catalog. [中文指南](README.zh-CN.md)
|
|
6
6
|
|
|
7
7
|
## Install and connect
|
|
8
8
|
|
|
9
|
-
In Activepieces 0.92.2+, open **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**. Enter `@acedatacloud/piece-gpt-image` and the published version (this release targets `0.1.
|
|
9
|
+
In Activepieces 0.92.2+, open **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**. Enter `@acedatacloud/piece-gpt-image` and the published version (this release targets `0.1.9`), then install it. Search for **GPT Image** when adding a flow action. Confirm the GPT Image icon and all three actions.
|
|
10
10
|
|
|
11
11
|
1. Register or sign in at [Ace Data Cloud Applications](https://platform.acedata.cloud/console/applications?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen). The page prepares your **General Application** card automatically. If the card has no key, select **Create API Key** first.
|
|
12
12
|
2. Use the **General Application** card and confirm your account has **GPT Image** access. A General key can access the services your account is entitled to use; a service-specific key is limited to that service.
|
package/README.zh-CN.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
通过 Ace Data Cloud 创建 GPT Image 任务,并按**同一个任务 ID**查询结果。Piece 提供 **Create GPT Image task**、**Edit a GPT Image** 和 **Get GPT Image task** 三个动作。提交返回 ID 并不代表图片已完成;查询到 `succeeded` 后才可使用成品。[English](README.md)
|
|
4
4
|
|
|
5
|
-
**分发方式:**在 Activepieces 实例中将 `@acedatacloud/piece-gpt-image`(本源码目标为 `0.1.
|
|
5
|
+
**分发方式:**在 Activepieces 实例中将 `@acedatacloud/piece-gpt-image`(本源码目标为 `0.1.9`,已发布版本请查看 npm) 作为自定义 Piece 安装。公开 npm 包不会自动进入 Activepieces 共享目录。
|
|
6
6
|
|
|
7
7
|
## 安装与连接
|
|
8
8
|
|
|
9
|
-
Activepieces 0.92.2+ 中进入 **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**,填写 `@acedatacloud/piece-gpt-image` 和已发布版本(本次目标为 `0.1.
|
|
9
|
+
Activepieces 0.92.2+ 中进入 **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**,填写 `@acedatacloud/piece-gpt-image` 和已发布版本(本次目标为 `0.1.9`)。在流程中搜索 **GPT Image**,核对 GPT Image 图标和三个动作。
|
|
10
10
|
|
|
11
11
|
1. 在 [Ace Data Cloud Applications](https://platform.acedata.cloud/console/applications?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen) 注册或登录。页面会自动准备好**通用应用**卡片。若卡片尚无 Key,请先选择**创建 API Key**。
|
|
12
12
|
2. 使用**通用应用**卡片,并确认账号具备 **GPT Image** 权限。通用 Key 可访问账号已获授权的服务;专用 Key 仅限对应服务。
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.gptImageClient = void 0;
|
|
4
|
-
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
5
4
|
const secure_http_1 = require("../secure-http");
|
|
6
5
|
async function post({ token, path, body, }) {
|
|
7
6
|
const response = await secure_http_1.httpClient.sendRequest({
|
|
8
|
-
method:
|
|
7
|
+
method: 'POST',
|
|
9
8
|
url: `https://api.acedata.cloud${path}`,
|
|
10
9
|
headers: {
|
|
11
10
|
Authorization: `Bearer ${token}`,
|
|
@@ -25,31 +24,35 @@ function normalizeTask({ body, taskId, traceId }) {
|
|
|
25
24
|
const values = record(payload);
|
|
26
25
|
const returnedTaskId = stringValue(envelope.id);
|
|
27
26
|
const resultTaskId = stringValue(values.task_id);
|
|
28
|
-
if ((taskId && returnedTaskId
|
|
27
|
+
if ((taskId && (!returnedTaskId || !sameTaskId(taskId, returnedTaskId))) ||
|
|
29
28
|
(resultTaskId && (returnedTaskId || taskId) && !sameTaskId(resultTaskId, returnedTaskId || taskId))) {
|
|
30
29
|
throw new Error('The response did not match the requested original task.');
|
|
31
30
|
}
|
|
32
31
|
const returnedTraceId = stringValue(envelope.trace_id);
|
|
33
32
|
const resultTraceId = stringValue(values.trace_id);
|
|
34
33
|
if ((returnedTraceId && resultTraceId && returnedTraceId !== resultTraceId) ||
|
|
35
|
-
(!taskId && traceId &&
|
|
34
|
+
(!taskId && traceId && traceId !== (returnedTraceId || resultTraceId))) {
|
|
36
35
|
throw new Error('The response did not match the requested original trace.');
|
|
37
36
|
}
|
|
38
37
|
const states = collectStates(payload);
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
const envelopeState = stringValue(envelope.status) || stringValue(envelope.state);
|
|
39
|
+
if (envelopeState)
|
|
40
|
+
states.push(envelopeState.toLowerCase());
|
|
41
|
+
const failed = states.some((state) => FAILED_STATES.has(state)) || hasFailure(payload) ||
|
|
42
|
+
envelope.success === false || Boolean(envelope.error);
|
|
43
|
+
const hasFinish = envelope.finished_at !== undefined && envelope.finished_at !== null && envelope.finished_at !== '';
|
|
44
|
+
const completeStates = states.length === 0 || states.every((state) => COMPLETE_STATES.has(state));
|
|
45
|
+
const media = collectMediaUrls(payload);
|
|
46
|
+
const finished = hasFinish && !failed && completeStates && media.length > 0;
|
|
47
|
+
const noFinalMedia = hasFinish && !failed && completeStates && media.length === 0;
|
|
45
48
|
const foundTraceId = stringValue(values.trace_id) || stringValue(envelope.trace_id) || traceId || '';
|
|
46
49
|
return {
|
|
47
50
|
task_id: stringValue(envelope.id) || taskId,
|
|
48
|
-
status: failed ? 'failed' : finished ? 'succeeded' : 'pending',
|
|
51
|
+
status: failed || noFinalMedia ? 'failed' : finished ? 'succeeded' : 'pending',
|
|
49
52
|
success: finished,
|
|
50
53
|
trace_id: foundTraceId,
|
|
51
|
-
media_urls: finished ?
|
|
52
|
-
result: sanitize(payload),
|
|
54
|
+
media_urls: finished ? media : [],
|
|
55
|
+
result: finished ? sanitize(payload) : failed ? sanitizeFailure(payload) : {},
|
|
53
56
|
};
|
|
54
57
|
}
|
|
55
58
|
function taskIdFromSubmission(body) {
|
|
@@ -124,9 +127,6 @@ function collectMediaUrls(value) {
|
|
|
124
127
|
});
|
|
125
128
|
return [...new Set(urls)];
|
|
126
129
|
}
|
|
127
|
-
function hasContent(value) {
|
|
128
|
-
return Array.isArray(value) ? value.length > 0 : Object.keys(record(value)).length > 0;
|
|
129
|
-
}
|
|
130
130
|
function sanitize(value) {
|
|
131
131
|
if (Array.isArray(value)) {
|
|
132
132
|
return value.map(sanitize);
|
|
@@ -138,6 +138,14 @@ function sanitize(value) {
|
|
|
138
138
|
.filter(([key]) => !SENSITIVE_KEYS.has(key.toLowerCase()) && !SENSITIVE_KEY_PATTERN.test(key))
|
|
139
139
|
.map(([key, child]) => [key, key === 'error' ? 'Task failed; inspect its task or trace ID.' : sanitize(child)]));
|
|
140
140
|
}
|
|
141
|
+
function sanitizeFailure(value) {
|
|
142
|
+
const item = record(value);
|
|
143
|
+
return {
|
|
144
|
+
...(item.success === false ? { success: false } : {}),
|
|
145
|
+
...(stringValue(item.task_id) ? { task_id: stringValue(item.task_id) } : {}),
|
|
146
|
+
...(item.error ? { error: 'Task failed; inspect its task or trace ID.' } : {}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
141
149
|
exports.gptImageClient = { post, normalizeTask, taskIdFromSubmission };
|
|
142
150
|
const COMPLETE_STATES = new Set(['complete', 'completed', 'succeeded', 'succeed', 'success', 'finished']);
|
|
143
151
|
const FAILED_STATES = new Set(['failed', 'error', 'cancelled', 'canceled', 'rejected']);
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"pieceName": "@acedatacloud/piece-gpt-image",
|
|
38
38
|
"actionName": "edit_image",
|
|
39
39
|
"sampleData": {},
|
|
40
|
-
"pieceVersion": "0.1.
|
|
40
|
+
"pieceVersion": "0.1.9",
|
|
41
41
|
"propertySettings": {
|
|
42
42
|
"imageUrls": {
|
|
43
43
|
"type": "MANUAL"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"pieceName": "@acedatacloud/piece-gpt-image",
|
|
76
76
|
"actionName": "get_task",
|
|
77
77
|
"sampleData": {},
|
|
78
|
-
"pieceVersion": "0.1.
|
|
78
|
+
"pieceVersion": "0.1.9",
|
|
79
79
|
"propertySettings": {
|
|
80
80
|
"taskId": {
|
|
81
81
|
"type": "MANUAL"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"pieceName": "@acedatacloud/piece-gpt-image",
|
|
38
38
|
"actionName": "generate_image",
|
|
39
39
|
"sampleData": {},
|
|
40
|
-
"pieceVersion": "0.1.
|
|
40
|
+
"pieceVersion": "0.1.9",
|
|
41
41
|
"propertySettings": {
|
|
42
42
|
"prompt": {
|
|
43
43
|
"type": "MANUAL"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"pieceName": "@acedatacloud/piece-gpt-image",
|
|
76
76
|
"actionName": "get_task",
|
|
77
77
|
"sampleData": {},
|
|
78
|
-
"pieceVersion": "0.1.
|
|
78
|
+
"pieceVersion": "0.1.9",
|
|
79
79
|
"propertySettings": {
|
|
80
80
|
"taskId": {
|
|
81
81
|
"type": "MANUAL"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acedatacloud/piece-gpt-image",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "GPT Image generation, editing and task lookup through Ace Data Cloud for Activepieces",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"bugs": "https://github.com/AceDataCloud/GPTImageActivepieces/issues",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@activepieces/pieces-common": "0.12.5",
|
|
28
27
|
"@activepieces/pieces-framework": "0.32.0"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|