-
when i am trying to langgraph customer support example (https://langchain-ai.github.io/langgraph/tutorials/customer-support/customer-support/) , it is facing below error--- Traceback (most recent call last): with the older version it was working fine but after upgradation it is facing above error |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 15 replies
-
@smanna123 it looks like you're using with SqliteSaver.from_conn_string(...) as checkpointer:
app = graph.compile(checkpointer=checkpointer)
app.invoke(...) hope this helps! |
Beta Was this translation helpful? Give feedback.
-
from langgraph.checkpoint.memory import MemorySaver This fixed the issue. |
Beta Was this translation helpful? Give feedback.
-
If anyone is running into this problem while doing the Deeplearning.AI course. I found this implementation of the SqliteSaver to work with the following package versions:
I have not figured out the proper way to close the SQLite connection after running the streaming. I just close it at the bottom of my notebook. I would still recommend @vbarda's answer as that is the proper way to use it. sqlite_conn = sqlite3.connect("checkpoints.sqlite", check_same_thread=False)
memory = SqliteSaver(sqlite_conn)
class SimpleMemoryAgent(SimpleAgent):
def __init__(self, model:ChatOpenAI, tools:list, checkpointer:BaseCheckpointSaver, system=""):
"""
An example of a simple agent with persistent memory and tools provided to it.
Args:
model (ChatOpenAI): The model to use for generating responses.
tools (list): A list of tools to use for processing tool calls.
checkpointer (BaseCheckpointSaver): The checkpointer to use for saving and loading the state of the agent.
system (str, optional): The system to use for generating the first response. Defaults to "".
"""
# save the initial system message
self.system = system
graph = StateGraph(SimpleAgentState)
graph.add_node("llm", self.call_openai) # add the agent (LLM) node
graph.add_node("action", self.take_action) # add the action node
# add the conditional edge to check if there are any tool calls.
# If there are, go to the action node, otherwise end.
graph.add_conditional_edges(
"llm",
self.exists_action,
{True: "action", False: END}
)
graph.add_edge("action", "llm") # add the edge to go back to the agent (LLM) node after the action node
graph.set_entry_point("llm") # set the entry point to the agent (LLM) node
self.graph = graph.compile(checkpointer=checkpointer) # !!! compile the graph but this time pass in the checkpointer !!!
self.tools = {t.name: t for t in tools} # save the tools. Map the tool name to the tool object.
self.model = model.bind_tools(tools) # bind the tools to the model. Lets the model know which tools to use. |
Beta Was this translation helpful? Give feedback.
-
Adding the correct answer and sequence of cells: ......
Delete this cell entirely:
The Agent class implementation will be as it is. Next cell:
next cell of messages, thread as is. Then add this cell:
|
Beta Was this translation helpful? Give feedback.
-
In reference to the
In later cells you can close the context by using |
Beta Was this translation helpful? Give feedback.
@smanna123 it looks like you're using
SqliteSaver.from_conn_string()
as a checkpointer, but it actually is a context manager. the right way to use it ishope this helps!