A Jupyter widget for exploring MongoDB AI capabilities through a challenge
Project description
MongoDB AI Playground
MongoDB AI Playground is a set of interactive widgets for to explore, test, and visualize MongoDB-powered AI capabilities in notebooks, including Retrieval-Augmented Generation (RAG) and GraphRAG workflows, using modern LLM and vector search integrations.
Overview
Built as a set of AnyWidget Jupyter widgets, this playground is designed for rapid prototyping, learning, and demonstration of GenAI + MongoDB workflows.
Prerequisites
- An Atlas account with a cluster running MongoDB version 6.0.11, 7.0.2, or later (including release candidates). Ensure your IP address is included in your Atlas project's access list. To learn more, see Create a Cluster.
- An environment to run interactive Python notebooks such as JupyterLab, Jupyter Notebook, Google Colab and VSCode. Make sure you have widget support enabled (it is enabled by default on most platforms).
- Create a database and collection (if you choose to use an existing collection, usage with the playground will erase the collection's data. Providing a new collection is recommended)
- Create an Atlas Vector Search index with the correct dimension associated with the embedding model you will use. The field containing the embedding must be named
embedding.
Installation
pip install mongodb-ai-playground
Usage
RAG Playground
from mongodb_ai_playground import MongoDBRAGPlayground
# Example: Pass your own loader, embedding model, LLM, and MongoDB collection
widget = MongoDBRAGPlayground(
loader=..., # LangChain loader
embedding_model=..., # LangChain embedding model
llm=..., # LangChain Chat Model (LLM) for answering questions (OpenAI, Claude, DeepSeek, etc.)
mongo_collection=..., # PyMongo collection for storing vectors
index_name=... # Name of your Atlas Vector Search index, you need to create if you don't have one, with the correct dimension (field containing the embedding is 'embedding')
)
widget # Display the playground widget
- All interactions are performed via the interactive UI in Jupyter-compatible environments.
- Visualize chunking, embeddings, vector search results, and question answering.
Notebook examples
| Description | Link |
|---|---|
| Wikipedia data + Voyage AI embedding + OpenAI LLM |
Development
Setup
To set up the environment for development, clone the repository and install the package in editable mode. This allows changes to the Python code and the JavaScript/CSS (via anywidget's live reloading) to be reflected immediately.
# Clone the repository
git clone https://github.com/mongodb-developer/mongodb-ai-playground.git
cd mongodb-ai-playground
# Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
# Install in editable mode
pip install -e .
Testing in a Notebook
To test the widget during development:
- Start JupyterLab or Jupyter Notebook:
pip install jupyterlab jupyter lab
- Open the example notebook in
examples/mongodb_rag_playground_wiki_voyageai_openai.ipynb. - Ensure you have the necessary environment variables or credentials set up (Atlas connection string, OpenAI API key, etc.) as described in the notebook.
- Run the notebook cells to interact with the widget. Changes to
mongodb_ai_playground/index.jsormongodb_ai_playground/index.csswill be reflected upon refreshing the page or re-running the widget cell.
Building the Package
To build the package for distribution (creating .tar.gz and .whl files):
- Install the build tool:
pip install build
- Run the build command from the root of the repository:
python -m build
- The build artifacts will be generated in the
dist/directory.
Features
- 📄 Document Chunking: Flexible strategies (fixed, recursive, markdown) for splitting documents.
- 🧠 Embeddings & Vector Search: Store and search embeddings in MongoDB Atlas using langchain-mongodb.
- 🔎 RAG Playground UI: Step-by-step interface for chunking, embedding, and querying.
- 🕸️ Knowledge Graph RAG: Build and visualize entity/relation graphs from docs and run graph-based QA.
- 🧩 Extensible: Built for experimentation with LangChain so that you can use different loaders, embeddings models, LLMs and more.
Project Structure
mongodb_ai_playground/
├── rag_widget.py # RAG playground widget (chunking, embedding, RAG)
├── graphrag_widget.py # Graph RAG playground widget (graph ingest, QA)
├── index.js # JS frontend for RAG widget
├── graphrag.js # JS frontend for Graph RAG widget
├── index.css # Shared widget styles
├── __init__.py # Exports widgets
...
Requirements
- Python 3.7+
- Jupyter widget compatible environments (JupyterLab, Jupyter Notebook, Colab, Marimo, etc.)
- MongoDB Atlas deployment (for vector/graph storage)
- Any LLM and embedding model using LangChain components (OpenAI, HuggingFace, etc.)
License
This project is licensed under the MIT License.
Acknowledgments
Additional Resources
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mongodb_ai_widget_challenge-0.21.tar.gz.
File metadata
- Download URL: mongodb_ai_widget_challenge-0.21.tar.gz
- Upload date:
- Size: 248.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e3323686e18c080a29fc0e1a5893a35be99449a5f3001889baa72ddd212477c
|
|
| MD5 |
58444330913e857a2661b26fa1fb2db5
|
|
| BLAKE2b-256 |
7e7161ef41ab7a085483a9324e5afcf6828c749cc28c7301e28308018f3fafe4
|
File details
Details for the file mongodb_ai_widget_challenge-0.21-py3-none-any.whl.
File metadata
- Download URL: mongodb_ai_widget_challenge-0.21-py3-none-any.whl
- Upload date:
- Size: 256.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a1152f2b2d1988dd64a3ac6eee14dc16c76ea4a5123f9274df27a2c6a8f4433
|
|
| MD5 |
70df7e302b3fe60c8d1df9dd82eab57a
|
|
| BLAKE2b-256 |
2a31792cb65d0efb9cb15d7270959ac095a73437437b4f054d5b9131b7766538
|