这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@timothycarambat
Copy link
Member

resolves #416

@review-agent-prime
Copy link

server/utils/chats/stream.js

Instead of just logging the error message when an exception occurs during chunk appending, it would be more informative to log the entire error object. This will provide more context about the error, such as the stack trace, which can be useful for debugging.
Create Issue
See the diff
Checkout the fix

    try {
      chunk += message;
    } catch (e) {
      console.log(`Chunk appending error`, e);
      chunk = "";
    }
git fetch origin && git checkout -b ReviewBot/Impro-r5py94p origin/ReviewBot/Impro-r5py94p

String concatenation in JavaScript can be expensive in terms of performance, especially in a loop. It would be more efficient to use an array to store the chunks and then join them together when needed.
Create Issue
See the diff
Checkout the fix

    let chunks = [];
    for await (const chunk of stream) {
      chunks.push(chunk.content);
      writeResponseChunk(response, {
        uuid,
        sources: [],
        type: "textResponseChunk",
        textResponse: chunk.content,
        close: false,
        error: false,
      });
    }
    let fullText = chunks.join("");
git fetch origin && git checkout -b ReviewBot/Impro-biw8829 origin/ReviewBot/Impro-biw8829

@timothycarambat timothycarambat merged commit 37cdb84 into master Dec 13, 2023
@timothycarambat timothycarambat deleted the 416-chunk-overflow-patch branch December 13, 2023 00:20
cabwds pushed a commit to cabwds/anything-llm that referenced this pull request Jul 3, 2025
…lows (Mintplex-Labs#433)

* patch: implement @LunaMidori hotfix for LocalAI streaming chunk overflows
resolves Mintplex-Labs#416

* change log to error log

* log trace

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LocalAI streaming text overflow

2 participants