From 650178e117bcad2e19fc93088b77ec4145011b84 Mon Sep 17 00:00:00 2001 From: Enrique Pedroza Date: Wed, 6 Nov 2024 10:02:50 +0000 Subject: [PATCH] Feature: now models are sorted correctly --- api/server/controllers/ModelController.js | 10 ++++++++-- api/utils/intelequia/clientConfigurationRequests.js | 12 ++++++++++++ api/utils/intelequia/index.js | 5 +++-- 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 api/utils/intelequia/clientConfigurationRequests.js diff --git a/api/server/controllers/ModelController.js b/api/server/controllers/ModelController.js index 79dc81d6b02..a0f78d9b518 100644 --- a/api/server/controllers/ModelController.js +++ b/api/server/controllers/ModelController.js @@ -1,7 +1,7 @@ const { CacheKeys } = require('librechat-data-provider'); const { loadDefaultModels, loadConfigModels } = require('~/server/services/Config'); const { getLogStores } = require('~/cache'); - +const { parseModels} = require('~/utils') /** * @param {ServerRequest} req */ @@ -36,7 +36,13 @@ async function loadModels(req) { } async function modelController(req, res) { - const modelConfig = await loadModels(req); + var modelConfig = await loadModels(req); + /** + * Sort Model list + * @Author Enrique M Pedroza Castillo + * @Organization Intelequia + */ + modelConfig = await parseModels (modelConfig) res.send(modelConfig); } diff --git a/api/utils/intelequia/clientConfigurationRequests.js b/api/utils/intelequia/clientConfigurationRequests.js new file mode 100644 index 00000000000..4ba80f58350 --- /dev/null +++ b/api/utils/intelequia/clientConfigurationRequests.js @@ -0,0 +1,12 @@ +async function parseModels (models){ + const {azureAssistants, azureOpenAI} = models + const assistantModelIndex = azureOpenAI.indexOf(azureAssistants[0]) + const [model] = azureOpenAI.splice(assistantModelIndex,1) + azureOpenAI.unshift(model) + models.azureOpenAI = azureOpenAI; + return models +} + +module.exports = { + parseModels +}; \ No newline at end of file diff --git a/api/utils/intelequia/index.js b/api/utils/intelequia/index.js index 909487aeb30..3c3c0bdc6bc 100644 --- a/api/utils/intelequia/index.js +++ b/api/utils/intelequia/index.js @@ -5,7 +5,7 @@ const toolsConfigurations = require('./toolsConfigurations'); const pluginsAndTools = require('./pluginsAndTools'); const constants = require('./constants'); const dynamics = require('./dynamicsToken'); - +const clientConfigurationRequests = require('./clientConfigurationRequests') module.exports = { intelequiaCountTokens, ...dynamics, @@ -13,5 +13,6 @@ module.exports = { ...assistantPermission, ...toolsConfigurations, ...pluginsAndTools, - ...constants + ...constants, + ...clientConfigurationRequests } \ No newline at end of file