Skip to content

Commit 8e066dc

Browse files
committed
docs: update docs for bulk-ai-flow
1 parent 5dba4ae commit 8e066dc

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

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

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,90 @@ export const admin = new AdminForth({
177177
![alt text](Bulk-vision-2.png)
178178
6. Save changhes
179179
![alt text](Bulk-vision-3.png)
180+
181+
182+
## Text-to-Text Processing
183+
This is the most basic plugin usage. You can connect any text completion adapter to fill one or several string/number/boolean fields from other fields.
184+
185+
### Example: Translate Names to English
186+
Normalize user names by translating them from any language to English for internal processing.
187+
188+
```ts
189+
import CompletionAdapterOpenAIChatGPT from '@adminforth/completion-adapter-open-ai-chat-gpt/index.js';
190+
191+
// Add to your resource plugins array
192+
new BulkAiFlowPlugin({
193+
actionName: 'Translate surnames',
194+
textCompleteAdapter: new CompletionAdapterOpenAIChatGPT({
195+
openAiApiKey: process.env.OPENAI_API_KEY as string,
196+
model: 'gpt-4o',
197+
expert: {
198+
temperature: 0.7
199+
}
200+
}),
201+
fillPlainFields: {
202+
'full_name_en': 'Translate this name to English: {{users_full_name}}',
203+
},
204+
}),
205+
```
206+
207+
## Image-to-Text Analysis (Vision)
208+
Analyze images and extract information to fill text, number, enum, or boolean fields.
209+
210+
### Example: Age Detection from Photos
211+
212+
```ts
213+
import AdminForthImageVisionAdapterOpenAi from '@adminforth/image-vision-adapter-openai/index.js';
214+
215+
// Add to your resource plugins array
216+
new BulkAiFlowPlugin({
217+
actionName: 'Guess age',
218+
visionAdapter: new AdminForthImageVisionAdapterOpenAi({
219+
openAiApiKey: process.env.OPENAI_API_KEY as string,
220+
model: 'gpt-4.1-mini',
221+
}),
222+
fillFieldsFromImages: {
223+
'age': 'Analyze the image and estimate the age of the person. Return only a number.',
224+
},
225+
attachFiles: async ({ record }) => {
226+
return [`https://users-images.s3.eu-north-1.amazonaws.com/${record.image_url}`];
227+
},
228+
}),
229+
```
230+
231+
## Text-to-Image generation
232+
Generate new images based on existing data and/or images using AI image generation adapters.
233+
234+
### Example: Creating Cartoon Avatars
235+
236+
```ts
237+
import ImageGenerationAdapterOpenAI from '@adminforth/image-generation-adapter-openai/index.js';
238+
239+
// Add to your resource plugins array
240+
new BulkAiFlowPlugin({
241+
actionName: 'Generate cartoon avatars',
242+
imageGenerationAdapter: new ImageGenerationAdapterOpenAI({
243+
openAiApiKey: process.env.OPENAI_API_KEY as string,
244+
model: 'gpt-image-1',
245+
}),
246+
attachFiles: async ({ record }) => {
247+
return [`https://bulk-ai-flow-playground.s3.eu-north-1.amazonaws.com/${record.users_photo}`];
248+
},
249+
generateImages: {
250+
users_avatar: {
251+
prompt: 'Transform this photo into a cartoon-style avatar. Maintain the person\'s features but apply cartoon styling. Do not add text or logos.',
252+
outputSize: '1024x1024',
253+
countToGenerate: 2,
254+
rateLimit: '3/1h'
255+
},
256+
},
257+
bulkGenerationRateLimit: "1/1h"
258+
}),
259+
```
260+
261+
## Rate Limiting and Best Practices
262+
263+
- Use `rateLimit` for individual image generation operations
264+
- Set `bulkGenerationRateLimit` to prevent API quota exhaustion
265+
- Consider using lower resolution (`512x512`) for faster generation and lower costs
266+
- Test prompts thoroughly before applying to large datasets

0 commit comments

Comments
 (0)