|
| 1 | +# Migration Guide: LangChain v1.0 |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +`langchain-redis` v0.3.0 adds support for LangChain v1.0, which was released in January 2025. This guide helps you migrate your applications to use the latest version. |
| 6 | + |
| 7 | +## What Changed |
| 8 | + |
| 9 | +### Breaking Changes |
| 10 | + |
| 11 | +#### 1. Python Version Requirement |
| 12 | + |
| 13 | +**Minimum Python version is now 3.10+** |
| 14 | + |
| 15 | +- **Python 3.9 is no longer supported** (reaches end-of-life October 2025) |
| 16 | +- **Supported versions**: Python 3.10, 3.11, 3.12, 3.13 |
| 17 | +- **Not yet supported**: Python 3.14 (awaiting dependency updates) |
| 18 | + |
| 19 | +**Action Required:** |
| 20 | +- If you're on Python 3.9, upgrade to Python 3.10 or higher |
| 21 | +- If you're on Python 3.10-3.13, no action needed |
| 22 | +- If you're on Python 3.14, please use Python 3.10-3.13 until future release |
| 23 | + |
| 24 | +#### 2. Dependency Updates |
| 25 | + |
| 26 | +**Updated to LangChain v1.0** |
| 27 | + |
| 28 | +```toml |
| 29 | +langchain-core = "^1.0" # was ^0.3 |
| 30 | +``` |
| 31 | + |
| 32 | +**Action Required:** |
| 33 | + |
| 34 | +```bash |
| 35 | +# Update your requirements.txt or pyproject.toml |
| 36 | +pip install --upgrade langchain-redis langchain-core |
| 37 | + |
| 38 | +# Or with poetry |
| 39 | +poetry update langchain-redis langchain-core |
| 40 | +``` |
| 41 | + |
| 42 | +### Recommended Changes (Optional but Encouraged) |
| 43 | + |
| 44 | +#### Import Path Updates |
| 45 | + |
| 46 | +While old imports still work, we recommend updating to the new paths for future compatibility: |
| 47 | + |
| 48 | +**Cache and Globals:** |
| 49 | + |
| 50 | +```python |
| 51 | +# Old (still works but deprecated): |
| 52 | +from langchain.globals import set_llm_cache |
| 53 | + |
| 54 | +# New (recommended): |
| 55 | +from langchain_core.globals import set_llm_cache |
| 56 | +``` |
| 57 | + |
| 58 | +**Output Types:** |
| 59 | + |
| 60 | +```python |
| 61 | +# Old (still works but deprecated): |
| 62 | +from langchain.schema import Generation |
| 63 | + |
| 64 | +# New (recommended): |
| 65 | +from langchain_core.outputs import Generation |
| 66 | +``` |
| 67 | + |
| 68 | +**Documents:** |
| 69 | + |
| 70 | +```python |
| 71 | +# Old (still works but deprecated): |
| 72 | +from langchain.docstore.document import Document |
| 73 | + |
| 74 | +# New (recommended): |
| 75 | +from langchain_core.documents import Document |
| 76 | +``` |
| 77 | + |
| 78 | +**Text Splitters:** |
| 79 | + |
| 80 | +```python |
| 81 | +# Old (still works but deprecated): |
| 82 | +from langchain.text_splitter import RecursiveCharacterTextSplitter |
| 83 | + |
| 84 | +# New (recommended): |
| 85 | +from langchain_text_splitters import RecursiveCharacterTextSplitter |
| 86 | +``` |
| 87 | + |
| 88 | +## What Did NOT Change |
| 89 | + |
| 90 | +**Good news**: The `langchain-redis` API remains completely unchanged! |
| 91 | + |
| 92 | +All three main components work seamlessly without any code changes: |
| 93 | + |
| 94 | +- ✅ **`RedisVectorStore`** - No changes required |
| 95 | +- ✅ **`RedisCache` / `RedisSemanticCache`** - No changes required |
| 96 | +- ✅ **`RedisChatMessageHistory`** - No changes required |
| 97 | +- ✅ **`RedisConfig`** - No changes required |
| 98 | + |
| 99 | +Your existing code will continue to work as-is after updating dependencies. |
| 100 | + |
| 101 | +## Migration Steps |
| 102 | + |
| 103 | +### Step 1: Check Your Python Version |
| 104 | + |
| 105 | +```bash |
| 106 | +python --version |
| 107 | +``` |
| 108 | + |
| 109 | +If you're on Python 3.9, upgrade to 3.10+: |
| 110 | + |
| 111 | +```bash |
| 112 | +# Using pyenv (recommended) |
| 113 | +pyenv install 3.10.15 # or 3.11, 3.12, 3.13 |
| 114 | +pyenv global 3.10.15 |
| 115 | + |
| 116 | +# Recreate your virtual environment |
| 117 | +python -m venv .venv |
| 118 | +source .venv/bin/activate # On Windows: .venv\Scripts\activate |
| 119 | +``` |
| 120 | + |
| 121 | +### Step 2: Update Dependencies |
| 122 | + |
| 123 | +**Option A: Using pip** |
| 124 | + |
| 125 | +```bash |
| 126 | +pip install --upgrade langchain-redis langchain-core |
| 127 | +``` |
| 128 | + |
| 129 | +**Option B: Using poetry** |
| 130 | + |
| 131 | +```bash |
| 132 | +# Update pyproject.toml |
| 133 | +# python = ">=3.10,<3.14" |
| 134 | +# langchain-core = "^1.0" |
| 135 | + |
| 136 | +poetry lock |
| 137 | +poetry install |
| 138 | +``` |
| 139 | + |
| 140 | +**Option C: Using requirements.txt** |
| 141 | + |
| 142 | +```txt |
| 143 | +langchain-redis>=0.3.0 |
| 144 | +langchain-core>=1.0 |
| 145 | +``` |
| 146 | + |
| 147 | +### Step 3: Update Imports (Optional) |
| 148 | + |
| 149 | +Update deprecated import paths in your code: |
| 150 | + |
| 151 | +```bash |
| 152 | +# Find deprecated imports |
| 153 | +grep -r "from langchain\\.globals" . |
| 154 | +grep -r "from langchain\\.schema" . |
| 155 | +grep -r "from langchain\\.docstore" . |
| 156 | +grep -r "from langchain\\.text_splitter" . |
| 157 | +``` |
| 158 | + |
| 159 | +Replace with new paths as shown in the "Recommended Changes" section above. |
| 160 | + |
| 161 | +### Step 4: Test Your Application |
| 162 | + |
| 163 | +```bash |
| 164 | +# Run your test suite |
| 165 | +pytest tests/ |
| 166 | + |
| 167 | +# Verify your application works |
| 168 | +python your_app.py |
| 169 | +``` |
| 170 | + |
| 171 | +## Example Migration |
| 172 | + |
| 173 | +### Before (works with both v0.2.x and v0.3.0) |
| 174 | + |
| 175 | +```python |
| 176 | +from langchain.globals import set_llm_cache |
| 177 | +from langchain.schema import Generation |
| 178 | +from langchain_openai import OpenAI |
| 179 | +from langchain_redis import RedisCache |
| 180 | + |
| 181 | +# Initialize cache |
| 182 | +cache = RedisCache(redis_url="redis://localhost:6379") |
| 183 | +set_llm_cache(cache) |
| 184 | + |
| 185 | +# Use as normal |
| 186 | +llm = OpenAI() |
| 187 | +result = llm.invoke("Hello!") |
| 188 | +``` |
| 189 | + |
| 190 | +### After (recommended for v0.3.0+) |
| 191 | + |
| 192 | +```python |
| 193 | +from langchain_core.globals import set_llm_cache |
| 194 | +from langchain_core.outputs import Generation |
| 195 | +from langchain_openai import OpenAI |
| 196 | +from langchain_redis import RedisCache |
| 197 | + |
| 198 | +# Initialize cache (no changes needed!) |
| 199 | +cache = RedisCache(redis_url="redis://localhost:6379") |
| 200 | +set_llm_cache(cache) |
| 201 | + |
| 202 | +# Use as normal (no changes needed!) |
| 203 | +llm = OpenAI() |
| 204 | +result = llm.invoke("Hello!") |
| 205 | +``` |
| 206 | + |
| 207 | +## Troubleshooting |
| 208 | + |
| 209 | +### Issue: Import errors after upgrade |
| 210 | + |
| 211 | +**Symptom:** |
| 212 | + |
| 213 | +```python |
| 214 | +ImportError: cannot import name 'set_llm_cache' from 'langchain.globals' |
| 215 | +``` |
| 216 | + |
| 217 | +**Solution:** |
| 218 | +Update your imports to use `langchain_core.globals`: |
| 219 | + |
| 220 | +```python |
| 221 | +from langchain_core.globals import set_llm_cache |
| 222 | +``` |
| 223 | + |
| 224 | +### Issue: Python version conflict |
| 225 | + |
| 226 | +**Symptom:** |
| 227 | + |
| 228 | +```bash |
| 229 | +ERROR: Package 'langchain-redis' requires a different Python: 3.9.x not in '>=3.10,<3.14' |
| 230 | +``` |
| 231 | + |
| 232 | +**Solution:** |
| 233 | +Upgrade to Python 3.10 or higher (see Step 1 above). |
| 234 | + |
| 235 | +### Issue: Dependency resolver conflicts |
| 236 | + |
| 237 | +**Symptom:** |
| 238 | + |
| 239 | +```bash |
| 240 | +ERROR: Cannot install langchain-redis and langchain-core because these package versions have conflicting dependencies. |
| 241 | +``` |
| 242 | + |
| 243 | +**Solution:** |
| 244 | + |
| 245 | +```bash |
| 246 | +# Clear dependency cache |
| 247 | +pip cache purge |
| 248 | + |
| 249 | +# Install with updated resolver |
| 250 | +pip install --upgrade --force-reinstall langchain-redis langchain-core |
| 251 | +``` |
| 252 | + |
| 253 | +## Version Compatibility Matrix |
| 254 | + |
| 255 | +| langchain-redis | langchain-core | Python | Status | |
| 256 | +|-----------------|----------------|--------|--------| |
| 257 | +| 0.2.x | ^0.3 | >=3.9,<3.14 | Legacy | |
| 258 | +| 0.3.x | ^1.0 | >=3.10,<3.14 | ✅ Current | |
| 259 | + |
| 260 | +## Python Version Support Matrix |
| 261 | + |
| 262 | +| Python Version | langchain-redis v0.3.0 | Notes | |
| 263 | +|----------------|------------------------|-------| |
| 264 | +| 3.9 | ❌ Not supported | EOL October 2025 | |
| 265 | +| 3.10 | ✅ Supported | Minimum version | |
| 266 | +| 3.11 | ✅ Supported | Recommended | |
| 267 | +| 3.12 | ✅ Supported | Recommended | |
| 268 | +| 3.13 | ✅ Supported | Latest | |
| 269 | +| 3.14 | ⏳ Coming soon | Awaiting redisvl update | |
| 270 | + |
| 271 | +## Need Help? |
| 272 | + |
| 273 | +- 📖 **Documentation**: [https://python.langchain.com/docs/integrations/providers/redis](https://python.langchain.com/docs/integrations/providers/redis) |
| 274 | +- 🐛 **Issues**: [https://github.com/langchain-ai/langchain-redis/issues](https://github.com/langchain-ai/langchain-redis/issues) |
| 275 | +- 💬 **Discord**: [LangChain Community Discord](https://discord.gg/langchain) |
| 276 | +- 📚 **LangChain v1.0 Migration Guide**: [https://docs.langchain.com/oss/python/migrate/langchain-v1](https://docs.langchain.com/oss/python/migrate/langchain-v1) |
| 277 | + |
| 278 | +## FAQ |
| 279 | + |
| 280 | +### Q: Do I need to change my application code? |
| 281 | + |
| 282 | +**A:** No! The `langchain-redis` API is unchanged. You only need to update dependencies and optionally update import paths for future compatibility. |
| 283 | + |
| 284 | +### Q: What if I can't upgrade from Python 3.9? |
| 285 | + |
| 286 | +**A:** Stay on `langchain-redis` v0.2.x until you can upgrade Python. Python 3.9 reaches end-of-life in October 2025, so we recommend planning your upgrade soon. |
| 287 | + |
| 288 | +### Q: Will my existing Redis data still work? |
| 289 | + |
| 290 | +**A:** Yes! There are no changes to how data is stored in Redis. All existing indices, caches, and chat histories will continue to work. |
| 291 | + |
| 292 | +### Q: When will Python 3.14 be supported? |
| 293 | + |
| 294 | +**A:** Python 3.14 support will be added in a future release (v0.4.0+) once our dependency `redisvl` adds support for Python 3.14. |
| 295 | + |
| 296 | +### Q: Can I use langchain-redis v0.3.0 with langchain-core 0.3.x? |
| 297 | + |
| 298 | +**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. |
| 299 | + |
| 300 | +### Q: Are there any performance improvements in v0.3.0? |
| 301 | + |
| 302 | +**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. |
| 303 | + |
| 304 | +## Changelog |
| 305 | + |
| 306 | +See [CHANGELOG.md](CHANGELOG.md) for detailed version history. |
| 307 | + |
| 308 | +## Next Steps |
| 309 | + |
| 310 | +After migration: |
| 311 | + |
| 312 | +1. ✅ Update your CI/CD pipelines to use Python 3.10+ |
| 313 | +2. ✅ Update import paths in your codebase (optional but recommended) |
| 314 | +3. ✅ Review your dependencies for other LangChain v1.0-compatible versions |
| 315 | +4. ✅ Test thoroughly in a staging environment before production deployment |
| 316 | + |
| 317 | +--- |
| 318 | + |
| 319 | +**Last Updated**: 2025-01-13 |
| 320 | +**Version**: langchain-redis v0.3.0 |
0 commit comments