@adminforth/bulk-ai-flow 1.26.1 → 1.26.2
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 +1 -1
- package/dist/index.d.ts +29 -0
- package/dist/types.d.ts +138 -0
- package/package.json +1 -1
- package/tsconfig.json +1 -0
package/build.log
CHANGED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AdminForthPlugin } from "adminforth";
|
|
2
|
+
import type { IAdminForth, IHttpServer, AdminForthResource } from "adminforth";
|
|
3
|
+
import type { PluginOptions } from './types.js';
|
|
4
|
+
import { RateLimiter } from "adminforth";
|
|
5
|
+
export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
6
|
+
options: PluginOptions;
|
|
7
|
+
uploadPlugin: AdminForthPlugin;
|
|
8
|
+
totalCalls: number;
|
|
9
|
+
totalDuration: number;
|
|
10
|
+
rateLimiters: Record<string, RateLimiter>;
|
|
11
|
+
constructor(options: PluginOptions);
|
|
12
|
+
private compileTemplates;
|
|
13
|
+
private compileOutputFieldsTemplates;
|
|
14
|
+
private compileOutputFieldsTemplatesNoImage;
|
|
15
|
+
private compileGenerationFieldTemplates;
|
|
16
|
+
private removeFromPromptFilledFields;
|
|
17
|
+
private checkRateLimit;
|
|
18
|
+
private getPromptForImageAnalysis;
|
|
19
|
+
private getPromptForPlainFields;
|
|
20
|
+
private analyze_image;
|
|
21
|
+
private analyzeNoImages;
|
|
22
|
+
private initialImageGenerate;
|
|
23
|
+
private regenerateImage;
|
|
24
|
+
private regenerateCell;
|
|
25
|
+
modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource): Promise<void>;
|
|
26
|
+
validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
|
|
27
|
+
instanceUniqueRepresentation(pluginOptions: any): string;
|
|
28
|
+
setupEndpoints(server: IHttpServer): void;
|
|
29
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { ImageVisionAdapter, ImageGenerationAdapter, CompletionAdapter } from "adminforth";
|
|
2
|
+
import { type PluginsCommonOptions } from "adminforth";
|
|
3
|
+
export interface PluginOptions extends PluginsCommonOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Name of the action in three dots menu.
|
|
6
|
+
*/
|
|
7
|
+
actionName: string;
|
|
8
|
+
/**
|
|
9
|
+
* The adapter to use for scaning images and filling fields basing on the image content.
|
|
10
|
+
*/
|
|
11
|
+
visionAdapter?: ImageVisionAdapter;
|
|
12
|
+
/**
|
|
13
|
+
* The adapter to use for text->text generation.
|
|
14
|
+
*/
|
|
15
|
+
textCompleteAdapter?: CompletionAdapter;
|
|
16
|
+
/**
|
|
17
|
+
* The adapter to use for image generation.
|
|
18
|
+
*/
|
|
19
|
+
imageGenerationAdapter?: ImageGenerationAdapter;
|
|
20
|
+
/**
|
|
21
|
+
* List of fields that should be filled based on the image content analysis.
|
|
22
|
+
*/
|
|
23
|
+
fillFieldsFromImages?: Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* List of fields that should be filled based on the text.
|
|
26
|
+
*/
|
|
27
|
+
fillPlainFields?: Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Number of tokens to generate (Only for text completion adapter). Default is 1000. 1 token ~= ¾ words
|
|
30
|
+
*/
|
|
31
|
+
fillPlainFieldsMaxTokens?: number;
|
|
32
|
+
/**
|
|
33
|
+
* If you want to generate fields or images based on the image content attached images
|
|
34
|
+
*/
|
|
35
|
+
attachFiles?: ({ record }: {
|
|
36
|
+
record: any;
|
|
37
|
+
}) => string[] | Promise<string[]>;
|
|
38
|
+
/**
|
|
39
|
+
* List of image fields, that should be filled.
|
|
40
|
+
*/
|
|
41
|
+
generateImages?: Record<string, {
|
|
42
|
+
prompt: string;
|
|
43
|
+
adapter?: ImageGenerationAdapter;
|
|
44
|
+
/**
|
|
45
|
+
* The size of the generated image.
|
|
46
|
+
*/
|
|
47
|
+
outputSize?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Since AI generation can be expensive, we can limit the number of requests per IP.
|
|
50
|
+
* E.g. 5/1d - 5 requests per day
|
|
51
|
+
* 3/1h - 3 requests per hour
|
|
52
|
+
*/
|
|
53
|
+
rateLimit?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The number of images to regenerate
|
|
56
|
+
* in one request
|
|
57
|
+
*/
|
|
58
|
+
countToGenerate: number;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Rate limits for each action.
|
|
62
|
+
*/
|
|
63
|
+
rateLimits?: {
|
|
64
|
+
fillFieldsFromImages?: string;
|
|
65
|
+
fillPlainFields?: string;
|
|
66
|
+
generateImages?: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Job refresh rate for each ai flow job in milliseconds
|
|
70
|
+
*/
|
|
71
|
+
refreshRates?: {
|
|
72
|
+
fillFieldsFromImages?: number;
|
|
73
|
+
fillPlainFields?: number;
|
|
74
|
+
generateImages?: number;
|
|
75
|
+
regenerateImages?: number;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Whether the user is allowed to save the generated images
|
|
79
|
+
*/
|
|
80
|
+
isAllowedToSave?: ({ record, adminUser, resource }: {
|
|
81
|
+
record: any;
|
|
82
|
+
adminUser: any;
|
|
83
|
+
resource: any;
|
|
84
|
+
}) => Promise<{
|
|
85
|
+
ok: boolean;
|
|
86
|
+
error: string;
|
|
87
|
+
} | {
|
|
88
|
+
ok: boolean;
|
|
89
|
+
error?: undefined;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Custom message for the context shown to the user when performing the action
|
|
93
|
+
*/
|
|
94
|
+
provideAdditionalContextForRecord?: ({ record, adminUser, resource }: {
|
|
95
|
+
record: any;
|
|
96
|
+
adminUser: any;
|
|
97
|
+
resource: any;
|
|
98
|
+
}) => Record<string, any> | Promise<Record<string, any>>;
|
|
99
|
+
askConfirmationBeforeGenerating?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Maximum number of records processed concurrently on the frontend.
|
|
102
|
+
*/
|
|
103
|
+
concurrencyLimit?: number;
|
|
104
|
+
/**
|
|
105
|
+
* Defines the way how records are selected for the action.
|
|
106
|
+
*
|
|
107
|
+
* 'checkbox' means that user will select records manually by checkboxes,
|
|
108
|
+
*
|
|
109
|
+
* 'filtered' means that action will be applied to all records matching current
|
|
110
|
+
* filters without showing any checkboxes (use with caution).
|
|
111
|
+
*
|
|
112
|
+
* Default is 'checkbox'.
|
|
113
|
+
*/
|
|
114
|
+
recordSelector?: 'checkbox' | 'filtered';
|
|
115
|
+
/**
|
|
116
|
+
* Additional confirmation settings for long-running generations.
|
|
117
|
+
*
|
|
118
|
+
* Generating a very large number of records can be expensive. This option
|
|
119
|
+
* lets you pause the process at specific checkpoints so the user can review
|
|
120
|
+
* everything generated so far and then choose to Resume or Stop the
|
|
121
|
+
* generation.
|
|
122
|
+
*
|
|
123
|
+
* Each entry in the array defines a confirmation breakpoint:
|
|
124
|
+
* - `{ afterRecords: N }` – show a confirmation once, after the first N
|
|
125
|
+
* records have been processed.
|
|
126
|
+
* - `{ everyRecords: N }` – show a confirmation after every N records.
|
|
127
|
+
*/
|
|
128
|
+
askConfirmation?: ({
|
|
129
|
+
afterRecords: number;
|
|
130
|
+
} | {
|
|
131
|
+
everyRecords: number;
|
|
132
|
+
})[];
|
|
133
|
+
/**
|
|
134
|
+
* Number of cards to show per page in the VisionTable component.
|
|
135
|
+
* If omitted, the component falls back to 6.
|
|
136
|
+
*/
|
|
137
|
+
pageSize?: number;
|
|
138
|
+
}
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include*/
|
|
4
4
|
"module": "node16", /* Specify what module code is generated. */
|
|
5
|
+
"declaration": true,
|
|
5
6
|
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
6
7
|
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. */
|
|
7
8
|
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|