πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

mongodb-ai-playground

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-ai-playground

A playground for building RAG applications with MongoDB and Langchain

0.0.9
PyPI
Maintainers
1

MongoDB AI Playground

MongoDB AI Playground is a set of interactive widgets to explore, test, and visualize MongoDB-powered AI capabilities, including Retrieval-Augmented Generation (RAG) and GraphRAG workflows, using modern LLM and vector search integrations.

Overview

The MongoDB AI Playground provides interactive widgets for experimenting with advanced AI capabilities on MongoDB, including:

  • RAG (Retrieval-Augmented Generation): Chunk, embed, store, and query documents using MongoDB Atlas Vector Search and LLMs.

Screenshot MongoDB AI Playground

Built as a set of AnyWidget Jupyter widgets, this playground is designed for rapid prototyping, learning, and demonstration of GenAI + MongoDB workflows.

Installation

  • Pre-requisites
  • 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.
  • Create a database and collection (:warning: 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.
  • Install dependencies:
pip install mongodb-ai-playground

The mongodb-ai-playground depends on the following Python libraries: anywidget, ipywidgets, langchain, langchain-mongodb, and pymongo.

Full examples

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 knowledge graphs.

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

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts