1. Learn
  2. /
  3. Courses
  4. /
  5. Designing Agentic Systems with LangChain

Connected

Exercise

Using graph memory for conversation

Now that your chatbot has access to memory, you can stream its responses to follow up questions. Note that your follow up questions will need no extra context as the chatbot can access the full conversation stored in its memory. The questions have already been set up for you.

Instructions

100 XP
  • Create a config dictionary with "configurable", containing "thread_id" set to "single_session_memory".
  • Loop through each graph event, applying the .stream() method to graph, passing a dictionary with "messages" containing the user_input labeled "user" and the config dictionary.
  • Loop through event.values() using value and print "Agent:" followed by "messages" if it exists in value and is not empty.