@adminforth/text-complete 1.4.3 → 1.5.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/custom/package-lock.json +4 -4
- package/custom/package.json +1 -1
- package/dist/custom/package-lock.json +4 -4
- package/dist/custom/package.json +1 -1
- package/dist/index.js +6 -7
- package/index.ts +6 -10
- package/package.json +1 -1
package/custom/package-lock.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@iconify-prerendered/vue-mdi": "^0.28.1737398331",
|
|
13
|
-
"vue-suggestion-input": "^1.0.
|
|
13
|
+
"vue-suggestion-input": "^1.0.11"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"node_modules/@babel/helper-string-parser": {
|
|
@@ -359,9 +359,9 @@
|
|
|
359
359
|
}
|
|
360
360
|
},
|
|
361
361
|
"node_modules/vue-suggestion-input": {
|
|
362
|
-
"version": "1.0.
|
|
363
|
-
"resolved": "https://registry.npmjs.org/vue-suggestion-input/-/vue-suggestion-input-1.0.
|
|
364
|
-
"integrity": "sha512-
|
|
362
|
+
"version": "1.0.11",
|
|
363
|
+
"resolved": "https://registry.npmjs.org/vue-suggestion-input/-/vue-suggestion-input-1.0.11.tgz",
|
|
364
|
+
"integrity": "sha512-biAo2PD5XTJl7Kp6bf9RFcqdiBcIgl73szfkNdqxVmngV+CltKf0UOLkfNIdijRX8s9JxIkPlpJYmYgYAjiXHw==",
|
|
365
365
|
"dependencies": {
|
|
366
366
|
"quill": "^2.0.2",
|
|
367
367
|
"vue": "^3.4.31"
|
package/custom/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@iconify-prerendered/vue-mdi": "^0.28.1737398331",
|
|
13
|
-
"vue-suggestion-input": "^1.0.
|
|
13
|
+
"vue-suggestion-input": "^1.0.11"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"node_modules/@babel/helper-string-parser": {
|
|
@@ -359,9 +359,9 @@
|
|
|
359
359
|
}
|
|
360
360
|
},
|
|
361
361
|
"node_modules/vue-suggestion-input": {
|
|
362
|
-
"version": "1.0.
|
|
363
|
-
"resolved": "https://registry.npmjs.org/vue-suggestion-input/-/vue-suggestion-input-1.0.
|
|
364
|
-
"integrity": "sha512-
|
|
362
|
+
"version": "1.0.11",
|
|
363
|
+
"resolved": "https://registry.npmjs.org/vue-suggestion-input/-/vue-suggestion-input-1.0.11.tgz",
|
|
364
|
+
"integrity": "sha512-biAo2PD5XTJl7Kp6bf9RFcqdiBcIgl73szfkNdqxVmngV+CltKf0UOLkfNIdijRX8s9JxIkPlpJYmYgYAjiXHw==",
|
|
365
365
|
"dependencies": {
|
|
366
366
|
"quill": "^2.0.2",
|
|
367
367
|
"vue": "^3.4.31"
|
package/dist/custom/package.json
CHANGED
package/dist/index.js
CHANGED
|
@@ -63,7 +63,7 @@ export default class TextCompletePlugin extends AdminForthPlugin {
|
|
|
63
63
|
method: 'POST',
|
|
64
64
|
path: `/plugin/${this.pluginInstanceId}/doComplete`,
|
|
65
65
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers }) {
|
|
66
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
66
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
67
67
|
if ((_b = this.options.rateLimit) === null || _b === void 0 ? void 0 : _b.limit) {
|
|
68
68
|
// rate limit
|
|
69
69
|
const { error } = RateLimiter.checkRateLimit(this.pluginInstanceId, (_c = this.options.rateLimit) === null || _c === void 0 ? void 0 : _c.limit, this.adminforth.auth.getClientIp(headers));
|
|
@@ -82,18 +82,17 @@ export default class TextCompletePlugin extends AdminForthPlugin {
|
|
|
82
82
|
if (currentVal && currentVal.length > promptLimit) {
|
|
83
83
|
currentVal = currentVal.slice(-promptLimit);
|
|
84
84
|
}
|
|
85
|
+
const fieldLabel = ((_m = (_l = this.resourceConfig) === null || _l === void 0 ? void 0 : _l.columns.find(c => c.name === this.options.fieldName)) === null || _m === void 0 ? void 0 : _m.label) || this.options.fieldName;
|
|
85
86
|
const resLabel = this.resourceConfig.label;
|
|
86
87
|
let content;
|
|
87
88
|
if (currentVal) {
|
|
88
|
-
content = `Continue writing for text/string field "${
|
|
89
|
+
content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
89
90
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
90
91
|
`Current field value: ${currentVal}\n` +
|
|
91
92
|
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
|
|
92
93
|
}
|
|
93
94
|
else {
|
|
94
95
|
if (this.options.initialPrompt) {
|
|
95
|
-
// initial prompt might have mustache syntax for current record value (several fields)
|
|
96
|
-
// use regex to replace it with current record value
|
|
97
96
|
const regex = /{{([^}]+)}}/g;
|
|
98
97
|
const interpretedPrompt = this.options.initialPrompt.replace(regex, (match, p1) => {
|
|
99
98
|
const fieldName = p1.trim();
|
|
@@ -107,14 +106,14 @@ export default class TextCompletePlugin extends AdminForthPlugin {
|
|
|
107
106
|
"No quotes. Don't talk to me. Just write text\n";
|
|
108
107
|
}
|
|
109
108
|
else {
|
|
110
|
-
content = `Fill text/string field "${
|
|
109
|
+
content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
111
110
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
112
111
|
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);
|
|
116
|
-
const { content: respContent, finishReason } = yield this.options.adapter.complete(content, (
|
|
117
|
-
const stop = ((
|
|
115
|
+
const { content: respContent, finishReason } = yield this.options.adapter.complete(content, (_o = this.options.expert) === null || _o === void 0 ? void 0 : _o.stop, (_p = this.options.expert) === null || _p === void 0 ? void 0 : _p.maxTokens);
|
|
116
|
+
const stop = ((_q = this.options.expert) === null || _q === void 0 ? void 0 : _q.stop) || ['.'];
|
|
118
117
|
let suggestion = respContent + (finishReason === 'stop' ? (stop[0] === '.' && stop.length === 1 && this.columnType === AdminForthDataTypes.TEXT ? '. ' : '') : '');
|
|
119
118
|
if (suggestion.startsWith(currentVal)) {
|
|
120
119
|
suggestion = suggestion.slice(currentVal.length);
|
package/index.ts
CHANGED
|
@@ -108,21 +108,18 @@ export default class TextCompletePlugin extends AdminForthPlugin {
|
|
|
108
108
|
currentVal = currentVal.slice(-promptLimit);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
const
|
|
112
|
-
|
|
111
|
+
const fieldLabel = this.resourceConfig?.columns.find(c => c.name === this.options.fieldName)?.label || this.options.fieldName;
|
|
112
|
+
const resLabel = this.resourceConfig!.label;
|
|
113
|
+
|
|
113
114
|
let content;
|
|
114
|
-
|
|
115
|
+
|
|
115
116
|
if (currentVal) {
|
|
116
|
-
content = `Continue writing for text/string field "${
|
|
117
|
+
content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
117
118
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
118
119
|
`Current field value: ${currentVal}\n` +
|
|
119
120
|
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
|
|
120
|
-
|
|
121
121
|
} else {
|
|
122
|
-
|
|
123
122
|
if (this.options.initialPrompt) {
|
|
124
|
-
// initial prompt might have mustache syntax for current record value (several fields)
|
|
125
|
-
// use regex to replace it with current record value
|
|
126
123
|
const regex = /{{([^}]+)}}/g;
|
|
127
124
|
const interpretedPrompt = this.options.initialPrompt.replace(regex, (match, p1) => {
|
|
128
125
|
const fieldName = p1.trim();
|
|
@@ -133,11 +130,10 @@ export default class TextCompletePlugin extends AdminForthPlugin {
|
|
|
133
130
|
return match;
|
|
134
131
|
});
|
|
135
132
|
|
|
136
|
-
|
|
137
133
|
content = `${interpretedPrompt}\n` +
|
|
138
134
|
"No quotes. Don't talk to me. Just write text\n";
|
|
139
135
|
} else {
|
|
140
|
-
content = `Fill text/string field "${
|
|
136
|
+
content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
|
|
141
137
|
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
|
|
142
138
|
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
|
|
143
139
|
}
|