diff --git a/core/commands/slash/http.ts b/core/commands/slash/http.ts index 2f5e2a7afb..7a662561c5 100644 --- a/core/commands/slash/http.ts +++ b/core/commands/slash/http.ts @@ -1,5 +1,6 @@ import { SlashCommand } from "../../index.js"; import { removeQuotesAndEscapes } from "../../util/index.js"; +import { streamResponse } from "../../llm/stream.js"; const HttpSlashCommand: SlashCommand = { name: "http", @@ -23,14 +24,8 @@ const HttpSlashCommand: SlashCommand = { if (response.body === null) { throw new Error("Response body is null"); } - const reader = response.body.getReader(); - while (true) { - const { done, value } = await reader.read(); - if (done) { - break; - } - const decoded = new TextDecoder("utf-8").decode(value); - yield decoded; + for await (const chunk of streamResponse(response)) { + yield chunk; } }, };