From bb5c8252bb805a0a20058766fd4cd89f9e1d41af Mon Sep 17 00:00:00 2001 From: Riceball LEE Date: Wed, 12 Jun 2024 21:40:43 +0800 Subject: [PATCH] fix: do not use logUpdate if noConsoleClear --- src/lib/run-script.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/run-script.ts b/src/lib/run-script.ts index ddf0900..4d83c10 100644 --- a/src/lib/run-script.ts +++ b/src/lib/run-script.ts @@ -124,8 +124,7 @@ export async function runScript(filename: string, options: IRunScriptOptions) { if (stream) { runtime.on('llm-stream', async function(llmResult, content: string, count: number) { const runtime = this.target as AIScriptEx - const s = llmResult.content - llmLastContent += s + let s = llmResult.content if (quit) { runtime.abort('quit') @@ -133,12 +132,19 @@ export async function runScript(filename: string, options: IRunScriptOptions) { } if (count !== retryCount) { retryCount = count - llmLastContent += colors.blue(`<续:${count}>`) + s += colors.blue(`<续:${count}>`) } + llmLastContent += s // if (llmLastContent.length > 100) { // llmLastContent = llmLastContent.slice(llmLastContent.length-100) // } - if (!isSilence && llmLastContent) {logUpdate(llmLastContent)} + if (!isSilence && llmLastContent) { + if (!options.noConsoleClear) { + logUpdate(llmLastContent) + } else { + process.stdout.write(s) + } + } }) }