@ -1,4 +1,12 @@
const $ = ( selector ) => document . querySelector ( selector ) ;
const $ = ( selector ) => document . querySelector ( selector ) ;
const escapeHtml = ( unsafe ) => {
return unsafe
. replace ( /&/g , "&" )
. replace ( /</g , "<" )
. replace ( />/g , ">" )
. replace ( /"/g , """ )
. replace ( /'/g , "'" ) ;
} ;
const setLoader = ( isLoading ) => {
const setLoader = ( isLoading ) => {
const button = $ ( "#submit" ) ;
const button = $ ( "#submit" ) ;
@ -144,10 +152,10 @@ const submit = async () => {
w . innerHTML = createActionCard (
w . innerHTML = createActionCard (
info . index ,
info . index ,
info . action ,
info . action ,
info. action _input ,
escapeHtml( info. action _input || "" ) ,
info . what _i _did ,
info . what _i _did ,
info . plan ,
info . plan ,
info. observation
escapeHtml( info. observation || "" )
) ;
) ;
actions . appendChild ( w ) ;
actions . appendChild ( w ) ;
} ;
} ;
@ -210,7 +218,7 @@ const createActionCard = (
action !== "Final Answer"
action !== "Final Answer"
? ` <tr>
? ` <tr>
< th style = "width: 100px" > Input < / t h >
< th style = "width: 100px" > Input < / t h >
< td > < div > $ { input } < / d i v > < / t d >
< td > < div style = "white-space: pre-wrap" > $ { input } < / d i v > < / t d >
< / t r > `
< / t r > `
: ""
: ""
}
}
@ -264,7 +272,7 @@ const createActionCard = (
< tbody >
< tbody >
< tr >
< tr >
< td >
< td >
< div > $ { observation } < / d i v >
< div style = "white-space: pre-wrap" > $ { observation } < / d i v >
< / t d >
< / t d >
< / t r >
< / t r >
< / t b o d y >
< / t b o d y >