🔁 refactor: Token Event Handler and Standardize maxTokens Key (#6886)

* refactor: agent token handling to use createHandleLLMNewToken for improved closure

* refactor: update llmConfig to use maxTokens instead of max_tokens for consistency
This commit is contained in:
Danny Avila 2025-04-14 22:38:35 -04:00 committed by GitHub
parent 52b3ed54ca
commit c49f883e1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 24 additions and 19 deletions

View file

@ -6,16 +6,11 @@ const {
} = require('librechat-data-provider');
const { getUserKeyValues, checkUserKeyExpiry } = require('~/server/services/UserService');
const { getLLMConfig } = require('~/server/services/Endpoints/openAI/llm');
const { isEnabled, isUserProvided, sleep } = require('~/server/utils');
const { createHandleLLMNewToken } = require('~/app/clients/generators');
const { isEnabled, isUserProvided } = require('~/server/utils');
const OpenAIClient = require('~/app/clients/OpenAIClient');
const { getAzureCredentials } = require('~/utils');
function createHandleNewToken(streamRate) {
async () => {
await sleep(streamRate);
};
}
const initializeClient = async ({
req,
res,
@ -152,7 +147,7 @@ const initializeClient = async ({
}
options.llmConfig.callbacks = [
{
handleLLMNewToken: createHandleNewToken(streamRate),
handleLLMNewToken: createHandleLLMNewToken(streamRate),
},
];
return options;