@@ -108,21 +108,18 @@ export default class TextCompletePlugin extends AdminForthPlugin {
108
108
currentVal = currentVal . slice ( - promptLimit ) ;
109
109
}
110
110
111
- const resLabel = this . resourceConfig . label ;
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 "${ this . options . fieldName } " in the table "${ resLabel } "\n` +
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 "${ this . options . fieldName } " in the table "${ resLabel } "\n` +
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
}
0 commit comments