Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

chore: meilisearch setup config

Danny Avila67161c983ff7
diff --git a/api/.env.example b/api/.env.example
index 012efa2583..9a594d4f57 100644
--- a/api/.env.example
+++ b/api/.env.example
@@ -27,7 +27,9 @@ BING_TOKEN=
# SEARCH=TRUE
SEARCH=
MEILI_HOST='http://localhost:7700'
-MEILI_KEY='MASTER_KEY'
+MEILI_HTTP_ADDR='http://localhost:7700'
+# needs a secure key, feel free to generate your own.
+MEILI_MASTER_KEY=WjRvKvpelIYHa4dlcDGsdT9c0CKRbY-4VcuCQ1iZPcc
# User System
# global enable/disable the sample user system.
diff --git a/api/lib/db/indexSync.js b/api/lib/db/indexSync.js
index 600b4fa6f0..257f645d23 100644
--- a/api/lib/db/indexSync.js
+++ b/api/lib/db/indexSync.js
@@ -6,13 +6,13 @@ const { MeiliSearch } = require('meilisearch');
// eslint-disable-next-line no-unused-vars
async function indexSync(req, res, next) {
try {
- if (!process.env.MEILI_HOST || !process.env.MEILI_KEY || !process.env.SEARCH) {
+ if (!process.env.MEILI_HOST || !process.env.MEILI_MASTER_KEY || !process.env.SEARCH) {
throw new Error('Meilisearch not configured, search will be disabled.');
}
const client = new MeiliSearch({
host: process.env.MEILI_HOST,
- apiKey: process.env.MEILI_KEY
+ apiKey: process.env.MEILI_MASTER_KEY
});
const { status } = await client.health();
diff --git a/api/models/schema/convoSchema.js b/api/models/schema/convoSchema.js
index f9d8127b01..a654b1425a 100644
--- a/api/models/schema/convoSchema.js
+++ b/api/models/schema/convoSchema.js
@@ -53,10 +53,10 @@ const convoSchema = mongoose.Schema(
{ timestamps: true }
);
-if (process.env.MEILI_HOST && process.env.MEILI_KEY) {
+if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
convoSchema.plugin(mongoMeili, {
host: process.env.MEILI_HOST,
- apiKey: process.env.MEILI_KEY,
+ apiKey: process.env.MEILI_MASTER_KEY,
indexName: 'convos', // Will get created automatically if it doesn't exist already
primaryKey: 'conversationId'
});
diff --git a/api/models/schema/messageSchema.js b/api/models/schema/messageSchema.js
index 01aa4feb2d..9d21dd5b92 100644
--- a/api/models/schema/messageSchema.js
+++ b/api/models/schema/messageSchema.js
@@ -57,10 +57,10 @@ const messageSchema = mongoose.Schema(
{ timestamps: true }
);
-if (process.env.MEILI_HOST && process.env.MEILI_KEY) {
+if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
messageSchema.plugin(mongoMeili, {
host: process.env.MEILI_HOST,
- apiKey: process.env.MEILI_KEY,
+ apiKey: process.env.MEILI_MASTER_KEY,
indexName: 'messages',
primaryKey: 'messageId'
});
diff --git a/api/server/routes/search.js b/api/server/routes/search.js
index ec05b52a27..3d2d8a0ce6 100644
--- a/api/server/routes/search.js
+++ b/api/server/routes/search.js
@@ -4,7 +4,6 @@ const { MeiliSearch } = require('meilisearch');
const { Message } = require('../../models/Message');
const { Conversation, getConvosQueried } = require('../../models/Conversation');
const { reduceHits } = require('../../lib/utils/reduceHits');
-// const { MeiliSearch } = require('meilisearch');
const cache = new Map();
router.get('/sync', async function (req, res) {
@@ -56,7 +55,8 @@ router.get('/', async function (req, res) {
cache.set(q, result.cache);
delete result.cache;
result.messages = messages.filter(message => !result.filter.has(message.conversationId));
- console.log(result, messages.length);
+ // for debugging
+ // console.log(result, messages.length);
res.status(200).send(result);
} catch (error) {
console.log(error);
@@ -85,7 +85,7 @@ router.get('/enable', async function (req, res) {
try {
const client = new MeiliSearch({
host: process.env.MEILI_HOST,
- apiKey: process.env.MEILI_KEY
+ apiKey: process.env.MEILI_MASTER_KEY
});
const { status } = await client.health();
diff --git a/meilisearch.yml b/meilisearch.yml
index 2379ce4429..f2ce5fe169 100644
--- a/meilisearch.yml
+++ b/meilisearch.yml
@@ -4,7 +4,10 @@ services:
image: getmeili/meilisearch:v1.0
ports:
- 7700:7700
- environment:
- - MEILI_MASTER_KEY=MASTER_KEY
+ env_file:
+ - ./api/.env
+ # environment:
+ # # needs a secure key, feel free to generate your own
+ # - MEILI_MASTER_KEY=WjRvKvpelIYHa4dlcDGsdT9c0CKRbY-4VcuCQ1iZPcc
volumes:
- ./meili_data:/meili_data
\ No newline at end of file