{"id":8786,"date":"2024-10-04T10:59:44","date_gmt":"2024-10-04T17:59:44","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=8786"},"modified":"2024-11-13T07:32:58","modified_gmt":"2024-11-13T15:32:58","slug":"announcing-azure-cosmos-db-integration-with-langchain-js","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/announcing-azure-cosmos-db-integration-with-langchain-js\/","title":{"rendered":"Announcing Azure Cosmos DB Integration with LangChain.js!"},"content":{"rendered":"<h2>Announcing Azure Cosmos DB Vector Store Integration with LangChain.js!<\/h2>\n<p>We&#8217;re simplifying AI app development by integrating <strong>Azure Cosmos DB&#8217;s<\/strong> cost-effective and scalable vector search directly with <strong>LangChain.js<\/strong>! This powerful combination empowers JavaScript developers to efficiently manage fast and accurate data retrieval with Azure Cosmos DB&#8217;s scalability and efficient vector search capabilities. This offers a powerful solution for developers aiming to leverage vector search capabilities in their applications. Azure Cosmos DB supports <a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/nosql\/vector-search\">vector indexing and search<\/a>, allowing for efficient handling of high-dimensional vectors. By using Azure Cosmos DB\u2019s vector store, developers can keep vectors directly within their documents, enabling seamless integration with LangChain.js for advanced vector search queries.<\/p>\n<p>To get started, simply import the package using a package manager of your choice<\/p>\n<ul>\n<li><strong><strong>npm: <\/strong><\/strong><code class=\"language-default\">npm install @langchain\/azure-cosmosdb @langchain\/core<\/code><\/li>\n<li><strong>yarn: <\/strong><code class=\"language-default\">yarn add @langchain\/azure-cosmosdb @langchain\/core<\/code><\/li>\n<li><strong>pnpm:<\/strong> <code class=\"language-default\">pnpm add @langchain\/azure-cosmosdb @langchain\/core<\/code><\/li>\n<\/ul>\n<p>Check out the <a href=\"https:\/\/js.langchain.com\/docs\/how_to\/installation#installing-integration-packages\" target=\"_blank\" rel=\"noopener\">LangChain.js documentation for full details on installation<\/a>. Next, you should be ready to start building AI apps with either <a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/nosql\/vector-search\" target=\"_blank\" rel=\"noopener\"><strong>Azure Cosmos DB for NoSQL<\/strong><\/a> or <a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/mongodb\/vcore\/vector-search\" target=\"_blank\" rel=\"noopener\"><strong>Azure Cosmos DB for MongoDB vCore<\/strong><\/a>.<\/p>\n<h2>Azure Cosmos DB for NoSQL<\/h2>\n<p><a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/nosql\/vector-search\" target=\"_blank\" rel=\"noopener\"><strong>Azure Cosmos DB for NoSQL<\/strong><\/a> is a world-class schema-free database that has built-in <a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/azure-cosmos-db-vector-search-with-diskann-part-1-full-space-search\/\" target=\"_blank\" rel=\"noopener\">vector indexing and search<\/a> at any scale. This provides flexibility for developers, mission-critical workloads, and serverless applications.<\/p>\n<p>You can easily import the integration functions for use in your JavaScript applications using:<\/p>\n<pre class=\"prettyprint language-js\"><code class=\"language-js\">import { AzureCosmosDBNoSQLVectorStore } from \"@langchain\/azure-cosmosdb\";\r\n\r\n<\/code><\/pre>\n<p>Now you\u2019re ready to start building AI apps using <a href=\"https:\/\/js.langchain.com\/v0.2\/docs\/integrations\/vectorstores\/azure_cosmosdb_nosql\/\" target=\"_blank\" rel=\"noopener\">Azure Cosmos DB for NoSQL&#8217;s LangChain.js<\/a> integration!<\/p>\n<p>&nbsp;<\/p>\n<h2>Azure Cosmos DB for MongoDB vCore<\/h2>\n<p><a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/mongodb\/vcore\/vector-search\" target=\"_blank\" rel=\"noopener\"><strong>Azure Cosmos DB for MongoDB vCore<\/strong><\/a> provides a fully managed, MongoDB-compatible database service with native vector indexing and search capabilities. This allows developers to use their existing MongoDB skills and tools while benefiting from Azure\u2019s robust infrastructure.<\/p>\n<p>You can easily import the integration functions for use in your JavaScript applications using:<\/p>\n<pre class=\"prettyprint language-js\"><code class=\"language-js\">import { AzureCosmosDBMongoDBVectorStore, AzureCosmosDBMongoDBSimilarityType, } from \"@langchain\/azure-cosmosdb\";<\/code><\/pre>\n<p>Now you\u2019re ready to start building AI apps using <a href=\"https:\/\/js.langchain.com\/v0.1\/docs\/integrations\/vectorstores\/azure_cosmosdb\/\" target=\"_blank\" rel=\"noopener\">Azure Cosmos DB for MongoDB vCore\u2019s LangChain.js<\/a> integration!<\/p>\n<p>&nbsp;<\/p>\n<h2>Build a Serverless AI Chat with RAG using LangChain.js<\/h2>\n<p>Creating AI applications can often feel daunting and time-intensive. However, leveraging <a href=\"https:\/\/js.langchain.com\/v0.1\/docs\/integrations\/vectorstores\/azure_cosmosdb\/\" target=\"_blank\" rel=\"noopener\">LangChain.js alongside Azure Cosmos DB<\/a> can significantly streamline the development process. In this <a href=\"https:\/\/learn.microsoft.com\/en-us\/samples\/azure-samples\/serverless-chat-langchainjs\/serverless-chat-langchainjs\/\" target=\"_blank\" rel=\"noopener\">sample<\/a>, we\u2019ll explore a chatbot application that utilizes a collection of enterprise documents to provide insightful responses to user inquiries. Check out the code on Github<\/p>\n<p>To help you get started, we\u2019ve included sample data that you can easily use, but feel free to substitute it with your own content! Our example features a fictional company, Contoso Real Estate, which enables customers to ask support-related questions about its products. The sample data encompasses essential documents, including the terms of service, privacy policy, and a support guide.<\/p>\n<h2><img decoding=\"async\" class=\"wp-image-8817 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2024\/10\/a-diagram-of-a-software-flow-description-automati.png\" alt=\"A diagram of a software flow Description automatically generated\" width=\"749\" height=\"660\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2024\/10\/a-diagram-of-a-software-flow-description-automati.png 1180w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2024\/10\/a-diagram-of-a-software-flow-description-automati-300x264.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2024\/10\/a-diagram-of-a-software-flow-description-automati-1024x903.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2024\/10\/a-diagram-of-a-software-flow-description-automati-768x677.png 768w\" sizes=\"(max-width: 749px) 100vw, 749px\" \/><\/h2>\n<p><a href=\"https:\/\/learn.microsoft.com\/en-us\/samples\/azure-samples\/serverless-chat-langchainjs\/serverless-chat-langchainjs\/\" target=\"_blank\" rel=\"noopener\">The application<\/a> is made from multiple components and is a great starting point for building more complex AI applications.:<\/p>\n<ul>\n<li>A web app made with a single chat web component built with\u00a0<a href=\"https:\/\/lit.dev\/\" target=\"_blank\" rel=\"noopener\">Lit<\/a>\u00a0and hosted on\u00a0<a href=\"https:\/\/learn.microsoft.com\/azure\/static-web-apps\/overview\" target=\"_blank\" rel=\"noopener\">Azure Static Web Apps<\/a>.<\/li>\n<li>A serverless API built with\u00a0<a href=\"https:\/\/learn.microsoft.com\/azure\/azure-functions\/functions-overview?pivots=programming-language-javascript\" target=\"_blank\" rel=\"noopener\">Azure Functions<\/a>\u00a0and using\u00a0<a href=\"https:\/\/js.langchain.com\/\" target=\"_blank\" rel=\"noopener\">LangChain.js<\/a>\u00a0to ingest the documents and generate responses to the user chat queries.<\/li>\n<li>A database to store the text extracted from the documents and the vectors generated by LangChain.js, using\u00a0<a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/nosql\/\" target=\"_blank\" rel=\"noopener\">Azure Cosmos DB for NoSQL<\/a>.<\/li>\n<li>A file storage to store the source documents, using\u00a0<a href=\"https:\/\/learn.microsoft.com\/azure\/storage\/blobs\/storage-blobs-introduction\" target=\"_blank\" rel=\"noopener\">Azure Blob Storage<\/a>.<\/li>\n<\/ul>\n<p>And there you have it! Azure Cosmos DB now features vector store integration with LangChain.js, making it even easier for developers to take advantage of fast and efficient vector search capabilities in their JavaScript AI applications, and there are many ways to get started quickly.<\/p>\n<h2>Learn more about Vector Search in Azure Cosmos DB<\/h2>\n<ul>\n<li><a href=\"https:\/\/js.langchain.com\/\" target=\"_blank\" rel=\"noopener\">LangChain.js documentation<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/Azure-Samples\/serverless-chat-langchainjs\" target=\"_blank\" rel=\"noopener\">Build a Serverless RAG Chatbot with Azure Cosmos DB + LangChain.JS<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoft\/generative-ai-for-beginners\" target=\"_blank\" rel=\"noopener\">Generative AI For Beginners<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/Azure-Samples\/langchainjs-quickstart-demo\" target=\"_blank\" rel=\"noopener\">Ask YouTube: LangChain.js + Azure Quickstart sample<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/nosql\/vector-search\" target=\"_blank\" rel=\"noopener\">Azure Cosmos DB for NoSQL<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/mongodb\/vcore\/vector-search\" target=\"_blank\" rel=\"noopener\">Azure Cosmos DB for MongoDB vCore<\/a><\/li>\n<\/ul>\n<h2>Leave a review<\/h2>\n<p>Tell us about your Azure Cosmos DB experience! Leave a review on PeerSpot and we\u2019ll gift you $50. <a href=\"https:\/\/peerspotdotcom.my.site.com\/proReviews\/?SalesOpportunityProduct=00kPy000004TKXJIA4&amp;productPeerspotNumber=30881&amp;CalendlyAccount=peerspot&amp;CalendlyFormLink=peerspot-product-reviews-ps-gc-vi-sf-50&amp;giftCard=50\" target=\"_blank\" rel=\"noopener\">Get started here<\/a>.<\/p>\n<h2>About Azure Cosmos DB<\/h2>\n<p>Azure Cosmos DB is a fully managed and serverless NoSQL and vector database for modern app development, including AI applications. With its SLA-backed speed and availability as well as instant dynamic scalability, it is ideal for real-time NoSQL and MongoDB applications that require high performance and distributed computing over massive volumes of NoSQL and vector data.<\/p>\n<p><a href=\"https:\/\/cosmos.azure.com\/try\/\" target=\"_blank\" rel=\"noopener\">Try Azure Cosmos DB for free here.<\/a> To stay in the loop on Azure Cosmos DB updates, follow us on <a href=\"https:\/\/twitter.com\/AzureCosmosDB\" target=\"_blank\" rel=\"noopener\">X<\/a>, <a href=\"https:\/\/aka.ms\/AzureCosmosDBYouTube\" target=\"_blank\" rel=\"noopener\">YouTube<\/a>, and <a href=\"https:\/\/www.linkedin.com\/company\/azure-cosmos-db\/\" target=\"_blank\" rel=\"noopener\">LinkedIn<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Announcing Azure Cosmos DB Vector Store Integration with LangChain.js! We&#8217;re simplifying AI app development by integrating Azure Cosmos DB&#8217;s cost-effective and scalable vector search directly with LangChain.js! This powerful combination empowers JavaScript developers to efficiently manage fast and accurate data retrieval with Azure Cosmos DB&#8217;s scalability and efficient vector search capabilities. This offers a powerful [&hellip;]<\/p>\n","protected":false},"author":118435,"featured_media":8818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1610,15,14,1884],"tags":[1236,1892,1920,1867,1868],"class_list":["post-8786","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-mongodb-api","category-core-sql-api","category-javascript-sdk","tag-ai","tag-generative-ai","tag-langchain","tag-vector-db","tag-vector-search"],"acf":[],"blog_post_summary":"<p>Announcing Azure Cosmos DB Vector Store Integration with LangChain.js! We&#8217;re simplifying AI app development by integrating Azure Cosmos DB&#8217;s cost-effective and scalable vector search directly with LangChain.js! This powerful combination empowers JavaScript developers to efficiently manage fast and accurate data retrieval with Azure Cosmos DB&#8217;s scalability and efficient vector search capabilities. This offers a powerful [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/8786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/118435"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=8786"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/8786\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/8818"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=8786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=8786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=8786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}