@adminforth/bulk-ai-flow 1.21.0 → 1.21.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/build.log +2 -2
- package/custom/VisionAction.vue +18 -2
- package/dist/custom/VisionAction.vue +18 -2
- package/dist/index.js +17 -3
- package/index.ts +20 -4
- package/package.json +1 -1
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
|
|
17
|
-
total size is
|
|
16
|
+
sent 96,594 bytes received 172 bytes 193,532.00 bytes/sec
|
|
17
|
+
total size is 95,949 speedup is 0.99
|
package/custom/VisionAction.vue
CHANGED
|
@@ -238,6 +238,8 @@ const isDataSaved = ref(false);
|
|
|
238
238
|
const regeneratingFieldsStatus = ref<Record<string, Record<string, boolean>>>({});
|
|
239
239
|
const overwriteExistingValues = ref<boolean>(false);
|
|
240
240
|
|
|
241
|
+
const listOfImageThatWasNotGeneratedPerRecord = ref<Record<string, string[]>>({});
|
|
242
|
+
|
|
241
243
|
const openDialog = async () => {
|
|
242
244
|
window.addEventListener('beforeunload', beforeUnloadHandler);
|
|
243
245
|
if (props.meta.askConfirmationBeforeGenerating) {
|
|
@@ -544,6 +546,14 @@ async function saveData() {
|
|
|
544
546
|
if (!value) {
|
|
545
547
|
continue;
|
|
546
548
|
}
|
|
549
|
+
if (!overwriteExistingValues.value) {
|
|
550
|
+
const imageURL = selected.value.find(rec => rec[primaryKey] === item[primaryKey])[key];
|
|
551
|
+
const originalImageUrl = listOfImageThatWasNotGeneratedPerRecord.value[item[primaryKey]][key].originalImage;
|
|
552
|
+
if (originalImageUrl === imageURL) {
|
|
553
|
+
reqData.find(rec => rec[primaryKey] === item[primaryKey])[key] = undefined;
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
547
557
|
const p = uploadImage(value, item[primaryKey], key).then(result => {
|
|
548
558
|
item[key] = result;
|
|
549
559
|
});
|
|
@@ -553,7 +563,6 @@ async function saveData() {
|
|
|
553
563
|
}
|
|
554
564
|
await Promise.all(imagesToUpload);
|
|
555
565
|
}
|
|
556
|
-
|
|
557
566
|
const res = await callAdminForthApi({
|
|
558
567
|
path: `/plugin/${props.meta.pluginInstanceId}/update_fields`,
|
|
559
568
|
method: 'POST',
|
|
@@ -729,7 +738,14 @@ async function runAiAction({
|
|
|
729
738
|
for (const [key, value] of Object.entries(carouselSaveImages.value[index])) {
|
|
730
739
|
if (props.meta.outputImageFields?.includes(key)) {
|
|
731
740
|
carouselSaveImages.value[index][key] = [jobResponse.job.result[key]];
|
|
732
|
-
|
|
741
|
+
if (jobResponse.job.recordMeta?.[`${key}_meta`]) {
|
|
742
|
+
carouselSaveImages.value[index][key] = [jobResponse.job.recordMeta[`${key}_meta`].originalImage];
|
|
743
|
+
if (!listOfImageThatWasNotGeneratedPerRecord.value[recordId]) {
|
|
744
|
+
listOfImageThatWasNotGeneratedPerRecord.value[recordId] = [];
|
|
745
|
+
}
|
|
746
|
+
listOfImageThatWasNotGeneratedPerRecord.value[recordId][key] = jobResponse.job.recordMeta[`${key}_meta`];
|
|
747
|
+
}
|
|
748
|
+
}
|
|
733
749
|
}
|
|
734
750
|
}
|
|
735
751
|
//marking that we received response for this record
|
|
@@ -238,6 +238,8 @@ const isDataSaved = ref(false);
|
|
|
238
238
|
const regeneratingFieldsStatus = ref<Record<string, Record<string, boolean>>>({});
|
|
239
239
|
const overwriteExistingValues = ref<boolean>(false);
|
|
240
240
|
|
|
241
|
+
const listOfImageThatWasNotGeneratedPerRecord = ref<Record<string, string[]>>({});
|
|
242
|
+
|
|
241
243
|
const openDialog = async () => {
|
|
242
244
|
window.addEventListener('beforeunload', beforeUnloadHandler);
|
|
243
245
|
if (props.meta.askConfirmationBeforeGenerating) {
|
|
@@ -544,6 +546,14 @@ async function saveData() {
|
|
|
544
546
|
if (!value) {
|
|
545
547
|
continue;
|
|
546
548
|
}
|
|
549
|
+
if (!overwriteExistingValues.value) {
|
|
550
|
+
const imageURL = selected.value.find(rec => rec[primaryKey] === item[primaryKey])[key];
|
|
551
|
+
const originalImageUrl = listOfImageThatWasNotGeneratedPerRecord.value[item[primaryKey]][key].originalImage;
|
|
552
|
+
if (originalImageUrl === imageURL) {
|
|
553
|
+
reqData.find(rec => rec[primaryKey] === item[primaryKey])[key] = undefined;
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
547
557
|
const p = uploadImage(value, item[primaryKey], key).then(result => {
|
|
548
558
|
item[key] = result;
|
|
549
559
|
});
|
|
@@ -553,7 +563,6 @@ async function saveData() {
|
|
|
553
563
|
}
|
|
554
564
|
await Promise.all(imagesToUpload);
|
|
555
565
|
}
|
|
556
|
-
|
|
557
566
|
const res = await callAdminForthApi({
|
|
558
567
|
path: `/plugin/${props.meta.pluginInstanceId}/update_fields`,
|
|
559
568
|
method: 'POST',
|
|
@@ -729,7 +738,14 @@ async function runAiAction({
|
|
|
729
738
|
for (const [key, value] of Object.entries(carouselSaveImages.value[index])) {
|
|
730
739
|
if (props.meta.outputImageFields?.includes(key)) {
|
|
731
740
|
carouselSaveImages.value[index][key] = [jobResponse.job.result[key]];
|
|
732
|
-
|
|
741
|
+
if (jobResponse.job.recordMeta?.[`${key}_meta`]) {
|
|
742
|
+
carouselSaveImages.value[index][key] = [jobResponse.job.recordMeta[`${key}_meta`].originalImage];
|
|
743
|
+
if (!listOfImageThatWasNotGeneratedPerRecord.value[recordId]) {
|
|
744
|
+
listOfImageThatWasNotGeneratedPerRecord.value[recordId] = [];
|
|
745
|
+
}
|
|
746
|
+
listOfImageThatWasNotGeneratedPerRecord.value[recordId][key] = jobResponse.job.recordMeta[`${key}_meta`];
|
|
747
|
+
}
|
|
748
|
+
}
|
|
733
749
|
}
|
|
734
750
|
}
|
|
735
751
|
//marking that we received response for this record
|
package/dist/index.js
CHANGED
|
@@ -265,7 +265,17 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
265
265
|
}
|
|
266
266
|
const fieldTasks = Object.keys(((_b = this.options) === null || _b === void 0 ? void 0 : _b.generateImages) || {}).map((key) => __awaiter(this, void 0, void 0, function* () {
|
|
267
267
|
if (record[key] && filterFilledFields) {
|
|
268
|
-
|
|
268
|
+
const plugin = this.adminforth.activatedPlugins.find(p => p.resourceConfig.resourceId === this.resourceConfig.resourceId &&
|
|
269
|
+
p.pluginOptions.pathColumnName === key);
|
|
270
|
+
const image_url = yield plugin.pluginOptions.storageAdapter.getDownloadUrl(record[key]);
|
|
271
|
+
return {
|
|
272
|
+
key,
|
|
273
|
+
images: [image_url],
|
|
274
|
+
meta: {
|
|
275
|
+
skippedToNotOverwrite: true,
|
|
276
|
+
originalImage: image_url,
|
|
277
|
+
}
|
|
278
|
+
};
|
|
269
279
|
}
|
|
270
280
|
const prompt = (yield this.compileGenerationFieldTemplates(record, customPrompt))[key];
|
|
271
281
|
let images;
|
|
@@ -320,14 +330,18 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
320
330
|
}));
|
|
321
331
|
const fieldResults = yield Promise.all(fieldTasks);
|
|
322
332
|
const recordResult = {};
|
|
323
|
-
|
|
333
|
+
const recordMeta = {};
|
|
334
|
+
fieldResults.forEach(({ key, images, meta }) => {
|
|
324
335
|
recordResult[key] = images;
|
|
336
|
+
if (meta) {
|
|
337
|
+
recordMeta[`${key}_meta`] = meta;
|
|
338
|
+
}
|
|
325
339
|
});
|
|
326
340
|
const result = recordResult;
|
|
327
341
|
if (!isError) {
|
|
328
342
|
this.totalCalls++;
|
|
329
343
|
this.totalDuration += (+new Date() - start) / 1000;
|
|
330
|
-
jobs.set(jobId, { status: 'completed', result });
|
|
344
|
+
jobs.set(jobId, { status: 'completed', result, recordMeta });
|
|
331
345
|
return { ok: true };
|
|
332
346
|
}
|
|
333
347
|
else {
|
package/index.ts
CHANGED
|
@@ -260,7 +260,19 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
260
260
|
}
|
|
261
261
|
const fieldTasks = Object.keys(this.options?.generateImages || {}).map(async (key) => {
|
|
262
262
|
if ( record[key] && filterFilledFields ) {
|
|
263
|
-
|
|
263
|
+
const plugin = this.adminforth.activatedPlugins.find(p =>
|
|
264
|
+
p.resourceConfig!.resourceId === this.resourceConfig.resourceId &&
|
|
265
|
+
p.pluginOptions.pathColumnName === key
|
|
266
|
+
);
|
|
267
|
+
const image_url = await plugin.pluginOptions.storageAdapter.getDownloadUrl(record[key]);
|
|
268
|
+
return {
|
|
269
|
+
key,
|
|
270
|
+
images: [image_url],
|
|
271
|
+
meta: {
|
|
272
|
+
skippedToNotOverwrite: true,
|
|
273
|
+
originalImage: image_url,
|
|
274
|
+
}
|
|
275
|
+
};
|
|
264
276
|
}
|
|
265
277
|
const prompt = (await this.compileGenerationFieldTemplates(record, customPrompt))[key];
|
|
266
278
|
let images;
|
|
@@ -312,10 +324,14 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
312
324
|
});
|
|
313
325
|
|
|
314
326
|
const fieldResults = await Promise.all(fieldTasks);
|
|
315
|
-
const recordResult: Record<string,
|
|
327
|
+
const recordResult: Record<string, any> = {};
|
|
328
|
+
const recordMeta: Record<string, any> = {};
|
|
316
329
|
|
|
317
|
-
fieldResults.forEach(({ key, images }) => {
|
|
330
|
+
fieldResults.forEach(({ key, images, meta }) => {
|
|
318
331
|
recordResult[key] = images;
|
|
332
|
+
if (meta) {
|
|
333
|
+
recordMeta[`${key}_meta`] = meta;
|
|
334
|
+
}
|
|
319
335
|
});
|
|
320
336
|
|
|
321
337
|
const result = recordResult;
|
|
@@ -323,7 +339,7 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
323
339
|
if (!isError) {
|
|
324
340
|
this.totalCalls++;
|
|
325
341
|
this.totalDuration += (+new Date() - start) / 1000;
|
|
326
|
-
jobs.set(jobId, { status: 'completed', result });
|
|
342
|
+
jobs.set(jobId, { status: 'completed', result, recordMeta });
|
|
327
343
|
return { ok: true }
|
|
328
344
|
} else {
|
|
329
345
|
return { ok: false, error: 'Error during image generation' };
|