Skip to content

Commit 5830663

Browse files
committed
fix!: remove support of the stop tokens
BREAKING CHANGE: stop tokens no longer supported.
1 parent 1d1e470 commit 5830663

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default class TextCompletePlugin extends AdminForthPlugin {
122122
content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
123123
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
124124
`Current field value: ${currentVal}\n` +
125-
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
125+
"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 GENERATED FIRST \".\"\n";
126126
} else {
127127
if (this.options.initialPrompt) {
128128
const regex = /{{([^}]+)}}/g;
@@ -140,18 +140,13 @@ export default class TextCompletePlugin extends AdminForthPlugin {
140140
} else {
141141
content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
142142
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
143-
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
143+
"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";
144144
}
145145
}
146146

147147
process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);
148-
const { content: respContent, finishReason } = await this.options.adapter.complete(content, this.options.expert?.stop, this.options.expert?.maxTokens);
149-
const stop = this.options.expert?.stop || ['.'];
150-
let suggestion = respContent + (
151-
finishReason === 'stop' ? (
152-
stop[0] === '.' && stop.length === 1 && this.columnType === AdminForthDataTypes.TEXT ? '. ' : ''
153-
) : ''
154-
);
148+
const { content: respContent } = await this.options.adapter.complete(content, [], this.options.expert?.maxTokens);
149+
let suggestion = respContent
155150

156151
if (suggestion.startsWith(currentVal)) {
157152
suggestion = suggestion.slice(currentVal.length);

types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ export interface PluginOptions {
6363
*/
6464
maxTokens?: number;
6565

66-
/**
67-
* Stop tokens. Default is ['.']
68-
*/
69-
stop?: string[];
7066
};
7167

7268
/**

0 commit comments

Comments
 (0)