@@ -21,35 +21,34 @@ class OutputParser {
21
21
this . callback = callback ;
22
22
}
23
23
updateOutput = ( line : any ) => {
24
- let output = [ ...this . output ] ;
25
24
if ( line . method === 'functions' ) {
26
25
const functions = line . params ;
27
26
for ( const func of functions ) {
28
27
const functionId = func . id ;
29
- const existingFunction = output . find ( o =>
28
+ const existingFunction = this . output . find ( o =>
30
29
o . method === 'functions'
31
30
&&
32
31
o . params . find ( ( p : { id : string } ) => p . id === functionId )
33
32
) ;
34
33
if ( existingFunction ) {
35
34
const existingFunctionParamsIndex = existingFunction . params . findIndex ( ( p : { id : string } ) => p . id === functionId ) ;
36
35
existingFunction . params [ existingFunctionParamsIndex ] = { ...existingFunction . params [ existingFunctionParamsIndex ] , ...func } ;
37
- output = output . map (
36
+ this . output = this . output . map (
38
37
o => o . method === 'functions'
39
38
?
40
39
{ ...o , params : o . params . map ( ( p : { id : string } ) => p . id === functionId ? { ...p , ...func } : p ) }
41
40
:
42
41
o
43
42
) ;
44
43
} else {
45
- output = [ ...output , line ] ;
44
+ this . output = [ ... this . output , line ] ;
46
45
}
47
46
}
48
47
}
49
48
else {
50
- output = [ ...output , line ] ;
49
+ this . output = [ ... this . output , line ] ;
51
50
}
52
- this . callback ( output ) ;
51
+ this . callback ( this . output ) ;
53
52
}
54
53
}
55
54
@@ -76,12 +75,14 @@ export function App() {
76
75
77
76
const [ runOut , setRunOut ] = React . useState < any [ ] > ( [ ] ) ;
78
77
78
+ const runOutput = new OutputParser ( setRunOut ) ;
79
+
79
80
const scrollRef = React . useRef < HTMLDivElement > ( null ) ;
80
81
81
82
const [ showDebug , setShowDebug ] = React . useState ( false ) ;
82
83
83
84
useEffect ( ( ) => {
84
- const runOutput = new OutputParser ( setRunOut ) ;
85
+
85
86
try {
86
87
client . docker . cli . exec ( "pull" , [ "vonwig/function_write_files" ] ) . then ( ( ) => {
87
88
client . docker . cli . exec ( "run" , [
@@ -167,8 +168,6 @@ export function App() {
167
168
168
169
const startPrompt = async ( ) => {
169
170
track ( 'start-prompt' ) ;
170
-
171
- const runOutput = new OutputParser ( setRunOut ) ;
172
171
runOutput . updateOutput ( { method : 'message' , params : { debug : 'Pulling images' } } )
173
172
174
173
runOutput . updateOutput ( { method : 'message' , params : { debug : 'Running prompts...' } } )
0 commit comments