mongodb-rag
:.mongodb-rag.json
với thông số như:{ "mongoUrl": "mongodb+srv://user:[email protected]/mongorag", "database": "helpdesk", "collection": "articles", "embedding": { "provider": "openai", "apiKey": "your-embedding-api-key", "model": "text-embedding-3-small", "dimensions": 1536 }, "search": { "maxResults": 5, "minScore": 0.7 }, "indexName": "vector_index"}
npx mongodb-rag create-env
.env
sẽ gồm:MONGODB_URI=mongodb+srv://user:[email protected]/mongoragMONGODB_DATABASE=helpdeskMONGODB_COLLECTION=articlesPORT=4001
EMBEDDING_PROVIDER=openaiEMBEDDING_API_KEY=your-embedding-api-keyEMBEDDING_MODEL=text-embedding-3-smallEMBEDDING_DIMENSIONS=1536
VECTOR_INDEX=vector_indexMAX_RESULTS=5
npx mongodb-rag create-index
Lệnh này sẽ tự động tạo index phù hợp với model OpenAI, dimension 1536, thuật toán cosine similarity.
{ "name": "vector_index", "type": "vectorSearch", "definition": { "fields": [{ "type": "vector", "path": "embedding", "numDimensions": 1536, "similarity": "cosine" }] }}
npx mongodb-rag create-rag-app my-helpdeskcd my-helpdesk
Thư mục | Mô tả |
---|---|
frontend/ | Giao diện React |
backend/ | API backend Express |
package.json | Quản lý workspace và dependencies |
npm installnpm run dev
helpdesk-docs
và thêm các file markdown ví dụ:### Wi-Fi Connection Issues**Issue:** My Wi-Fi is not working.**Solution:**1. Restart your router and modem2. Check if other devices can connect3. Forget the Wi-Fi network and reconnect4. If the issue persists, contact your ISP
### Password Reset Guide**Issue:** I forgot my password.**Solution:**1. Go to the login page and click "Forgot Password?"2. Enter your registered email address3. Check your email for a password reset link4. Click the link and enter a new password
### Software Installation Issues**Issue:** I can't install the application.**Solution:**1. Ensure your device meets the system requirements2. Check if you have administrator privileges3. Disable any antivirus software temporarily4. Try reinstalling the application
npx mongodb-rag ingest --directory ./helpdesk-docs
await fetch('http://localhost:4001/api/ingest', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ documents: [ { id: 'wifi-help', content: fs.readFileSync('./helpdesk-docs/wifi-connection.md', 'utf8'), metadata: { category: 'network', topic: 'wifi' } } ] })});
npx mongodb-rag search "wifi not connecting"npx mongodb-rag search "how to reset password"npx mongodb-rag search "software installation failed"
Phương thức | Đường dẫn | Mô tả |
---|---|---|
GET | /api/search?query= |