mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🐛 fix: Prevent Empty File Uploads & Assistants Fixes (#2611)
* chore: update default models for openai/assistants * fix: allows assistants models fetching * change default models order, ensure assistant_id is defined if intended * fix: prevent empty files from being uploaded
This commit is contained in:
parent
a0288f1c5c
commit
c8baceac76
6 changed files with 24 additions and 7 deletions
|
|
@ -514,6 +514,10 @@ function filterFile({ req, file, image }) {
|
|||
throw new Error('No file_id provided');
|
||||
}
|
||||
|
||||
if (file.size === 0) {
|
||||
throw new Error('Empty file uploaded');
|
||||
}
|
||||
|
||||
/* parse to validate api call, throws error on fail */
|
||||
isUUID.parse(file_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ const fetchModels = async ({
|
|||
* @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.assistants=false] - Whether to fetch models from Azure.
|
||||
* @param {boolean} [opts.plugins=false] - Whether to fetch models from the plugins.
|
||||
* @param {string[]} [_models=[]] - The models to use as a fallback.
|
||||
*/
|
||||
|
|
@ -150,7 +151,10 @@ const fetchOpenAIModels = async (opts, _models = []) => {
|
|||
const openaiBaseURL = 'https://api.openai.com/v1';
|
||||
let baseURL = openaiBaseURL;
|
||||
let reverseProxyUrl = process.env.OPENAI_REVERSE_PROXY;
|
||||
if (opts.azure) {
|
||||
|
||||
if (opts.assistants && process.env.ASSISTANTS_BASE_URL) {
|
||||
reverseProxyUrl = process.env.ASSISTANTS_BASE_URL;
|
||||
} else if (opts.azure) {
|
||||
return models;
|
||||
// const azure = getAzureCredentials();
|
||||
// baseURL = (genAzureChatCompletion(azure))
|
||||
|
|
@ -245,10 +249,6 @@ const getOpenAIModels = async (opts) => {
|
|||
return models;
|
||||
}
|
||||
|
||||
if (opts.assistants) {
|
||||
return models;
|
||||
}
|
||||
|
||||
return await fetchOpenAIModels(opts, models);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue