Skip to content

Conversation

YasharF
Copy link
Contributor

@YasharF YasharF commented May 26, 2025

This PR is adds MongoDBCache and MongoDBAtlasSemanticCache functionality for feature parity with Python LangChain.

  • Add MongoDBCache and MongoDBAtlasSemanticCache classes to @langchain/mongodb for key-value and semantic LLM caching.
  • Implement integration tests for both cache types.
  • Update documentation:
    • Add guide for using MongoDB as a key-value cache.
    • Add guide for using MongoDB Atlas as semantic cache.
    • Added additional information and clarification on semantic vs. key-value caching.
  • Fix test DB usage to consistently use langchain_test collection for all MongoDB tests and clean up the DB after running the tests when not using a container.

Partial Fix for #7048 (fixes the mongoDB use case)

x: YasharF3
linkedin.com/in/yasharf

Copy link

vercel bot commented May 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
langchainjs-docs Ready Ready Preview Sep 10, 2025 5:09am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchainjs-api-refs Ignored Ignored Sep 10, 2025 5:09am

@YasharF YasharF force-pushed the mongodb-semantic-cache branch from a0b3193 to 4ec1f1f Compare May 26, 2025 00:44
@YasharF YasharF force-pushed the mongodb-semantic-cache branch from 4ec1f1f to 66b6c00 Compare May 26, 2025 02:11
@YasharF YasharF changed the title feat(mongodb): add MongoDB LLM cache integrations feat(mongodb): add MongoDB LLM cache - Python parity May 26, 2025
@YasharF YasharF changed the title feat(mongodb): add MongoDB LLM cache - Python parity feat(mongodb): add MongoDB LLM cache May 26, 2025
@YasharF
Copy link
Contributor Author

YasharF commented May 27, 2025

The current remaining task is to update docs by moving the in-text code examples to the examples folder, and some minor document adjustments as part of that task. I believe the changes are ready for review.

@YasharF YasharF marked this pull request as ready for review May 27, 2025 19:02
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label May 27, 2025
@YasharF
Copy link
Contributor Author

YasharF commented May 27, 2025

Moved sample codes to examples/

@christian-bromann
Copy link
Member

@YasharF thanks for your contribution 🙏 our team has been focused on working on LangChain v1 and unfortunately couldn't give PRs as much attention as they need. We are in an effort to picking up where we left off. I will take this PR and discuss it with the team. Please stay tuned!

@YasharF YasharF force-pushed the mongodb-semantic-cache branch from e2b4789 to 13c49e6 Compare September 10, 2025 04:36
Copy link

changeset-bot bot commented Sep 10, 2025

⚠️ No Changeset found

Latest commit: bac2a64

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@YasharF
Copy link
Contributor Author

YasharF commented Sep 10, 2025

Squashed and rebased.

I saw a comment in another one of my PRs, that docs are now in https://github.com/langchain-ai/docs/tree/main/src/oss/javascript . Do you want me to take my doc updates out of this PR and just update the docs there, and have the two repos be out of sync, or should I do something else like update the other doc repo and delete the mongodb doc files from this repo entirely?

- Add `MongoDBCache` and `MongoDBAtlasSemanticCache` classes to `@langchain/mongodb` for key-value and semantic LLM caching.
- Implement integration tests for both cache types.
- Update documentation:
  - Add guide for using MongoDB as a key-value cache.
  - Add guide for using MongoDB Atlas as semantic cache.
  - Added additional information and clarification on semantic vs. key-value caching.
- Fix test issues
  - DB usage to consistently use `langchain_test` collection for all MongoDB tests.
  - Use namespace for db naming for all MongoDB tests
  - Improve test error msg if there is no docker
  - Always create a search index for a test vector store since the test may fail under some setups otherwise
@christian-bromann
Copy link
Member

Do you want me to take my doc updates out of this PR and just update the docs there

Let's land this first and then raise a PR for docs.

or should I do something else

All good so far, let me discuss this with the team and get back to you.

@hntrl hntrl self-assigned this Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants