diff --git a/examples/persistence.ipynb b/examples/persistence.ipynb index 23f0473f3..98edfb1b0 100644 --- a/examples/persistence.ipynb +++ b/examples/persistence.ipynb @@ -356,11 +356,9 @@ "id": "2a1b56c5-bd61-4192-8bdb-458a1e9f0159", "metadata": {}, "source": [ - "## Streaming LLM Tokens\n", + "## Interacting with the Agent\n", "\n", - "You can access the LLM tokens as they are produced by each node. \n", - "In this case only the \"agent\" node produces LLM tokens.\n", - "In order for this to work properly, you must be using an LLM that supports streaming as well as have set it when constructing the LLM (e.g. `ChatOpenAI(model=\"gpt-3.5-turbo-1106\", streaming=True)`)\n" + "We can now interact with the agent and see that it remembers previous messages!\n" ] }, { @@ -408,10 +406,40 @@ " print(v)" ] }, + { + "cell_type": "markdown", + "id": "3f47bbfc-d9ef-4288-ba4a-ebbc0136fa9d", + "metadata": {}, + "source": [ + "If we want to start a new conversation, we can pass in a different thread id" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "273d56a8-f40f-4a51-a27f-7c6bb2bda0ba", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "content=\"I'm sorry, but I don't have access to personal information.\"\n" + ] + } + ], + "source": [ + "inputs = [HumanMessage(content=\"what is my name?\")]\n", + "for event in app.stream(inputs, {\"configurable\": {\"thread_id\": \"3\"}}):\n", + " for k, v in event.items():\n", + " if k != \"__end__\":\n", + " print(v)" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "778ec05e-720c-4c9b-a226-78988942b49d", + "id": "8578a66d-6489-4e03-8c23-fd0530278455", "metadata": {}, "outputs": [], "source": []