- 日期
- 作者
- LangChain 团队
✔️ LangGraph v0.2:通过新的检查点程序增强了自定义性
我们发布了 LangGraph v0.2,通过新的检查点程序库增强了自定义性。
LangGraph v0.2 允许您根据自定义需求定制有状态的 LangGraph 应用程序。使用检查点程序,您可以管理图状态,并构建具有会话记忆、强大的错误恢复和人机环路功能的弹性 LLM 应用程序。
我们现在拥有一套新的专用检查点程序库:
langgraph_checkpoint
:检查点程序保存器 (BaseCheckpointSaver
) 和序列化/反序列化接口 (SerializationProtocol
) 的基本接口。包括用于实验的内存检查点程序实现 (MemorySaver
)。langgraph_checkpoint_sqlite
:LangGraph 检查点程序的实现,使用 SQLite 数据库。非常适合实验和本地工作流程。langgraph_checkpoint_postgres
:我们为 LangGraph Cloud 中的 Postgres 编写和优化的高级检查点程序现在已开源,可供社区在此基础上进行构建。非常适合在生产环境中使用。
由于 LangGraph 检查点程序库以命名空间包的形式实现,您可以像以前一样导入检查点程序接口和实现,使用
from langgraph.checkpoint.base import BaseCheckpointSaver
from langgraph.checkpoint.memory import MemorySaver
from langgraph.checkpoint.sqlite import SqliteSaver
from langgraph.checkpoint.postgres import PostgresSaver
由于 SQLite 和 Postgres 检查点程序是通过单独的库提供的,因此您需要使用 pip install langgraph-checkpoint-sqlite
或 pip install langgraph-checkpoint-postgres
单独安装它们。
我们将 LangGraph v0.2 设计为在很大程度上向后兼容。以下是此最新版本中的重大更改和弃用列表。
重大更改
LangGraph v0.2 引入了以下重大更改
thread_ts
和parent_ts
已分别重命名为checkpoint_id
和parent_checkpoint_id
(通过langgraph_checkpoint==1.0.0
)。注意:LangGraph 检查点程序仍然识别通过配置传递的
thread_ts
,并将其视为checkpoint_id
由于使用了命名空间包,因此不再可能进行像
from langgraph.checkpoint import BaseCheckpointSaver
这样的重新导出的导入。请改为使用from langgraph.checkpoint.base import BaseCheckpointSaver
SQLite 检查点程序已移至单独的库,因此您需要使用
pip install langgraph-checkpoint-sqlite
单独安装它
弃用
在 LangGraph v0.2 中,我们已删除
langgraph.prebuilt.chat
_agent_executor.create_function_calling_executor
。我们建议您改用langgraph.prebuilt.chat
_agent_executor.create_react_agent
langgraph.prebuilt.agent_executor
。我们建议您改用langgraph.prebuilt.chat
_agent_executor.create_react_agent
更多资源