@adminforth/rich-editor 1.3.1 → 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/build.log CHANGED
@@ -10,5 +10,5 @@ custom/package.json
10
10
  custom/quillEditor.vue
11
11
  custom/tsconfig.json
12
12
 
13
- sent 21,044 bytes received 115 bytes 42,318.00 bytes/sec
13
+ sent 21,050 bytes received 115 bytes 42,330.00 bytes/sec
14
14
  total size is 20,627 speedup is 0.97
package/dist/index.js CHANGED
@@ -215,7 +215,7 @@ export default class RichEditorPlugin extends AdminForthPlugin {
215
215
  method: 'POST',
216
216
  path: `/plugin/${this.pluginInstanceId}/doComplete`,
217
217
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers }) {
218
- 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;
219
219
  const { record } = body;
220
220
  if ((_b = this.options.completion.rateLimit) === null || _b === void 0 ? void 0 : _b.limit) {
221
221
  // rate limit
@@ -234,22 +234,23 @@ export default class RichEditorPlugin extends AdminForthPlugin {
234
234
  if (currentVal && currentVal.length > promptLimit) {
235
235
  currentVal = currentVal.slice(-promptLimit);
236
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;
237
238
  const resLabel = this.resourceConfig.label;
238
239
  let content;
239
240
  if (currentVal) {
240
- content = `Continue writing for text/string field "${this.options.htmlFieldName}" in the table "${resLabel}"\n` +
241
+ content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
241
242
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
242
243
  `Current field value: ${currentVal}\n` +
243
244
  "Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
244
245
  }
245
246
  else {
246
- content = `Fill text/string field "${this.options.htmlFieldName}" in the table "${resLabel}"\n` +
247
+ content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
247
248
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
248
249
  "Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
249
250
  }
250
251
  process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);
251
- const { content: respContent, finishReason } = 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.stop, (_p = (_o = this.options.completion) === null || _o === void 0 ? void 0 : _o.expert) === null || _p === void 0 ? void 0 : _p.maxTokens);
252
- const stop = ((_q = this.options.completion.expert) === null || _q === void 0 ? void 0 : _q.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) || ['.'];
253
254
  let suggestion = respContent + (finishReason === 'stop' ? (stop[0] === '.' && stop.length === 1 ? '. ' : '') : '');
254
255
  if (suggestion.startsWith(currentVal)) {
255
256
  suggestion = suggestion.slice(currentVal.length);
package/index.ts CHANGED
@@ -300,18 +300,19 @@ export default class RichEditorPlugin extends AdminForthPlugin {
300
300
  currentVal = currentVal.slice(-promptLimit);
301
301
  }
302
302
 
303
+ const fieldLabel = this.resourceConfig?.columns.find(c => c.name === this.options.htmlFieldName)?.label || this.options.htmlFieldName;
303
304
  const resLabel = this.resourceConfig!.label;
304
-
305
+
305
306
  let content;
306
307
 
307
308
  if (currentVal) {
308
- content = `Continue writing for text/string field "${this.options.htmlFieldName}" in the table "${resLabel}"\n` +
309
+ content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
309
310
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
310
311
  `Current field value: ${currentVal}\n` +
311
312
  "Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
312
313
 
313
314
  } else {
314
- content = `Fill text/string field "${this.options.htmlFieldName}" in the table "${resLabel}"\n` +
315
+ content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
315
316
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
316
317
  "Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
317
318
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/rich-editor",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Rich editor plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",