mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-09 19:27:54 +02:00
Merge pull request #82 from langchain-ai/harrison/add-persistence-nb
add more examples
This commit is contained in:
@@ -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": []
|
||||
|
||||
Reference in New Issue
Block a user