@@ -108,21 +108,19 @@ export default class TextCompletePlugin extends AdminForthPlugin {
108108 currentVal = currentVal . slice ( - promptLimit ) ;
109109 }
110110
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+
113115 let content ;
114-
116+
115117 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` +
117119 ( Object . keys ( recordNoField ) . length > 0 ? `Record has values for the context: ${ inputContext } \n` : '' ) +
118120 `Current field value: ${ currentVal } \n` +
119121 "Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n" ;
120-
121122 } else {
122-
123123 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
126124 const regex = / { { ( [ ^ } ] + ) } } / g;
127125 const interpretedPrompt = this . options . initialPrompt . replace ( regex , ( match , p1 ) => {
128126 const fieldName = p1 . trim ( ) ;
@@ -133,11 +131,10 @@ export default class TextCompletePlugin extends AdminForthPlugin {
133131 return match ;
134132 } ) ;
135133
136-
137134 content = `${ interpretedPrompt } \n` +
138135 "No quotes. Don't talk to me. Just write text\n" ;
139136 } 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` +
141138 ( Object . keys ( recordNoField ) . length > 0 ? `Record has values for the context: ${ inputContext } \n` : '' ) +
142139 "Be short, clear and precise. No quotes. Don't talk to me. Just write text\n" ;
143140 }
0 commit comments