mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🕒 feat: Add 5-second timeout for Fetching Model Lists (#4423)
* refactor: add 5 second timeout for fetching AI provider model lists * ci: fix test due to recent changes
This commit is contained in:
parent
ef118009f6
commit
c54a57019e
5 changed files with 16 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
|||
const axios = require('axios');
|
||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
const { EModelEndpoint, defaultModels, CacheKeys } = require('librechat-data-provider');
|
||||
const { extractBaseURL, inputSchema, processModelData, logAxiosError } = require('~/utils');
|
||||
const { inputSchema, logAxiosError, extractBaseURL, processModelData } = require('~/utils');
|
||||
const { OllamaClient } = require('~/app/clients/OllamaClient');
|
||||
const getLogStores = require('~/cache/getLogStores');
|
||||
|
||||
|
|
@ -66,6 +66,7 @@ const fetchModels = async ({
|
|||
headers: {
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
},
|
||||
timeout: 5000,
|
||||
};
|
||||
|
||||
if (process.env.PROXY) {
|
||||
|
|
@ -149,6 +150,7 @@ const fetchOpenAIModels = async (opts, _models = []) => {
|
|||
baseURL,
|
||||
azure: opts.azure,
|
||||
user: opts.user,
|
||||
name: baseURL,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +177,8 @@ const fetchOpenAIModels = async (opts, _models = []) => {
|
|||
* @param {object} opts - The options for fetching the models.
|
||||
* @param {string} opts.user - The user ID to send to the API.
|
||||
* @param {boolean} [opts.azure=false] - Whether to fetch models from Azure.
|
||||
* @param {boolean} [opts.plugins=false] - Whether to fetch models from the plugins.
|
||||
* @param {boolean} [opts.plugins=false] - Whether to fetch models for the plugins endpoint.
|
||||
* @param {boolean} [opts.assistants=false] - Whether to fetch models for the Assistants endpoint.
|
||||
*/
|
||||
const getOpenAIModels = async (opts) => {
|
||||
let models = defaultModels[EModelEndpoint.openAI];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue