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

Conversation

@timothycarambat
Copy link
Member

@timothycarambat timothycarambat commented Jan 4, 2024

resolves #491

@timothycarambat timothycarambat merged commit 75dd869 into master Jan 4, 2024
@timothycarambat timothycarambat deleted the 492-azure-open-ai-streaming branch January 4, 2024 00:25
@review-agent-prime
Copy link

server/utils/AiProviders/azureOpenAi/index.js

It's a good practice to log the error messages for debugging purposes. In the catch block of the try-catch statement, you are currently just logging the error object. It would be more informative to log a custom error message along with the error stack trace. This will make it easier to identify and debug any issues that may arise.
Create Issue
See the diff
Checkout the fix

    .catch((error) => {
        console.error(`AzureOpenAI::getChatCompletions failed with: ${error.message}`, error.stack);
        throw new Error(`AzureOpenAI::getChatCompletions failed with: ${error.message}`);
      });
git fetch origin && git checkout -b ReviewBot/Impro-d2af7x9 origin/ReviewBot/Impro-d2af7x9

The error message "No OPEN_MODEL_PREF ENV defined. This must the name of a deployment on your Azure account for an LLM chat model like GPT-3.5." is repeated multiple times in the code. It would be better to define it as a constant at the top of the file and use the constant instead. This will make the code cleaner and easier to maintain.
Create Issue
See the diff
Checkout the fix

    const MODEL_ERROR_MESSAGE = "No OPEN_MODEL_PREF ENV defined. This must the name of a deployment on your Azure account for an LLM chat model like GPT-3.5.";

    // Then replace the repeated error messages with MODEL_ERROR_MESSAGE
    throw new Error(MODEL_ERROR_MESSAGE);
git fetch origin && git checkout -b ReviewBot/Impro-ow3h4tx origin/ReviewBot/Impro-ow3h4tx

server/utils/chats/stream.js

In the handleStreamResponses function, the line.split("\n") operation is performed for each line of data, which can be computationally expensive for large data sets. It would be more efficient to perform this operation once, store the result in a variable, and then use that variable in the for loop.
Create Issue
See the diff
Checkout the fix

    const splitLines = data?.toString()?.split("\n").filter((line) => line.trim() !== "");
    for (const line of splitLines) {
      // rest of the code...
    }
git fetch origin && git checkout -b ReviewBot/Impro-j2l5acl origin/ReviewBot/Impro-j2l5acl

cabwds pushed a commit to cabwds/anything-llm that referenced this pull request Jul 3, 2025
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.

[FEAT] Azure OpenAI answer streaming

2 participants