@@ -42,12 +42,12 @@ function App() {
42
42
Array . from ( [
43
43
{
44
44
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 " ,
46
46
type : "message" ,
47
47
} ,
48
48
{
49
49
text : "If I get stuck just type 'reset' and I'll restart the kernel." ,
50
- role : "system " ,
50
+ role : "generator " ,
51
51
type : "message" ,
52
52
} ,
53
53
] )
@@ -77,11 +77,7 @@ function App() {
77
77
78
78
const handleCommand = ( command : string ) => {
79
79
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" } ) ;
85
81
86
82
fetch ( `${ Config . API_ADDRESS } /restart` , {
87
83
method : "POST" ,
@@ -121,20 +117,22 @@ function App() {
121
117
} ) ,
122
118
} ) ;
123
119
124
-
125
-
126
120
const data = await response . json ( ) ;
127
121
const code = data . code ;
128
122
129
- addMessage ( { text : data . text , type : "message" , role : "system " } ) ;
123
+ addMessage ( { text : data . text , type : "message" , role : "generator " } ) ;
130
124
131
125
if ( response . status != 200 ) {
132
126
setWaitingForSystem ( WaitingStates . Idle ) ;
133
127
return ;
134
128
}
135
129
136
- submitCode ( code ) ;
137
- setWaitingForSystem ( WaitingStates . RunningCode ) ;
130
+ if ( ! ! code ) {
131
+ submitCode ( code ) ;
132
+ setWaitingForSystem ( WaitingStates . RunningCode ) ;
133
+ } else {
134
+ setWaitingForSystem ( WaitingStates . Idle ) ;
135
+ }
138
136
} catch ( error ) {
139
137
console . error (
140
138
"There has been a problem with your fetch operation:" ,
@@ -161,12 +159,7 @@ function App() {
161
159
}
162
160
163
161
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" } ) ;
170
163
setWaitingForSystem ( WaitingStates . Idle ) ;
171
164
172
165
// Inform prompt server
0 commit comments