Lesson 4: Persistence and Streaming -> AttributeError: '_GeneratorContextManager' object has no attribute 'get_next_version'

Hi everyone!

I have the error bellow after that I execute this code:

for event in abot.graph.stream({“messages”: messages}, thread):
for v in event.values():
print(v[‘messages’])


→ 663 self.checkpointer_get_next_version = checkpointer.get_next_version
664 self.checkpointer_put_writes = checkpointer.put_writes
665 else:

AttributeError: ‘_GeneratorContextManager’ object has no attribute ‘get_next_version’

Someone with the same problem?

Thanks!

It works if you put all code that depens on “memory” inside a with declaration:

with SqliteSaver.from_conn_string(":memory:") as memory:
  abot = Agent(model, [tool], system=prompt, checkpointer=memory)

  messages = [HumanMessage(content="What is the weather in sf?")]
  thread = {"configurable": {"thread_id": "1"}}
  
  for event in abot.graph.stream({"messages": messages}, thread):
      for v in event.values():
          print(v['messages'])

Someone with a solution without refactoring?

Thanks!

1 Like