The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
docs: Update couchbase vector store docs (#30710)
Nithish Raghunandanan893942651bd3
diff --git a/docs/docs/integrations/llm_caching.ipynb b/docs/docs/integrations/llm_caching.ipynbindex 3788ad5bfd..ccc3c6edfb 100644--- a/docs/docs/integrations/llm_caching.ipynb+++ b/docs/docs/integrations/llm_caching.ipynb@@ -2669,7 +2669,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -qU langchain_couchbase couchbase"+ "%pip install -qU langchain_couchbase"]},{diff --git a/docs/docs/integrations/providers/couchbase.mdx b/docs/docs/integrations/providers/couchbase.mdxindex 35ef674806..b9633b3824 100644--- a/docs/docs/integrations/providers/couchbase.mdx+++ b/docs/docs/integrations/providers/couchbase.mdx@@ -17,7 +17,7 @@ pip install langchain-couchbaseSee a [usage example](/docs/integrations/vectorstores/couchbase).```python-from langchain_couchbase import CouchbaseVectorStore+from langchain_couchbase import CouchbaseSearchVectorStore```## Document loaderdiff --git a/docs/docs/integrations/vectorstores/couchbase.ipynb b/docs/docs/integrations/vectorstores/couchbase.ipynbindex efc6b8a4c7..142f227e6b 100644--- a/docs/docs/integrations/vectorstores/couchbase.ipynb+++ b/docs/docs/integrations/vectorstores/couchbase.ipynb@@ -20,15 +20,26 @@"source": ["## Setup\n","\n",- "To access the `CouchbaseVectorStore` you first need to install the `langchain-couchbase` partner package:"+ "To access the `CouchbaseSearchVectorStore` you first need to install the `langchain-couchbase` partner package:"]},{"cell_type": "code",- "execution_count": null,+ "execution_count": 1,"id": "bec8d532-fec7-4dc7-9be3-020aa7bdb01f","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "\n",+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.1.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.0.1\u001b[0m\n",+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",+ "Note: you may need to restart the kernel to use updated packages.\n"+ ]+ }+ ],"source": ["pip install -qU langchain-couchbase"]@@ -45,10 +56,20 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 2,"id": "d98e3baa","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdin",+ "output_type": "stream",+ "text": [+ "Enter the connection string for the Couchbase cluster: ········\n",+ "Enter the username for the Couchbase cluster: ········\n",+ "Enter the password for the Couchbase cluster: ········\n"+ ]+ }+ ],"source": ["import getpass\n","\n",@@ -104,7 +125,7 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 3,"id": "9986c6b9","metadata": {},"outputs": [],@@ -135,14 +156,14 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 4,"id": "1b1d0a26-e9d4-4823-9800-9549d24d3d16","metadata": {},"outputs": [],"source": ["BUCKET_NAME = \"langchain_bucket\"\n","SCOPE_NAME = \"_default\"\n",- "COLLECTION_NAME = \"default\"\n",+ "COLLECTION_NAME = \"_default\"\n","SEARCH_INDEX_NAME = \"langchain-test-index\""]},@@ -174,7 +195,7 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 5,"id": "6706efdd","metadata": {},"outputs": [],@@ -188,14 +209,14 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 6,"id": "33db4670-76c5-49ba-94d6-a8fa35583058","metadata": {},"outputs": [],"source": [- "from langchain_couchbase.vectorstores import CouchbaseVectorStore\n",+ "from langchain_couchbase.vectorstores import CouchbaseSearchVectorStore\n","\n",- "vector_store = CouchbaseVectorStore(\n",+ "vector_store = CouchbaseSearchVectorStore(\n"," cluster=cluster,\n"," bucket_name=BUCKET_NAME,\n"," scope_name=SCOPE_NAME,\n",@@ -217,12 +238,12 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 7,"id": "49c38634","metadata": {},"outputs": [],"source": [- "vector_store_specific = CouchbaseVectorStore(\n",+ "vector_store_specific = CouchbaseSearchVectorStore(\n"," cluster=cluster,\n"," bucket_name=BUCKET_NAME,\n"," scope_name=SCOPE_NAME,\n",@@ -250,10 +271,30 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 8,"id": "65a35f00","metadata": {},- "outputs": [],+ "outputs": [+ {+ "data": {+ "text/plain": [+ "['4a6b5252-24ca-4e48-97a9-c33211fc7736',\n",+ " '594a413d-761a-44f1-8f0c-6418700b198d',\n",+ " 'fdd8461c-f4e3-4c85-af8e-7782ce4d2311',\n",+ " '3f6a82b2-7464-4eee-b209-cbca5a236a8a',\n",+ " 'df8b87ad-464e-4f83-a007-ccf5a8fa4ff5',\n",+ " 'aa18502e-6fb4-4578-9c63-b9a299259b01',\n",+ " '8c55a17d-5fa7-4c30-a55d-7ded0d39bf46',\n",+ " '41b68c5a-ebf5-4d7a-a079-5e32926ca484',\n",+ " '146ac3e0-474a-422a-b0ac-c9fee718396b',\n",+ " 'e44941e9-fb3a-4090-88a0-9ffecee3e80e']"+ ]+ },+ "execution_count": 8,+ "metadata": {},+ "output_type": "execute_result"+ }+ ],"source": ["from uuid import uuid4\n","\n",@@ -336,10 +377,21 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 9,"id": "3a05f294","metadata": {},- "outputs": [],+ "outputs": [+ {+ "data": {+ "text/plain": [+ "True"+ ]+ },+ "execution_count": 9,+ "metadata": {},+ "output_type": "execute_result"+ }+ ],"source": ["vector_store.delete(ids=[uuids[-1]])"]@@ -362,10 +414,19 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 10,"id": "8e00bb23","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "* Building an exciting new project with LangChain - come check it out! [{'source': 'tweet'}]\n",+ "* LangGraph is the best framework for building stateful, agentic applications! [{'source': 'tweet'}]\n"+ ]+ }+ ],"source": ["results = vector_store.similarity_search(\n"," \"LangChain provides abstractions to make working with LLMs easy\",\n",@@ -387,10 +448,18 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 11,"id": "24b146b2-55a2-4fe8-8659-3649032f5dc7","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "* [SIM=0.553145] The weather forecast for tomorrow is cloudy and overcast, with a high of 62 degrees. [{'source': 'news'}]\n"+ ]+ }+ ],"source": ["results = vector_store.similarity_search_with_score(\"Will it be hot tomorrow?\", k=1)\n","for res, score in results:\n",@@ -415,10 +484,18 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 12,"id": "ffa743dc-4e89-405b-ad71-7390338889e6","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "page_content='I had chocalate chip pancakes and scrambled eggs for breakfast this morning.' metadata={'source': 'tweet'}\n"+ ]+ }+ ],"source": ["query = \"What did I eat for breakfast today?\"\n","results = vector_store.similarity_search(query, fields=[\"metadata.source\"])\n",@@ -452,10 +529,18 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 13,"id": "7d2e607d-6bbc-4cef-83e3-b6a28bb269ea","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "{'author': 'John Doe', 'date': '2016-01-01', 'rating': 2, 'source': '../../how_to/state_of_the_union.txt'}\n"+ ]+ }+ ],"source": ["from langchain_community.document_loaders import TextLoader\n","from langchain_text_splitters import CharacterTextSplitter\n",@@ -489,10 +574,20 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 14,"id": "dc06ba4a-8a6b-4c55-bb69-95cd92db273f","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "page_content='One of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \n",+ "\n",+ "And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.' metadata={'author': 'John Doe'}\n"+ ]+ }+ ],"source": ["query = \"What did the president say about Ketanji Brown Jackson\"\n","results = vector_store.similarity_search(\n",@@ -516,10 +611,20 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 15,"id": "fd4749e6-ef4f-4cb5-95ff-37c4fa8283d8","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "page_content='A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by Democrats and Republicans. \n",+ "\n",+ "And if we are to advance liberty and justice, we need to secure the Border and fix the immigration system.' metadata={'author': 'Jane Doe'}\n"+ ]+ }+ ],"source": ["query = \"What did the president say about Ketanji Brown Jackson\"\n","results = vector_store.similarity_search(\n",@@ -543,10 +648,24 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 16,"id": "b7b47e7d-c32f-4999-bce9-3c3c3cebffd0","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "page_content='We are cutting off Russia’s largest banks from the international financial system. \n",+ "\n",+ "Preventing Russia’s central bank from defending the Russian Ruble making Putin’s $630 Billion “war fund” worthless. \n",+ "\n",+ "We are choking off Russia’s access to technology that will sap its economic strength and weaken its military for years to come. \n",+ "\n",+ "Tonight I say to the Russian oligarchs and corrupt leaders who have bilked billions of dollars off this violent regime no more.' metadata={'author': 'Jane Doe', 'date': '2017-01-01', 'rating': 3, 'source': '../../how_to/state_of_the_union.txt'}\n"+ ]+ }+ ],"source": ["query = \"Any mention about independence?\"\n","results = vector_store.similarity_search(\n",@@ -575,10 +694,18 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 17,"id": "7e8bf7c5-07d1-4c3f-86d7-1fa3a454dc7f","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "(Document(id='8616f24425b94a52af3d32d20e6ffb4b', metadata={'author': 'John Doe', 'date': '2014-01-01', 'rating': 5, 'source': '../../how_to/state_of_the_union.txt'}, page_content='In this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. \\n\\nWe have fought for freedom, expanded liberty, defeated totalitarianism and terror. \\n\\nAnd built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself.'), 0.361933544533826)\n"+ ]+ }+ ],"source": ["query = \"Any mention about independence?\"\n","results = vector_store.similarity_search_with_score(\n",@@ -609,10 +736,18 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 18,"id": "dd0fe7f1-aa40-4c6f-889b-99ad5efcd88b","metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "(Document(id='d9b36ef70b8942dda4db63563f51cf0f', metadata={'author': 'Jane Doe', 'date': '2017-01-01', 'rating': 3, 'source': '../../how_to/state_of_the_union.txt'}, page_content='We are cutting off Russia’s largest banks from the international financial system. \\n\\nPreventing Russia’s central bank from defending the Russian Ruble making Putin’s $630 Billion “war fund” worthless. \\n\\nWe are choking off Russia’s access to technology that will sap its economic strength and weaken its military for years to come. \\n\\nTonight I say to the Russian oligarchs and corrupt leaders who have bilked billions of dollars off this violent regime no more.'), 0.7107075545629284)\n"+ ]+ }+ ],"source": ["query = \"Any mention about independence?\"\n","results = vector_store.similarity_search_with_score(\n",@@ -655,13 +790,24 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 19,"id": "3666265a","metadata": {},- "outputs": [],+ "outputs": [+ {+ "data": {+ "text/plain": [+ "[Document(id='3f6a82b2-7464-4eee-b209-cbca5a236a8a', metadata={'source': 'news'}, page_content='Robbers broke into the city bank and stole $1 million in cash.')]"+ ]+ },+ "execution_count": 19,+ "metadata": {},+ "output_type": "execute_result"+ }+ ],"source": ["retriever = vector_store.as_retriever(\n",- " search_type=\"similarity_score_threshold\",\n",+ " search_type=\"similarity\",\n"," search_kwargs={\"k\": 1, \"score_threshold\": 0.5},\n",")\n","retriever.invoke(\"Stealing from the bank is a crime\", filter={\"source\": \"news\"})"@@ -740,7 +886,7 @@"source": ["## API reference\n","\n",- "For detailed documentation of all `CouchbaseVectorStore` features and configurations head to the API reference: https://python.langchain.com/api_reference/couchbase/vectorstores/langchain_couchbase.vectorstores.CouchbaseVectorStore.html"+ "For detailed documentation of all `CouchbaseSearchVectorStore` features and configurations head to the API reference: https://couchbase-ecosystem.github.io/langchain-couchbase/langchain_couchbase.html "]}],@@ -760,7 +906,7 @@"name": "python","nbconvert_exporter": "python","pygments_lexer": "ipython3",- "version": "3.11.9"+ "version": "3.10.13"}},"nbformat": 4,diff --git a/docs/scripts/vectorstore_feat_table.py b/docs/scripts/vectorstore_feat_table.pyindex 4e2af5e153..dae42f9596 100644--- a/docs/scripts/vectorstore_feat_table.py+++ b/docs/scripts/vectorstore_feat_table.py@@ -6,7 +6,7 @@ from langchain_astradb import AstraDBVectorStorefrom langchain_chroma import Chromafrom langchain_community import vectorstoresfrom langchain_core.vectorstores import VectorStore-from langchain_couchbase import CouchbaseVectorStore+from langchain_couchbase import CouchbaseSearchVectorStorefrom langchain_milvus import Milvusfrom langchain_mongodb import MongoDBAtlasVectorSearchfrom langchain_pinecone import PineconeVectorStore@@ -28,7 +28,7 @@ from_partners = [("PineconeVectorStore", PineconeVectorStore),("Milvus", Milvus),("MongoDBAtlasVectorSearch", MongoDBAtlasVectorSearch),- ("CouchbaseVectorStore", CouchbaseVectorStore),+ ("CouchbaseSearchVectorStore", CouchbaseSearchVectorStore),]VECTORSTORE_TEMPLATE = """\@@ -184,7 +184,7 @@ def get_vectorstore_table():"Local/Cloud": "Local","IDs in add Documents": True,},- "CouchbaseVectorStore": {+ "CouchbaseSearchVectorStore": {"Delete by ID": True,"Filtering": True,"similarity_search_by_vector": True,diff --git a/libs/community/langchain_community/vectorstores/couchbase.py b/libs/community/langchain_community/vectorstores/couchbase.pyindex 0c9897110c..b853cb7900 100644--- a/libs/community/langchain_community/vectorstores/couchbase.py+++ b/libs/community/langchain_community/vectorstores/couchbase.py@@ -15,7 +15,7 @@ if TYPE_CHECKING:@deprecated(since="0.2.4",removal="1.0",- alternative_import="langchain_couchbase.CouchbaseVectorStore",+ alternative_import="langchain_couchbase.CouchbaseSearchVectorStore",)class CouchbaseVectorStore(VectorStore):"""`Couchbase Vector Store` vector store.