mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
feat: search, refactoring messages model
This commit is contained in:
parent
dcc13daf67
commit
854f1c3572
3 changed files with 44 additions and 16 deletions
|
|
@ -1,5 +1,7 @@
|
|||
const mongoose = require('mongoose');
|
||||
const mongomeili = require('mongomeili');
|
||||
// const mongomeili = require('mongomeili');
|
||||
const MeiliSearch = require('meilisearch');
|
||||
const _ = require('lodash');
|
||||
|
||||
const messageSchema = mongoose.Schema({
|
||||
messageId: {
|
||||
|
|
@ -9,7 +11,8 @@ const messageSchema = mongoose.Schema({
|
|||
},
|
||||
conversationId: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
meiliIndex: true
|
||||
},
|
||||
conversationSignature: {
|
||||
type: String,
|
||||
|
|
@ -27,7 +30,8 @@ const messageSchema = mongoose.Schema({
|
|||
},
|
||||
sender: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
meiliIndex: true
|
||||
},
|
||||
text: {
|
||||
type: String,
|
||||
|
|
@ -43,13 +47,19 @@ const messageSchema = mongoose.Schema({
|
|||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
_meiliIndex: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
select: false,
|
||||
default: false
|
||||
}
|
||||
}, { timestamps: true });
|
||||
|
||||
messageSchema.plugin(mongomeili, {
|
||||
host: 'http://localhost:7700',
|
||||
apiKey: 'MASTER_KEY',
|
||||
indexName: 'text' // Will get created automatically if it doesn't exist already
|
||||
});
|
||||
// messageSchema.plugin(mongomeili, {
|
||||
// host: 'http://localhost:7700',
|
||||
// apiKey: 'MASTER_KEY',
|
||||
// indexName: 'messages' // Will get created automatically if it doesn't exist already
|
||||
// });
|
||||
|
||||
const Message = mongoose.models.Message || mongoose.model('Message', messageSchema);
|
||||
|
||||
|
|
|
|||
33
api/package-lock.json
generated
33
api/package-lock.json
generated
|
|
@ -20,6 +20,7 @@
|
|||
"keyv": "^4.5.2",
|
||||
"keyv-file": "^0.2.0",
|
||||
"lodash": "^4.17.21",
|
||||
"meilisearch": "^0.31.1",
|
||||
"mongomeili": "^0.1.8",
|
||||
"mongoose": "^6.9.0",
|
||||
"openai": "^3.1.0",
|
||||
|
|
@ -3300,11 +3301,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/meilisearch": {
|
||||
"version": "0.14.2",
|
||||
"resolved": "https://registry.npmjs.org/meilisearch/-/meilisearch-0.14.2.tgz",
|
||||
"integrity": "sha512-0PbZxyuUPqaHRHSgIZIDzeMbf45JhE1ctmcRZnWp2NkUp8Ub4XiS+qhXSMYtXNzQq1cpBIed7EcCBgjbcSdGSg==",
|
||||
"version": "0.31.1",
|
||||
"resolved": "https://registry.npmjs.org/meilisearch/-/meilisearch-0.31.1.tgz",
|
||||
"integrity": "sha512-ajMieU0e25lLkT+05J0snX0Ycow1UofxIy5sag03flERUbjXq8ouVwkrJkW27JsKftIeDeffRRRr89LasU9+0w==",
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.0.5"
|
||||
"cross-fetch": "^3.1.5"
|
||||
}
|
||||
},
|
||||
"node_modules/memory-pager": {
|
||||
|
|
@ -3461,6 +3462,14 @@
|
|||
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.2.tgz",
|
||||
"integrity": "sha512-STHz9P7X2L4Kwn72fA4rGyqyXdmrMSdxqHx9IXon/FXluXieaFA6KJ2upcHAHxQPQ0LeM/OjLrhFxifHewOALQ=="
|
||||
},
|
||||
"node_modules/mongomeili/node_modules/meilisearch": {
|
||||
"version": "0.14.2",
|
||||
"resolved": "https://registry.npmjs.org/meilisearch/-/meilisearch-0.14.2.tgz",
|
||||
"integrity": "sha512-0PbZxyuUPqaHRHSgIZIDzeMbf45JhE1ctmcRZnWp2NkUp8Ub4XiS+qhXSMYtXNzQq1cpBIed7EcCBgjbcSdGSg==",
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/mongomeili/node_modules/mongodb": {
|
||||
"version": "3.7.3",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.7.3.tgz",
|
||||
|
|
@ -7663,11 +7672,11 @@
|
|||
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ=="
|
||||
},
|
||||
"meilisearch": {
|
||||
"version": "0.14.2",
|
||||
"resolved": "https://registry.npmjs.org/meilisearch/-/meilisearch-0.14.2.tgz",
|
||||
"integrity": "sha512-0PbZxyuUPqaHRHSgIZIDzeMbf45JhE1ctmcRZnWp2NkUp8Ub4XiS+qhXSMYtXNzQq1cpBIed7EcCBgjbcSdGSg==",
|
||||
"version": "0.31.1",
|
||||
"resolved": "https://registry.npmjs.org/meilisearch/-/meilisearch-0.31.1.tgz",
|
||||
"integrity": "sha512-ajMieU0e25lLkT+05J0snX0Ycow1UofxIy5sag03flERUbjXq8ouVwkrJkW27JsKftIeDeffRRRr89LasU9+0w==",
|
||||
"requires": {
|
||||
"cross-fetch": "^3.0.5"
|
||||
"cross-fetch": "^3.1.5"
|
||||
}
|
||||
},
|
||||
"memory-pager": {
|
||||
|
|
@ -7796,6 +7805,14 @@
|
|||
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.2.tgz",
|
||||
"integrity": "sha512-STHz9P7X2L4Kwn72fA4rGyqyXdmrMSdxqHx9IXon/FXluXieaFA6KJ2upcHAHxQPQ0LeM/OjLrhFxifHewOALQ=="
|
||||
},
|
||||
"meilisearch": {
|
||||
"version": "0.14.2",
|
||||
"resolved": "https://registry.npmjs.org/meilisearch/-/meilisearch-0.14.2.tgz",
|
||||
"integrity": "sha512-0PbZxyuUPqaHRHSgIZIDzeMbf45JhE1ctmcRZnWp2NkUp8Ub4XiS+qhXSMYtXNzQq1cpBIed7EcCBgjbcSdGSg==",
|
||||
"requires": {
|
||||
"cross-fetch": "^3.0.5"
|
||||
}
|
||||
},
|
||||
"mongodb": {
|
||||
"version": "3.7.3",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.7.3.tgz",
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
"keyv": "^4.5.2",
|
||||
"keyv-file": "^0.2.0",
|
||||
"lodash": "^4.17.21",
|
||||
"meilisearch": "^0.31.1",
|
||||
"mongomeili": "^0.1.8",
|
||||
"mongoose": "^6.9.0",
|
||||
"openai": "^3.1.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue