Skip to content

Commit 394fffe

Browse files
committed
docs: update docs for the bulk-ai-flow
1 parent 556b17c commit 394fffe

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

adminforth/documentation/docs/tutorial/07-Plugins/17-bulk-ai-flow.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ model apartments {
4242
listed Boolean
4343
realtor_id String?
4444
//diff-add
45-
apartment_image String?
45+
apartment_image String?
4646
}
4747
```
4848
@@ -73,6 +73,12 @@ Add column to `aparts` resource configuration:
7373
import BulkAiFlowPlugin from '@adminforth/bulk-ai-flow';
7474
//diff-add
7575
import AdminForthImageVisionAdapterOpenAi from '@adminforth/image-vision-adapter-openai';
76+
//diff-add
77+
import UploadPlugin from '@adminforth/upload';
78+
//diff-add
79+
import { randomUUID } from 'crypto';
80+
//diff-add
81+
import AdminForthAdapterS3Storage from '@adminforth/storage-adapter-amazon-s3'
7682

7783
export const admin = new AdminForth({
7884
...
@@ -126,6 +132,12 @@ export const admin = new AdminForth({
126132
actionName: 'Analyze',
127133
//diff-add
128134
attachFiles: async ({ record }: { record: any }) => {
135+
//diff-add
136+
if (!record.apartment_image) {
137+
//diff-add
138+
return [];
139+
//diff-add
140+
}
129141
//diff-add
130142
return [`https://tmpbucket-adminforth.s3.eu-central-1.amazonaws.com/${record.apartment_image}`];
131143
//diff-add
@@ -166,6 +178,7 @@ export const admin = new AdminForth({
166178

167179
});
168180
```
181+
> ⚠️ Make sure your attachFiles function returns a valid array of image URLs or an empty array. Returning anything else may cause an error.
169182
170183
## Usage
171184
1. Select fields you want to fill
@@ -223,6 +236,9 @@ new BulkAiFlowPlugin({
223236
'age': 'Analyze the image and estimate the age of the person. Return only a number.',
224237
},
225238
attachFiles: async ({ record }) => {
239+
if (!record.image_url) {
240+
return [];
241+
}
226242
return [`https://users-images.s3.eu-north-1.amazonaws.com/${record.image_url}`];
227243
},
228244
}),
@@ -244,6 +260,9 @@ new BulkAiFlowPlugin({
244260
model: 'gpt-image-1',
245261
}),
246262
attachFiles: async ({ record }) => {
263+
if (!record.user_photo) {
264+
return [];
265+
}
247266
return [`https://bulk-ai-flow-playground.s3.eu-north-1.amazonaws.com/${record.users_photo}`];
248267
},
249268
generateImages: {

0 commit comments

Comments
 (0)