{"id":24284545,"url":"https://github.com/couchbase-ecosystem/langchain-couchbase","last_synced_at":"2025-03-05T17:18:36.649Z","repository":{"id":272643262,"uuid":"914431269","full_name":"Couchbase-Ecosystem/langchain-couchbase","owner":"Couchbase-Ecosystem","description":"Couchbase integration with LangChain","archived":false,"fork":false,"pushed_at":"2025-01-30T14:07:58.000Z","size":131,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T15:20:00.415Z","etag":null,"topics":["langchain-python","nosql","vector-database"],"latest_commit_sha":null,"homepage":"https://python.langchain.com/docs/integrations/providers/couchbase/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Couchbase-Ecosystem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-09T15:29:14.000Z","updated_at":"2025-01-30T14:07:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"b6bcf186-6ad0-4753-b8e6-27b9db4dd73b","html_url":"https://github.com/Couchbase-Ecosystem/langchain-couchbase","commit_stats":null,"previous_names":["couchbase-ecosystem/langchain-couchbase"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Couchbase-Ecosystem%2Flangchain-couchbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Couchbase-Ecosystem%2Flangchain-couchbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Couchbase-Ecosystem%2Flangchain-couchbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Couchbase-Ecosystem%2Flangchain-couchbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Couchbase-Ecosystem","download_url":"https://codeload.github.com/Couchbase-Ecosystem/langchain-couchbase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242067714,"owners_count":20066751,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["langchain-python","nosql","vector-database"],"created_at":"2025-01-16T05:18:06.916Z","updated_at":"2025-03-05T17:18:36.640Z","avatar_url":"https://github.com/Couchbase-Ecosystem.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# langchain-couchbase\n\nThis package contains the LangChain integration with Couchbase\n\n## Installation\n\n```bash\npip install -U langchain-couchbase\n```\n\n## Vector Store\n\n`CouchbaseVectorStore` class enables the usage of Couchbase for Vector Search.\n\n```python\nfrom langchain_couchbase import CouchbaseVectorStore\n```\n\nTo use this in an application:\n\n```python\nimport getpass\n\n# Constants for the connection\nCOUCHBASE_CONNECTION_STRING = getpass.getpass(\n    \"Enter the connection string for the Couchbase cluster: \"\n)\nDB_USERNAME = getpass.getpass(\"Enter the username for the Couchbase cluster: \")\nDB_PASSWORD = getpass.getpass(\"Enter the password for the Couchbase cluster: \")\n\n# Create Couchbase connection object\nfrom datetime import timedelta\n\nfrom couchbase.auth import PasswordAuthenticator\nfrom couchbase.cluster import Cluster\nfrom couchbase.options import ClusterOptions\n\nauth = PasswordAuthenticator(DB_USERNAME, DB_PASSWORD)\noptions = ClusterOptions(auth)\ncluster = Cluster(COUCHBASE_CONNECTION_STRING, options)\n\n# Wait until the cluster is ready for use.\ncluster.wait_until_ready(timedelta(seconds=5))\n\nvector_store = CouchbaseVectorStore(\n    cluster=cluster,\n    bucket_name=BUCKET_NAME,\n    scope_name=SCOPE_NAME,\n    collection_name=COLLECTION_NAME,\n    embedding=my_embeddings,\n    index_name=SEARCH_INDEX_NAME,\n)\n```\n\nSee a [usage example](https://python.langchain.com/docs/integrations/vectorstores/couchbase/)\n\n## LLM Caches\n\n### CouchbaseCache\n\nUse Couchbase as a cache for prompts and responses.\n\nSee a [usage example](https://python.langchain.com/docs/integrations/llm_caching/#couchbase-caches).\n\nTo import this cache:\n\n```python\nfrom langchain_couchbase.cache import CouchbaseCache\n```\n\nTo use this cache with your LLMs:\n\n```python\nfrom langchain_core.globals import set_llm_cache\n\ncluster = couchbase_cluster_connection_object\n\nset_llm_cache(\n    CouchbaseCache(\n        cluster=cluster,\n        bucket_name=BUCKET_NAME,\n        scope_name=SCOPE_NAME,\n        collection_name=COLLECTION_NAME,\n    )\n)\n```\n\n### CouchbaseSemanticCache\n\nSemantic caching allows users to retrieve cached prompts based on the semantic similarity between the user input and previously cached inputs. Under the hood it uses Couchbase as both a cache and a vectorstore. The `CouchbaseSemanticCache` needs a Search Index defined to work. Please look at the usage example on how to set up the index.\n\nSee a [usage example](https://python.langchain.com/docs/integrations/llm_caching/#couchbase-caches).\n\nTo import this cache:\n\n```python\nfrom langchain_couchbase.cache import CouchbaseSemanticCache\n```\n\nTo use this cache with your LLMs:\n\n```python\nfrom langchain_core.globals import set_llm_cache\n\n# use any embedding provider...\n\nfrom langchain_openai.Embeddings import OpenAIEmbeddings\n\nembeddings = OpenAIEmbeddings()\ncluster = couchbase_cluster_connection_object\n\nset_llm_cache(\n    CouchbaseSemanticCache(\n        cluster=cluster,\n        embedding = embeddings,\n        bucket_name=BUCKET_NAME,\n        scope_name=SCOPE_NAME,\n        collection_name=COLLECTION_NAME,\n        index_name=INDEX_NAME,\n    )\n)\n```\n\n## Chat Message History\n\nUse Couchbase as the storage for your chat messages.\n\nSee a [usage example](https://python.langchain.com/docs/integrations/memory/couchbase_chat_message_history/).\n\nTo use the chat message history in your applications:\n\n```python\nfrom langchain_couchbase.chat_message_histories import CouchbaseChatMessageHistory\n\nmessage_history = CouchbaseChatMessageHistory(\ncluster=cluster,\nbucket_name=BUCKET_NAME,\nscope_name=SCOPE_NAME,\ncollection_name=COLLECTION_NAME,\nsession_id=\"test-session\",\n)\n\nmessage_history.add_user_message(\"hi!\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcouchbase-ecosystem%2Flangchain-couchbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcouchbase-ecosystem%2Flangchain-couchbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcouchbase-ecosystem%2Flangchain-couchbase/lists"}