mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00
39 lines
1 KiB
JavaScript
39 lines
1 KiB
JavaScript
const mongoose = require('mongoose');
|
|
const mongoMeili = require('../plugins/mongoMeili');
|
|
const conversationPreset = require('./conversationPreset');
|
|
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,
|
|
default: null
|
|
},
|
|
messages: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Message' }],
|
|
...conversationPreset
|
|
},
|
|
{ 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'
|
|
});
|
|
}
|
|
|
|
const Conversation = mongoose.models.Conversation || mongoose.model('Conversation', convoSchema);
|
|
|
|
module.exports = Conversation;
|