@@ -42,12 +42,12 @@ function App() {
4242 Array . from ( [
4343 {
4444 text : "Hello! I'm a GPT Code assistant. Ask me to do something for you! Pro tip: you can upload a file and I'll be able to use it." ,
45- role : "system " ,
45+ role : "generator " ,
4646 type : "message" ,
4747 } ,
4848 {
4949 text : "If I get stuck just type 'reset' and I'll restart the kernel." ,
50- role : "system " ,
50+ role : "generator " ,
5151 type : "message" ,
5252 } ,
5353 ] )
@@ -77,11 +77,7 @@ function App() {
7777
7878 const handleCommand = ( command : string ) => {
7979 if ( command == "reset" ) {
80- addMessage ( {
81- text : "Restarting the kernel." ,
82- type : "message" ,
83- role : "system" ,
84- } ) ;
80+ addMessage ( { text : "Restarting the kernel." , type : "message" , role : "system" } ) ;
8581
8682 fetch ( `${ Config . API_ADDRESS } /restart` , {
8783 method : "POST" ,
@@ -121,20 +117,22 @@ function App() {
121117 } ) ,
122118 } ) ;
123119
124-
125-
126120 const data = await response . json ( ) ;
127121 const code = data . code ;
128122
129- addMessage ( { text : data . text , type : "message" , role : "system " } ) ;
123+ addMessage ( { text : data . text , type : "message" , role : "generator " } ) ;
130124
131125 if ( response . status != 200 ) {
132126 setWaitingForSystem ( WaitingStates . Idle ) ;
133127 return ;
134128 }
135129
136- submitCode ( code ) ;
137- setWaitingForSystem ( WaitingStates . RunningCode ) ;
130+ if ( ! ! code ) {
131+ submitCode ( code ) ;
132+ setWaitingForSystem ( WaitingStates . RunningCode ) ;
133+ } else {
134+ setWaitingForSystem ( WaitingStates . Idle ) ;
135+ }
138136 } catch ( error ) {
139137 console . error (
140138 "There has been a problem with your fetch operation:" ,
@@ -161,12 +159,7 @@ function App() {
161159 }
162160
163161 function completeUpload ( message : string ) {
164- addMessage ( {
165- text : message ,
166- type : "message" ,
167- role : "system" ,
168- } ) ;
169-
162+ addMessage ( { text : message , type : "message" , role : "upload" } ) ;
170163 setWaitingForSystem ( WaitingStates . Idle ) ;
171164
172165 // Inform prompt server
0 commit comments