You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Lab_7_Agent_Memory/01_memory_context_provider.ipynb
+7-115Lines changed: 7 additions & 115 deletions
Original file line number
Diff line number
Diff line change
@@ -4,18 +4,7 @@
4
4
"cell_type": "markdown",
5
5
"id": "0",
6
6
"metadata": {},
7
-
"source": [
8
-
"# Memory Context Provider\n",
9
-
"\n",
10
-
"This notebook uses the [`neo4j-agent-memory`](https://github.com/neo4j-labs/agent-memory) package — a graph-native memory system for AI agents, and the second Neo4j context provider package covered in this workshop. Unlike the `agent-framework-neo4j` provider in Lab 6 that retrieves from a static knowledge base, agent memory is dynamic: it grows with every conversation.\n",
11
-
"\n",
12
-
"Here you'll use its `Neo4jContextProvider` (distinct from the one in Lab 6) as a MAF context provider for automatic memory injection. The provider supports three memory types:\n",
13
-
"- **Short-term**: Recent conversation history with semantic search\n",
14
-
"- **Long-term**: Entities, preferences, and facts extracted from conversations\n",
15
-
"- **Reasoning**: Similar past task traces for learning from experience\n",
16
-
"\n",
17
-
"***"
18
-
]
7
+
"source": "# Memory Context Provider\n\nThis notebook uses the [`neo4j-agent-memory`](https://github.com/neo4j-labs/agent-memory) package — a graph-native memory system for AI agents, and the second Neo4j context provider package covered in this workshop. Unlike the `agent-framework-neo4j` provider in Lab 6 that retrieves from a static knowledge base, agent memory is dynamic: it grows with every conversation.\n\nHere you'll use its `Neo4jContextProvider` (distinct from the one in Lab 6) as a MAF context provider for automatic memory injection. The provider supports three memory types:\n- **Short-term**: Recent conversation history with semantic search\n- **Long-term**: Entities, preferences, and facts extracted from conversations\n- **Reasoning**: Similar past task traces for learning from experience\n\n***"
"source": "async def run_conversation():\n async with AzureCliCredential() as credential:\n async with AzureAIClient(\n project_endpoint=config.project_endpoint,\n model_deployment_name=config.model_name,\n credential=credential,\n ) as client:\n agent = client.as_agent(\n name=\"workshop-memory-agent\",\n instructions=(\n \"You are a helpful assistant with persistent memory. \"\n \"You can remember previous conversations and user preferences. \"\n \"When you notice the user expressing a preference, acknowledge it.\"\n ),\n context_providers=[memory.context_provider],\n )\n session = agent.create_session()\n\n # First interaction\n queries = [\n \"Hi! I'm interested in learning about Apple's products.\",\n \"What about their risk factors? I'm particularly concerned about supply chain issues.\",\n \"Can you remind me what we discussed about Apple?\",\n ]\n\n for query in queries:\n print(f\"User: {query}\\n\")\n print(\"Assistant: \", end=\"\", flush=True)\n\n response = await agent.run(query, session=session)\n print(response.text)\n print(\"\\n\" + \"-\" * 50 + \"\\n\")\n\n await asyncio.sleep(0.1)\n\nawait run_conversation()"
195
93
},
196
94
{
197
95
"cell_type": "markdown",
@@ -253,13 +151,7 @@
253
151
"cell_type": "markdown",
254
152
"id": "13",
255
153
"metadata": {},
256
-
"source": [
257
-
"***\n",
258
-
"\n",
259
-
"[View the complete code](../financial_data_load/solution_srcs/07_01_memory_context_provider.py)\n",
260
-
"\n",
261
-
"[Move on to the Memory Tools Agent Notebook](02_memory_tools_agent.ipynb)"
262
-
]
154
+
"source": "***\n\n[View the complete code](../financial_data_load/solution_srcs/07_01_memory_context_provider.py)\n\n[Move on to the Memory Tools Agent Notebook](02_memory_tools_agent.ipynb)"
0 commit comments