mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-19 13:23:35 +00:00
docs: integrations cache table of content (#28755)
Issue: the current [Cache](https://python.langchain.com/docs/integrations/llm_caching/) page has an inconsistent heading. Mixed terms are used; mixed casing; and mixed `selecting`. Excessively long titles make right-side ToC hard to read and unnecessarily long. Changes: consitent and more-readable ToC
This commit is contained in:
parent
a00258ec12
commit
6479fd8c1c
@ -15,12 +15,20 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f938e881",
|
||||
"id": "bedbf252-4ea5-4eea-a3dc-d18ccc84aca3",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%pip install -qU langchain-openai langchain-community"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "88486f6f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%pip install -qU langchain-openai langchain-community\n",
|
||||
"\n",
|
||||
"import os\n",
|
||||
"from getpass import getpass\n",
|
||||
"\n",
|
||||
@ -30,12 +38,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"id": "10ad9224",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-12-06T00:54:06.474593Z",
|
||||
"start_time": "2024-12-06T00:53:58.727138Z"
|
||||
"end_time": "2024-04-12T02:05:57.319706Z",
|
||||
"start_time": "2024-04-12T02:05:57.303868Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
@ -55,7 +63,7 @@
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"## `In Memory` Cache"
|
||||
"## `In Memory` cache"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -139,7 +147,7 @@
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"## `SQLite` Cache"
|
||||
"## `SQLite` cache"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -234,7 +242,7 @@
|
||||
"id": "e71273ab",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## `Upstash Redis` Cache"
|
||||
"## `Upstash Redis` caches"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -242,7 +250,7 @@
|
||||
"id": "f10dabef",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Standard Cache\n",
|
||||
"### Standard cache\n",
|
||||
"Use [Upstash Redis](https://upstash.com) to cache prompts and responses with a serverless HTTP API."
|
||||
]
|
||||
},
|
||||
@ -340,7 +348,8 @@
|
||||
"id": "b29dd776",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Semantic Cache\n",
|
||||
"### Semantic cache\n",
|
||||
"\n",
|
||||
"Use [Upstash Vector](https://upstash.com/docs/vector/overall/whatisvector) to do a semantic similarity search and cache the most similar response in the database. The vectorization is automatically done by the selected embedding model while creating Upstash Vector database. "
|
||||
]
|
||||
},
|
||||
@ -454,11 +463,10 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "278ad7ae",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"## `Redis` Cache\n",
|
||||
"## `Redis` caches\n",
|
||||
"\n",
|
||||
"See the main [Redis cache docs](/docs/integrations/caches/redis_llm_caching/) for detail."
|
||||
]
|
||||
@ -468,7 +476,7 @@
|
||||
"id": "c5c9a4d5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Standard Cache\n",
|
||||
"### Standard cache\n",
|
||||
"Use [Redis](/docs/integrations/providers/redis) to cache prompts and responses."
|
||||
]
|
||||
},
|
||||
@ -564,7 +572,7 @@
|
||||
"id": "82be23f6",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Semantic Cache\n",
|
||||
"### Semantic cache\n",
|
||||
"Use [Redis](/docs/integrations/providers/redis) to cache prompts and responses and evaluate hits based on semantic similarity."
|
||||
]
|
||||
},
|
||||
@ -660,7 +668,6 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "684eab55",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
@ -905,7 +912,7 @@
|
||||
"id": "9b2b2777",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## `MongoDB Atlas` Cache\n",
|
||||
"## `MongoDB Atlas` caches\n",
|
||||
"\n",
|
||||
"[MongoDB Atlas](https://www.mongodb.com/docs/atlas/) is a fully-managed cloud database available in AWS, Azure, and GCP. It has native support for \n",
|
||||
"Vector Search on the MongoDB document data.\n",
|
||||
@ -917,8 +924,9 @@
|
||||
"id": "ecdc2a0a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### `MongoDBCache`\n",
|
||||
"An abstraction to store a simple cache in MongoDB. This does not use Semantic Caching, nor does it require an index to be made on the collection before generation.\n",
|
||||
"### Standard cache\n",
|
||||
"\n",
|
||||
"Standard cache is a simple cache in MongoDB. It does not use Semantic Caching, nor does it require an index to be made on the collection before generation.\n",
|
||||
"\n",
|
||||
"To import this cache, first install the required dependency:\n",
|
||||
"\n",
|
||||
@ -950,8 +958,9 @@
|
||||
"```\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"### `MongoDBAtlasSemanticCache`\n",
|
||||
"Semantic caching allows users to retrieve cached prompts based on semantic similarity between the user input and previously cached results. Under the hood it blends MongoDBAtlas as both a cache and a vectorstore.\n",
|
||||
"### Semantic cache\n",
|
||||
"\n",
|
||||
"Semantic caching allows retrieval of cached prompts based on semantic similarity between the user input and previously cached results. Under the hood, it blends MongoDBAtlas as both a cache and a vectorstore.\n",
|
||||
"The MongoDBAtlasSemanticCache inherits from `MongoDBAtlasVectorSearch` and needs an Atlas Vector Search Index defined to work. Please look at the [usage example](/docs/integrations/vectorstores/mongodb_atlas) on how to set up the index.\n",
|
||||
"\n",
|
||||
"To import this cache:\n",
|
||||
@ -985,14 +994,13 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "726fe754",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"## `Momento` Cache\n",
|
||||
"## `Momento` cache\n",
|
||||
"Use [Momento](/docs/integrations/providers/momento) to cache prompts and responses.\n",
|
||||
"\n",
|
||||
"Requires momento to use, uncomment below to install:"
|
||||
"Requires installing the `momento` package:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1096,13 +1104,14 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "934943dc",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"## `SQLAlchemy` Cache\n",
|
||||
"## `SQLAlchemy` cache\n",
|
||||
"\n",
|
||||
"You can use `SQLAlchemyCache` to cache with any SQL database supported by `SQLAlchemy`."
|
||||
"You can use `SQLAlchemyCache` to cache with any SQL database supported by `SQLAlchemy`.\n",
|
||||
"\n",
|
||||
"### Standard cache"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1112,11 +1121,11 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# from langchain.cache import SQLAlchemyCache\n",
|
||||
"# from sqlalchemy import create_engine\n",
|
||||
"from langchain.cache import SQLAlchemyCache\n",
|
||||
"from sqlalchemy import create_engine\n",
|
||||
"\n",
|
||||
"# engine = create_engine(\"postgresql://postgres:postgres@localhost:5432/postgres\")\n",
|
||||
"# set_llm_cache(SQLAlchemyCache(engine))"
|
||||
"engine = create_engine(\"postgresql://postgres:postgres@localhost:5432/postgres\")\n",
|
||||
"set_llm_cache(SQLAlchemyCache(engine))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1124,7 +1133,9 @@
|
||||
"id": "0959d640",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Custom SQLAlchemy Schemas"
|
||||
"### Custom SQLAlchemy schemas\n",
|
||||
"\n",
|
||||
"You can define your own declarative `SQLAlchemyCache` child class to customize the schema used for caching. For example, to support high-speed fulltext prompt indexing with `Postgres`, use:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1134,8 +1145,6 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# You can define your own declarative SQLAlchemyCache child class to customize the schema used for caching. For example, to support high-speed fulltext prompt indexing with Postgres, use:\n",
|
||||
"\n",
|
||||
"from langchain_community.cache import SQLAlchemyCache\n",
|
||||
"from sqlalchemy import Column, Computed, Index, Integer, Sequence, String, create_engine\n",
|
||||
"from sqlalchemy.ext.declarative import declarative_base\n",
|
||||
@ -1185,7 +1194,7 @@
|
||||
"id": "6cf6acb4-1bc4-4c4b-9325-2420c17e5e2b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Required dependency"
|
||||
"Required dependency:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1203,7 +1212,7 @@
|
||||
"id": "a4a6725d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Connect to the DB\n",
|
||||
"### Connecting to the DB\n",
|
||||
"\n",
|
||||
"The Cassandra caches shown in this page can be used with Cassandra as well as other derived databases, such as Astra DB, which use the CQL (Cassandra Query Language) protocol.\n",
|
||||
"\n",
|
||||
@ -1217,7 +1226,7 @@
|
||||
"id": "15735abe-2567-43ce-aa91-f253b33b5a88",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"#### Connecting to a Cassandra cluster\n",
|
||||
"#### to a Cassandra cluster\n",
|
||||
"\n",
|
||||
"You first need to create a `cassandra.cluster.Session` object, as described in the [Cassandra driver documentation](https://docs.datastax.com/en/developer/python-driver/latest/api/cassandra/cluster/#module-cassandra.cluster). The details vary (e.g. with network settings and authentication), but this might be something like:"
|
||||
]
|
||||
@ -1270,7 +1279,7 @@
|
||||
"id": "2cc7ba29-8f84-4fbf-aaf7-3daa1be7e7b0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"#### Connecting to Astra DB through CQL\n",
|
||||
"#### to Astra DB through CQL\n",
|
||||
"\n",
|
||||
"In this case you initialize CassIO with the following connection parameters:\n",
|
||||
"\n",
|
||||
@ -1329,7 +1338,7 @@
|
||||
"id": "8665664a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Cassandra: Exact cache\n",
|
||||
"### Standard cache\n",
|
||||
"\n",
|
||||
"This will avoid invoking the LLM when the supplied prompt is _exactly_ the same as one encountered already:"
|
||||
]
|
||||
@ -1400,7 +1409,7 @@
|
||||
"id": "8fc4d017",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Cassandra: Semantic cache\n",
|
||||
"### Semantic cache\n",
|
||||
"\n",
|
||||
"This cache will do a semantic similarity search and return a hit if it finds a cached entry that is similar enough, For this, you need to provide an `Embeddings` instance of your choice."
|
||||
]
|
||||
@ -1488,9 +1497,9 @@
|
||||
"id": "55dc84b3-37cb-4f19-b175-40e18e06f83f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"#### Attribution statement\n",
|
||||
"**Attribution statement:**\n",
|
||||
"\n",
|
||||
">Apache Cassandra, Cassandra and Apache are either registered trademarks or trademarks of the [Apache Software Foundation](http://www.apache.org/) in the United States and/or other countries."
|
||||
">`Apache Cassandra`, `Cassandra` and `Apache` are either registered trademarks or trademarks of the [Apache Software Foundation](http://www.apache.org/) in the United States and/or other countries."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1498,7 +1507,7 @@
|
||||
"id": "8712f8fc-bb89-4164-beb9-c672778bbd91",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## `Astra DB` Caches"
|
||||
"## `Astra DB` caches"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1543,7 +1552,7 @@
|
||||
"id": "ee6d587f-4b7c-43f4-9e90-5129c842a143",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Astra DB exact LLM cache\n",
|
||||
"### Standard cache\n",
|
||||
"\n",
|
||||
"This will avoid invoking the LLM when the supplied prompt is _exactly_ the same as one encountered already:"
|
||||
]
|
||||
@ -1619,7 +1628,7 @@
|
||||
"id": "524b94fa-6162-4880-884d-d008749d14e2",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Astra DB Semantic cache\n",
|
||||
"### Semantic cache\n",
|
||||
"\n",
|
||||
"This cache will do a semantic similarity search and return a hit if it finds a cached entry that is similar enough, For this, you need to provide an `Embeddings` instance of your choice."
|
||||
]
|
||||
@ -1713,7 +1722,7 @@
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"## Azure Cosmos DB Semantic Cache\n",
|
||||
"## `Azure Cosmos DB` semantic cache\n",
|
||||
"\n",
|
||||
"You can use this integrated [vector database](https://learn.microsoft.com/en-us/azure/cosmos-db/vector-database) for caching."
|
||||
]
|
||||
@ -1820,7 +1829,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 83,
|
||||
"id": "bc1570a2a77b58c8",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@ -1859,7 +1868,7 @@
|
||||
"id": "235ff73bf7143f13",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Azure CosmosDB NoSql Semantic Cache\n",
|
||||
"## `Azure Cosmos DB NoSql` semantic cache\n",
|
||||
"\n",
|
||||
"You can use this integrated [vector database](https://learn.microsoft.com/en-us/azure/cosmos-db/vector-database) for caching."
|
||||
]
|
||||
@ -2002,7 +2011,8 @@
|
||||
"id": "306ff47b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## `Elasticsearch` Cache\n",
|
||||
"## `Elasticsearch` caches\n",
|
||||
"\n",
|
||||
"A caching layer for LLMs that uses Elasticsearch.\n",
|
||||
"\n",
|
||||
"First install the LangChain integration with Elasticsearch."
|
||||
@ -2023,6 +2033,8 @@
|
||||
"id": "9e70b0a0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Standard cache\n",
|
||||
"\n",
|
||||
"Use the class `ElasticsearchCache`.\n",
|
||||
"\n",
|
||||
"Simple example:"
|
||||
@ -2130,6 +2142,26 @@
|
||||
"please only make additive modifications, keeping the base mapping intact."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3dc15b3c-8793-432e-98c3-d2726d497a5a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Embedding cache\n",
|
||||
"\n",
|
||||
"An Elasticsearch store for caching embeddings."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "b0ae5bd3-517d-470f-9b44-14d9359e6940",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_elasticsearch import ElasticsearchEmbeddingsCache"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0c69d84d",
|
||||
@ -2137,8 +2169,9 @@
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"## Optional Caching\n",
|
||||
"You can also turn off caching for specific LLMs should you choose. In the example below, even though global caching is enabled, we turn it off for a specific LLM"
|
||||
"## LLM-specific optional caching\n",
|
||||
"\n",
|
||||
"You can also turn off caching for specific LLMs. In the example below, even though global caching is enabled, we turn it off for a specific LLM."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -2218,7 +2251,8 @@
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"## Optional Caching in Chains\n",
|
||||
"## Optional caching in Chains\n",
|
||||
"\n",
|
||||
"You can also turn off caching for particular nodes in chains. Note that because of certain interfaces, its often easier to construct the chain first, and then edit the LLM afterwards.\n",
|
||||
"\n",
|
||||
"As an example, we will load a summarizer map-reduce chain. We will cache results for the map-step, but then not freeze it for the combine step."
|
||||
@ -2385,7 +2419,7 @@
|
||||
"id": "9ecfa565038eff71",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## OpenSearch Semantic Cache\n",
|
||||
"## `OpenSearch` semantic cache\n",
|
||||
"Use [OpenSearch](https://python.langchain.com/docs/integrations/vectorstores/opensearch/) as a semantic cache to cache prompts and responses and evaluate hits based on semantic similarity."
|
||||
]
|
||||
},
|
||||
@ -2489,7 +2523,8 @@
|
||||
"id": "2ac1a8c7",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## SingleStoreDB Semantic Cache\n",
|
||||
"## `SingleStoreDB` semantic cache\n",
|
||||
"\n",
|
||||
"You can use [SingleStoreDB](https://python.langchain.com/docs/integrations/vectorstores/singlestoredb/) as a semantic cache to cache prompts and responses."
|
||||
]
|
||||
},
|
||||
@ -2516,7 +2551,7 @@
|
||||
"id": "7e6b9b1a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## `Memcached` Cache\n",
|
||||
"## `Memcached` cache\n",
|
||||
"You can use [Memcached](https://www.memcached.org/) as a cache to cache prompts and responses through [pymemcache](https://github.com/pinterest/pymemcache).\n",
|
||||
"\n",
|
||||
"This cache requires the pymemcache dependency to be installed:"
|
||||
@ -2612,7 +2647,7 @@
|
||||
"id": "7019c991-0101-4f9c-b212-5729a5471293",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Couchbase Caches\n",
|
||||
"## `Couchbase` caches\n",
|
||||
"\n",
|
||||
"Use [Couchbase](https://couchbase.com/) as a cache for prompts and responses."
|
||||
]
|
||||
@ -2622,7 +2657,7 @@
|
||||
"id": "d6aac680-ba32-4c19-8864-6471cf0e7d5a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Couchbase Cache\n",
|
||||
"### Standard cache\n",
|
||||
"\n",
|
||||
"The standard cache that looks for an exact match of the user prompt."
|
||||
]
|
||||
@ -2756,7 +2791,7 @@
|
||||
"id": "1dca39d8-233a-45ba-ad7d-0920dfbc4a50",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Specifying a Time to Live (TTL) for the Cached entries\n",
|
||||
"#### Time to Live (TTL) for the cached entries\n",
|
||||
"The Cached documents can be deleted after a specified time automatically by specifying a `ttl` parameter along with the initialization of the Cache."
|
||||
]
|
||||
},
|
||||
@ -2785,7 +2820,7 @@
|
||||
"id": "43626f33-d184-4260-b641-c9341cef5842",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Couchbase Semantic Cache\n",
|
||||
"### Semantic cache\n",
|
||||
"Semantic caching allows users to retrieve cached prompts based on semantic similarity between the user input and previously cached inputs. Under the hood it uses Couchbase as both a cache and a vectorstore. This needs an appropriate Vector Search Index defined to work. Please look at the usage example on how to set up the index."
|
||||
]
|
||||
},
|
||||
@ -2828,7 +2863,9 @@
|
||||
"- The search index for the semantic cache needs to be defined before using the semantic cache. \n",
|
||||
"- The optional parameter, `score_threshold` in the Semantic Cache that you can use to tune the results of the semantic search.\n",
|
||||
"\n",
|
||||
"### How to Import an Index to the Full Text Search service?\n",
|
||||
"#### Index to the Full Text Search service\n",
|
||||
"\n",
|
||||
"How to Import an Index to the Full Text Search service?\n",
|
||||
" - [Couchbase Server](https://docs.couchbase.com/server/current/search/import-search-index.html)\n",
|
||||
" - Click on Search -> Add Index -> Import\n",
|
||||
" - Copy the following Index definition in the Import screen\n",
|
||||
@ -2838,7 +2875,8 @@
|
||||
" - Import the file in Capella using the instructions in the documentation.\n",
|
||||
" - Click on Create Index to create the index.\n",
|
||||
"\n",
|
||||
"#### Example index for the vector search. \n",
|
||||
"**Example index for the vector search:**\n",
|
||||
"\n",
|
||||
" ```\n",
|
||||
" {\n",
|
||||
" \"type\": \"fulltext-index\",\n",
|
||||
@ -2998,7 +3036,8 @@
|
||||
"id": "f6f674fa-70b5-4cf9-a208-992aad2c3c89",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Specifying a Time to Live (TTL) for the Cached entries\n",
|
||||
"#### Time to Live (TTL) for the cached entries\n",
|
||||
"\n",
|
||||
"The Cached documents can be deleted after a specified time automatically by specifying a `ttl` parameter along with the initialization of the Cache."
|
||||
]
|
||||
},
|
||||
@ -3056,10 +3095,10 @@
|
||||
"source": [
|
||||
"**Cache** classes are implemented by inheriting the [BaseCache](https://python.langchain.com/api_reference/core/caches/langchain_core.caches.BaseCache.html) class.\n",
|
||||
"\n",
|
||||
"This table lists all 21 derived classes with links to the API Reference.\n",
|
||||
"This table lists all derived classes with links to the API Reference.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"| Namespace 🔻 | Class |\n",
|
||||
"| Namespace | Class 🔻 |\n",
|
||||
"|------------|---------|\n",
|
||||
"| langchain_astradb.cache | [AstraDBCache](https://python.langchain.com/api_reference/astradb/cache/langchain_astradb.cache.AstraDBCache.html) |\n",
|
||||
"| langchain_astradb.cache | [AstraDBSemanticCache](https://python.langchain.com/api_reference/astradb/cache/langchain_astradb.cache.AstraDBSemanticCache.html) |\n",
|
||||
@ -3068,22 +3107,31 @@
|
||||
"| langchain_community.cache | [AzureCosmosDBSemanticCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.AzureCosmosDBSemanticCache.html) |\n",
|
||||
"| langchain_community.cache | [CassandraCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.CassandraCache.html) |\n",
|
||||
"| langchain_community.cache | [CassandraSemanticCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.CassandraSemanticCache.html) |\n",
|
||||
"| langchain_couchbase.cache | [CouchbaseCache](https://python.langchain.com/api_reference/couchbase/cache/langchain_couchbase.cache.CouchbaseCache.html) |\n",
|
||||
"| langchain_couchbase.cache | [CouchbaseSemanticCache](https://python.langchain.com/api_reference/couchbase/cache/langchain_couchbase.cache.CouchbaseSemanticCache.html) |\n",
|
||||
"| langchain_elasticsearch.cache | [ElasticsearchCache](https://python.langchain.com/api_reference/elasticsearch/cache/langchain_elasticsearch.cache.AsyncElasticsearchCache.html) |\n",
|
||||
"| langchain_elasticsearch.cache | [ElasticsearchEmbeddingsCache](https://python.langchain.com/api_reference/elasticsearch/cache/langchain_elasticsearch.cache.AsyncElasticsearchEmbeddingsCache.html) |\n",
|
||||
"| langchain_community.cache | [GPTCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.GPTCache.html) |\n",
|
||||
"| langchain_core.caches | [InMemoryCache](https://python.langchain.com/api_reference/core/caches/langchain_core.caches.InMemoryCache.html) |\n",
|
||||
"| langchain_community.cache | [InMemoryCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.InMemoryCache.html) |\n",
|
||||
"| langchain_community.cache | [MomentoCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.MomentoCache.html) |\n",
|
||||
"| langchain_mongodb.cache | [MongoDBAtlasSemanticCache](https://python.langchain.com/api_reference/mongodb/cache/langchain_mongodb.cache.MongoDBAtlasSemanticCache.html) |\n",
|
||||
"| langchain_mongodb.cache | [MongoDBCache](https://python.langchain.com/api_reference/mongodb/cache/langchain_mongodb.cache.MongoDBCache.html) |\n",
|
||||
"| langchain_community.cache | [OpenSearchSemanticCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.OpenSearchSemanticCache.html) |\n",
|
||||
"| langchain_community.cache | [RedisSemanticCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.RedisSemanticCache.html) |\n",
|
||||
"| langchain_community.cache | [SingleStoreDBSemanticCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.SingleStoreDBSemanticCache.html) |\n",
|
||||
"| langchain_community.cache | [SQLAlchemyCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.SQLAlchemyCache.html) |\n",
|
||||
"| langchain_community.cache | [SQLAlchemyMd5Cache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.SQLAlchemyMd5Cache.html) |\n",
|
||||
"| langchain_community.cache | [UpstashRedisCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.UpstashRedisCache.html) |\n",
|
||||
"| langchain_core.caches | [InMemoryCache](https://python.langchain.com/api_reference/core/caches/langchain_core.caches.InMemoryCache.html) |\n",
|
||||
"| langchain_elasticsearch.cache | [ElasticsearchCache](https://python.langchain.com/api_reference/elasticsearch/cache/langchain_elasticsearch.cache.ElasticsearchCache.html) |\n",
|
||||
"| langchain_mongodb.cache | [MongoDBAtlasSemanticCache](https://python.langchain.com/api_reference/mongodb/cache/langchain_mongodb.cache.MongoDBAtlasSemanticCache.html) |\n",
|
||||
"| langchain_mongodb.cache | [MongoDBCache](https://python.langchain.com/api_reference/mongodb/cache/langchain_mongodb.cache.MongoDBCache.html) |\n",
|
||||
"| langchain_couchbase.cache | [CouchbaseCache](https://python.langchain.com/api_reference/couchbase/cache/langchain_couchbase.cache.CouchbaseCache.html) |\n",
|
||||
"| langchain_couchbase.cache | [CouchbaseSemanticCache](https://python.langchain.com/api_reference/couchbase/cache/langchain_couchbase.cache.CouchbaseSemanticCache.html) |\n"
|
||||
"| langchain_community.cache | [UpstashRedisCache](https://python.langchain.com/api_reference/community/cache/langchain_community.cache.UpstashRedisCache.html) |\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "1ef1a2d4-da2e-4fb1-aae4-ffc4aef6c3ad",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
@ -3102,7 +3150,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.13"
|
||||
"version": "3.10.12"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@ -33,7 +33,7 @@ from langchain_community.document_loaders.couchbase import CouchbaseLoader
|
||||
### CouchbaseCache
|
||||
Use Couchbase as a cache for prompts and responses.
|
||||
|
||||
See a [usage example](/docs/integrations/llm_caching/#couchbase-cache).
|
||||
See a [usage example](/docs/integrations/llm_caching/#couchbase-caches).
|
||||
|
||||
To import this cache:
|
||||
```python
|
||||
@ -61,7 +61,7 @@ set_llm_cache(
|
||||
Semantic 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](/docs/integrations/vectorstores/couchbase) on how to set up the index.
|
||||
|
||||
See a [usage example](/docs/integrations/llm_caching/#couchbase-semantic-cache).
|
||||
See a [usage example](/docs/integrations/llm_caching/#couchbase-caches).
|
||||
|
||||
To import this cache:
|
||||
```python
|
||||
|
@ -84,7 +84,7 @@ from langchain_elasticsearch import ElasticsearchChatMessageHistory
|
||||
|
||||
## LLM cache
|
||||
|
||||
See a [usage example](/docs/integrations/llm_caching/#elasticsearch-cache).
|
||||
See a [usage example](/docs/integrations/llm_caching/#elasticsearch-caches).
|
||||
|
||||
```python
|
||||
from langchain_elasticsearch import ElasticsearchCache
|
||||
|
Loading…
Reference in New Issue
Block a user