-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
171 lines (147 loc) · 5.44 KB
/
types.ts
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import { CompletionAdapter } from "adminforth";
// example options ussage:
//{
// htmlFieldName: 'description',
// completion: {
// provider: 'openai-chat-gpt',
// params: {
// apiKey: process.env.OPENAI_API_KEY as string,
// model: 'gpt-4o',
// },
// expert: {
// debounceTime: 250,
// }
// }
//}
export interface PluginOptions {
/**
* Field where plugin will auto-complete text. Should be string or text field.
*/
htmlFieldName: string;
/**
* Quill toolbar setting, full toolbar:
*
* ```
* [
* ['bold', 'italic', 'underline', 'strike'], // toggled buttons
* ['blockquote', 'code-block', 'link'],
* // [ 'image', 'video', 'formula' ],
*
* [{ 'header': 2 }, { 'header': 3 }], // custom button values
* [{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
* // [{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript
* // [{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent
* // [{ 'direction': 'rtl' }], // text direction
* // [{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
* // [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
* // [{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
* // [{ 'font': [] }],
* [{ 'align': [] }],
*
* ['clean']
* ]
*```
*/
toolbar?: any[];
/**
* The completion section is used to define the completion provider and its parameters.
*/
completion?: {
/**
* Adapter for completion.
*/
adapter: CompletionAdapter;
/**
* Expert settings
*/
expert?: {
/**
* Number of tokens to generate. Default is 50. 1 token ~= ¾ words
*/
maxTokens?: number;
/**
* Maximum number of last characters which will be used for completion for target field. Default is 500.
* Higher value will give better context but will cost more.
*/
promptInputLimit?: number;
/**
* Time in ms to wait after user stops typing before sending request to completion provider. Default is 300 ms.
*/
debounceTime?: number;
/**
* Stop completion on these characters. Default is ['.']
*/
stop?: string[];
/**
* When completion is made, this plugin passes non-empty fields of the record to the LLM model for record context understanding.
*/
recordContext?: {
/**
* Using this field you can limit number of fields passed to the model.
* Default is 5.
* Completion field is not included in this limit.
* Set to 0 to disable context passing at all.
* If count of fields exceeds this number, longest fields will be selected.
* If some of values will exceed maxFieldLength, it will be smartly truncated by splitting ito splitParts, taking their
* starting substring and joining back with '...'.
*/
maxFields?: number;
/**
* Limit of input field value. Default is 300. If field is longer, it will be truncated.
*/
maxFieldLength?: number;
/**
* How many parts to split field value if it exceeds maxFieldLength. Default is 5.
*/
splitParts?: number;
}
}
/**
* Since AI generation can be expensive, we can limit the number of requests per IP.
* Completion will simply stop working when limit is reached so user will not be bothered with error messages.
*/
rateLimit?: {
/**
* E.g. 5/1d - 5 requests per day
* 3/1h - 3 requests per hour
*/
limit: string,
/**
* Not used now
* Message shown to user when rate limit is reached
*/
errorMessage: string,
},
}
/**
* Allows to attach images to the HTML text
* Requires to have a separate resource with Upload Plugin installed on attachment field.
* Each attachment used in HTML will create one record in the attachment resource.
*/
attachments?: {
/**
* Resource name where images are stored. Should point to the existing resource.
*/
attachmentResource: string;
/**
* Field name in the attachment resource where image is stored. Should point to the existing field in the attachment resource.
* Also there should be upload plugin installed on this field.
*/
attachmentFieldName: string; // e.g. 'image_path',
/**
* When attachment is created, it will be linked to the record, by storing id of the record with editor in attachment resource.
* Here you define the field name where this id will be stored.
*
* Linking is needed to remove all attachments when record is deleted.
*
* For example when RichEditor installed on description field of apartment resource,
* field in attachment resource described hear will store id of apartment record.
*/
attachmentRecordIdFieldName: string; // e.g. 'apartment_id',
/**
* When attachment is created, it will be linked to the resource, by storing id of the resource with editor in attachment resource.
* For example when RichEditor installed on description field of apartment resource, it will store id of apartment resource.
*/
attachmentResourceIdFieldName: string; // e.g. 'apartment_resource_id',
},
}