mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
* refactor: scrollToEnd * fix(validateConvoAccess): search conversation by ID for proper validation * feat: Add unique index for conversationId and user in convoSchema * refactor: Update font sizes 1 rem -> font-size-base in style.css * fix: Assistants map type issues * refactor: Remove obsolete scripts * fix: Update DropdownNoState component to handle both string and OptionType values * refactor: Remove config/loader.js file * fix: remove crypto.randomBytes(); refactor: Create reusable function for generating token and hash
68 lines
1.7 KiB
JavaScript
68 lines
1.7 KiB
JavaScript
const mongoose = require('mongoose');
|
|
const mongoMeili = require('../plugins/mongoMeili');
|
|
const { conversationPreset } = require('./defaults');
|
|
const convoSchema = mongoose.Schema(
|
|
{
|
|
conversationId: {
|
|
type: String,
|
|
unique: true,
|
|
required: true,
|
|
index: true,
|
|
meiliIndex: true,
|
|
},
|
|
title: {
|
|
type: String,
|
|
default: 'New Chat',
|
|
meiliIndex: true,
|
|
},
|
|
user: {
|
|
type: String,
|
|
index: true,
|
|
},
|
|
messages: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Message' }],
|
|
// google only
|
|
examples: { type: [{ type: mongoose.Schema.Types.Mixed }], default: undefined },
|
|
agentOptions: {
|
|
type: mongoose.Schema.Types.Mixed,
|
|
},
|
|
...conversationPreset,
|
|
// for bingAI only
|
|
bingConversationId: {
|
|
type: String,
|
|
},
|
|
jailbreakConversationId: {
|
|
type: String,
|
|
},
|
|
conversationSignature: {
|
|
type: String,
|
|
},
|
|
clientId: {
|
|
type: String,
|
|
},
|
|
invocationId: {
|
|
type: Number,
|
|
},
|
|
tags: {
|
|
type: [String],
|
|
default: [],
|
|
meiliIndex: true,
|
|
},
|
|
},
|
|
{ timestamps: true },
|
|
);
|
|
|
|
if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
|
convoSchema.plugin(mongoMeili, {
|
|
host: process.env.MEILI_HOST,
|
|
apiKey: process.env.MEILI_MASTER_KEY,
|
|
indexName: 'convos', // Will get created automatically if it doesn't exist already
|
|
primaryKey: 'conversationId',
|
|
});
|
|
}
|
|
|
|
convoSchema.index({ createdAt: 1, updatedAt: 1 });
|
|
convoSchema.index({ conversationId: 1, user: 1 }, { unique: true });
|
|
|
|
const Conversation = mongoose.models.Conversation || mongoose.model('Conversation', convoSchema);
|
|
|
|
module.exports = Conversation;
|