flowscale 1.0.12 → 1.0.14
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 +51 -6
- package/dist/index.d.ts +11 -0
- package/dist/index.js +49 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Flowscale Node.js SDK
|
|
2
2
|
|
|
3
|
-
A comprehensive Node.js SDK designed to simplify interaction with the
|
|
3
|
+
A comprehensive Node.js SDK designed to simplify interaction with the FlowScale ComfyUI API. This library abstracts away the complexities of API calls, enabling you to effortlessly invoke workflows, retrieve outputs, manage workflow runs, and monitor system health.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -45,7 +45,7 @@ const flowscale = new FlowscaleAPI(apiKey, apiUrl);
|
|
|
45
45
|
|
|
46
46
|
```plaintext
|
|
47
47
|
FLOWSCALE_API_KEY=your-api-key
|
|
48
|
-
FLOWSCALE_API_URL=https://api.flowscale.ai
|
|
48
|
+
FLOWSCALE_API_URL=https://your-api-url.pod.flowscale.ai
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
---
|
|
@@ -165,6 +165,51 @@ console.log('Workflow Result:', result);
|
|
|
165
165
|
|
|
166
166
|
---
|
|
167
167
|
|
|
168
|
+
### 3.1 `executeWorkflowAsync(workflowId, data, groupId?, pollIntervalMs?, timeoutMs?)`
|
|
169
|
+
|
|
170
|
+
**Description:**
|
|
171
|
+
Execute a workflow and automatically wait for the result by polling the output. This is a convenience method that combines `executeWorkflow` and `getOutput` with automatic polling.
|
|
172
|
+
|
|
173
|
+
**Parameters:**
|
|
174
|
+
- `workflowId` *(string)*: The unique ID of the workflow.
|
|
175
|
+
- `data` *(object)*: Input parameters for the workflow.
|
|
176
|
+
- `groupId` *(string, optional)*: A custom identifier for grouping runs.
|
|
177
|
+
- `pollIntervalMs` *(number, optional)*: Polling interval in milliseconds (default: 1000).
|
|
178
|
+
- `timeoutMs` *(number, optional)*: Maximum time to wait for results in milliseconds (default: 300000 - 5 minutes).
|
|
179
|
+
|
|
180
|
+
**Usage:**
|
|
181
|
+
```javascript
|
|
182
|
+
const workflowId = "bncu0a1kipv";
|
|
183
|
+
const inputs = {
|
|
184
|
+
"text_51536": "Prompt test",
|
|
185
|
+
"image_1234": { /* File or Blob of image */ }
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
const result = await flowscale.executeWorkflowAsync(workflowId, inputs);
|
|
190
|
+
console.log('Workflow Result:', result);
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (error.message.includes('timed out')) {
|
|
193
|
+
console.error('Workflow took too long to complete');
|
|
194
|
+
} else {
|
|
195
|
+
console.error('Workflow error:', error);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Response Example:**
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"status": "success",
|
|
204
|
+
"data": {
|
|
205
|
+
"download_url": "https://runs.s3.amazonaws.com/generations/...",
|
|
206
|
+
"generation_status": "success"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
168
213
|
### 4. `getOutput(filename)`
|
|
169
214
|
|
|
170
215
|
**Description:**
|
|
@@ -184,7 +229,7 @@ console.log('Workflow Output:', output);
|
|
|
184
229
|
{
|
|
185
230
|
"status": "success",
|
|
186
231
|
"data": {
|
|
187
|
-
"download_url": "https://runs
|
|
232
|
+
"download_url": "https://runs.s3.amazonaws.com/generations/...",
|
|
188
233
|
"generation_status": "success"
|
|
189
234
|
}
|
|
190
235
|
}
|
|
@@ -240,13 +285,13 @@ console.log('Run Details:', runDetails);
|
|
|
240
285
|
"inputs": [
|
|
241
286
|
{
|
|
242
287
|
"path": "text_51536",
|
|
243
|
-
"value": "
|
|
288
|
+
"value": "a man riding a bike"
|
|
244
289
|
}
|
|
245
290
|
],
|
|
246
291
|
"outputs": [
|
|
247
292
|
{
|
|
248
293
|
"filename": "filename_prefix_58358_5WWF7GQUYF.png",
|
|
249
|
-
"url": "https://runs
|
|
294
|
+
"url": "https://runs.s3.amazonaws.com/generations/..."
|
|
250
295
|
}
|
|
251
296
|
]
|
|
252
297
|
}
|
|
@@ -287,7 +332,7 @@ console.log('All Runs:', allRuns);
|
|
|
287
332
|
"outputs": [
|
|
288
333
|
{
|
|
289
334
|
"filename": "filename_prefix_58358_G3DRLIVVYP.png",
|
|
290
|
-
"url": "https://runs
|
|
335
|
+
"url": "https://runs.s3.amazonaws.com/generations/..."
|
|
291
336
|
}
|
|
292
337
|
]
|
|
293
338
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,17 @@ export declare class FlowscaleAPI {
|
|
|
21
21
|
executeWorkflow(workflowId: string, data: {
|
|
22
22
|
[key: string]: any;
|
|
23
23
|
}, groupId?: string): Promise<ExecuteWorkflowResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Executes a workflow and waits for the output by polling.
|
|
26
|
+
* @param workflowId - The ID of the workflow to execute.
|
|
27
|
+
* @param data - Form data including text fields and file uploads.
|
|
28
|
+
* @param groupId - Optional group ID.
|
|
29
|
+
* @param pollIntervalMs - Optional polling interval in milliseconds (default: 1000)
|
|
30
|
+
* @param timeoutMs - Optional timeout in milliseconds (default: 300000 - 5 minutes)
|
|
31
|
+
*/
|
|
32
|
+
executeWorkflowAsync(workflowId: string, data: {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}, groupId?: string, pollIntervalMs?: number, timeoutMs?: number): Promise<GetOutputResponse>;
|
|
24
35
|
/**
|
|
25
36
|
* Retrieves the output of a specific run by providing the filename.
|
|
26
37
|
* @param filename - The filename of the output to retrieve.
|
package/dist/index.js
CHANGED
|
@@ -167,6 +167,55 @@ var FlowscaleAPI = /** @class */ (function () {
|
|
|
167
167
|
});
|
|
168
168
|
});
|
|
169
169
|
};
|
|
170
|
+
/**
|
|
171
|
+
* Executes a workflow and waits for the output by polling.
|
|
172
|
+
* @param workflowId - The ID of the workflow to execute.
|
|
173
|
+
* @param data - Form data including text fields and file uploads.
|
|
174
|
+
* @param groupId - Optional group ID.
|
|
175
|
+
* @param pollIntervalMs - Optional polling interval in milliseconds (default: 1000)
|
|
176
|
+
* @param timeoutMs - Optional timeout in milliseconds (default: 300000 - 5 minutes)
|
|
177
|
+
*/
|
|
178
|
+
FlowscaleAPI.prototype.executeWorkflowAsync = function (workflowId_1, data_1, groupId_1) {
|
|
179
|
+
return __awaiter(this, arguments, void 0, function (workflowId, data, groupId, pollIntervalMs, timeoutMs) {
|
|
180
|
+
var startTime, executeResponse, outputName, output;
|
|
181
|
+
var _a, _b;
|
|
182
|
+
if (pollIntervalMs === void 0) { pollIntervalMs = 1000; }
|
|
183
|
+
if (timeoutMs === void 0) { timeoutMs = 300000; }
|
|
184
|
+
return __generator(this, function (_c) {
|
|
185
|
+
switch (_c.label) {
|
|
186
|
+
case 0:
|
|
187
|
+
startTime = Date.now();
|
|
188
|
+
return [4 /*yield*/, this.executeWorkflow(workflowId, data, groupId)];
|
|
189
|
+
case 1:
|
|
190
|
+
executeResponse = _c.sent();
|
|
191
|
+
// If there are no output names, throw an error
|
|
192
|
+
if (!((_b = (_a = executeResponse === null || executeResponse === void 0 ? void 0 : executeResponse.data) === null || _a === void 0 ? void 0 : _a.output_names) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
193
|
+
throw new Error('No output names returned from workflow execution');
|
|
194
|
+
}
|
|
195
|
+
outputName = executeResponse.data.output_names[0];
|
|
196
|
+
_c.label = 2;
|
|
197
|
+
case 2:
|
|
198
|
+
if (!true) return [3 /*break*/, 5];
|
|
199
|
+
if (Date.now() - startTime > timeoutMs) {
|
|
200
|
+
throw new Error("Workflow execution timed out after ".concat(timeoutMs, "ms"));
|
|
201
|
+
}
|
|
202
|
+
return [4 /*yield*/, this.getOutput(outputName)];
|
|
203
|
+
case 3:
|
|
204
|
+
output = _c.sent();
|
|
205
|
+
if (output !== null) {
|
|
206
|
+
return [2 /*return*/, output];
|
|
207
|
+
}
|
|
208
|
+
// Wait for the polling interval
|
|
209
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, pollIntervalMs); })];
|
|
210
|
+
case 4:
|
|
211
|
+
// Wait for the polling interval
|
|
212
|
+
_c.sent();
|
|
213
|
+
return [3 /*break*/, 2];
|
|
214
|
+
case 5: return [2 /*return*/];
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
};
|
|
170
219
|
/**
|
|
171
220
|
* Retrieves the output of a specific run by providing the filename.
|
|
172
221
|
* @param filename - The filename of the output to retrieve.
|