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 community[patch]: Release 0.2.11 (#24989) 2024-08-02 20:08:44 +00:00
cache community: Memcached LLM Cache Integration (#27323) 2024-11-07 03:07:59 +00:00
callbacks infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
chains all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00
chat_message_histories infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
chat_models community: Add Naver chat model & embeddings (#25162) 2024-10-24 20:54:13 +00:00
cross_encoders langchain[minor], community[minor]: add CrossEncoderReranker with HuggingFaceCrossEncoder and SagemakerEndpointCrossEncoder (#13687) 2024-03-31 20:51:31 +00:00
document_compressors community: add InfinityRerank (#27043) 2024-11-06 17:26:30 -08:00
document_loaders community[patch]: add to pypdf tests and run in CI (#26663) 2024-09-19 14:45:49 +00:00
document_transformers infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
embeddings all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00
examples community: support advanced text extraction options for pdf documents (#20265) 2024-07-17 20:47:09 +00:00
graph_vectorstores community: fixed bug in GraphVectorStoreRetriever (#27846) 2024-11-04 20:27:17 +00:00
graphs Sanitize backticks from neo4j labels and types for import (#23367) 2024-06-24 19:05:31 +00:00
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 infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
prompts multiple: langchain 0.2 in master (#21191) 2024-05-08 16:46:52 -04:00
retrievers multiple: rely on asyncio_mode auto in tests (#27200) 2024-10-15 16:26:38 +00:00
smith/evaluation multiple: langchain 0.2 in master (#21191) 2024-05-08 16:46:52 -04:00
storage multiple: rely on asyncio_mode auto in tests (#27200) 2024-10-15 16:26:38 +00:00
tools community[patch]: Add missing annotations (#24890) 2024-07-31 18:13:44 +00:00
utilities multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
vectorstores community: added Document.id support to opensearch vectorstore (#27945) 2024-11-06 15:04:09 -05:00
__init__.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
.env.example community: add support for 'cloud' parameter in JiraAPIWrapper (#23057) 2024-07-05 15:11:10 +00:00
conftest.py infra: Use dotenv in langchain-community's integration tests (#16137) 2024-01-17 18:18:26 -08:00
test_compile.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
test_dalle.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
test_document_transformers.py multiple: langchain 0.2 in master (#21191) 2024-05-08 16:46:52 -04:00
test_long_context_reorder.py community[patch]: deprecate langchain_community Chroma in favor of langchain_chroma (#24474) 2024-07-22 11:00:13 -04:00
test_nuclia_transformer.py multiple: langchain 0.2 in master (#21191) 2024-05-08 16:46:52 -04:00
test_pdf_pagesplitter.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00