@@ -108,21 +108,19 @@ 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 resLabel = this.resourceConfig.label;
112
+ const fieldLabel = this . resourceConfig ?. columns . find ( c => c . name === this . options . fieldName ) ?. label || this . options . fieldName ;
113
+ const resourceLabel = this . resourceConfig ?. label || this . resourceConfig ?. resourceId ;
114
+
113
115
let content ;
114
-
116
+
115
117
if ( currentVal ) {
116
- content = `Continue writing for text/string field "${ this . options . fieldName } " in the table "${ resLabel } "\n` +
118
+ content = `Continue writing for text/string field "${ fieldLabel } " in the table "${ resourceLabel } "\n` +
117
119
( Object . keys ( recordNoField ) . length > 0 ? `Record has values for the context: ${ inputContext } \n` : '' ) +
118
120
`Current field value: ${ currentVal } \n` +
119
121
"Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n" ;
120
-
121
122
} else {
122
-
123
123
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
124
const regex = / { { ( [ ^ } ] + ) } } / g;
127
125
const interpretedPrompt = this . options . initialPrompt . replace ( regex , ( match , p1 ) => {
128
126
const fieldName = p1 . trim ( ) ;
@@ -133,11 +131,10 @@ export default class TextCompletePlugin extends AdminForthPlugin {
133
131
return match ;
134
132
} ) ;
135
133
136
-
137
134
content = `${ interpretedPrompt } \n` +
138
135
"No quotes. Don't talk to me. Just write text\n" ;
139
136
} else {
140
- content = `Fill text/string field "${ this . options . fieldName } " in the table "${ resLabel } "\n` +
137
+ content = `Fill text/string field "${ fieldLabel } " in the table "${ resourceLabel } "\n` +
141
138
( Object . keys ( recordNoField ) . length > 0 ? `Record has values for the context: ${ inputContext } \n` : '' ) +
142
139
"Be short, clear and precise. No quotes. Don't talk to me. Just write text\n" ;
143
140
}
0 commit comments