@@ -15,7 +15,7 @@ const profile = {
1515 name : 'solcoder' ,
1616 displayName : 'solcoder' ,
1717 description : 'solcoder' ,
18- methods : [ 'code_generation' , 'code_completion' , "solidity_answer" , "code_explaining" , "code_insertion" ] ,
18+ methods : [ 'code_generation' , 'code_completion' , "solidity_answer" , "code_explaining" , "code_insertion" , "error_explaining" ] ,
1919 events : [ ] ,
2020 maintainedBy : 'Remix' ,
2121}
@@ -50,6 +50,8 @@ export class SolCoder extends Plugin {
5050 async code_generation ( prompt ) : Promise < any > {
5151 this . emit ( "aiInfering" )
5252 this . call ( 'layout' , 'maximizeTerminal' )
53+ _paq . push ( [ 'trackEvent' , 'ai' , 'solcoder' , 'code_generation' ] )
54+
5355 let result
5456 try {
5557 result = await (
@@ -78,6 +80,9 @@ export class SolCoder extends Plugin {
7880 async solidity_answer ( prompt ) : Promise < any > {
7981 this . emit ( "aiInfering" )
8082 this . call ( 'layout' , 'maximizeTerminal' )
83+ this . call ( 'terminal' , 'log' , { type : 'aitypewriterwarning' , value : `\n\nWaiting for RemixAI answer...` } )
84+ _paq . push ( [ 'trackEvent' , 'ai' , 'solcoder' , 'answering' ] )
85+
8186 let result
8287 try {
8388 const main_prompt = this . _build_solgpt_promt ( prompt )
@@ -112,6 +117,9 @@ export class SolCoder extends Plugin {
112117 async code_explaining ( prompt , context :string = "" ) : Promise < any > {
113118 this . emit ( "aiInfering" )
114119 this . call ( 'layout' , 'maximizeTerminal' )
120+ this . call ( 'terminal' , 'log' , { type : 'aitypewriterwarning' , value : `\n\nWaiting for RemixAI answer...` } )
121+ _paq . push ( [ 'trackEvent' , 'ai' , 'solcoder' , 'explaining' ] )
122+
115123 let result
116124 try {
117125 result = await (
@@ -138,6 +146,8 @@ export class SolCoder extends Plugin {
138146
139147 async code_completion ( prompt , options :SuggestOptions = null ) : Promise < any > {
140148 this . emit ( "aiInfering" )
149+ _paq . push ( [ 'trackEvent' , 'ai' , 'solcoder' , 'code_completion' ] )
150+
141151 let result
142152 try {
143153 result = await (
@@ -184,6 +194,8 @@ export class SolCoder extends Plugin {
184194
185195 async code_insertion ( msg_pfx , msg_sfx ) : Promise < any > {
186196 this . emit ( "aiInfering" )
197+ _paq . push ( [ 'trackEvent' , 'ai' , 'solcoder' , 'code_insertion' ] )
198+
187199 let result
188200 try {
189201 result = await (
@@ -218,6 +230,36 @@ export class SolCoder extends Plugin {
218230 }
219231 }
220232
233+ async error_explaining ( prompt ) : Promise < any > {
234+ this . emit ( "aiInfering" )
235+ this . call ( 'layout' , 'maximizeTerminal' )
236+ this . call ( 'terminal' , 'log' , { type : 'aitypewriterwarning' , value : `\n\nWaiting for RemixAI answer...` } )
237+ _paq . push ( [ 'trackEvent' , 'ai' , 'solcoder' , 'explaining' ] )
238+
239+ let result
240+ try {
241+ result = await (
242+ await fetch ( this . api_url , {
243+ method : 'POST' ,
244+ headers : {
245+ Accept : 'application/json' ,
246+ 'Content-Type' : 'application/json' ,
247+ } ,
248+ body : JSON . stringify ( { "data" :[ prompt , "error_explaining" , false , 2000 , 0.9 , 0.8 , 50 ] } ) ,
249+ } )
250+ ) . json ( )
251+ if ( result ) {
252+ this . call ( 'terminal' , 'log' , { type : 'aitypewriterwarning' , value : result . data [ 0 ] } )
253+ }
254+ return result . data [ 0 ]
255+ } catch ( e ) {
256+ this . call ( 'terminal' , 'log' , { type : 'typewritererror' , value : `Unable to get a response ${ e . message } ` } )
257+ return
258+ } finally {
259+ this . emit ( "aiInferingDone" )
260+ }
261+ }
262+
221263 _build_solgpt_promt ( user_promt :string ) {
222264 if ( this . solgpt_chat_history . length === 0 ) {
223265 return user_promt
0 commit comments