langchain-ai / langgraph

Build resilient language agents as graphs.
https://langchain-ai.github.io/langgraph/
MIT License
5.86k stars 923 forks source link

sqlite checkpointer import error #1831

Open openSourcerer9000 opened 3 days ago

openSourcerer9000 commented 3 days ago

Checked other resources

Example Code

from langgraph.checkpoint.sqlite import SqliteSaver

Error Message and Stack Trace (if applicable)

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[46], line 1
----> 1 from langgraph.checkpoint.sqlite import SqliteSaver
      2 # SqliteSaver.config_specs

File ...\Lib\site-packages\langgraph\checkpoint\sqlite\__init__.py:9
      5 from typing import Any, AsyncIterator, Dict, Iterator, Optional, Sequence, Tuple
      7 from langchain_core.runnables import RunnableConfig
----> 9 from langgraph.checkpoint.base import (
     10     WRITES_IDX_MAP,
     11     BaseCheckpointSaver,
     12     ChannelVersions,
     13     Checkpoint,
     14     CheckpointMetadata,
     15     CheckpointTuple,
     16     SerializerProtocol,
     17     get_checkpoint_id,
     18 )
     19 from langgraph.checkpoint.serde.jsonplus import JsonPlusSerializer
     20 from langgraph.checkpoint.serde.types import ChannelProtocol

ImportError: cannot import name 'WRITES_IDX_MAP' from 'langgraph.checkpoint.base'```

Description

Checkpointing is broken- something broke with internal import statements.

This documentation is also out of date: https://langchain-ai.github.io/langgraph/reference/checkpoints/#sqlitesaver

System Info

System Information

OS: Windows OS Version: 10.0.19045 Python Version: 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:40:50) [MSC v.1937 64 bit (AMD64)]

Package Information

langchain_core: 0.2.34 langchain: 0.2.12 langchain_community: 0.2.11 langsmith: 0.1.127 langchain_cli: 0.0.29 langchain_ollama: 0.1.1 langchain_openai: 0.1.22 langchain_text_splitters: 0.2.2 langgraph: 0.2.3 langserve: 0.2.2

Other Dependencies

aiohttp: 3.10.1 async-timeout: 4.0.3 dataclasses-json: 0.6.7 fastapi: 0.112.0 gitpython: 3.1.43 httpx: 0.27.0 jsonpatch: 1.33 langgraph-checkpoint: 1.0.11 langserve[all]: Installed. No version info available. libcst: 1.4.0 numpy: 1.26.4 ollama: 0.3.1 openai: 1.40.1 orjson: 3.10.6 packaging: 24.1 pydantic: 2.8.2 pyproject-toml: 0.0.10 PyYAML: 6.0.1 requests: 2.31.0 SQLAlchemy: 2.0.32 sse-starlette: 1.8.2 tenacity: 8.5.0 tiktoken: 0.7.0 tomlkit: 0.12.5 typer[all]: Installed. No version info available. typing-extensions: 4.11.0 uvicorn: 0.23.2

nfcampos commented 3 days ago

Your dependency list suggests you don't have langgraph-checkpoint-sqlite installed but are trying to import it anyway. I'd suggest installing it with pip install langgraph-checkpoint-sqlite and trying again

openSourcerer9000 commented 3 days ago

mm didn't realize it was unable to install.

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
langchain 0.2.12 requires langchain-core<0.3.0,>=0.2.27, but you have langchain-core 0.3.5 which is incompatible.
langchain-community 0.2.11 requires langchain-core<0.3.0,>=0.2.27, but you have langchain-core 0.3.5 which is incompatible.
langchain-ollama 0.1.1 requires langchain-core<0.3.0,>=0.2.20, but you have langchain-core 0.3.5 which is incompatible.
langchain-openai 0.1.22 requires langchain-core<0.3.0,>=0.2.33, but you have langchain-core 0.3.5 which is incompatible.
langchain-text-splitters 0.2.2 requires langchain-core<0.3.0,>=0.2.10, but you have langchain-core 0.3.5 which is incompatible.
langgraph 0.2.3 requires langchain-core<0.3,>=0.2.27, but you have langchain-core 0.3.5 which is incompatible.
langserve 0.2.2 requires langchain-core<0.3,>=0.1, but you have langchain-core 0.3.5 which is incompatible.

I understand the langchain,langgraph, langsmith ecosystem, but it seems langchain alone being split up into 50 separate libs causes a lot of issues.

It seems it's not on conda either. what's the latest working combination of all this stuff?

hinthornw commented 2 days ago

Langchain 0.3.0 is on conda: https://anaconda.org/conda-forge/langchain

openSourcerer9000 commented 2 days ago

I was just referring to langgraph-checkpoint-sqlite which is not, and no one seems to know the last time all these packages used to work together.

openSourcerer9000 commented 2 days ago

My env got nuked uninstalling and reinstalling these packages; I eventually had to reinstall the 15 GB's of stuff in my env to get to get it working again. Besides this deprecation warning, the following versions seem to work. I would recommend following best practices for packaging ecosystems, or simply having a single langchain lib rather than all these separate packages.

LangChainDeprecationWarning: As of langchain-core 0.3.0, LangChain uses pydantic v2 internally. The langchain_core.pydantic_v1 module was a compatibility shim 
for pydantic v1, and should no longer be used. Please update the code to import from Pydantic directly. 

For example, replace imports like: `from langchain_core.pydantic_v1 import BaseModel`
with: `from pydantic import BaseModel`
or the v1 compatibility namespace if you are working in a code base that has not been fully upgraded to 
pydantic 2 yet.         from pydantic.v1 import BaseModel
System Information
------------------
> OS:  Windows
> OS Version:  10.0.19045
> Python Version:  3.12.6 | packaged by conda-forge | (main, Sep 22 2024, 14:01:26) [MSC v.1941 64 bit (AMD64)]

Package Information
-------------------
> langchain_core: 0.3.6
> langchain: 0.3.1
> langchain_community: 0.3.1
> langsmith: 0.1.128
> langchain_ollama: 0.2.0
> langchain_openai: 0.2.0
> langchain_text_splitters: 0.3.0
> langgraph: 0.2.28

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp: 3.10.6
> async-timeout: Installed. No version info available.
> dataclasses-json: 0.6.7
> httpx: 0.27.2
> jsonpatch: 1.33
> langgraph-checkpoint: 1.0.11
> numpy: 1.26.4
> ollama: 0.3.3
> openai: 1.48.0
> orjson: 3.10.7
> packaging: 24.1
> pydantic: 2.8.2
> pydantic-settings: 2.5.2
> PyYAML: 6.0.2
> requests: 2.32.3
> SQLAlchemy: 2.0.35
> tenacity: 8.5.0
> tiktoken: 0.7.0
> typing-extensions: 4.12.2