persist token window for NIM and not only on model change

This commit is contained in:
timothycarambat 2024-12-05 11:57:07 -08:00
parent b2dd35fe15
commit 4b09a06590
2 changed files with 5 additions and 2 deletions
server/utils
AiProviders/nvidiaNim
helpers

View file

@ -45,7 +45,7 @@ class NvidiaNimLLM {
} }
/** /**
* Set the model token limit `NVIDIA_NIM_LLM_TOKEN_LIMIT` for the given model ID * Set the model token limit `NVIDIA_NIM_LLM_MODEL_TOKEN_LIMIT` for the given model ID
* @param {string} modelId * @param {string} modelId
* @param {string} basePath * @param {string} basePath
* @returns {Promise<void>} * @returns {Promise<void>}
@ -69,7 +69,7 @@ class NvidiaNimLLM {
if (!model.length) return; if (!model.length) return;
const modelInfo = model.find((model) => model.id === modelId); const modelInfo = model.find((model) => model.id === modelId);
if (!modelInfo) return; if (!modelInfo) return;
process.env.NVIDIA_NIM_LLM_TOKEN_LIMIT = Number( process.env.NVIDIA_NIM_LLM_MODEL_TOKEN_LIMIT = Number(
modelInfo.max_model_len || 4096 modelInfo.max_model_len || 4096
); );
} }

View file

@ -965,6 +965,9 @@ function dumpENV() {
"SIMPLE_SSO_ENABLED", "SIMPLE_SSO_ENABLED",
// Community Hub // Community Hub
"COMMUNITY_HUB_BUNDLE_DOWNLOADS_ENABLED", "COMMUNITY_HUB_BUNDLE_DOWNLOADS_ENABLED",
// Nvidia NIM Keys that are automatically managed
"NVIDIA_NIM_LLM_MODEL_TOKEN_LIMIT",
]; ];
// Simple sanitization of each value to prevent ENV injection via newline or quote escaping. // Simple sanitization of each value to prevent ENV injection via newline or quote escaping.