Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/_compile_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ jobs:
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
name: "poetry run pytest -m compile tests/integration_tests #${{ matrix.python-version }}"
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libopenblas-dev liblapack-dev gfortran

- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
with:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ jobs:
# Starting new jobs is also relatively slow,
# so linting on fewer versions makes CI faster.
python-version:
- "3.9"
- "3.12"
- "3.10"
- "3.13"
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libopenblas-dev liblapack-dev gfortran

- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
with:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ jobs:
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
name: "make test #${{ matrix.python-version }}"
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libopenblas-dev liblapack-dev gfortran

- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
with:
Expand Down
13 changes: 2 additions & 11 deletions libs/redis/docs/cache.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,10 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"from getpass import getpass\n",
"\n",
"from langchain.globals import set_llm_cache\n",
"from langchain.schema import Generation\n",
"from langchain_openai import OpenAI, OpenAIEmbeddings\n",
"\n",
"from langchain_redis import RedisCache, RedisSemanticCache"
]
"source": "import time\nfrom getpass import getpass\n\nfrom langchain_core.globals import set_llm_cache\nfrom langchain_core.outputs import Generation\nfrom langchain_openai import OpenAI, OpenAIEmbeddings\n\nfrom langchain_redis import RedisCache, RedisSemanticCache"
},
{
"cell_type": "markdown",
Expand Down
4 changes: 2 additions & 2 deletions libs/redis/docs/chat_history.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from langchain_core.chat_history import BaseChatMessageHistory\n",
"from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder\n",
"from langchain_core.runnables.history import RunnableWithMessageHistory\n",
"from langchain_openai import ChatOpenAI\n",
"\n",
"from langchain_redis import RedisChatMessageHistory\n",
"\n",
"import logging\n",
"\n",
"logging.getLogger('redisvl').setLevel(logging.WARNING)"
]
},
Expand Down
11 changes: 2 additions & 9 deletions libs/redis/docs/kitchensink.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,10 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from langchain_redis import RedisVectorStore, RedisCache, RedisChatMessageHistory\n",
"from langchain_openai import OpenAIEmbeddings, OpenAI\n",
"from langchain.globals import set_llm_cache\n",
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_core.output_parsers import StrOutputParser\n",
"import wikipedia"
]
"source": "from langchain_redis import RedisVectorStore, RedisCache, RedisChatMessageHistory\nfrom langchain_openai import OpenAIEmbeddings, OpenAI\nfrom langchain_core.globals import set_llm_cache\nfrom langchain_core.prompts import PromptTemplate\nfrom langchain_core.output_parsers import StrOutputParser\nimport wikipedia"
},
{
"cell_type": "markdown",
Expand Down
204 changes: 204 additions & 0 deletions libs/redis/docs/langchain_v1_migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
# Migration Guide: LangChain v1.0

## Overview

`langchain-redis` v0.3.0 adds support for LangChain v1.0. This guide helps you migrate your applications to use the latest version.

## What Changed

### Breaking Changes

#### 1. Python Version Requirement

**Minimum Python version is now 3.10+**

- **Python 3.9 is no longer supported** (reaches end-of-life October 2025)
- **Supported versions**: Python 3.10, 3.11, 3.12, 3.13

**Action Required:**
- If you're on Python 3.9, upgrade to Python 3.10 or higher
- If you're on Python 3.10-3.13, no action needed

#### 2. Dependency Updates

**Updated to LangChain v1.0**

```toml
langchain-core = "^1.0" # was ^0.3
```

**Action Required:**
```bash
# Update your requirements.txt or pyproject.toml
pip install --upgrade langchain-redis langchain-core

# Or with poetry
poetry update langchain-redis langchain-core
```

## What Did NOT Change

**Good news**: The `langchain-redis` API remains completely unchanged!

All three main components work seamlessly without any code changes:

- ✅ **`RedisVectorStore`** - No changes required
- ✅ **`RedisCache` / `RedisSemanticCache`** - No changes required
- ✅ **`RedisChatMessageHistory`** - No changes required
- ✅ **`RedisConfig`** - No changes required

Your existing code will continue to work as-is after updating dependencies.

## Migration Steps

### Step 1: Check Your Python Version

```bash
python --version
```

If you're on Python 3.9, upgrade to 3.10+:

```bash
# Using pyenv (recommended)
pyenv install 3.10.15 # or 3.11, 3.12, 3.13
pyenv global 3.10.15

# Recreate your virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```

### Step 2: Update Dependencies

**Option A: Using pip**
```bash
pip install --upgrade langchain-redis langchain-core
```

**Option B: Using poetry**
```bash
# Update pyproject.toml
# python = ">=3.10,<3.14"
# langchain-core = "^1.0"

poetry lock
poetry install
```

**Option C: Using requirements.txt**
```txt
langchain-redis>=0.3.0
langchain-core>=1.0
```

### Step 4: Test Your Application

```bash
# Run your test suite
pytest tests/

# Verify your application works
python your_app.py
```

## Example Migration

### Before (works with both v0.2.x and v0.3.x):

```python
from langchain.globals import set_llm_cache
from langchain.schema import Generation
from langchain_openai import OpenAI
from langchain_redis import RedisCache

# Initialize cache
cache = RedisCache(redis_url="redis://localhost:6379")
set_llm_cache(cache)

# Use as normal
llm = OpenAI()
result = llm.invoke("Hello!")
```

### After (recommended for v0.3.0+):

```python
# Note that `langchain` became `langchain_core`
from langchain_core.globals import set_llm_cache
from langchain_core.outputs import Generation
from langchain_openai import OpenAI
from langchain_redis import RedisCache

# Initialize cache (no changes needed)
cache = RedisCache(redis_url="redis://localhost:6379")
set_llm_cache(cache)

# Use as normal (no changes needed)
llm = OpenAI()
result = llm.invoke("Hello!")
```

## Troubleshooting

### Issue: Import errors after upgrade

**Symptom:**
```python
ImportError: cannot import name 'set_llm_cache' from 'langchain.globals'
```

**Solution:**
Update your imports to use `langchain_core.globals`:
```python
from langchain_core.globals import set_llm_cache
```

### Issue: Python version conflict

**Symptom:**
```
ERROR: Package 'langchain-redis' requires a different Python: 3.9.x not in '>=3.10,<3.14'
```

**Solution:**
Upgrade to Python 3.10 or higher (see Step 1 above).

### Issue: Dependency resolver conflicts

**Symptom:**
```
ERROR: Cannot install langchain-redis and langchain-core because these package versions have conflicting dependencies.
```

**Solution:**
```bash
# Clear dependency cache
pip cache purge

# Install with updated resolver
pip install --upgrade --force-reinstall langchain-redis langchain-core
```

## FAQ

### Q: Do I need to change my application code?

**A:** No! The `langchain-redis` API is unchanged. You only need to update dependencies and optionally update import paths for future compatibility.

### Q: What if I can't upgrade from Python 3.9?

**A:** Stay on `langchain-redis` v0.3.x until you can upgrade Python. Python 3.9 reaches end-of-life in October 2025, so we recommend planning your upgrade soon.

### Q: Will my existing Redis data still work?

**A:** Yes! There are no changes to how data is stored in Redis. All existing indices, caches, and chat histories will continue to work.

### Q: Can I use langchain-redis v0.3.0 with langchain-core 0.3.x?

**A:** No, v0.3.0 requires langchain-core ^1.0. If you need to stay on langchain-core 0.3.x, use langchain-redis v0.2.x.

### Q: Are there any performance improvements in v0.3.0?

**A:** The migration to LangChain v1.0 includes upstream performance improvements and bug fixes. `langchain-redis` itself has no performance-related changes in this release.

41 changes: 3 additions & 38 deletions libs/redis/docs/langgraph_self_rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -160,46 +160,11 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"id": "565a6d44-2c9f-4fff-b1ec-eea05df9350d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"00:26:48 redisvl.index.index INFO Index already exists, not overwriting.\n"
]
}
],
"source": [
"from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
"from langchain_community.document_loaders import WebBaseLoader\n",
"from langchain_openai import OpenAIEmbeddings\n",
"\n",
"from langchain_redis import RedisVectorStore\n",
"\n",
"urls = [\n",
" \"https://lilianweng.github.io/posts/2023-06-23-agent/\",\n",
" \"https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/\",\n",
" \"https://lilianweng.github.io/posts/2023-10-25-adv-attack-llm/\",\n",
"]\n",
"\n",
"docs = [WebBaseLoader(url).load() for url in urls]\n",
"docs_list = [item for sublist in docs for item in sublist]\n",
"\n",
"text_splitter = RecursiveCharacterTextSplitter.from_tiktoken_encoder(\n",
" chunk_size=250, chunk_overlap=0\n",
")\n",
"doc_splits = text_splitter.split_documents(docs_list)\n",
"\n",
"# Add to vectorDB\n",
"vectorstore = RedisVectorStore.from_documents(\n",
" doc_splits, OpenAIEmbeddings(), redis_url=REDIS_URL, index_name=\"rag-redis\"\n",
")\n",
"\n",
"retriever = vectorstore.as_retriever()"
]
"outputs": [],
"source": "from langchain_text_splitters import RecursiveCharacterTextSplitter\nfrom langchain_community.document_loaders import WebBaseLoader\nfrom langchain_openai import OpenAIEmbeddings\n\nfrom langchain_redis import RedisVectorStore\n\nurls = [\n \"https://lilianweng.github.io/posts/2023-06-23-agent/\",\n \"https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/\",\n \"https://lilianweng.github.io/posts/2023-10-25-adv-attack-llm/\",\n]\n\ndocs = [WebBaseLoader(url).load() for url in urls]\ndocs_list = [item for sublist in docs for item in sublist]\n\ntext_splitter = RecursiveCharacterTextSplitter.from_tiktoken_encoder(\n chunk_size=250, chunk_overlap=0\n)\ndoc_splits = text_splitter.split_documents(docs_list)\n\n# Add to vectorDB\nvectorstore = RedisVectorStore.from_documents(\n doc_splits, OpenAIEmbeddings(), redis_url=REDIS_URL, index_name=\"rag-redis\"\n)\n\nretriever = vectorstore.as_retriever()"
},
{
"cell_type": "markdown",
Expand Down
4 changes: 2 additions & 2 deletions libs/redis/docs/vectorstores.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ruff: noqa: E501\n",
"import os\n",
"\n",
"from langchain.docstore.document import Document\n",
"from langchain_core.documents import Document\n",
"from sklearn.datasets import fetch_20newsgroups\n",
"\n",
"from langchain_redis import RedisVectorStore"
Expand Down
Loading
Loading