Skip to content

Commit 4baeda5

Browse files
authored
Merge pull request #747 from devforth/feature/AdminForth/2056/bulk-ai-flow-needs-something-l
docs: ai-flow edit access AdminForth/2056/bulk-ai-flow-needs-something-l
2 parents 9f35c78 + 509f780 commit 4baeda5

2 files changed

Lines changed: 2 additions & 24 deletions

File tree

‎dev-demo/resources/cars_resources/carsResourseTemplate.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,6 @@ export default function carsResourseTemplate(resourceId: string, dataSource: Car
420420
}),
421421
new BulkAiFlowPlugin({
422422
actionName: 'Analyze image',
423-
allowedActions: {
424-
generate: ({ adminUser }) => adminUser.dbUser.role === 'superadmin',
425-
},
426423
askConfirmationBeforeGenerating: true,
427424
visionAdapter: new AdminForthImageVisionAdapterOpenAi({
428425
openAiApiKey: process.env.OPENAI_API_KEY as string,

‎documentation/docs/tutorial/09-Plugins/17-bulk-ai-flow.md‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ slug: /tutorial/Plugins/bulk-ai-flow
99
This plugin allows filling fields in multiple selected records based on data from other fields using LLM.
1010
This also supports vision tasks so you can ask it to e.g. detect dominant color on image or describe what is on the image. Plugin supports classification to enum options automatically.
1111

12-
:::warning
13-
Since version 2.2.0 AI generation is disabled for all users until you set `allowedActions.generate` in the plugin options. After updating from an older version, add it to every `BulkAiFlowPlugin` instance, see [Who can run generation](#who-can-run-generation).
14-
:::
15-
1612
## Installation
1713

1814
To install the plugin:
@@ -140,12 +136,6 @@ export const admin = new AdminForth({
140136
new BulkAiFlowPlugin({
141137
//diff-add
142138
actionName: 'Analyze',
143-
//diff-add
144-
allowedActions: {
145-
//diff-add
146-
generate: ({ adminUser }) => adminUser.dbUser.role === 'superadmin',
147-
//diff-add
148-
},
149139
//diff-add
150140
attachFiles: async ({ record }: { record: any }) => {
151141
//diff-add
@@ -209,7 +199,7 @@ export const admin = new AdminForth({
209199
210200
## Who can run generation
211201
212-
Generation calls a paid AI provider, so it is disabled for all users by default. Set `allowedActions.generate` to choose who can run it. Users who are not allowed don't see the action, and their generation requests are rejected:
202+
By default generation is allowed to users with the `edit` permission on the resource, because only they can save the generated values. Generation calls a paid AI provider, so you can narrow it down with `allowedActions.generate`. Users who are not allowed don't see the action, and their generation requests are rejected:
213203
214204
```ts
215205
new BulkAiFlowPlugin({
@@ -224,7 +214,7 @@ new BulkAiFlowPlugin({
224214
}),
225215
```
226216
227-
`generate: true` allows generation to every user who can see the resource. If `allowedActions.generate` is not set, the plugin logs a warning on startup.
217+
`generate: true` allows generation to every user who can see the resource, `false` disables it for everyone.
228218
229219
Saving the generated values also needs the `edit` permission on the resource and, if set, `isAllowedToSave`.
230220
@@ -240,9 +230,6 @@ import CompletionAdapterOpenAIResponses from '@adminforth/completion-adapter-ope
240230
// Add to your resource plugins array
241231
new BulkAiFlowPlugin({
242232
actionName: 'Translate surnames',
243-
allowedActions: {
244-
generate: ({ adminUser }) => adminUser.dbUser.role === 'superadmin',
245-
},
246233
textCompleteAdapter: new CompletionAdapterOpenAIResponses({
247234
openAiApiKey: process.env.OPENAI_API_KEY as string,
248235
model: 'gpt-5-nano',
@@ -267,9 +254,6 @@ import AdminForthImageVisionAdapterOpenAi from '@adminforth/image-vision-adapter
267254
// Add to your resource plugins array
268255
new BulkAiFlowPlugin({
269256
actionName: 'Guess age',
270-
allowedActions: {
271-
generate: ({ adminUser }) => adminUser.dbUser.role === 'superadmin',
272-
},
273257
visionAdapter: new AdminForthImageVisionAdapterOpenAi({
274258
openAiApiKey: process.env.OPENAI_API_KEY as string,
275259
model: 'gpt-6-luna',
@@ -297,9 +281,6 @@ import ImageGenerationAdapterOpenAI from '@adminforth/image-generation-adapter-o
297281
// Add to your resource plugins array
298282
new BulkAiFlowPlugin({
299283
actionName: 'Generate cartoon avatars',
300-
allowedActions: {
301-
generate: ({ adminUser }) => adminUser.dbUser.role === 'superadmin',
302-
},
303284
imageGenerationAdapter: new ImageGenerationAdapterOpenAI({
304285
openAiApiKey: process.env.OPENAI_API_KEY as string,
305286
model: 'gpt-image-1.5',

0 commit comments

Comments
 (0)