Skip to content

Commit 924a1af

Browse files
authored
Merge pull request #42 from couchbase-examples/DA-767-update-tutorials-as-per-couchbase-langchain-version
Updated lanchain-couchbase version
2 parents b67b6aa + c4ddcae commit 924a1af

38 files changed

+1713
-1169
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ For more information on creating a vector search index, please follow the [instr
7676
{
7777
"type": "fulltext-index",
7878
"name": "vector_search_azure",
79-
"uuid": "12fe1360b64a69c0",
79+
"uuid": "",
8080
"sourceType": "gocbcore",
8181
"sourceName": "vector-search-testing",
82-
"sourceUUID": "ee9841e7b3a580d76862bb00927affc4",
8382
"planParams": {
8483
"maxPartitionsPerPIndex": 64,
8584
"indexPartitions": 16

ag2/agentchat_RetrieveChat_couchbase.ipynb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"outputs": [],
5050
"source": [
51-
"!pip install \"pyautogen[openai,retrievechat-couchbase]\" \"flaml[automl]\" couchbase==4.3.3\n",
51+
"%pip install \"pyautogen[openai,retrievechat-couchbase]==0.8.7\" \"flaml[automl]==2.3.4\" couchbase==4.3.3\n",
5252
"# For more information, please refer to the [installation guide](/docs/installation/)."
5353
]
5454
},
@@ -260,7 +260,7 @@
260260
"\n",
261261
"from autogen.agentchat.contrib.retrieve_user_proxy_agent import RetrieveUserProxyAgent\n",
262262
"\n",
263-
"# Accepted file formats for that can be stored in\n",
263+
"# Accepted file formats that can be stored in\n",
264264
"# a vector database instance\n",
265265
"from autogen.retrieve_utils import TEXT_FORMATS\n",
266266
"\n",
@@ -383,7 +383,7 @@
383383
},
384384
{
385385
"cell_type": "code",
386-
"execution_count": null,
386+
"execution_count": 6,
387387
"metadata": {
388388
"id": "NaKfEfFmdM_v"
389389
},
@@ -444,7 +444,7 @@
444444
},
445445
{
446446
"cell_type": "code",
447-
"execution_count": null,
447+
"execution_count": 7,
448448
"metadata": {
449449
"id": "sPXTA8GhjS_d"
450450
},
@@ -486,7 +486,7 @@
486486
},
487487
{
488488
"cell_type": "code",
489-
"execution_count": null,
489+
"execution_count": 8,
490490
"metadata": {
491491
"id": "umjcgXZtr9bz"
492492
},
@@ -553,7 +553,7 @@
553553
},
554554
{
555555
"cell_type": "code",
556-
"execution_count": null,
556+
"execution_count": 10,
557557
"metadata": {
558558
"collapsed": true,
559559
"id": "hTb8DV6Rr_i-"
@@ -566,11 +566,22 @@
566566
},
567567
{
568568
"cell_type": "code",
569-
"execution_count": null,
569+
"execution_count": 11,
570570
"metadata": {
571571
"id": "FOQqd3TqsyeT"
572572
},
573-
"outputs": [],
573+
"outputs": [
574+
{
575+
"data": {
576+
"text/plain": [
577+
"(454, 454)"
578+
]
579+
},
580+
"execution_count": 54,
581+
"metadata": {},
582+
"output_type": "execute_result"
583+
}
584+
],
574585
"source": [
575586
"len(docs_file_paths), len(docs_links)"
576587
]
@@ -665,7 +676,7 @@
665676
},
666677
{
667678
"cell_type": "code",
668-
"execution_count": null,
679+
"execution_count": 55,
669680
"metadata": {
670681
"id": "qiRGwh1FcUpt"
671682
},

awsbedrock/RAG_with_Couchbase_and_Bedrock.ipynb

Lines changed: 85 additions & 55 deletions
Large diffs are not rendered by default.

awsbedrock/aws_index.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"type": "fulltext-index",
33
"name": "vector_search_bedrock",
4-
"uuid": "12fe1360b64a69c0",
4+
"uuid": "",
55
"sourceType": "gocbcore",
66
"sourceName": "vector-search-testing",
7-
"sourceUUID": "ee9841e7b3a580d76862bb00927affc4",
87
"planParams": {
98
"maxPartitionsPerPIndex": 64,
109
"indexPartitions": 16

azure/RAG_with_Couchbase_and_AzureOpenAI.ipynb

Lines changed: 16 additions & 137 deletions
Large diffs are not rendered by default.

azure/azure_index.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"type": "fulltext-index",
33
"name": "vector_search_azure",
4-
"uuid": "12fe1360b64a69c0",
4+
"uuid": "",
55
"sourceType": "gocbcore",
66
"sourceName": "vector-search-testing",
7-
"sourceUUID": "ee9841e7b3a580d76862bb00927affc4",
87
"planParams": {
98
"maxPartitionsPerPIndex": 64,
109
"indexPartitions": 16

capella-ai/langchain/RAG_with_Couchbase_Capella.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
},
7676
"outputs": [],
7777
"source": [
78-
"!pip install --quiet datasets langchain-couchbase langchain-openai"
78+
"!pip install --quiet datasets==3.6.0 langchain-couchbase==0.3.0 langchain-openai==0.3.17"
7979
]
8080
},
8181
{
@@ -115,7 +115,7 @@
115115
"from langchain_core.output_parsers import StrOutputParser\n",
116116
"from langchain_core.prompts import ChatPromptTemplate\n",
117117
"from langchain_core.runnables import RunnablePassthrough\n",
118-
"from langchain_couchbase.vectorstores import CouchbaseVectorStore\n",
118+
"from langchain_couchbase.vectorstores import CouchbaseSearchVectorStore\n",
119119
"from langchain_openai import ChatOpenAI, OpenAIEmbeddings\n",
120120
"\n",
121121
"from tqdm import tqdm\n",
@@ -283,6 +283,7 @@
283283
" print(f\"Collection '{collection_name}' already exists. Skipping creation.\")\n",
284284
"\n",
285285
" collection = bucket.scope(scope_name).collection(collection_name)\n",
286+
" time.sleep(2) # Give the collection time to be ready for queries\n",
286287
"\n",
287288
" # Ensure primary index exists\n",
288289
" try:\n",
@@ -640,7 +641,7 @@
640641
"outputs": [],
641642
"source": [
642643
"try:\n",
643-
" vector_store = CouchbaseVectorStore(\n",
644+
" vector_store = CouchbaseSearchVectorStore(\n",
644645
" cluster=cluster,\n",
645646
" bucket_name=CB_BUCKET_NAME,\n",
646647
" scope_name=SCOPE_NAME,\n",
@@ -732,7 +733,7 @@
732733
"# Perform Semantic Search\n",
733734
"Semantic search in Couchbase involves converting queries and documents into vector representations using an embeddings model. These vectors capture the semantic meaning of the text and are stored directly in Couchbase. When a query is made, Couchbase performs a similarity search by comparing the query vector against the stored document vectors. The similarity metric used for this comparison is configurable, allowing flexibility in how the relevance of documents is determined. Common metrics include cosine similarity, Euclidean distance, or dot product, but other metrics can be implemented based on specific use cases. Different embedding models like BERT, Word2Vec, or GloVe can also be used depending on the application's needs, with the vectors generated by these models stored and searched within Couchbase itself.\n",
734735
"\n",
735-
"In the provided code, the search process begins by recording the start time, followed by executing the `similarity_search_with_score` method of the `CouchbaseVectorStore`. This method searches Couchbase for the most relevant documents based on the vector similarity to the query. The search results include the document content and a similarity score that reflects how closely each document aligns with the query in the defined semantic space. The time taken to perform this search is then calculated and logged, and the results are displayed, showing the most relevant documents along with their similarity scores. This approach leverages Couchbase as both a storage and retrieval engine for vector data, enabling efficient and scalable semantic searches. The integration of vector storage and search capabilities within Couchbase allows for sophisticated semantic search operations without relying on external services for vector storage or comparison."
736+
"In the provided code, the search process begins by recording the start time, followed by executing the `similarity_search_with_score` method of the `CouchbaseSearchVectorStore`. This method searches Couchbase for the most relevant documents based on the vector similarity to the query. The search results include the document content and a similarity score that reflects how closely each document aligns with the query in the defined semantic space. The time taken to perform this search is then calculated and logged, and the results are displayed, showing the most relevant documents along with their similarity scores. This approach leverages Couchbase as both a storage and retrieval engine for vector data, enabling efficient and scalable semantic searches. The integration of vector storage and search capabilities within Couchbase allows for sophisticated semantic search operations without relying on external services for vector storage or comparison."
736737
]
737738
},
738739
{

capella-ai/langchain/capella_index.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"type": "fulltext-index",
33
"name": "model_tutorial.rag.vs-index",
4-
"uuid": "7377c28e3b64270f",
4+
"uuid": "",
55
"sourceType": "gocbcore",
66
"sourceName": "model_tutorial",
7-
"sourceUUID": "23a9a323ea50144479be8c1deb2a3ad0",
87
"planParams": {
98
"maxPartitionsPerPIndex": 1024,
109
"indexPartitions": 1

capella-ai/llamaindex/RAG_with_Couchbase_Capella.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"outputs": [],
6969
"source": [
7070
"# Install required packages\n",
71-
"%pip install datasets llama-index-vector-stores-couchbase llama-index-embeddings-openai llama-index-llms-openai-like llama-index"
71+
"%pip install datasets llama-index-vector-stores-couchbase==0.4.0 llama-index-embeddings-openai==0.3.1 llama-index-llms-openai-like==0.3.5 llama-index==0.12.37"
7272
]
7373
},
7474
{
@@ -102,7 +102,7 @@
102102
"from llama_index.core import Settings, Document\n",
103103
"from llama_index.core.ingestion import IngestionPipeline\n",
104104
"from llama_index.core.node_parser import SentenceSplitter\n",
105-
"from llama_index.vector_stores.couchbase import CouchbaseVectorStore\n",
105+
"from llama_index.vector_stores.couchbase import CouchbaseSearchVectorStore\n",
106106
"from llama_index.embeddings.openai import OpenAIEmbedding\n",
107107
"from llama_index.llms.openai_like import OpenAILike\n"
108108
]
@@ -430,7 +430,7 @@
430430
"source": [
431431
"try:\n",
432432
" # Create the Couchbase vector store\n",
433-
" vector_store = CouchbaseVectorStore(\n",
433+
" vector_store = CouchbaseSearchVectorStore(\n",
434434
" cluster=cluster,\n",
435435
" bucket_name=CB_BUCKET_NAME,\n",
436436
" scope_name=SCOPE_NAME,\n",

claudeai/RAG_with_Couchbase_and_Claude(by_Anthropic).ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
}
7878
],
7979
"source": [
80-
"%pip install --quiet datasets langchain-couchbase langchain-anthropic langchain-openai python-dotenv"
80+
"%pip install --quiet datasets==3.5.0 langchain-couchbase==0.3.0 langchain-anthropic==0.3.11 langchain-openai==0.3.13 python-dotenv==1.1.0"
8181
]
8282
},
8383
{
@@ -124,7 +124,7 @@
124124
" SystemMessagePromptTemplate)\n",
125125
"from langchain_core.runnables import RunnablePassthrough\n",
126126
"from langchain_couchbase.cache import CouchbaseCache\n",
127-
"from langchain_couchbase.vectorstores import CouchbaseVectorStore\n",
127+
"from langchain_couchbase.vectorstores import CouchbaseSearchVectorStore\n",
128128
"from langchain_openai import OpenAIEmbeddings"
129129
]
130130
},
@@ -330,6 +330,7 @@
330330
" num_replicas=0\n",
331331
" )\n",
332332
" cluster.buckets().create_bucket(bucket_settings)\n",
333+
" time.sleep(2) # Wait for bucket creation to complete and become available\n",
333334
" bucket = cluster.bucket(bucket_name)\n",
334335
" logging.info(f\"Bucket '{bucket_name}' created successfully.\")\n",
335336
"\n",
@@ -576,7 +577,7 @@
576577
],
577578
"source": [
578579
"try:\n",
579-
" vector_store = CouchbaseVectorStore(\n",
580+
" vector_store = CouchbaseSearchVectorStore(\n",
580581
" cluster=cluster,\n",
581582
" bucket_name=CB_BUCKET_NAME,\n",
582583
" scope_name=SCOPE_NAME,\n",
@@ -812,7 +813,7 @@
812813
"# Perform Semantic Search\n",
813814
"Semantic search in Couchbase involves converting queries and documents into vector representations using an embeddings model. These vectors capture the semantic meaning of the text and are stored directly in Couchbase. When a query is made, Couchbase performs a similarity search by comparing the query vector against the stored document vectors. The similarity metric used for this comparison is configurable, allowing flexibility in how the relevance of documents is determined. \n",
814815
"\n",
815-
"In the provided code, the search process begins by recording the start time, followed by executing the similarity_search_with_score method of the CouchbaseVectorStore. This method searches Couchbase for the most relevant documents based on the vector similarity to the query. The search results include the document content and a similarity score that reflects how closely each document aligns with the query in the defined semantic space. The time taken to perform this search is then calculated and logged, and the results are displayed, showing the most relevant documents along with their similarity scores. This approach leverages Couchbase as both a storage and retrieval engine for vector data, enabling efficient and scalable semantic searches. The integration of vector storage and search capabilities within Couchbase allows for sophisticated semantic search operations without relying on external services for vector storage or comparison."
816+
"In the provided code, the search process begins by recording the start time, followed by executing the similarity_search_with_score method of the CouchbaseSearchVectorStore. This method searches Couchbase for the most relevant documents based on the vector similarity to the query. The search results include the document content and a similarity score that reflects how closely each document aligns with the query in the defined semantic space. The time taken to perform this search is then calculated and logged, and the results are displayed, showing the most relevant documents along with their similarity scores. This approach leverages Couchbase as both a storage and retrieval engine for vector data, enabling efficient and scalable semantic searches. The integration of vector storage and search capabilities within Couchbase allows for sophisticated semantic search operations without relying on external services for vector storage or comparison."
816817
]
817818
},
818819
{

0 commit comments

Comments
 (0)