@@ -108,21 +108,18 @@ export default class TextCompletePlugin extends AdminForthPlugin {
108108          currentVal  =  currentVal . slice ( - promptLimit ) ; 
109109        } 
110110
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+ 
113114        let  content ; 
114-          
115+ 
115116        if  ( currentVal )  { 
116-           content  =  `Continue writing for text/string field "${ this . options . fieldName } ${ resLabel }   + 
117+           content  =  `Continue writing for text/string field "${ fieldLabel } ${ resLabel }   + 
117118              ( Object . keys ( recordNoField ) . length  >  0  ? `Record has values for the context: ${ inputContext }   : '' )  + 
118119              `Current field value: ${ currentVal }   + 
119120              "Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n" ; 
120- 
121121        }  else  { 
122- 
123122          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 
126123            const  regex  =  / { { ( [ ^ } ] + ) } } / g; 
127124            const  interpretedPrompt  =  this . options . initialPrompt . replace ( regex ,  ( match ,  p1 )  =>  { 
128125              const  fieldName  =  p1 . trim ( ) ; 
@@ -133,11 +130,10 @@ export default class TextCompletePlugin extends AdminForthPlugin {
133130              return  match ; 
134131            } ) ; 
135132
136- 
137133            content  =  `${ interpretedPrompt }   + 
138134              "No quotes. Don't talk to me. Just write text\n" ; 
139135          }  else  { 
140-             content  =  `Fill text/string field "${ this . options . fieldName } ${ resLabel }   + 
136+             content  =  `Fill text/string field "${ fieldLabel } ${ resLabel }   + 
141137                ( Object . keys ( recordNoField ) . length  >  0  ? `Record has values for the context: ${ inputContext }   : '' )  + 
142138                "Be short, clear and precise. No quotes. Don't talk to me. Just write text\n" ; 
143139          } 
0 commit comments