Skip to content

Commit e364984

Browse files
committed
feat: allow to set custom prompt for initial value
1 parent 6d869d1 commit e364984

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,15 @@ export default class TextCompletePlugin extends AdminForthPlugin {
119119
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
120120

121121
} else {
122-
content = `Fill text/string field "${this.options.fieldName}" in the table "${resLabel}"\n` +
123-
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
124-
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
122+
123+
if (this.options.initialPrompt) {
124+
content = `${this.options.initialPrompt}\n` +
125+
"No quotes. Don't talk to me. Just write text\n";
126+
} else {
127+
content = `Fill text/string field "${this.options.fieldName}" in the table "${resLabel}"\n` +
128+
(Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
129+
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
130+
}
125131
}
126132

127133
process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);

types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ export interface PluginOptions {
66
*/
77
fieldName: string;
88

9+
10+
/**
11+
* Initial prompt request when field is empty. Mustache syntax for record context fields is supported.
12+
* E.g.
13+
* 'I need to introduce "{{ name }}" technology to my software development company website, I need short but very attractive description if it.'
14+
*
15+
* Where `name` is a field name which contains technology name e.g. Vue.js
16+
*/
17+
initialPrompt?: string;
18+
919
/**
1020
* Expert settings
1121
*/
@@ -21,6 +31,7 @@ export interface PluginOptions {
2131
*/
2232
debounceTime?: number;
2333

34+
2435
/**
2536
* When completion is made, this plugin passes non-empty fields of the record to the LLM model for record context understanding.
2637
*/

0 commit comments

Comments
 (0)