【已解决】报错ModuleNotFoundError: No module named ‘langgraph.checkpoint.aiosqlite‘
在使用异步langgraph时,解决报错ModuleNotFoundError: No module named 'langgraph.checkpoint.aiosqlite'
·
当我想要使用langgraph的异步流时候,想要引用from langgraph.checkpoint.aiosqlite import AsyncSqliteSaver
但是报错ModuleNotFoundError: No module named 'langgraph.checkpoint.aiosqlite'
查阅大量资料发现不知道为什么这个包没用了,我找到了别的方法让它能够跑起来。
首先需要下载这个包(这个包也可以用于普通版本的checkpoint)
pip install langgraph-checkpoint-sqlite==2.0.3
再在代码里导入from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver就可以运行了,比如我的使用场景
from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
query = "What is the weather in New York?"
messages = [HumanMessage(content=query)]
async with AsyncSqliteSaver.from_conn_string("checkpoints.sqlite") as saver:
abot = Agent(model, [tool], system=prompt, checkpointer=saver)
config = {"configurable": {"thread_id": "thread-1"}}
async for event in abot.graph.astream_events({"messages": messages}, config):
kind = event["event"]
if kind == "on_chat_model_stream":
content = event["data"]["chunk"].content
if content:
# empty content in the context of Ollama means
# that the model is asking for a tool to be invoked.
# So we only print non-empty content.
print(content, end="|")
👉 完整项目请访问这里(后续还会更新更多实现!想要追更请关注订阅我哦):点击传送门
⭐ 如果这些资源对您有所帮助,请不要忘记点个Star支持!您的每一次收藏都是对我工作的莫大鼓励。
更多推荐




所有评论(0)