2023-12-16 20:45:27 -05:00
|
|
|
const { EModelEndpoint } = require('librechat-data-provider');
|
2023-12-15 02:18:07 -05:00
|
|
|
const { useAzurePlugins } = require('~/server/services/Config/EndpointService').config;
|
2023-12-06 19:36:57 -05:00
|
|
|
const {
|
|
|
|
getOpenAIModels,
|
2023-12-16 20:45:27 -05:00
|
|
|
getGoogleModels,
|
2023-12-06 19:36:57 -05:00
|
|
|
getAnthropicModels,
|
2023-12-16 20:45:27 -05:00
|
|
|
getChatGPTBrowserModels,
|
2023-12-06 19:36:57 -05:00
|
|
|
} = require('~/server/services/ModelService');
|
|
|
|
|
|
|
|
const fitlerAssistantModels = (str) => {
|
|
|
|
return /gpt-4|gpt-3\\.5/i.test(str) && !/vision|instruct/i.test(str);
|
|
|
|
};
|
|
|
|
|
2024-02-08 10:06:58 -05:00
|
|
|
/**
|
|
|
|
* Loads the default models for the application.
|
|
|
|
* @async
|
|
|
|
* @function
|
|
|
|
* @param {Express.Request} req - The Express request object.
|
|
|
|
*/
|
|
|
|
async function loadDefaultModels(req) {
|
2023-12-16 20:45:27 -05:00
|
|
|
const google = getGoogleModels();
|
2024-02-08 10:06:58 -05:00
|
|
|
const openAI = await getOpenAIModels({ user: req.user.id });
|
2023-12-06 19:36:57 -05:00
|
|
|
const anthropic = getAnthropicModels();
|
|
|
|
const chatGPTBrowser = getChatGPTBrowserModels();
|
2024-02-08 10:06:58 -05:00
|
|
|
const azureOpenAI = await getOpenAIModels({ user: req.user.id, azure: true });
|
|
|
|
const gptPlugins = await getOpenAIModels({
|
|
|
|
user: req.user.id,
|
|
|
|
azure: useAzurePlugins,
|
|
|
|
plugins: true,
|
|
|
|
});
|
2023-12-06 19:36:57 -05:00
|
|
|
|
|
|
|
return {
|
|
|
|
[EModelEndpoint.openAI]: openAI,
|
2023-12-16 20:45:27 -05:00
|
|
|
[EModelEndpoint.google]: google,
|
|
|
|
[EModelEndpoint.anthropic]: anthropic,
|
|
|
|
[EModelEndpoint.gptPlugins]: gptPlugins,
|
2023-12-06 19:36:57 -05:00
|
|
|
[EModelEndpoint.azureOpenAI]: azureOpenAI,
|
|
|
|
[EModelEndpoint.bingAI]: ['BingAI', 'Sydney'],
|
|
|
|
[EModelEndpoint.chatGPTBrowser]: chatGPTBrowser,
|
2023-12-16 20:45:27 -05:00
|
|
|
[EModelEndpoint.assistant]: openAI.filter(fitlerAssistantModels),
|
2023-12-06 19:36:57 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = loadDefaultModels;
|