@@ -80,7 +80,7 @@ export class Client {
8080 * @return {Run } The Run object representing the running tool.
8181 */
8282 run ( toolName : string , opts : RunOpts = { } ) : Run {
83- return ( new Run ( "run-file-stream-with-events" , toolName , "" , opts ) ) . nextChat ( opts . input )
83+ return ( new Run ( "run-file-stream-with-events" , toolName , "" , opts , this . gptscriptBin , this . gptscriptURL ) ) . nextChat ( opts . input )
8484 }
8585
8686 /**
@@ -101,7 +101,7 @@ export class Client {
101101 toolString = toolDefToString ( tool )
102102 }
103103
104- return ( new Run ( "run-tool-stream-with-event" , "" , toolString , opts ) ) . nextChat ( opts . input )
104+ return ( new Run ( "run-tool-stream-with-event" , "" , toolString , opts , this . gptscriptBin , this . gptscriptURL ) ) . nextChat ( opts . input )
105105 }
106106
107107 async parse ( fileName : string ) : Promise < Block [ ] > {
@@ -196,7 +196,7 @@ export class Run {
196196
197197 let run = this
198198 if ( run . state !== RunState . Creating ) {
199- run = new ( this . constructor as any ) ( run . requestPath , run . filePath , run . content , run . opts )
199+ run = new ( this . constructor as any ) ( run . requestPath , run . filePath , run . content , run . opts , run . gptscriptURL )
200200 }
201201
202202 run . chatState = this . chatState
@@ -379,9 +379,10 @@ export class Run {
379379 if ( typeof window !== "undefined" && typeof window . document !== "undefined" ) {
380380 // @ts -ignore
381381 const { SSE } = await import ( "sse.js" )
382- this . sse = new SSE ( this . gptscriptURL + "/" + this . filePath , {
382+ this . sse = new SSE ( this . gptscriptURL + "/" + this . requestPath , {
383383 headers : { "Content-Type" : "application/json" } ,
384- payload : postData
384+ payload : tool ? postData : undefined ,
385+ method : tool ? "POST" : "GET"
385386 } as any )
386387
387388 this . sse . addEventListener ( "open" , ( ) => {
0 commit comments