@adminforth/bulk-ai-flow 1.15.1 → 1.15.3

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/build.log CHANGED
@@ -13,5 +13,5 @@ custom/package-lock.json
13
13
  custom/package.json
14
14
  custom/tsconfig.json
15
15
 
16
- sent 80,944 bytes received 172 bytes 162,232.00 bytes/sec
17
- total size is 80,312 speedup is 0.99
16
+ sent 80,746 bytes received 172 bytes 161,836.00 bytes/sec
17
+ total size is 80,105 speedup is 0.99
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "baseUrl": ".", // This should point to your project root
3
+ "baseUrl": ".",
4
4
  "paths": {
5
5
  "@/*": [
6
- // "node_modules/adminforth/dist/spa/src/*"
7
6
  "../../../adminforth/spa/src/*"
8
7
  ],
9
8
  "*": [
10
- // "node_modules/adminforth/dist/spa/node_modules/*"
11
9
  "../../../adminforth/spa/node_modules/*"
12
10
  ],
13
11
  "@@/*": [
14
- // "node_modules/adminforth/dist/spa/src/*"
15
12
  "."
16
13
  ]
17
14
  }
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "baseUrl": ".", // This should point to your project root
3
+ "baseUrl": ".",
4
4
  "paths": {
5
5
  "@/*": [
6
- // "node_modules/adminforth/dist/spa/src/*"
7
6
  "../../../adminforth/spa/src/*"
8
7
  ],
9
8
  "*": [
10
- // "node_modules/adminforth/dist/spa/node_modules/*"
11
9
  "../../../adminforth/spa/node_modules/*"
12
10
  ],
13
11
  "@@/*": [
14
- // "node_modules/adminforth/dist/spa/src/*"
15
12
  "."
16
13
  ]
17
14
  }
package/dist/index.js CHANGED
@@ -131,7 +131,8 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
131
131
  const resp = chatResponse.response;
132
132
  const topLevelError = chatResponse.error;
133
133
  if (topLevelError || (resp === null || resp === void 0 ? void 0 : resp.error)) {
134
- jobs.set(jobId, { status: 'failed', error: `ERROR: ${JSON.stringify(topLevelError || (resp === null || resp === void 0 ? void 0 : resp.error))}` });
134
+ jobs.set(jobId, { status: 'failed', error: `ERROR: ${JSON.stringify(topLevelError.message || (resp === null || resp === void 0 ? void 0 : resp.error.message))}` });
135
+ return { ok: false, error: `ERROR: ${JSON.stringify(topLevelError.message || (resp === null || resp === void 0 ? void 0 : resp.error.message))}` };
135
136
  }
136
137
  const textOutput = (_f = (_e = (_d = (_c = (_b = (_a = resp === null || resp === void 0 ? void 0 : resp.output) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.text) !== null && _e !== void 0 ? _e : resp === null || resp === void 0 ? void 0 : resp.output_text) !== null && _f !== void 0 ? _f : (_j = (_h = (_g = resp === null || resp === void 0 ? void 0 : resp.choices) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.message) === null || _j === void 0 ? void 0 : _j.content;
137
138
  if (!textOutput || typeof textOutput !== 'string') {
@@ -178,12 +179,12 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
178
179
  const numberOfTokens = this.options.fillPlainFieldsMaxTokens ? this.options.fillPlainFieldsMaxTokens : 1000;
179
180
  let resp;
180
181
  try {
181
- const { content: chatResponse } = yield this.options.textCompleteAdapter.complete(prompt, [], numberOfTokens);
182
- resp = chatResponse.response;
183
- const topLevelError = chatResponse.error;
182
+ const { content: chatResponse, error: topLevelError } = yield this.options.textCompleteAdapter.complete(prompt, [], numberOfTokens);
183
+ // resp = (chatResponse as any).response;
184
184
  if (topLevelError || (resp === null || resp === void 0 ? void 0 : resp.error)) {
185
185
  isError = true;
186
- jobs.set(jobId, { status: 'failed', error: `ERROR: ${JSON.stringify(topLevelError || (resp === null || resp === void 0 ? void 0 : resp.error))}` });
186
+ jobs.set(jobId, { status: 'failed', error: `ERROR: ${JSON.stringify(topLevelError)}` });
187
+ return { ok: false, error: `ERROR: ${JSON.stringify(topLevelError)}` };
187
188
  }
188
189
  resp = chatResponse;
189
190
  }
@@ -258,6 +259,11 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
258
259
  n: 1,
259
260
  size: this.options.generateImages[key].outputSize,
260
261
  });
262
+ if (resp.error) {
263
+ isError = true;
264
+ jobs.set(jobId, { status: 'failed', error: `AI provider refused to generate image: ${JSON.stringify(resp.error)}` });
265
+ return { key, images: [] };
266
+ }
261
267
  }
262
268
  catch (e) {
263
269
  jobs.set(jobId, { status: 'failed', error: "AI provider refused to generate image" });
@@ -330,6 +336,11 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
330
336
  n: 1,
331
337
  size: this.options.generateImages[fieldName].outputSize,
332
338
  });
339
+ if (resp.error) {
340
+ isError = true;
341
+ jobs.set(jobId, { status: 'failed', error: `AI provider refused to generate image: ${JSON.stringify(resp.error)}` });
342
+ return [];
343
+ }
333
344
  }
334
345
  catch (e) {
335
346
  jobs.set(jobId, { status: 'failed', error: "AI provider refused to generate image" });
package/index.ts CHANGED
@@ -125,7 +125,8 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
125
125
  const resp: any = (chatResponse as any).response;
126
126
  const topLevelError = (chatResponse as any).error;
127
127
  if (topLevelError || resp?.error) {
128
- jobs.set(jobId, { status: 'failed', error: `ERROR: ${JSON.stringify(topLevelError || resp?.error)}` });
128
+ jobs.set(jobId, { status: 'failed', error: `ERROR: ${JSON.stringify(topLevelError.message || resp?.error.message)}` });
129
+ return { ok: false, error: `ERROR: ${JSON.stringify(topLevelError.message || resp?.error.message)}` };
129
130
  }
130
131
 
131
132
  const textOutput = resp?.output?.[0]?.content?.[0]?.text ?? resp?.output_text ?? resp?.choices?.[0]?.message?.content;
@@ -172,12 +173,12 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
172
173
  const numberOfTokens = this.options.fillPlainFieldsMaxTokens ? this.options.fillPlainFieldsMaxTokens : 1000;
173
174
  let resp: any;
174
175
  try {
175
- const { content: chatResponse } = await this.options.textCompleteAdapter.complete(prompt, [], numberOfTokens);
176
- resp = (chatResponse as any).response;
177
- const topLevelError = (chatResponse as any).error;
176
+ const { content: chatResponse, error: topLevelError } = await this.options.textCompleteAdapter.complete(prompt, [], numberOfTokens);
177
+ // resp = (chatResponse as any).response;
178
178
  if (topLevelError || resp?.error) {
179
179
  isError = true;
180
- jobs.set(jobId, { status: 'failed', error: `ERROR: ${JSON.stringify(topLevelError || resp?.error)}` });
180
+ jobs.set(jobId, { status: 'failed', error: `ERROR: ${JSON.stringify(topLevelError)}` });
181
+ return { ok: false, error: `ERROR: ${JSON.stringify(topLevelError)}` };
181
182
  }
182
183
  resp = chatResponse
183
184
  } catch (e) {
@@ -245,6 +246,11 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
245
246
  size: this.options.generateImages[key].outputSize,
246
247
  }
247
248
  )
249
+ if (resp.error) {
250
+ isError = true;
251
+ jobs.set(jobId, { status: 'failed', error: `AI provider refused to generate image: ${JSON.stringify(resp.error)}` });
252
+ return { key, images: [] };
253
+ }
248
254
  } catch (e) {
249
255
  jobs.set(jobId, { status: 'failed', error: "AI provider refused to generate image" });
250
256
  isError = true;
@@ -319,6 +325,11 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
319
325
  size: this.options.generateImages[fieldName].outputSize,
320
326
  }
321
327
  )
328
+ if (resp.error) {
329
+ isError = true;
330
+ jobs.set(jobId, { status: 'failed', error: `AI provider refused to generate image: ${JSON.stringify(resp.error)}` });
331
+ return [];
332
+ }
322
333
  } catch (e) {
323
334
  jobs.set(jobId, { status: 'failed', error: "AI provider refused to generate image" });
324
335
  isError = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/bulk-ai-flow",
3
- "version": "1.15.1",
3
+ "version": "1.15.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },