Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions partners/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ Each partner brings their unique expertise and technology stack to create compre
| **Galileo** | AI Hallucination Detection and Reduction | AI Safety - Techniques for detecting and reducing hallucinations in AI systems to improve reliability and accuracy | [View Notebook](galileo/ai_hallucination_detection_and_reduction.ipynb) |
| **Gravity9** | Agentic System Enhanced Contract and Supply Chain Management for International Shipping | Supply Chain Management - Agentic RAG solution for contract and supply chain management in international shipping | [View Notebook](gravity9/Agentic_System_Enhanced_Contract_and_Supply_Chain_Management_for_International_Shipping.ipynb) |
| **LangChain** | Agentic Knowledge Discovery | Knowledge Discovery - Advanced agentic systems for intelligent knowledge discovery and information retrieval | [View Notebook](langchain/agentic_knowledge_discovery_notebook.ipynb) |
| **LangChain** | Advanced RAG (3 notebooks) | Movie Discovery - Vector, full-text, hybrid `$rankFusion`, reranking, `$graphLookup`, and auto-embedding retrieval with LangChain on a free M0 cluster | [View Notebooks](langchain/advanced-rag/) |
| **LangChain** | MongoDB MCP Server + AI Agents | Database Agents - A LangGraph agent that answers questions about a cluster by calling MongoDB MCP Server tools | [View Notebook](langchain/claude-code-mcp/01_mongodb_mcp_and_agent.ipynb) |
| **LlamaIndex** | Cemex + MongoDB + LlamaCloud Demo | Enterprise Integration - Demonstration of MongoDB integration with LlamaCloud using real-world enterprise data from Cemex | [View Notebook](llamaindex/Cemex+MongoDB+LlamaCloud_demo.ipynb) |
| **Mastra** | Movie-Discovery Agent with Mastra (4 notebooks, TypeScript) | Agents - Vector, hybrid, and reranked retrieval, bring-your-own collections, tools, and persistent memory with Mastra's MongoDB integration | [View Notebooks](mastra/) |

## About Our Partners

Expand All @@ -31,6 +34,9 @@ Each partner brings their unique expertise and technology stack to create compre
### LlamaIndex
[LlamaIndex](https://www.llamaindex.ai/) is a data framework for building LLM applications, providing tools for data ingestion, indexing, and querying to connect custom data sources with large language models.

### Mastra
[Mastra](https://mastra.ai/) is a TypeScript framework for building AI agents and workflows, with built-in memory, tools, and retrieval backed by stores such as MongoDB.

---

These partnerships demonstrate MongoDB's commitment to fostering innovation in the AI ecosystem and providing developers with comprehensive solutions for building intelligent applications across various domains and industries.
33 changes: 33 additions & 0 deletions partners/langchain/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copy to .env in this folder and fill it in. Both sets here, advanced-rag/ and
# claude-code-mcp/, read it via python-dotenv, which finds the nearest .env at or above
# the notebook's folder. A missing value falls back to an interactive getpass prompt, so
# Colab works without a .env at all.

# --- MongoDB Atlas ---
# Your Atlas M0 (free tier) SRV connection string.
MONGODB_URI=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/?retryWrites=true&w=majority
MONGODB_DB=sample_mflix
# Advanced RAG notebook 3 creates one scratch collection for its auto-embedding demo and
# drops it during cleanup. It refuses to reuse a collection that already exists, so set
# this only if the default name is already taken on your cluster.
LANGCHAIN_AUTO_EMBED_COLLECTION=auto_embed_demo

# --- Atlas-hosted embeddings + reranking (ai.mongodb.com) ---
# Atlas Admin API key used to call the hosted embedding and rerank endpoints.
MDB_ATLAS_API_KEY=
# sample_mflix.embedded_movies ships with voyage-3-large (2048-d) plot vectors,
# so query embeddings use the same model/dimensions to share the vector space.
EMBEDDING_MODEL=voyage-3-large
EMBEDDING_DIMENSIONS=2048

# --- Claude (LLM) ---
ANTHROPIC_API_KEY=
ANTHROPIC_MODEL=claude-haiku-4-5
# Optional: point ChatAnthropic at an Anthropic-compatible gateway (e.g. Grove).
# Leave blank to use the default Anthropic API (api.anthropic.com).
# Give the ROOT url WITHOUT the trailing /v1/messages -- the SDK appends that
# itself, e.g. https://<gateway-host>/<path>/anthropic
ANTHROPIC_BASE_URL=
# Some gateways (e.g. Azure API Management fronting Grove) authenticate with an
# "api-key" header instead of Anthropic's default "x-api-key". When ANTHROPIC_BASE_URL
# is set, the notebooks send ANTHROPIC_API_KEY in the "api-key" header automatically.
2 changes: 2 additions & 0 deletions partners/langchain/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__/
.pytest_cache/
58 changes: 58 additions & 0 deletions partners/langchain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# LangChain + MongoDB Atlas

Two notebook sets built on LangChain and LangGraph, in Python. Both run on a free Atlas M0
cluster against the `sample_mflix` sample dataset, and both open in Colab.

| Set | What you'll build | Notebooks |
|-----|-------------------|-----------|
| [Advanced RAG](./advanced-rag/) | A movie-discovery assistant that retrieves with vector, full-text, hybrid, graph, and auto-embedding techniques | 3 |
| [Claude Code & MCP](./claude-code-mcp/) | An agent that answers questions about your cluster by calling MongoDB MCP Server tools | 1 |

The MCP set lives here because its agent is built with `langgraph` and
`langchain-mcp-adapters`. MongoDB's MCP Server is the subject; LangChain is how the agent
around it is assembled.

## What you need

- A free Atlas **M0** cluster with **Load Sample Dataset** run (see
[Load Sample Data](https://www.mongodb.com/docs/atlas/sample-data/)).
- An **Atlas API key** for the hosted embedding and rerank services at `ai.mongodb.com`.
- A **Claude API key**, or an Anthropic-compatible gateway via `ANTHROPIC_BASE_URL`.
- **Node.js 20+** for the MCP set only. The MCP Server runs on Node.

## Running locally

```bash
cd partners/langchain
pip install -r requirements.txt
cp .env.example .env # then fill in your connection string and keys
jupyter lab
```

`requirements.txt` pins every version, verified together on Python 3.12. The notebooks read
credentials from `partners/langchain/.env` when there is one and prompt for anything missing,
which is what lets the same notebook run in Colab or on your machine.

Or click the **Open in Colab** badge at the top of any notebook and skip the install.

## The index budget

An M0 cluster allows three Atlas Search indexes, and these notebooks are built to fit.
Notebook 1 of Advanced RAG creates `movies_vector_index`, notebook 2 creates
`movies_fulltext_index`, and notebook 3 creates a short-lived index for the auto-embedding
demo that it drops when it finishes. Each creation is guarded by an existence check, so
re-running is free.

At the limit they stop and list what is occupying the slots rather than freeing one: an
index these notebooks did not create might be behind something you depend on, so asking
for a fresh cluster is the safe failure. Notebook 3's scratch collection works the same
way -- it refuses to reuse a collection it did not create, and
`LANGCHAIN_AUTO_EMBED_COLLECTION` renames it if the default is taken on your cluster.

The Mastra set uses the same two index names and also creates them if absent. The two sets
are independent — run either first — and sharing the names is what keeps the pair inside the
M0 budget. On a paid tier the limit is not binding.

If you hit an index limit, look for leftovers from an interrupted run: the
`auto_embed_demo` collection, or a demo index that outlived its notebook. Both are safe
for you to drop. No notebook here deletes a collection or an index it did not create.
Loading
Loading