forked from devforth/adminforth-bulk-vision
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.ts
More file actions
155 lines (133 loc) · 4.47 KB
/
types.ts
File metadata and controls
155 lines (133 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import AdminForth, { ImageVisionAdapter, ImageGenerationAdapter, CompletionAdapter } from "adminforth";
export interface PluginOptions {
/**
* Name of the action in three dots menu.
*/
actionName: string,
/**
* The adapter to use for scaning images and filling fields basing on the image content.
*/
visionAdapter?: ImageVisionAdapter,
/**
* The adapter to use for text->text generation.
*/
textCompleteAdapter?: CompletionAdapter,
/**
* The adapter to use for image generation.
*/
imageGenerationAdapter?: ImageGenerationAdapter,
/**
* List of fields that should be filled based on the image content analysis.
*/
fillFieldsFromImages?: Record<string, string>, // can analyze what is on image and fill fields, typical tasks "find dominant color", "describe what is on image", "clasify to one enum item, e.g. what is on image dog/cat/plant"
/**
* List of fields that should be filled based on the text.
*/
fillPlainFields?: Record<string, string>,
/**
* Number of tokens to generate (Only for text completion adapter). Default is 1000. 1 token ~= ¾ words
*/
fillPlainFieldsMaxTokens?: number,
/**
* If you want to generate fields or images based on the image content attached images
*/
attachFiles?: ({ record }: {
record: any,
}) => string[] | Promise<string[]>,
/**
* List of image fields, that should be filled.
*/
generateImages?: Record<
string, {
// can generate from images or just from another fields, e.g. "remove text from images", "improve image quality", "turn image into ghibli style"
prompt: string,
/*
* Redefine the adapter for your specific generation task
*/
adapter?: ImageGenerationAdapter,
/**
* The size of the generated image.
*/
outputSize?: string,
/**
* Since AI generation can be expensive, we can limit the number of requests per IP.
* E.g. 5/1d - 5 requests per day
* 3/1h - 3 requests per hour
*/
rateLimit?: string,
/**
* The number of images to regenerate
* in one request
*/
countToGenerate: number,
}>,
/**
* Rate limits for each action.
*/
rateLimits?: {
fillFieldsFromImages?: string, // e.g. 5/1d - 5 requests per day
fillPlainFields?: string,
generateImages?: string,
},
/**
* Job refresh rate for each ai flow job in milliseconds
*/
refreshRates?: {
fillFieldsFromImages?: number,
fillPlainFields?: number,
generateImages?: number,
regenerateImages?: number,
},
/**
* Whether the user is allowed to save the generated images
*/
isAllowedToSave?: ({ record, adminUser, resource }: {
record: any;
adminUser: any;
resource: any;
}) => Promise<{
ok: boolean;
error: string;
} | {
ok: boolean;
error?: undefined;
}>
/**
* Custom message for the context shown to the user when performing the action
*/
provideAdditionalContextForRecord?: ({record, adminUser, resource}: {
record: any;
adminUser: any;
resource: any;
}) => Record<string, any> | Promise<Record<string, any>>;
askConfirmationBeforeGenerating?: boolean;
/**
* Maximum number of records processed concurrently on the frontend.
*/
concurrencyLimit?: number;
/**
* Defines the way how records are selected for the action.
*
* 'checkbox' means that user will select records manually by checkboxes,
*
* 'filtered' means that action will be applied to all records matching current
* filters without showing any checkboxes (use with caution).
*
* Default is 'checkbox'.
*/
recordSelector?: 'checkbox' | 'filtered';
/**
* Additional confirmation settings for long-running generations.
*
* Generating a very large number of records can be expensive. This option
* lets you pause the process at specific checkpoints so the user can review
* everything generated so far and then choose to Resume or Stop the
* generation.
*
* Each entry in the array defines a confirmation breakpoint:
* - `{ afterRecords: N }` – show a confirmation once, after the first N
* records have been processed.
* - `{ everyRecords: N }` – show a confirmation after every N records.
*/
askConfirmation?: ({ afterRecords: number } | { everyRecords: number })[]
}