Updating README

This commit is contained in:
ajosh0504
2025-02-05 11:54:43 -08:00
parent ddf02d0dfa
commit 4d8e8b6aa4
47 changed files with 749 additions and 799 deletions
+19 -152
View File
@@ -1,166 +1,33 @@
# Generative AI Use Cases Repository
## MongoDB's GenAI Showcase
## Introduction
Generative AI Use Cases Repository
Welcome to the Generative AI Use Cases Repository! This comprehensive resource showcases cutting-edge applications in generative AI, including Retrieval-Augmented Generation (RAG), AI Agents, and industry-specific use cases. Discover how MongoDB integrates with RAG pipelines and AI Agents, serving as a vector database, operational database, and memory provider.
Welcome to MongoDB's Generative AI Showcase Repository! Whether you are just starting out on your Generative AI journey, or looking to build advanced GenAI applications, we've got you covered. This repository has an exhaustive list of examples and sample applications that cover Retrieval-Augmented Generation (RAG), AI Agents, and industry-specific use cases. Discover how MongoDB integrates into RAG pipelines and AI Agents, serving as a vector database, operational database, and memory provider.
**Key Features:**
## Contents
- RAG pipelines and applications leveraging MongoDB for efficient data retrieval and management
- AI Agents utilizing MongoDB as a scalable memory provider
- Practical notebooks and guidance on frameworks like LlamaIndex, Haystack and LangChain
- Integration with state-of-the-art models from Anthropic and OpenAI
- Industry-specific use cases across healthcare, finance, e-commerce, and more
This repo mainly contains:
## Table of Contents
- [Introduction](#introduction)
- [Use Cases](#use-cases)
- [Notebooks](#notebooks)
- [Evaluations](#evaluations)
- [RAG](#rag)
- [Agents](#agents)
- [Workshops](#workshops)
- [Tools](#tools)
- [Datasets](#datasets)
- [General Knowledge](#general-knowledge)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)
* Jupyter notebooks examples for RAG, agentic applications, evaluations etc. under `notebooks`.
* Javascipt and Pythons apps and demos under `apps`.
* Contributions from our AI partners under `partners`.
## Use Cases
This section contains examples of use cases that are commonly seen in industry-focused scenarios and generic applications. Each entry in the table includes a description and links to production-level examples and relevant code.
| Use Case | Stack | Link | Description |
|--------------------------------|------------------------|---------------------------------------------------|-------------|
| **Customer Support Chatbot** | JavaScript, OpenAI, MongoDB | [![GitHub](https://img.shields.io/badge/GitHub-View_on_GitHub-blue?logo=GitHub)](https://github.com/mongodb/chatbot) | The MongoDB Chatbot Framework provides libraries that enable the creation of sophisticated chatbot |
| **HR Support Chatbot** | LangGraph.JS, Anthropic, OpenAI, MongoDB | [![GitHub](https://img.shields.io/badge/GitHub-View_on_GitHub-blue?logo=GitHub)](https://github.com/mongodb-developer/LangGraph.js-MongoDB-Example/) | Create an AI-powered HR assistant using LangGraph.js and MongoDB |
| **Trip Advisor - Laravel, OpenAI and Atlas** | PHP (Laravel), OpenAI, MongoDB | [![GitHub](https://img.shields.io/badge/GitHub-View_on_GitHub-blue?logo=GitHub)](https://github.com/mongodb-developer/laravel-openai-vector-search)|Leverage PHP, Laravel and OpenAI to build suphisticated recommendation engines|
| **MongoDB AI Framework** | Key AI Stack components|[![GitHub](https://img.shields.io/badge/GitHub-View_on_GitHub-blue?logo=GitHub)](https://github.com/mongodb-partners/maap-framework) | The MAAP framework is a set of libraries that you can use to build your RAG Application using MongoDB and Atlas Vector Search and associated MAAP partners |
| **MongoDB and BuildShip Agents** | MongoDB Atlas, BuildShip low-code, Anthropic | [![GitHub](https://img.shields.io/badge/GitHub-View_on_GitHub-blue?logo=GitHub)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/snippets/low-code/BuildShip.md) | This guide demonstrates how to create an AI agent for handling rental booking workflows using BuildShip's no-code platform with MongoDB Aggregation and Insert integrations. |
| **Realtime Voice OpenAI API and Atlas Vector Search Rental Agent** | OpenAI, Atlas , Python , React | [![GitHub](https://img.shields.io/badge/GitHub-View_on_GitHub-blue?logo=GitHub)](https://github.com/Pash10g/voice-openai-mongo-rentals-agent)|Sample application that use OpenAI Realtime API and MongoDB Atlas vector/CRUD as tools for a full voice based rental assistant. |
| **MongoDB and n8n.io AI template** | n8n AI automation, MongoDB, JS | [template](https://n8n.io/workflows/2554-mongodb-ai-agent-intelligent-movie-recommendations/)| A sample workflow to start of when building AI context aware flows with [n8n platform](https://n8n.io)|
| **MongoMP - Music Platform** | Next.js 14, MongoDB Atlas, JWT | [![GitHub](https://img.shields.io/badge/GitHub-View_on_GitHub-blue?logo=GitHub)](apps/mongo-mp)| A music streaming platform with AI-powered recommendations using MongoDB's vector search capabilities|
## Evaluations
- [Evaluating your LLM applications](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/evals/ragas-evaluation.ipynb)
- [Angle Embeddings Evaluation](/notebooks/evals/angle-embeddings-eval.ipynb)
- [OpenAI Embeddings Evaluation](/notebooks/evals/openai-embeddings-eval.ipynb)
- [VoyageAI Embeddings Evaluation](/notebooks/evals/voyageai-embeddings-eval.ipynb)
## RAG
| Title | Stack | Colab | Article |
|---------------------------------------------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| RAG with Llama3, Hugging Face and MongoDB | Hugging Face, Llama3, MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/rag_mongodb_llama3_huggingface_open_source.ipynb) | |
| How to Build a RAG System Using Claude 3 Opus and MongoDB | MongoDB, Anthropic, Python | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/anthropic_mongodb_pam_ai_stack.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/rag_with_claude_opus_mongodb/) |
| How to Build a RAG System with the POLM AI Stack | POLM (Python, OpenAI, LlamaIndex, MongoDB) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/building_RAG_with_LlamaIndex_and_MongoDB_Vector_Database.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](#) |
| MongoDB LangChain Cache Memory Python Example | POLM (Python, OpenAI, LangChain, MongoDB) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/mongodb-langchain-cache-memory.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/advanced-rag-langchain-mongodb/) |
| MongoDB LangChain Cache Memory JavaScript Example | JavaScript, OpenAI, LangChain, MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/mongodb-langchain-js-memory.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/add-memory-to-javascript-rag-application-mongodb-langchain/) |
| Naive RAG Implementation Example | POLM (Python, OpenAI, LlamaIndex, MongoDB) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]( https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/naive_rag_implemenation_llamaindex.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/rag-with-polm-stack-llamaindex-openai-mongodb/) |
| OpenAI Text Embedding Example | Python, MongoDB, OpenAI | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/openai_text_3_emebdding.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/using-openai-latest-embeddings-rag-system-mongodb/) |
| RAG with Hugging Face and MongoDB Example | Hugging Face, Gemma, MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/rag_with_hugging_face_gemma_mongodb.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/gemma-mongodb-huggingface-rag) |
| Chat With PDF Example | Python, MongoDB, OpenAI, LangChain | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/chat_with_pdf_mongodb_openai_langchain_POLM_AI_Stack.ipynb) |
| RAG Pipeline | Python, MongoDB, Gemma2, KeraNLP | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/rag_pipeline_kerasnlp_mongodb_gemma2.ipynb) |
| RAG Pipeline with Open Models| Python, MongoDB, Gemma2, Hugging Face | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/rag_with_gemma2_mongodb_open_models.ipynb) |
| MongoDB and Haystack cooking advisor| Python, Haystack , OpenAI | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/haystack_mongodb_cooking_advisor_pipeline.ipynb)| [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/haystack-ai-mongodb-atlas-vector-demo)|
| MongoDB and Semantic Kernel Movie Recommendation Bot | C# Console App, MongoDB, Semantic Kernel, Azure OpenAI or OpenAI | [GitHub Repo](https://github.com/mongodb-developer/SemanticKernel_With_CSharp_And_Atlas) | [View Article](https://www.mongodb.com/developer/languages/csharp/getting-started-with-semantic-kernel-dotnet/) |
| Build an Asset Manager RAG Chatbot | Cohere, MongoDB, Python | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/rag_chatbot_with_cohere_and_mongodb.ipynb) | Coming soon |
| Asset Manager Chatbot with LLM Evals and Moderation | Gemma 2B, ShieldGemma, MongoDB, Python | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/rag/rag_with_gemma2_2b_mongodb_open_models.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/gemma2b_mongodb_rag/) |
| Lyric Semantic Search with MongoDB and Spring AI | Java, Spring AI, OpenAI, MongoDB | [Github Repo](https://github.com/mongodb-developer/lyric-semantic-search) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/languages/java/spring-ai-mongodb-atlas/) |
| Terraforming AI Workflows: RAG With MongoDB Atlas and Spring AI | Java, Spring AI, OpenAI, MongoDB, Terraform | [Github Repo](https://github.com/mongodb-developer/springai-terraform) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/languages/java/terraform-springai-rag/) |
| RAG with local MongoDB Atlas | Docker, MongoDB, Python | [Github Repo](https://github.com/ranfysvalle02/local-atlas-RAG) | |
## Agents
An agent is an artificial computational entity with an awareness of its environment. It is equipped with faculties that enable perception through input, action through tool use, and cognitive abilities through foundation models backed by long-term and short-term memory. Within AI, agents are artificial entities that can make intelligent decisions followed by actions based on environmental perception, enabled by large language models.
| Title | Stack | Colab Link | Article Link |
|--------------------------------|----------------------|------------------------------------------------|--------------------------------------------------|
| Agentic Factory Safety Assistant | LangGraph, Open AI, MongoDB, LangChain |[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/agentic_rag_factory_safety_assistant_with_langgraph_langchain_mongodb.ipynb) | |
| AI Research Assistant | FireWorks AI, MongoDB, LangChain |[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/agent_fireworks_ai_langchain_mongodb.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/agent-fireworksai-mongodb-langchain/) |
AI Investment Researcher | MongoDB, CrewAI and LangChain | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/crewai-mdb-agg.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/mongodb/augment-llm-capabilities-with-mdb-aggregation/)
| Agentic RAG: Recommmendation System | Claude 3.5, LlamaIndex, MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/how_to_build_ai_agent_claude_3_5_sonnet_llamaindex_mongodb.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/claude_3_5_sonnet_rag/)|
| Agentic HR Chatbot | Claude 3.5, LangGraph, MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/hr_agentic_chatbot_with_langgraph_claude.ipynb) | Coming Soon|
|AWS Bedrock Agent | Claude 3, AWS Bedrock, Python, MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/mongodb_with_aws_bedrock_agent.ipynb) | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/mdb-aws-bedrock-agent-start/)
|Asset Manager Assistant | LangGraph, OpenAI, Anthropic, MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/asset_management_analyst_assistant_agentic_chatbot_langgraph_mongodb.ipynb) |
| Implementing Working Memory with Tavily and MongoDB | Python, Tavily, MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/implementing_working_memory_with_tavily_and_mongodb.ipynb) |
|AI Food Assistant | Semantic Kernel, C#, OpenAI, MongoDB | [GitHub Repo](https://github.com/mongodb-developer/foodagent-dotnet) |[![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/languages/csharp/ai-agents-dotnet-with-semantic-kernel/) | |
|Google Gemini2.0 Multimodal agent | Google Gemini 2.0, Google embeddings, Langchain, MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/Gemini2_0_multi_modality_with_mongodb_atlas_vector_store.ipynb) | |
|Smolagents MongoDB tools integration | Smolagents by HF, MongoDB, OpenAI | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/smolagents_hf_with_mongodb.ipynb) | |
|Multi-Agent Order Management System | Smolagents by HF, MongoDB, DeepSeek | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/smolagents_multi-agent_micro_agents.ipynb) | |
|Beyond Vectors: Augment LLM Capabilities with MongoDB Aggregation Framework and CrewAI | CrewAI, Python, OpenAI, MongoDB | [GitHub Repo](https://github.com/ranfysvalle02/mdb-agg-crewai) |[![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/mongodb/augment-llm-capabilities-with-mdb-aggregation/) | |
|Self-Reflecting Gift Agent with Haystack and MongoDB Atlas | Haystack, Python, OpenAI, MongoDB |[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/self_reflecting_gift_agent_haystack.ipynb) | |
## ML
This folder will contain all traditional machine learning tutorials. They include important explanations, step-by-step instructions, and everything a reader needs in order to be successful following the tutorial from beginning to end.
| Title | Colab Link |
|-------|------------|
| Written in the Stars: Predict Your Future With Tensorflow and MongoDB Charts | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/ml/tensorflow_mongodbcharts_horoscopes.ipynb) |
## MongoDB Specific
These MongoDB specific tutorials are meant to showcase a specific MongoDB platform integrated with artificial intelligence or machine learning. These step-by-step tutorials will allow the reader to truly understand not only the platform, but also the AI use-case.
| Title | Colab Link |
|-------|------------|
| Aperol Spritz Summer With MongoDB Geospatial Queries & Vector Search | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/mongodb-specific/geospatialqueries_vectorsearch_spritzes.ipynb) |
| Sip, Swig, and Search With Playwright, OpenAI, and MongoDB Atlas Search | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/mongodb-specific/SwigMenu_Playwright_OpenAI_MongoDB.ipynb) |
| Ingesting Quantized vectors with Cohere and MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/techniques/evaluating_information_retrival_techniques_mongondb_langchain.ipynb)
| Evaluating quantized vectors vs Non-Quantized Vectors with MongoDB | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/techniques/advanced_evaluation_of_quantized_vectors_using_cohere_mongodb_beir.ipynb)
## Workshops
Workshops are designed to take learners through the step-by-step process of developing LLM applications. These workshops include essential explanations, definitions, and resources provided within the notebooks and projects. Each workshop is structured to build foundational knowledge and progressively advance to more complex topics. Practical exercises and real-world examples ensure that learners can apply the concepts effectively, making it easier to understand the integration and deployment of generative AI applications.
| Title | Colab Link |
|-------|------------|
| Pragmatic LLM Application Development: From RAG Pipelines to AI Agent | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/workshops/Pragmatic_LLM_Application_Introduction_From_RAG_to_Agents_with_MongoDB.ipynb) |
| Building chatbots with NextJS and Atlas Vector search | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://mongodb-developer.github.io/vector-search-workshop)
## Tools
Useful tools and utilities for working with generative AI models:
- [Embeddings Generator](/tools/embeddings_generator): A set of scripts for generating and manipulating embeddings.
- [MongoDB as a Toolbox](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/tools/function_calling_mongodb_as_a_toolbox.ipynb) for Agentic Systems
## Datasets
Below are various datasets with embeddings for use in LLM application POCs and demos. All datasets can be accessed and downloaded from their respective Hugging Face pages.
| Dataset Name | Description | Link |
| ------------------------------------------------- | ----------- | ---- |
| Cosmopedia | Chunked version of a subset of the data Cosmopedia dataset | [![View Dataset](https://img.shields.io/badge/View%20Dataset-8A2BE2)](https://huggingface.co/datasets/MongoDB/subset_arxiv_papers_with_embeddings) |
| Movies | Western, Action, and Fantasy movies, including title, release year, cast, and OpenAI embeddings for vector search. | [![View Dataset](https://img.shields.io/badge/View%20Dataset-8A2BE2)](https://huggingface.co/datasets/MongoDB/embedded_movies) |
| Airbnb | AirBnB listings dataset with property descriptions, reviews, metadata and embeddings. | [![View Dataset](https://img.shields.io/badge/View%20Dataset-8A2BE2)](https://huggingface.co/datasets/MongoDB/airbnb_embeddings) |
| Tech News | Tech news articles from 2022 and 2023 on valuable tech companies. | [![View Dataset](https://img.shields.io/badge/View%20Dataset-8A2BE2)](https://huggingface.co/datasets/MongoDB/tech-news-embeddings) |
| Restaurant | Restaurant dataset with location, cuisine, ratings, attributes for industry analysis, recommendations, and geographical studies. | [![View Dataset](https://img.shields.io/badge/View%20Dataset-8A2BE2)](https://huggingface.co/datasets/MongoDB/whatscooking.restaurants) |
Subset Arxiv papers | This arXiv subset has 256-dimensional OpenAI embeddings for each entry, created by combining title, author(s), and abstract. | [![View Dataset](https://img.shields.io/badge/View%20Dataset-8A2BE2)](https://huggingface.co/datasets/MongoDB/subset_arxiv_papers_with_embeddings)
## General Knowledge
Thought leadership in AI is not an option, we take it seriously. That's why we've curated articles and pieces created by our team to get you conversation-ready and equipped with the right information to make key decisions when building AI products.
| Title | Link |
|-------|------|
| What is an AI Stack? | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/agent-fireworksai-mongodb-langchain/) |
| How to Optimize LLM Applications With Prompt Compression Using LLMLingua and LangChain | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/prompt_compression/) |
| What is Atlas Vector Search | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/products/platform/atlas-vector-search) |
| How to Choose the Right Chunking Strategy for Your LLM Application | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/choosing-chunking-strategy-rag/) |
| How to Choose the Right Embedding Model for Your LLM Application | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/choose-embedding-model-rag/) |
| How to Evaluate Your LLM Application | [![View Article](https://img.shields.io/badge/View%20Article-blue)](https://www.mongodb.com/developer/products/atlas/evaluate-llm-applications-rag/) |
## Getting Started
You will need to connect to a MongoDB cluster to run any of the apps or examples in this repo. Follow these steps to get set up:
* Register for a [free MongoDB Atlas account](https://www.mongodb.com/cloud/atlas/register)
* [Create a new database cluster](https://www.mongodb.com/docs/guides/atlas/cluster/)
* [Obtain the connection string](https://www.mongodb.com/docs/guides/atlas/connection-string/) for your database cluster
## Contributing
We welcome contributions! Please read our [Contribution Guidelines](CONTRIBUTING.md) for more information on how to participate.
## License
This project is licensed under the [MIT License](LICENSE).
## Contact
Feel free to reach out for any queries or suggestions:
- Email: richmond.alake@mongodb.com
- Email: apoorva.joshi@mongodb.com
- Email: pavel.duchovny@mongodb.com
## Getting Support
As you work through these examples, if you encounter any problems, please [open a new issue](https://github.com/mongodb-developer/GenAI-Showcase/issues/new).
You can also reach us in our [GenAI community forum](https://www.mongodb.com/community/forums/c/generative-ai/162).
+1
View File
@@ -0,0 +1 @@
Javascript and Python apps and demos showcasing how to use MongoDB in GenAI applications.
+33 -20
View File
@@ -1,55 +1,66 @@
from langchain_core.documents import Document
from langchain_community.graphs.graph_document import GraphDocument, Node, Relationship
from pymongo import MongoClient
from dotenv import load_dotenv
from pprint import pprint
import os
import json
from nodes_relationships import nodes,links
from dotenv import load_dotenv
from nodes_relationships import links, nodes
from pymongo import MongoClient
def build_lookup_map():
quick_lookup = {}
for key in links.keys():
relationship = links[key]
source_node = relationship.source
lookup_key = str(source_node.id)+":"+str(source_node.type)
lookup_content = quick_lookup.get(lookup_key,"empty")
lookup_key = str(source_node.id) + ":" + str(source_node.type)
lookup_content = quick_lookup.get(lookup_key, "empty")
if lookup_content != "empty":
quick_lookup.get(lookup_key).append(relationship)
else:
quick_lookup[lookup_key] = [relationship]
return quick_lookup
def create_mongo_documents():
mongo_documents = []
quick_lookup = build_lookup_map()
for key in nodes.keys():
node = nodes[key]
id = str(node.id)+":"+str(node.type)
id = str(node.id) + ":" + str(node.type)
type = node.type
rel = quick_lookup.get(id,None)
rel = quick_lookup.get(id, None)
relationships = set()
targets = {}
if rel!=None:
if rel is not None:
for relationship in rel:
target_id = str(relationship.target.id)+":"+str(relationship.target.type)
target_id = (
str(relationship.target.id) + ":" + str(relationship.target.type)
)
relationships.add(target_id)
target_type = targets.get(target_id,None)
if target_type != None:
target_type = targets.get(target_id, None)
if target_type is not None:
targets[target_id].append(relationship.type)
else:
targets[target_id] = [relationship.type]
mongo_documents.append({"_id":id,"type":type,"relationships":list(relationships),"targets":targets})
mongo_documents.append(
{
"_id": id,
"type": type,
"relationships": list(relationships),
"targets": targets,
}
)
else:
mongo_documents.append({"_id":id,"type":type,"relationships":[],"targets":{}})
mongo_documents.append(
{"_id": id, "type": type, "relationships": [], "targets": {}}
)
return mongo_documents
def mongo_insert():
mongo_documents = create_mongo_documents()
try:
uri = os.getenv("ATLAS_CONNECTION_STRING")
print(uri)
client = MongoClient(uri)
client = MongoClient(uri, appname="devrel.showcase.graph_rag_app")
database = client["langchain_db"]
collection = database["nodes_relationships"]
for doc in mongo_documents:
@@ -58,8 +69,10 @@ def mongo_insert():
print(e)
finally:
client.close()
if __name__=="__main__":
if __name__ == "__main__":
load_dotenv()
print("Inserting Documents")
mongo_insert()
print("Successfully Inserted Documents")
print("Successfully Inserted Documents")
+44 -27
View File
@@ -1,16 +1,17 @@
from langchain_core.globals import set_verbose, set_debug
from langchain_ollama import ChatOllama, OllamaEmbeddings
from langchain.schema.output_parser import StrOutputParser
from langchain_mongodb.vectorstores import MongoDBAtlasVectorSearch
from pymongo import MongoClient
from langchain_community.document_loaders import PyPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.schema.runnable import RunnablePassthrough
from langchain_community.vectorstores.utils import filter_complex_metadata
from langchain_core.prompts import ChatPromptTemplate
import logging
import yaml
from typing import Optional
import yaml
from langchain.schema.output_parser import StrOutputParser
from langchain.schema.runnable import RunnablePassthrough
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.document_loaders import PyPDFLoader
from langchain_community.vectorstores.utils import filter_complex_metadata
from langchain_core.globals import set_debug, set_verbose
from langchain_core.prompts import ChatPromptTemplate
from langchain_mongodb.vectorstores import MongoDBAtlasVectorSearch
from langchain_ollama import ChatOllama, OllamaEmbeddings
from pymongo import MongoClient
# Enable verbose debugging
set_debug(True)
@@ -20,11 +21,13 @@ set_verbose(True)
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def load_config(config_file: str = "config.yaml"):
"""Load configuration from a YAML file."""
with open(config_file, "r") as file:
with open(config_file) as file:
return yaml.safe_load(file)
class ChatPDF:
"""A class designed for PDF ingestion and question answering using RAG with detailed debugging logs."""
@@ -40,29 +43,33 @@ class ChatPDF:
mongo_connection_str = config["mongo_connection_str"]
database_name = config["database_name"]
collection_name = config["collection_name"]
self.model = ChatOllama(model=llm_model)
self.embeddings = OllamaEmbeddings(model=embedding_model)
self.text_splitter = RecursiveCharacterTextSplitter(chunk_size=1024, chunk_overlap=100)
self.text_splitter = RecursiveCharacterTextSplitter(
chunk_size=1024, chunk_overlap=100
)
self.prompt = ChatPromptTemplate.from_template(
"""
You are a helpful assistant answering questions based on the uploaded document and the conversation.
Conversation History:
{conversation_history}
Context from Documents:
{context}
Question:
{question}
Provide a concise, accurate answer (preferably within three sentences), ensuring it directly addresses the question.
"""
)
# Setup MongoDB connection
self.client = MongoClient(mongo_connection_str)
self.client = MongoClient(
mongo_connection_str, appname="devrel.showcase.local_rag_pdf_app"
)
self.collection = self.client[database_name][collection_name]
# Verbose connection check
@@ -74,7 +81,7 @@ class ChatPDF:
collection=self.collection,
embedding=self.embeddings,
index_name="vector_index",
relevance_score_fn="cosine"
relevance_score_fn="cosine",
)
# Create vector search index on the collection
@@ -107,7 +114,13 @@ class ChatPDF:
self.vector_store.add_documents(documents=chunks)
logger.info("Document embeddings stored successfully in MongoDB Atlas.")
def query_with_context(self, query: str, conversation_history: list = None, k: int = 5, score_threshold: float = 0.2):
def query_with_context(
self,
query: str,
conversation_history: Optional[list] = None,
k: int = 5,
score_threshold: float = 0.2,
):
"""
Answer a query using the RAG pipeline with verbose debugging and conversation history.
@@ -132,7 +145,9 @@ class ChatPDF:
# Generate and log query embeddings
query_embedding = self.embeddings.embed_query(query)
logger.info(f"User Query: {query}")
logger.debug(f"Query Embedding (sample values): {query_embedding[:10]}... [Total Length: {len(query_embedding)}]")
logger.debug(
f"Query Embedding (sample values): {query_embedding[:10]}... [Total Length: {len(query_embedding)}]"
)
logger.info(f"Retrieving context for query: {query}")
retrieved_docs = self.retriever.invoke(query)
@@ -147,7 +162,9 @@ class ChatPDF:
# Format the input for the LLM, including conversation history
formatted_input = {
"conversation_history": "\n".join(conversation_history) if conversation_history else "",
"conversation_history": (
"\n".join(conversation_history) if conversation_history else ""
),
"context": "\n\n".join(doc.page_content for doc in retrieved_docs),
"question": query,
}
@@ -155,9 +172,9 @@ class ChatPDF:
# Build the RAG chain
chain = (
RunnablePassthrough() # Passes the input as-is
| self.prompt # Formats the input for the LLM
| self.model # Queries the LLM
| StrOutputParser() # Parses the LLM's output
| self.prompt # Formats the input for the LLM
| self.model # Queries the LLM
| StrOutputParser() # Parses the LLM's output
)
logger.info("Generating response using the LLM.")
+1
View File
@@ -0,0 +1 @@
Miscellaneous collection of guides, code snippets etc.

Before

Width:  |  Height:  |  Size: 243 KiB

After

Width:  |  Height:  |  Size: 243 KiB

+5
View File
@@ -0,0 +1,5 @@
Step-by-step Jupyter Notebook examples on how to use MongoDB as a vector database, data store, memory provider etc. in AI applications.
The easiest way to run these notebooks is in Google Colab by clicking on the [Open In Colab](https://colab.research.google.com/assets/colab-badge.svg) button at the top of the notebook.
Some notebooks also have written articles/tutorials associated with them. To read the article, click the [View Article](https://img.shields.io/badge/View%20Article-blue) at the top of the notebook.
+1
View File
@@ -0,0 +1 @@
Jupyter Notebooks that cover advanced techniques such as vector quantization, parent document retrieval, hybrid search etc. that can help improve and/or optimize LLM applications.
@@ -435,7 +435,9 @@
"connection_string = getpass.getpass(\n",
" prompt=\"Enter connection string WITH USER + PASS here\"\n",
")\n",
"client = MongoClient(connection_string)\n",
"client = MongoClient(\n",
" connection_string, appname=\"devrel.showcase.geospatial_vector_search\"\n",
")\n",
"\n",
"# name your database and collection anything you want since it will be created when you enter your data\n",
"database = client[\"spritz_summer\"]\n",
@@ -110,7 +110,7 @@
"source": [
"MONGODB_URI = getpass.getpass(\"Enter your MongoDB URI: \")\n",
"mongodb_client = MongoClient(\n",
" MONGODB_URI, appname=\"devrel.content.retrieval_strategies_llamaindex\"\n",
" MONGODB_URI, appname=\"devrel.showcase.retrieval_strategies_llamaindex\"\n",
")"
]
},
@@ -117,7 +117,7 @@
"source": [
"MONGODB_URI = getpass.getpass(\"Enter your MongoDB URI: \")\n",
"mongodb_client = MongoClient(\n",
" MONGODB_URI, appname=\"devrel.content.retrieval_strategies_llamaindex\"\n",
" MONGODB_URI, appname=\"devrel.showcase.retrieval_strategies_llamaindex\"\n",
")"
]
},
@@ -1571,7 +1571,10 @@
"doc[\"date\"] = datetime.datetime.now()\n",
"\n",
"# Insert JSON reciepe into MongoDB\n",
"mongo_client = MongoClient(os.environ[\"MONGO_CONNECTION_STRING\"])\n",
"mongo_client = MongoClient(\n",
" os.environ[\"MONGO_CONNECTION_STRING\"],\n",
" appname=\"devrel.showcase.haystack_cooking_agent\",\n",
")\n",
"db = mongo_client[\"ai_shop\"]\n",
"collection = db[\"reciepes\"]\n",
"collection.insert_one(doc)"
+1
View File
@@ -0,0 +1 @@
Jupyter Notebooks showing how to build agentic AI applications using MongoDB's integrations with CrewAI, Haystack, LangGraph, LlamaIndex etc.
@@ -1027,7 +1027,9 @@
"def get_mongo_client(mongo_uri):\n",
" \"\"\"Establish and validate connection to the MongoDB.\"\"\"\n",
"\n",
" client = pymongo.MongoClient(mongo_uri, appname=\"devrel.showcase.python\")\n",
" client = pymongo.MongoClient(\n",
" mongo_uri, appname=\"devrel.showcase.claude_llamaindex_agent\"\n",
" )\n",
"\n",
" # Validate the connection\n",
" ping_result = client.admin.command(\"ping\")\n",
@@ -1027,7 +1027,9 @@
"def get_mongo_client(mongo_uri):\n",
" \"\"\"Establish and validate connection to the MongoDB.\"\"\"\n",
"\n",
" client = pymongo.MongoClient(mongo_uri, appname=\"devrel.showcase.python\")\n",
" client = pymongo.MongoClient(\n",
" mongo_uri, appname=\"devrel.showcase.openai_llamaindex_agent\"\n",
" )\n",
"\n",
" # Validate the connection\n",
" ping_result = client.admin.command(\"ping\")\n",
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
Performance benchmarks showing how MongoDB Atlas Vector Search compares against other vector databases.
+1
View File
@@ -0,0 +1 @@
Jupyter Notebooks showing how to evaluate GenAI applications.
+1 -1
View File
@@ -429,7 +429,7 @@
"metadata": {},
"outputs": [],
"source": [
"client = MongoClient(MONGODB_URI, appname=\"devrel.content.python\")\n",
"client = MongoClient(MONGODB_URI, appname=\"devrel.showcase.ragas_eval\")\n",
"DB_NAME = \"ragas_evals\"\n",
"db = client[DB_NAME]"
]
+1
View File
@@ -0,0 +1 @@
Example showcasing the usage of MongoDB in traditional machine learning applications.
@@ -1420,7 +1420,9 @@
"connection_string = getpass.getpass(\n",
" prompt=\"Enter connection string WITH USER + PASS here\"\n",
")\n",
"client = MongoClient(connection_string)\n",
"client = MongoClient(\n",
" connection_string, appname=\"devrel.showcase.tensorflow_mongodbcharts\"\n",
")\n",
"\n",
"# we are creating a new collection in the same database as before\n",
"database = client[\"horoscopes\"]\n",
+1
View File
@@ -0,0 +1 @@
Jupyter Notebooks showing how to build RAG applications using different LLM providers, frameworks and MongoDB.
@@ -330,7 +330,9 @@
"def get_mongo_client(mongo_uri):\n",
" \"\"\"Establish connection to the MongoDB.\"\"\"\n",
" try:\n",
" client = pymongo.MongoClient(mongo_uri, appname=\"devrel.content.python\")\n",
" client = pymongo.MongoClient(\n",
" mongo_uri, appname=\"devrel.showcase.rag_llamaindex_mongodb\"\n",
" )\n",
" print(\"Connection to MongoDB successful\")\n",
" return client\n",
" except pymongo.errors.ConnectionFailure as e:\n",
@@ -378,7 +378,9 @@
"from pymongo import MongoClient\n",
"\n",
"# Initialize MongoDB python client\n",
"client = MongoClient(MONGODB_URI, appname=\"devrel.content.python\")\n",
"client = MongoClient(\n",
" MONGODB_URI, appname=\"devrel.showcase.mongodb_langchain_cache_memory\"\n",
")\n",
"\n",
"DB_NAME = \"langchain_chatbot\"\n",
"COLLECTION_NAME = \"data\"\n",
@@ -1788,7 +1788,7 @@
"import { MongoClient } from \"npm:mongodb\";\n",
"\n",
"// Initialize MongoDB client\n",
"const client = new MongoClient(MONGODB_URI);\n",
"const client = new MongoClient(MONGODB_URI, {appName=\"devrel.showcase.langchain_js_memory\"});\n",
"const DB_NAME = \"langchain_chatbot\";\n",
"const COLLECTION_NAME = \"data\";\n",
"const INDEX_NAME = \"vector_index\";\n",
@@ -1184,7 +1184,9 @@
"def get_mongo_client(mongo_uri):\n",
" \"\"\"Establish connection to the MongoDB.\"\"\"\n",
" try:\n",
" client = pymongo.MongoClient(mongo_uri, appname=\"devrel.content.python\")\n",
" client = pymongo.MongoClient(\n",
" mongo_uri, appname=\"devrel.showcase.naive_rag_llamaindex\"\n",
" )\n",
" print(\"Connection to MongoDB successful\")\n",
" return client\n",
" except pymongo.errors.ConnectionFailure as e:\n",
+4 -4
View File
@@ -1833,7 +1833,9 @@
"def get_mongo_client(mongo_uri):\n",
" \"\"\"Establish connection to the MongoDB.\"\"\"\n",
" try:\n",
" client = pymongo.MongoClient(mongo_uri, appname=\"devrel.content.python\")\n",
" client = pymongo.MongoClient(\n",
" mongo_uri, appname=\"devrel.showcase.rag_openai_text_embedding_3\"\n",
" )\n",
" print(\"Connection to MongoDB successful\")\n",
" return client\n",
" except pymongo.errors.ConnectionFailure as e:\n",
@@ -1977,9 +1979,7 @@
" \"plot\": 1, # Include the plot field\n",
" \"title\": 1, # Include the title field\n",
" \"genres\": 1, # Include the genres field\n",
" \"score\": {\n",
" \"$meta\": \"vectorSearchScore\" # Include the search score\n",
" },\n",
" \"score\": {\"$meta\": \"vectorSearchScore\"}, # Include the search score\n",
" }\n",
" },\n",
" ]\n",
+1 -1
View File
@@ -479,7 +479,7 @@
"from langchain_mongodb import MongoDBAtlasVectorSearch\n",
"from pymongo import MongoClient\n",
"\n",
"client = MongoClient(MONGODB_URI, appname=\"devrel.content.python\")\n",
"client = MongoClient(MONGODB_URI, appname=\"devrel.showcase.chunking_strategies\")\n",
"DB_NAME = \"evals\"\n",
"COLLECTION_NAME = \"chunking\"\n",
"ATLAS_VECTOR_SEARCH_INDEX_NAME = \"vector_index\"\n",
@@ -673,7 +673,9 @@
"def get_mongo_client(mongo_uri):\n",
" \"\"\"Establish connection to the MongoDB.\"\"\"\n",
" try:\n",
" client = pymongo.MongoClient(mongo_uri, appname=\"devrel.content.python\")\n",
" client = pymongo.MongoClient(\n",
" mongo_uri, appname=\"devrel.showcase.rag_llama3_huggingface\"\n",
" )\n",
" print(\"Connection to MongoDB successful\")\n",
" return client\n",
" except pymongo.errors.ConnectionFailure as e:\n",
@@ -812,9 +814,7 @@
" \"fullplot\": 1, # Include the plot field\n",
" \"title\": 1, # Include the title field\n",
" \"genres\": 1, # Include the genres field\n",
" \"score\": {\n",
" \"$meta\": \"vectorSearchScore\" # Include the search score\n",
" },\n",
" \"score\": {\"$meta\": \"vectorSearchScore\"}, # Include the search score\n",
" }\n",
" }\n",
"\n",
@@ -1482,7 +1482,9 @@
"def get_mongo_client(mongo_uri):\n",
" \"\"\"Establish connection to the MongoDB.\"\"\"\n",
" try:\n",
" client = pymongo.MongoClient(mongo_uri, appname=\"devrel.content.python\")\n",
" client = pymongo.MongoClient(\n",
" mongo_uri, appname=\"devrel.showcase.rag_huggingface_gemma\"\n",
" )\n",
" print(\"Connection to MongoDB successful\")\n",
" return client\n",
" except pymongo.errors.ConnectionFailure as e:\n",
@@ -1601,9 +1603,7 @@
" \"fullplot\": 1, # Include the plot field\n",
" \"title\": 1, # Include the title field\n",
" \"genres\": 1, # Include the genres field\n",
" \"score\": {\n",
" \"$meta\": \"vectorSearchScore\" # Include the search score\n",
" },\n",
" \"score\": {\"$meta\": \"vectorSearchScore\"}, # Include the search score\n",
" }\n",
" }\n",
"\n",
@@ -152,7 +152,7 @@
"MONGODB_COLLECTION = \"\"\n",
"# Instantiate the MongoDB client\n",
"mongodb_client = MongoClient(\n",
" MONGODB_URI, appname=\"devrel.content.selfquery_mongodb_unstructured\"\n",
" MONGODB_URI, appname=\"devrel.showcase.selfquery_mongodb_unstructured\"\n",
")"
]
},
+1
View File
@@ -0,0 +1 @@
Self-paced hands-on workshops to learn how to build GenAI applications.
+1
View File
@@ -0,0 +1 @@
Contributions from our AI partners.
+1
View File
@@ -28,6 +28,7 @@ ignore = [
"F841", # Local variable `full_text_search_result` is assigned to but never used"
"UP006", # Use `list` instead of `List` for type annotation"
"UP035", # `typing.List` is deprecated, use `list` instead"
"E731", # Do not assign a `lambda` expression, use a `def`
]
unfixable = ["F401"]
+1
View File
@@ -0,0 +1 @@
Tools and utilities to help with quick prototyping of GenAI applications using MongoDB.