<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: LangGraph MemorySaver checkpointer usage with MLflow in Generative AI</title>
    <link>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/113076#M799</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/142310"&gt;@moemedina&lt;/a&gt;. No, I didn't.&lt;BR /&gt;&lt;BR /&gt;I'm considering using ChatModel/ChatAgent class to wrap the graph and be able to move on. However, the MLflow documentation is still referring to ChatModel where Chat Agent is the latest recommendation:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebascardonal_0-1742408476084.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/15507iBCDF273D4CFC31EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebascardonal_0-1742408476084.png" alt="sebascardonal_0-1742408476084.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebascardonal_1-1742408588246.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/15509i54E1D99290BEAB6D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebascardonal_1-1742408588246.png" alt="sebascardonal_1-1742408588246.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;MLflow ChatModel Doc:&amp;nbsp;&lt;A href="https://mlflow.org/docs/latest/llms/chat-model-intro/" target="_blank"&gt;https://mlflow.org/docs/latest/llms/chat-model-intro/&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Databricks Doc: &lt;A href="https://docs.databricks.com/aws/en/generative-ai/agent-framework/author-agent" target="_blank"&gt;https://docs.databricks.com/aws/en/generative-ai/agent-framework/author-agent&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;ChatAgent API Doc:&amp;nbsp;&lt;A href="https://mlflow.org/docs/latest/api_reference/python_api/mlflow.pyfunc.html#mlflow.pyfunc.ChatAgent" target="_blank"&gt;https://mlflow.org/docs/latest/api_reference/python_api/mlflow.pyfunc.html#mlflow.pyfunc.ChatAgent&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Mar 2025 18:24:41 GMT</pubDate>
    <dc:creator>sebascardonal</dc:creator>
    <dc:date>2025-03-19T18:24:41Z</dc:date>
    <item>
      <title>LangGraph MemorySaver checkpointer usage with MLflow</title>
      <link>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/109909#M766</link>
      <description>&lt;P&gt;Hi everyone.&lt;BR /&gt;&lt;BR /&gt;I am working on a graph that utilizes the MemorySaver class to incorporate short-term memory. This will enable me to maintain a multi-turn conversation with the user by storing the chat history.&lt;/P&gt;&lt;P&gt;I am using the MLflow "models from code"&amp;nbsp;feature but I'm getting an error because when the model is invoked it requires the config parameter with a thread_id:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN&gt;ValueError("Checkpointer requires one or more of the following 'configurable' keys: ['thread_id', 'checkpoint_ns', 'checkpoint_id']")Traceback (most recent call last)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV class=""&gt;&amp;nbsp;The graph compilation is:&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;# Compile&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;memory &lt;SPAN&gt;= &lt;SPAN&gt;MemorySaver&lt;SPAN&gt;()&lt;BR /&gt;&lt;SPAN&gt;graph &lt;SPAN&gt;=&lt;SPAN&gt; graph_builder.&lt;SPAN&gt;compile&lt;SPAN&gt;(&lt;SPAN&gt;checkpointer&lt;SPAN&gt;=&lt;SPAN&gt;memory)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;How to register a LangGraph graph in MLflow that uses the MemorySaver to store the chat history in the short-term memory?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 11 Feb 2025 21:38:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/109909#M766</guid>
      <dc:creator>sebascardonal</dc:creator>
      <dc:date>2025-02-11T21:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: LangGraph MemorySaver checkpointer usage with MLflow</title>
      <link>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/109956#M768</link>
      <description>&lt;P&gt;To register a LangGraph graph in MLflow using MemorySaver for short-term memory, you can follow these steps:&lt;/P&gt;&lt;P&gt;1. **Set up MemorySaver:** Create a `MemorySaver` checkpointer to enable persistent checkpointing, which saves the state of the graph after each step. This allows the chatbot to remember the context of previous interactions[3][5].&lt;/P&gt;&lt;P&gt;```python&lt;BR /&gt;from langgraph.checkpoint.memory import MemorySaver&lt;BR /&gt;memory = MemorySaver()&lt;BR /&gt;```&lt;BR /&gt;2. **Compile the graph with the checkpointer:** When compiling the graph, provide the `MemorySaver` checkpointer. Also, specify a `thread_id` when calling your graph, which allows LangGraph to load the saved state when the graph is invoked again[3].&lt;/P&gt;&lt;P&gt;```python&lt;BR /&gt;from langgraph.checkpoint.memory import MemorySaver&lt;BR /&gt;&lt;BR /&gt;# We need this because we want to enable threads (conversations)&lt;BR /&gt;checkpointer = MemorySaver()&lt;BR /&gt;&lt;BR /&gt;# ... Define the graph ...&lt;BR /&gt;&lt;BR /&gt;# Compile the graph with the checkpointer and store&lt;BR /&gt;graph = graph.compile(checkpointer=checkpointer, store=in_memory_store)&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;When you invoke the graph, use a `thread_id` and a `user_id` to namespace memories to a particular user[2].&lt;/P&gt;&lt;P&gt;```python&lt;BR /&gt;# Invoke the graph&lt;BR /&gt;user_id = "1"&lt;BR /&gt;config = {"configurable": {"thread_id": "1", "user_id": user_id}}&lt;BR /&gt;&lt;BR /&gt;# First let's just say hi to the AI&lt;BR /&gt;for update in graph.stream(&lt;BR /&gt;{"messages": [{"role": "user", "content": "hi"}]}, config, stream_mode="updates"&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;print(update)&lt;BR /&gt;```&lt;BR /&gt;3. **Define the LangGraph agent in a script:** Create a Python script (e.g., `langgraph.py`) that defines your LangGraph agent[1].&lt;BR /&gt;4. **Log the LangGraph model to MLflow:** Use `mlflow.langchain.log_model` to log the LangGraph agent to MLflow. Specify the path to the script defining the agent, the artifact path, and an input example[1].&lt;/P&gt;&lt;P&gt;```python&lt;BR /&gt;import mlflow&lt;BR /&gt;&lt;BR /&gt;input_example = {&lt;BR /&gt;"messages": [{"role": "user", "content": "what is the weather in seattle today?"}]&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;with mlflow.start_run():&lt;BR /&gt;model_info = mlflow.langchain.log_model(&lt;BR /&gt;lc_model="./langgraph.py", # specify the path to the LangGraph agent script definition&lt;BR /&gt;artifact_path="langgraph",&lt;BR /&gt;input_example=input_example,&lt;BR /&gt;)&lt;BR /&gt;```&lt;BR /&gt;5. **Load the model from MLflow and use it for inference:** Load the LangGraph agent from MLflow using `mlflow.langchain.load_model` and then invoke it with a query[1].&lt;/P&gt;&lt;P&gt;```python&lt;BR /&gt;agent = mlflow.langchain.load_model(model_info.model_uri)&lt;BR /&gt;query = {&lt;BR /&gt;"messages": [&lt;BR /&gt;{&lt;BR /&gt;"role": "user",&lt;BR /&gt;"content": "Should I bring an umbrella today when I go to work in San Francisco?",&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;agent.invoke(query)&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;By using MemorySaver, LangGraph can store and recall information between conversations, allowing the agent to learn from feedback and adapt to user preferences[8].&lt;/P&gt;&lt;P&gt;Citations:&lt;BR /&gt;[1] &lt;A href="https://mlflow.org/docs/latest/llms/langchain/index.html" target="_blank"&gt;https://mlflow.org/docs/latest/llms/langchain/index.html&lt;/A&gt;&lt;BR /&gt;[2] &lt;A href="https://langchain-ai.github.io/langgraph/concepts/persistence/" target="_blank"&gt;https://langchain-ai.github.io/langgraph/concepts/persistence/&lt;/A&gt;&lt;BR /&gt;[3] &lt;A href="https://langchain-ai.github.io/langgraph/tutorials/introduction/" target="_blank"&gt;https://langchain-ai.github.io/langgraph/tutorials/introduction/&lt;/A&gt;&lt;BR /&gt;[4] &lt;A href="https://mlflow.org/docs/latest/model-registry.html" target="_blank"&gt;https://mlflow.org/docs/latest/model-registry.html&lt;/A&gt;&lt;BR /&gt;[5] &lt;A href="https://www.youtube.com/watch?v=GMaGG8UBek8" target="_blank"&gt;https://www.youtube.com/watch?v=GMaGG8UBek8&lt;/A&gt;&lt;BR /&gt;[6] &lt;A href="https://langchain-ai.github.io/langgraph/how-tos/memory/manage-conversation-history/" target="_blank"&gt;https://langchain-ai.github.io/langgraph/how-tos/memory/manage-conversation-history/&lt;/A&gt;&lt;BR /&gt;[7] &lt;A href="https://mlflow.org/blog/langgraph-model-from-code" target="_blank"&gt;https://mlflow.org/blog/langgraph-model-from-code&lt;/A&gt;&lt;BR /&gt;[8] &lt;A href="https://blog.langchain.dev/launching-long-term-memory-support-in-langgraph/" target="_blank"&gt;https://blog.langchain.dev/launching-long-term-memory-support-in-langgraph/&lt;/A&gt;&lt;BR /&gt;[9] &lt;A href="https://www.getzep.com/ai-agents/langgraph-tutorial" target="_blank"&gt;https://www.getzep.com/ai-agents/langgraph-tutorial&lt;/A&gt;&lt;BR /&gt;[10] &lt;A href="https://mlflow.org/docs/latest/python_api/mlflow.langchain.html" target="_blank"&gt;https://mlflow.org/docs/latest/python_api/mlflow.langchain.html&lt;/A&gt;&lt;BR /&gt;[11] &lt;A href="https://github.com/langchain-ai/langgraph/discussions/352" target="_blank"&gt;https://github.com/langchain-ai/langgraph/discussions/352&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 10:59:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/109956#M768</guid>
      <dc:creator>Pawan1979</dc:creator>
      <dc:date>2025-02-12T10:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: LangGraph MemorySaver checkpointer usage with MLflow</title>
      <link>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/109998#M769</link>
      <description>&lt;P&gt;Hi Pawan.&lt;BR /&gt;&lt;BR /&gt;Thanks for your answer. However, the issue is more related to MLflow than LangGraph. My graph is working perfectly in the notebook, but I need to put it into production and create the API, and to do that, I need to register the graph and be able to use it.&lt;BR /&gt;&lt;BR /&gt;The question is, how MLflow or Databricks would know that a threat_id is needed for every chat session? How should I register the graph to be able to use the short-term memory in the API?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 14:12:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/109998#M769</guid>
      <dc:creator>sebascardonal</dc:creator>
      <dc:date>2025-02-12T14:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: LangGraph MemorySaver checkpointer usage with MLflow</title>
      <link>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/113056#M797</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/115539"&gt;@sebascardonal&lt;/a&gt;,&amp;nbsp;I am having the same issue. Did you find a way to proceed?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 14:53:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/113056#M797</guid>
      <dc:creator>moemedina</dc:creator>
      <dc:date>2025-03-19T14:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: LangGraph MemorySaver checkpointer usage with MLflow</title>
      <link>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/113076#M799</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/142310"&gt;@moemedina&lt;/a&gt;. No, I didn't.&lt;BR /&gt;&lt;BR /&gt;I'm considering using ChatModel/ChatAgent class to wrap the graph and be able to move on. However, the MLflow documentation is still referring to ChatModel where Chat Agent is the latest recommendation:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebascardonal_0-1742408476084.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/15507iBCDF273D4CFC31EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebascardonal_0-1742408476084.png" alt="sebascardonal_0-1742408476084.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebascardonal_1-1742408588246.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/15509i54E1D99290BEAB6D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebascardonal_1-1742408588246.png" alt="sebascardonal_1-1742408588246.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;MLflow ChatModel Doc:&amp;nbsp;&lt;A href="https://mlflow.org/docs/latest/llms/chat-model-intro/" target="_blank"&gt;https://mlflow.org/docs/latest/llms/chat-model-intro/&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Databricks Doc: &lt;A href="https://docs.databricks.com/aws/en/generative-ai/agent-framework/author-agent" target="_blank"&gt;https://docs.databricks.com/aws/en/generative-ai/agent-framework/author-agent&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;ChatAgent API Doc:&amp;nbsp;&lt;A href="https://mlflow.org/docs/latest/api_reference/python_api/mlflow.pyfunc.html#mlflow.pyfunc.ChatAgent" target="_blank"&gt;https://mlflow.org/docs/latest/api_reference/python_api/mlflow.pyfunc.html#mlflow.pyfunc.ChatAgent&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 18:24:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/langgraph-memorysaver-checkpointer-usage-with-mlflow/m-p/113076#M799</guid>
      <dc:creator>sebascardonal</dc:creator>
      <dc:date>2025-03-19T18:24:41Z</dc:date>
    </item>
  </channel>
</rss>

