@adminforth/rich-editor 1.3.0 → 1.4.0
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/.woodpecker/release.yml +0 -2
- package/build.log +1 -1
- package/dist/index.js +10 -7
- package/index.ts +8 -5
- package/package.json +1 -1
package/.woodpecker/release.yml
CHANGED
package/build.log
CHANGED
package/dist/index.js
CHANGED
|
@@ -51,9 +51,11 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
51
51
|
if (!plugin) {
|
|
52
52
|
throw new Error(`Plugin for attachment field '${this.options.attachments.attachmentFieldName}' not found in resource '${this.options.attachments.attachmentResource}', please check if Upload Plugin is installed on the field ${this.options.attachments.attachmentFieldName}`);
|
|
53
53
|
}
|
|
54
|
-
if (plugin.pluginOptions.
|
|
54
|
+
if (!plugin.pluginOptions.storageAdapter.objectCanBeAccesedPublicly()) {
|
|
55
55
|
throw new Error(`Upload Plugin for attachment field '${this.options.attachments.attachmentFieldName}' in resource '${this.options.attachments.attachmentResource}'
|
|
56
|
-
|
|
56
|
+
uses adapter which is not configured to store objects in public way, so it will produce only signed private URLs which can not be used in HTML text of blog posts.
|
|
57
|
+
Please configure adapter in such way that it will store objects publicly (e.g. for S3 use 'public-read' ACL).
|
|
58
|
+
`);
|
|
57
59
|
}
|
|
58
60
|
this.uploadPlugin = plugin;
|
|
59
61
|
}
|
|
@@ -213,7 +215,7 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
213
215
|
method: 'POST',
|
|
214
216
|
path: `/plugin/${this.pluginInstanceId}/doComplete`,
|
|
215
217
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers }) {
|
|
216
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
218
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
217
219
|
const { record } = body;
|
|
218
220
|
if ((_b = this.options.completion.rateLimit) === null || _b === void 0 ? void 0 : _b.limit) {
|
|
219
221
|
// rate limit
|
|
@@ -232,22 +234,23 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
232
234
|
if (currentVal && currentVal.length > promptLimit) {
|
|
233
235
|
currentVal = currentVal.slice(-promptLimit);
|
|
234
236
|
}
|
|
237
|
+
const fieldLabel = ((_m = (_l = this.resourceConfig) === null || _l === void 0 ? void 0 : _l.columns.find(c => c.name === this.options.htmlFieldName)) === null || _m === void 0 ? void 0 : _m.label) || this.options.htmlFieldName;
|
|
235
238
|
const resLabel = this.resourceConfig.label;
|
|
236
239
|
let content;
|
|
237
240
|
if (currentVal) {
|
|
238
|
-
content = `Continue writing for text/string field "${
|
|
241
|
+
content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
239
242
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
240
243
|
`Current field value: ${currentVal}\n` +
|
|
241
244
|
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
|
|
242
245
|
}
|
|
243
246
|
else {
|
|
244
|
-
content = `Fill text/string field "${
|
|
247
|
+
content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
245
248
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
246
249
|
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
|
|
247
250
|
}
|
|
248
251
|
process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);
|
|
249
|
-
const { content: respContent, finishReason } = yield this.options.completion.adapter.complete(content, (
|
|
250
|
-
const stop = ((
|
|
252
|
+
const { content: respContent, finishReason } = yield this.options.completion.adapter.complete(content, (_p = (_o = this.options.completion) === null || _o === void 0 ? void 0 : _o.expert) === null || _p === void 0 ? void 0 : _p.stop, (_r = (_q = this.options.completion) === null || _q === void 0 ? void 0 : _q.expert) === null || _r === void 0 ? void 0 : _r.maxTokens);
|
|
253
|
+
const stop = ((_s = this.options.completion.expert) === null || _s === void 0 ? void 0 : _s.stop) || ['.'];
|
|
251
254
|
let suggestion = respContent + (finishReason === 'stop' ? (stop[0] === '.' && stop.length === 1 ? '. ' : '') : '');
|
|
252
255
|
if (suggestion.startsWith(currentVal)) {
|
|
253
256
|
suggestion = suggestion.slice(currentVal.length);
|
package/index.ts
CHANGED
|
@@ -57,9 +57,11 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
57
57
|
throw new Error(`Plugin for attachment field '${this.options.attachments!.attachmentFieldName}' not found in resource '${this.options.attachments!.attachmentResource}', please check if Upload Plugin is installed on the field ${this.options.attachments!.attachmentFieldName}`);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
if (plugin.pluginOptions.
|
|
60
|
+
if (!plugin.pluginOptions.storageAdapter.objectCanBeAccesedPublicly()) {
|
|
61
61
|
throw new Error(`Upload Plugin for attachment field '${this.options.attachments!.attachmentFieldName}' in resource '${this.options.attachments!.attachmentResource}'
|
|
62
|
-
|
|
62
|
+
uses adapter which is not configured to store objects in public way, so it will produce only signed private URLs which can not be used in HTML text of blog posts.
|
|
63
|
+
Please configure adapter in such way that it will store objects publicly (e.g. for S3 use 'public-read' ACL).
|
|
64
|
+
`);
|
|
63
65
|
}
|
|
64
66
|
this.uploadPlugin = plugin;
|
|
65
67
|
}
|
|
@@ -298,18 +300,19 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
298
300
|
currentVal = currentVal.slice(-promptLimit);
|
|
299
301
|
}
|
|
300
302
|
|
|
303
|
+
const fieldLabel = this.resourceConfig?.columns.find(c => c.name === this.options.htmlFieldName)?.label || this.options.htmlFieldName;
|
|
301
304
|
const resLabel = this.resourceConfig!.label;
|
|
302
|
-
|
|
305
|
+
|
|
303
306
|
let content;
|
|
304
307
|
|
|
305
308
|
if (currentVal) {
|
|
306
|
-
content = `Continue writing for text/string field "${
|
|
309
|
+
content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
307
310
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
308
311
|
`Current field value: ${currentVal}\n` +
|
|
309
312
|
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
|
|
310
313
|
|
|
311
314
|
} else {
|
|
312
|
-
content = `Fill text/string field "${
|
|
315
|
+
content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
313
316
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
314
317
|
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
|
|
315
318
|
}
|