langchain/libs/community/tests/integration_tests
Dmitriy Prokopchuk 53b0a99f37
community: Memcached LLM Cache Integration (#27323)
## Description
This PR adds support for Memcached as a usable LLM model cache by adding
the ```MemcachedCache``` implementation relying on the
[pymemcache](https://github.com/pinterest/pymemcache) client.

Unit test-wise, the new integration is generally covered under existing
import testing. All new functionality depends on pymemcache if
instantiated and used, so to comply with the other cache implementations
the PR also adds optional integration tests for ```MemcachedCache```.

Since this is a new integration, documentation is added for Memcached as
an integration and as an LLM Cache.

## Issue
This PR closes #27275 which was originally raised as a discussion in
#27035

## Dependencies
There are no new required dependencies for langchain, but
[pymemcache](https://github.com/pinterest/pymemcache) is required to
instantiate the new ```MemcachedCache```.

## Example Usage
```python3
from langchain.globals import set_llm_cache
from langchain_openai import OpenAI

from langchain_community.cache import MemcachedCache
from pymemcache.client.base import Client

llm = OpenAI(model="gpt-3.5-turbo-instruct", n=2, best_of=2)
set_llm_cache(MemcachedCache(Client('localhost')))

# The first time, it is not yet in cache, so it should take longer
llm.invoke("Which city is the most crowded city in the USA?")

# The second time it is, so it goes faster
llm.invoke("Which city is the most crowded city in the USA?")
```

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
2024-11-07 03:07:59 +00:00
..
adapters all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00
agent
cache community: Memcached LLM Cache Integration (#27323) 2024-11-07 03:07:59 +00:00
callbacks
chains all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00
chat_message_histories
chat_models community: Add Naver chat model & embeddings (#25162) 2024-10-24 20:54:13 +00:00
cross_encoders
document_compressors community: add InfinityRerank (#27043) 2024-11-06 17:26:30 -08:00
document_loaders
document_transformers
embeddings all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00
examples
graph_vectorstores community: fixed bug in GraphVectorStoreRetriever (#27846) 2024-11-04 20:27:17 +00:00
graphs
indexes multiple: rely on asyncio_mode auto in tests (#27200) 2024-10-15 16:26:38 +00:00
llms community: Update Replicate LLM and fix tests (#27655) 2024-10-30 16:07:08 +00:00
memory
prompts
retrievers multiple: rely on asyncio_mode auto in tests (#27200) 2024-10-15 16:26:38 +00:00
smith/evaluation
storage multiple: rely on asyncio_mode auto in tests (#27200) 2024-10-15 16:26:38 +00:00
tools
utilities
vectorstores community: added Document.id support to opensearch vectorstore (#27945) 2024-11-06 15:04:09 -05:00
__init__.py
.env.example
conftest.py
test_compile.py
test_dalle.py
test_document_transformers.py
test_long_context_reorder.py
test_nuclia_transformer.py
test_pdf_pagesplitter.py