@adminforth/rich-editor 1.6.16 → 2.0.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/dist/index.js +5 -6
- package/index.ts +4 -9
- package/package.json +1 -1
- package/types.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -219,7 +219,7 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
219
219
|
method: 'POST',
|
|
220
220
|
path: `/plugin/${this.pluginInstanceId}/doComplete`,
|
|
221
221
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers }) {
|
|
222
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
222
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
223
223
|
const { record } = body;
|
|
224
224
|
if (this.rateLimiter) {
|
|
225
225
|
// rate limit
|
|
@@ -249,17 +249,16 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
249
249
|
content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
250
250
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
251
251
|
`Current field value: ${currentVal}\n` +
|
|
252
|
-
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
|
|
252
|
+
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion. Stop generating when you finish the sentence. DO NOT GENERATE AFTER YOU GENERATED FIRST\".\" \n";
|
|
253
253
|
}
|
|
254
254
|
else {
|
|
255
255
|
content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
256
256
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
257
|
-
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
|
|
257
|
+
"Be short, clear and precise. No quotes. Don't talk to me. Just write text. Stop generating when you finish the sentence. DO NOT GENERATE AFTER YOU GENERATED FIRST\".\" \n";
|
|
258
258
|
}
|
|
259
259
|
process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);
|
|
260
|
-
const { content: respContent
|
|
261
|
-
|
|
262
|
-
let suggestion = respContent + (finishReason === 'stop' ? (stop[0] === '.' && stop.length === 1 ? '. ' : '') : '');
|
|
260
|
+
const { content: respContent } = yield this.options.completion.adapter.complete(content, [], (_m = (_l = this.options.completion) === null || _l === void 0 ? void 0 : _l.expert) === null || _m === void 0 ? void 0 : _m.maxTokens);
|
|
261
|
+
let suggestion = respContent;
|
|
263
262
|
if (suggestion.startsWith(currentVal)) {
|
|
264
263
|
suggestion = suggestion.slice(currentVal.length);
|
|
265
264
|
}
|
package/index.ts
CHANGED
|
@@ -315,22 +315,17 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
315
315
|
content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
316
316
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
317
317
|
`Current field value: ${currentVal}\n` +
|
|
318
|
-
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
|
|
318
|
+
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion. Stop generating when you finish the sentence. DO NOT GENERATE AFTER YOU GENERATED FIRST\".\" \n";
|
|
319
319
|
|
|
320
320
|
} else {
|
|
321
321
|
content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
322
322
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
323
|
-
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
|
|
323
|
+
"Be short, clear and precise. No quotes. Don't talk to me. Just write text. Stop generating when you finish the sentence. DO NOT GENERATE AFTER YOU GENERATED FIRST\".\" \n";
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);
|
|
327
|
-
const { content: respContent
|
|
328
|
-
|
|
329
|
-
let suggestion = respContent + (
|
|
330
|
-
finishReason === 'stop' ? (
|
|
331
|
-
stop[0] === '.' && stop.length === 1 ? '. ' : ''
|
|
332
|
-
) : ''
|
|
333
|
-
);
|
|
327
|
+
const { content: respContent } = await this.options.completion.adapter.complete(content, [], this.options.completion?.expert?.maxTokens);
|
|
328
|
+
let suggestion = respContent
|
|
334
329
|
|
|
335
330
|
if (suggestion.startsWith(currentVal)) {
|
|
336
331
|
suggestion = suggestion.slice(currentVal.length);
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -79,11 +79,6 @@ export interface PluginOptions {
|
|
|
79
79
|
*/
|
|
80
80
|
debounceTime?: number;
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* Stop completion on these characters. Default is ['.']
|
|
84
|
-
*/
|
|
85
|
-
stop?: string[];
|
|
86
|
-
|
|
87
82
|
/**
|
|
88
83
|
* When completion is made, this plugin passes non-empty fields of the record to the LLM model for record context understanding.
|
|
89
84
|
*/
|