mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
* refactor: re-purpose `resendImages` as `resendFiles` * refactor: re-purpose `resendImages` as `resendFiles` * feat: upload general files * feat: embed file during upload * feat: delete file embeddings on file deletion * chore(fileConfig): add epub+zip type * feat(encodeAndFormat): handle non-image files * feat(createContextHandlers): build context prompt from file attachments and successful RAG * fix: prevent non-temp files as well as embedded files to be deleted on new conversation * fix: remove temp_file_id on usage, prevent non-temp files as well as embedded files to be deleted on new conversation * fix: prevent non-temp files as well as embedded files to be deleted on new conversation * feat(OpenAI/Anthropic/Google): basic RAG support * fix: delete `resendFiles` only when true (Default) * refactor(RAG): update endpoints and pass JWT * fix(resendFiles): default values * fix(context/processFile): query unique ids only * feat: rag-api.yaml * feat: file upload improved ux for longer uploads * chore: await embed call and catch embedding errors * refactor: store augmentedPrompt in Client * refactor(processFileUpload): throw error if not assistant file upload * fix(useFileHandling): handle markdown empty mimetype issue * chore: necessary compose file changes
97 lines
2.4 KiB
JavaScript
97 lines
2.4 KiB
JavaScript
const { FileSources } = require('librechat-data-provider');
|
|
const mongoose = require('mongoose');
|
|
|
|
/**
|
|
* @typedef {Object} MongoFile
|
|
* @property {mongoose.Schema.Types.ObjectId} [_id] - MongoDB Document ID
|
|
* @property {number} [__v] - MongoDB Version Key
|
|
* @property {mongoose.Schema.Types.ObjectId} user - User ID
|
|
* @property {string} [conversationId] - Optional conversation ID
|
|
* @property {string} file_id - File identifier
|
|
* @property {string} [temp_file_id] - Temporary File identifier
|
|
* @property {number} bytes - Size of the file in bytes
|
|
* @property {string} filename - Name of the file
|
|
* @property {string} filepath - Location of the file
|
|
* @property {'file'} object - Type of object, always 'file'
|
|
* @property {string} type - Type of file
|
|
* @property {number} usage - Number of uses of the file
|
|
* @property {boolean} [embedded] - Whether or not the file is embedded in vector db
|
|
* @property {string} [source] - The source of the file
|
|
* @property {number} [width] - Optional width of the file
|
|
* @property {number} [height] - Optional height of the file
|
|
* @property {Date} [expiresAt] - Optional height of the file
|
|
* @property {Date} [createdAt] - Date when the file was created
|
|
* @property {Date} [updatedAt] - Date when the file was updated
|
|
*/
|
|
const fileSchema = mongoose.Schema(
|
|
{
|
|
user: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'User',
|
|
index: true,
|
|
required: true,
|
|
},
|
|
conversationId: {
|
|
type: String,
|
|
ref: 'Conversation',
|
|
index: true,
|
|
},
|
|
file_id: {
|
|
type: String,
|
|
// required: true,
|
|
index: true,
|
|
},
|
|
temp_file_id: {
|
|
type: String,
|
|
// required: true,
|
|
},
|
|
bytes: {
|
|
type: Number,
|
|
required: true,
|
|
},
|
|
filename: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
filepath: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
object: {
|
|
type: String,
|
|
required: true,
|
|
default: 'file',
|
|
},
|
|
embedded: {
|
|
type: Boolean,
|
|
},
|
|
type: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
context: {
|
|
type: String,
|
|
// required: true,
|
|
},
|
|
usage: {
|
|
type: Number,
|
|
required: true,
|
|
default: 0,
|
|
},
|
|
source: {
|
|
type: String,
|
|
default: FileSources.local,
|
|
},
|
|
width: Number,
|
|
height: Number,
|
|
expiresAt: {
|
|
type: Date,
|
|
expires: 3600,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
},
|
|
);
|
|
|
|
module.exports = fileSchema;
|