Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async function streamExecFileWithEvents() {
// Wait for the initial run to complete.
await run.text();

while (run.RunState === gptscript.RunState.Continue) {
while (run.state === gptscript.RunState.Continue) {
// ...Get the next input from the user somehow...

run = run.nextChat(inputFromUser)
Expand Down
11 changes: 6 additions & 5 deletions src/gptscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class Client {
* @return {Run} The Run object representing the running tool.
*/
run(toolName: string, opts: RunOpts = {}): Run {
return (new Run("run-file-stream-with-events", toolName, "", opts)).nextChat(opts.input)
return (new Run("run-file-stream-with-events", toolName, "", opts, this.gptscriptBin, this.gptscriptURL)).nextChat(opts.input)
}

/**
Expand All @@ -101,7 +101,7 @@ export class Client {
toolString = toolDefToString(tool)
}

return (new Run("run-tool-stream-with-event", "", toolString, opts)).nextChat(opts.input)
return (new Run("run-tool-stream-with-event", "", toolString, opts, this.gptscriptBin, this.gptscriptURL)).nextChat(opts.input)
}

async parse(fileName: string): Promise<Block[]> {
Expand Down Expand Up @@ -196,7 +196,7 @@ export class Run {

let run = this
if (run.state !== RunState.Creating) {
run = new (this.constructor as any)(run.requestPath, run.filePath, run.content, run.opts)
run = new (this.constructor as any)(run.requestPath, run.filePath, run.content, run.opts, run.gptscriptURL)
}

run.chatState = this.chatState
Expand Down Expand Up @@ -379,9 +379,10 @@ export class Run {
if (typeof window !== "undefined" && typeof window.document !== "undefined") {
// @ts-ignore
const {SSE} = await import("sse.js")
this.sse = new SSE(this.gptscriptURL + "/" + this.filePath, {
this.sse = new SSE(this.gptscriptURL + "/" + this.requestPath, {
headers: {"Content-Type": "application/json"},
payload: postData
payload: tool ? postData : undefined,
method: tool ? "POST" : "GET"
} as any)

this.sse.addEventListener("open", () => {
Expand Down