From 8c103de5db731bb55fbaf9f91b63428a7df48f1c Mon Sep 17 00:00:00 2001 From: Ryan Knight Date: Tue, 17 Feb 2026 20:40:02 -0700 Subject: [PATCH 1/7] Python: Adds sample documentation for two separate Neo4j context providers for retrieval and memory --- .../context_providers/neo4j/README.md | 19 +++ .../neo4j_graphrag/README.md | 140 ++++++++++++++++++ .../context_providers/neo4j_memory/README.md | 103 +++++++++++++ 3 files changed, 262 insertions(+) create mode 100644 python/samples/02-agents/context_providers/neo4j/README.md create mode 100644 python/samples/02-agents/context_providers/neo4j_graphrag/README.md create mode 100644 python/samples/02-agents/context_providers/neo4j_memory/README.md diff --git a/python/samples/02-agents/context_providers/neo4j/README.md b/python/samples/02-agents/context_providers/neo4j/README.md new file mode 100644 index 0000000000..a56881b748 --- /dev/null +++ b/python/samples/02-agents/context_providers/neo4j/README.md @@ -0,0 +1,19 @@ +# Neo4j Context Providers + +Neo4j offers two context providers for the Agent Framework, each serving a different purpose: + +| | [Neo4j Memory](../neo4j_memory/README.md) | [Neo4j GraphRAG](../neo4j_graphrag/README.md) | +|---|---|---| +| **What it does** | Read-write memory — stores conversations, builds knowledge graphs, learns from interactions | Read-only retrieval from a pre-existing knowledge base with optional graph traversal | +| **Data source** | Agent interactions (grows over time) | Pre-loaded documents and indexes | +| **Package** | [`neo4j-agent-memory`](https://github.com/neo4j-labs/agent-memory) | [`agent-framework-neo4j`](https://github.com/neo4j-labs/neo4j-maf-provider) | +| **Database setup** | Empty — creates its own schema | Requires pre-indexed documents with vector or fulltext indexes | +| **Example use case** | "Remember my preferences", "What did we discuss last time?" | "Search our documents", "What risks does Acme Corp face?" | + +## Which should I use? + +**Use [Neo4j Memory](../neo4j_memory/README.md)** when your agent needs to remember things across sessions — user preferences, past conversations, extracted entities, and reasoning traces. The memory provider writes to the database on every interaction, building a knowledge graph that grows over time. + +**Use [Neo4j GraphRAG](../neo4j_graphrag/README.md)** when your agent needs to search an existing knowledge base — documents, articles, product catalogs — and optionally enrich results by traversing graph relationships. The GraphRAG provider is read-only and does not modify your data. + +You can use both together: GraphRAG for domain knowledge retrieval, Memory for personalization and learning. diff --git a/python/samples/02-agents/context_providers/neo4j_graphrag/README.md b/python/samples/02-agents/context_providers/neo4j_graphrag/README.md new file mode 100644 index 0000000000..3b933ac88d --- /dev/null +++ b/python/samples/02-agents/context_providers/neo4j_graphrag/README.md @@ -0,0 +1,140 @@ +# Neo4j GraphRAG Context Provider Examples + +The [Neo4j GraphRAG context provider](https://github.com/neo4j-labs/neo4j-maf-provider) retrieves relevant documents from Neo4j vector and fulltext indexes and optionally enriches results by traversing graph relationships, giving agents access to connected knowledge that flat document search cannot provide. + +This is a **read-only retrieval provider** — it queries a pre-existing knowledge base and does not modify data. For persistent agent memory that grows from interactions, see the [Neo4j Memory Provider](../neo4j_memory/README.md). For help choosing between the two, see the [Neo4j Context Providers overview](../neo4j/README.md). + +## Examples + +- **Vector search**: Semantic similarity search using embeddings to retrieve conceptually related document chunks +- **Fulltext search**: Keyword search using BM25 scoring — no embedder required +- **Hybrid search**: Vector + fulltext combined for best of both worlds +- **Graph-enriched search**: Any search mode combined with a custom Cypher `retrieval_query` to traverse related entities + +For full runnable examples, see the [Neo4j GraphRAG Provider samples](https://github.com/neo4j-labs/neo4j-maf-provider/tree/main/python/samples). + +## Installation + +```bash +pip install agent-framework-neo4j +``` + +## Prerequisites + +### Required Resources + +1. **Neo4j database** with a vector or fulltext index containing your documents + - [Neo4j AuraDB](https://neo4j.com/cloud/auradb/) (managed) or self-hosted + - Documents must be indexed with a vector or fulltext index +2. **Azure AI Foundry project** with a model deployment (for the agent's chat model) +3. **For vector/hybrid search**: An embedding model endpoint (e.g., Azure AI `text-embedding-ada-002`) + +### Authentication + +- Neo4j: Username/password authentication +- Azure AI: Uses `DefaultAzureCredential` for embeddings and chat model + +Run `az login` for Azure authentication. + +## Configuration + +### Environment Variables + +**Neo4j** (auto-loaded by `Neo4jSettings`): +- `NEO4J_URI`: Neo4j connection URI (e.g., `neo4j+s://your-instance.databases.neo4j.io`) +- `NEO4J_USERNAME`: Database username +- `NEO4J_PASSWORD`: Database password + +**Azure AI** (auto-loaded by `AzureAISettings`): +- `AZURE_AI_PROJECT_ENDPOINT`: Azure AI Foundry project endpoint +- `AZURE_AI_MODEL_DEPLOYMENT_NAME`: Chat model deployment name (e.g., `gpt-4o`) +- `AZURE_AI_EMBEDDING_NAME`: Embedding model name (default: `text-embedding-ada-002`) + +## Code Example + +### Vector Search with Graph Enrichment + +```python +import os + +from agent_framework import Agent +from agent_framework.azure import AzureAIClient +from agent_framework_neo4j import Neo4jContextProvider, Neo4jSettings, AzureAIEmbedder, AzureAISettings +from azure.identity import DefaultAzureCredential +from azure.identity.aio import AzureCliCredential + +neo4j_settings = Neo4jSettings() +azure_settings = AzureAISettings() + +embedder = AzureAIEmbedder( + endpoint=azure_settings.inference_endpoint, + credential=DefaultAzureCredential(), + model=azure_settings.embedding_model, +) + +provider = Neo4jContextProvider( + uri=neo4j_settings.uri, + username=neo4j_settings.username, + password=neo4j_settings.get_password(), + index_name="chunkEmbeddings", + index_type="vector", + embedder=embedder, + top_k=5, + retrieval_query=""" + MATCH (node)-[:FROM_DOCUMENT]->(doc:Document)<-[:FILED]-(company:Company) + RETURN node.text AS text, score, company.name AS company, doc.title AS title + ORDER BY score DESC + """, +) + +async with ( + provider, + AzureAIClient( + credential=AzureCliCredential(), + project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"], + ) as client, + Agent( + client=client, + name="FinancialAnalyst", + instructions="You are a financial analyst assistant.", + context_providers=[provider], + ) as agent, +): + session = agent.create_session() + response = await agent.run("What risks does Acme Corp face?", session=session) + print(response.text) +``` + +### Fulltext Search (No Embedder Required) + +```python +provider = Neo4jContextProvider( + uri=neo4j_settings.uri, + username=neo4j_settings.username, + password=neo4j_settings.get_password(), + index_name="search_chunks", + index_type="fulltext", + top_k=5, +) +``` + +### Hybrid Search + +```python +provider = Neo4jContextProvider( + uri=neo4j_settings.uri, + username=neo4j_settings.username, + password=neo4j_settings.get_password(), + index_name="chunkEmbeddings", + index_type="hybrid", + fulltext_index_name="chunkFulltext", + embedder=embedder, + top_k=5, +) +``` + +## Additional Resources + +- [Neo4j GraphRAG Provider Repository](https://github.com/neo4j-labs/neo4j-maf-provider) +- [Neo4j GraphRAG Python Library](https://neo4j.com/docs/neo4j-graphrag-python/current/) +- [Neo4j Vector Index Documentation](https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes/) diff --git a/python/samples/02-agents/context_providers/neo4j_memory/README.md b/python/samples/02-agents/context_providers/neo4j_memory/README.md new file mode 100644 index 0000000000..7c3f557be5 --- /dev/null +++ b/python/samples/02-agents/context_providers/neo4j_memory/README.md @@ -0,0 +1,103 @@ +# Neo4j Memory Context Provider Examples + +[Neo4j Agent Memory](https://github.com/neo4j-labs/agent-memory) is a graph-native memory system for AI agents that stores conversations, builds knowledge graphs from interactions, and lets agents learn from their own reasoning — all backed by Neo4j. + +This is a **read-write memory provider** — it grows over time as the agent interacts with users. For read-only retrieval from an existing knowledge base, see the [Neo4j GraphRAG Provider](../neo4j_graphrag/README.md). For help choosing between the two, see the [Neo4j Context Providers overview](../neo4j/README.md). + +## Examples + +- **Basic memory**: Store conversations and recall context across sessions +- **Memory with tools**: Give the agent tools to search memory, remember preferences, and find entity connections in the knowledge graph + +For a full runnable example, see the [retail assistant sample](https://github.com/neo4j-labs/agent-memory/tree/main/examples/microsoft_agent_retail_assistant). + +## Installation + +```bash +pip install neo4j-agent-memory[microsoft-agent] +``` + +## Prerequisites + +### Required Resources + +1. **Neo4j database** (empty — the memory provider creates its own schema) + - [Neo4j AuraDB](https://neo4j.com/cloud/auradb/) (managed) or self-hosted + - No pre-existing indexes or data required +2. **Azure AI Foundry project** with a model deployment (for the agent's chat model) +3. **Embedding model** — supports OpenAI, Azure AI, or other providers for semantic search over memories + +### Authentication + +- Neo4j: Username/password authentication +- Azure AI: Uses `DefaultAzureCredential` + +Run `az login` for Azure authentication. + +## Configuration + +### Environment Variables + +**Neo4j:** +- `NEO4J_URI`: Neo4j connection URI (e.g., `neo4j+s://your-instance.databases.neo4j.io`) +- `NEO4J_USERNAME`: Database username +- `NEO4J_PASSWORD`: Database password + +**Azure AI:** +- `AZURE_AI_PROJECT_ENDPOINT`: Azure AI Foundry project endpoint +- `AZURE_AI_MODEL_DEPLOYMENT_NAME`: Chat model deployment name (e.g., `gpt-4o`) + +**Embeddings (pick one):** +- `OPENAI_API_KEY`: For OpenAI embeddings +- Or configure Azure AI embeddings via `AZURE_AI_PROJECT_ENDPOINT` + +## Code Example + +```python +import os + +from agent_framework import Agent +from agent_framework.azure import AzureAIClient +from azure.identity.aio import AzureCliCredential +from neo4j_agent_memory import MemoryClient, MemorySettings +from neo4j_agent_memory.integrations.microsoft_agent import ( + Neo4jMicrosoftMemory, + create_memory_tools, +) + +settings = MemorySettings(...) +memory_client = MemoryClient(settings) + +async with memory_client: + memory = Neo4jMicrosoftMemory.from_memory_client( + memory_client=memory_client, + session_id="user-123", + ) + tools = create_memory_tools(memory) + + async with ( + AzureAIClient( + credential=AzureCliCredential(), + project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"], + ) as client, + Agent( + client=client, + name="MemoryAssistant", + instructions="You are a helpful assistant with persistent memory.", + tools=tools, + context_providers=[memory.context_provider], + ) as agent, + ): + session = agent.create_session() + response = await agent.run( + "Remember that I prefer window seats on flights.", session=session + ) + print(response.text) +``` + +`create_memory_tools()` returns callable `FunctionTool` instances that the framework auto-invokes during streaming — no manual tool dispatch is needed. The core tools are: `search_memory`, `remember_preference`, `recall_preferences`, `search_knowledge`, `remember_fact`, and `find_similar_tasks`. Optional GDS graph algorithm tools (`find_connection_path`, `find_similar_items`, `find_important_entities`) are included when a `GDSConfig` is provided. + +## Additional Resources + +- [Neo4j Agent Memory Repository](https://github.com/neo4j-labs/agent-memory) +- [Neo4j AuraDB](https://neo4j.com/cloud/auradb/) From 68afbcbbb47794374199415aea022893e4449147 Mon Sep 17 00:00:00 2001 From: Ryan Knight Date: Thu, 26 Feb 2026 14:26:23 -0700 Subject: [PATCH 2/7] adding pypi links --- python/samples/02-agents/context_providers/neo4j/README.md | 2 +- .../02-agents/context_providers/neo4j_memory/README.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/python/samples/02-agents/context_providers/neo4j/README.md b/python/samples/02-agents/context_providers/neo4j/README.md index a56881b748..24a29d0f25 100644 --- a/python/samples/02-agents/context_providers/neo4j/README.md +++ b/python/samples/02-agents/context_providers/neo4j/README.md @@ -6,7 +6,7 @@ Neo4j offers two context providers for the Agent Framework, each serving a diffe |---|---|---| | **What it does** | Read-write memory — stores conversations, builds knowledge graphs, learns from interactions | Read-only retrieval from a pre-existing knowledge base with optional graph traversal | | **Data source** | Agent interactions (grows over time) | Pre-loaded documents and indexes | -| **Package** | [`neo4j-agent-memory`](https://github.com/neo4j-labs/agent-memory) | [`agent-framework-neo4j`](https://github.com/neo4j-labs/neo4j-maf-provider) | +| **Package** | [`neo4j-agent-memory`](https://pypi.org/project/neo4j-agent-memory/) | [`agent-framework-neo4j`](https://pypi.org/project/agent-framework-neo4j/) | | **Database setup** | Empty — creates its own schema | Requires pre-indexed documents with vector or fulltext indexes | | **Example use case** | "Remember my preferences", "What did we discuss last time?" | "Search our documents", "What risks does Acme Corp face?" | diff --git a/python/samples/02-agents/context_providers/neo4j_memory/README.md b/python/samples/02-agents/context_providers/neo4j_memory/README.md index 7c3f557be5..6dab7465d5 100644 --- a/python/samples/02-agents/context_providers/neo4j_memory/README.md +++ b/python/samples/02-agents/context_providers/neo4j_memory/README.md @@ -1,6 +1,6 @@ # Neo4j Memory Context Provider Examples -[Neo4j Agent Memory](https://github.com/neo4j-labs/agent-memory) is a graph-native memory system for AI agents that stores conversations, builds knowledge graphs from interactions, and lets agents learn from their own reasoning — all backed by Neo4j. +[Neo4j Agent Memory](https://github.com/neo4j-labs/agent-memory) ([PyPI](https://pypi.org/project/neo4j-agent-memory/) · [Documentation](https://neo4j-agent-memory.vercel.app/)) is a graph-native memory system for AI agents that stores conversations, builds knowledge graphs from interactions, and lets agents learn from their own reasoning — all backed by Neo4j. This is a **read-write memory provider** — it grows over time as the agent interacts with users. For read-only retrieval from an existing knowledge base, see the [Neo4j GraphRAG Provider](../neo4j_graphrag/README.md). For help choosing between the two, see the [Neo4j Context Providers overview](../neo4j/README.md). @@ -100,4 +100,6 @@ async with memory_client: ## Additional Resources - [Neo4j Agent Memory Repository](https://github.com/neo4j-labs/agent-memory) +- [Neo4j Agent Memory Documentation](https://neo4j-agent-memory.vercel.app/) +- [Neo4j Agent Memory on PyPI](https://pypi.org/project/neo4j-agent-memory/) - [Neo4j AuraDB](https://neo4j.com/cloud/auradb/) From aade778411bfd4ffc65d0f2a94a18f59eadc5141 Mon Sep 17 00:00:00 2001 From: Ryan Knight Date: Tue, 31 Mar 2026 07:51:31 -0700 Subject: [PATCH 3/7] adding dotnot examples --- .../AgentWithNeo4j_Step01_GraphRAG/README.md | 129 ++++++++++++++++++ .../02-agents/AgentWithNeo4j/README.md | 23 ++++ dotnet/samples/02-agents/README.md | 1 + .../context_providers/neo4j/README.md | 7 +- .../neo4j_graphrag/README.md | 2 + 5 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md create mode 100644 dotnet/samples/02-agents/AgentWithNeo4j/README.md diff --git a/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md b/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md new file mode 100644 index 0000000000..42d53635e6 --- /dev/null +++ b/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md @@ -0,0 +1,129 @@ +# Agent with Neo4j GraphRAG Context Provider + +This sample demonstrates how to create and run an agent that uses the [Neo4j GraphRAG context provider](https://github.com/neo4j-labs/neo4j-maf-provider) to retrieve relevant documents from Neo4j vector and fulltext indexes, optionally enriching results by traversing graph relationships. + +## Features Demonstrated + +- Vector search with semantic similarity using embeddings +- Fulltext search with BM25 scoring (no embedding generator required) +- Hybrid search combining vector + fulltext for best of both worlds +- Graph-enriched search using custom Cypher `RetrievalQuery` to traverse related entities + +## Prerequisites + +- .NET 10 SDK or later +- Neo4j database with a vector or fulltext index containing your documents + - [Neo4j AuraDB](https://neo4j.com/cloud/auradb/) (managed) or self-hosted +- Azure OpenAI service endpoint with both a chat completion and embedding deployment configured +- Azure CLI installed and authenticated (for Azure credential authentication) +- User has the `Cognitive Services OpenAI Contributor` role for the Azure OpenAI resource + +**Note**: These samples use Azure OpenAI models. For more information, see [how to deploy Azure OpenAI models with Azure AI Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/deploy-models-openai). + +**Note**: These samples use Azure CLI credentials for authentication. Make sure you're logged in with `az login` and have access to the Azure OpenAI resource and have the `Cognitive Services OpenAI Contributor` role. For more information, see the [Azure CLI documentation](https://learn.microsoft.com/cli/azure/authenticate-azure-cli-interactively). + +## Environment Variables + +```powershell +# Neo4j connection +$env:NEO4J_URI="neo4j+s://your-instance.databases.neo4j.io" +$env:NEO4J_USERNAME="neo4j" +$env:NEO4J_PASSWORD="your-password" +$env:NEO4J_VECTOR_INDEX_NAME="chunkEmbeddings" # Required for vector/hybrid search +$env:NEO4J_FULLTEXT_INDEX_NAME="chunkFulltext" # Required for fulltext/hybrid search + +# Azure OpenAI +$env:AZURE_AI_SERVICES_ENDPOINT="https://your-resource.openai.azure.com/" +$env:AZURE_AI_MODEL_NAME="gpt-4o" # Chat model deployment name +$env:AZURE_AI_EMBEDDING_NAME="text-embedding-3-small" # Embedding model deployment name +``` + +## Code Example + +### Vector Search with Graph Enrichment + +```csharp +using Azure.AI.OpenAI; +using Azure.Identity; +using Microsoft.Extensions.AI; +using Neo4j.AgentFramework.GraphRAG; + +var neo4jSettings = Neo4jSettings.FromEnvironment(); + +var azureClient = new AzureOpenAIClient( + new Uri(Environment.GetEnvironmentVariable("AZURE_AI_SERVICES_ENDPOINT")!), + new DefaultAzureCredential()); + +var embeddingGenerator = azureClient + .GetEmbeddingClient(Environment.GetEnvironmentVariable("AZURE_AI_EMBEDDING_NAME")) + .AsIEmbeddingGenerator(); + +var provider = new Neo4jContextProvider( + neo4jSettings, + new Neo4jContextProviderOptions + { + IndexName = "chunkEmbeddings", + IndexType = IndexType.Vector, + EmbeddingGenerator = embeddingGenerator, + TopK = 5, + RetrievalQuery = """ + MATCH (node)-[:FROM_DOCUMENT]->(doc:Document)<-[:FILED]-(company:Company) + RETURN node.text AS text, score, company.name AS company, doc.title AS title + ORDER BY score DESC + """ + }); + +var chatClient = azureClient + .GetChatClient(Environment.GetEnvironmentVariable("AZURE_AI_MODEL_NAME")) + .AsIChatClient(); + +var agent = chatClient + .AsBuilder() + .UseAIContextProviders(provider) + .BuildAIAgent(new ChatClientAgentOptions + { + Instructions = "You are a financial analyst assistant.", + }); + +var session = await agent.CreateSessionAsync(); +var response = await agent.RunAsync("What risks does Acme Corp face?", session); +Console.WriteLine(response.Text); +``` + +### Fulltext Search (No Embedding Generator Required) + +```csharp +var provider = new Neo4jContextProvider( + neo4jSettings, + new Neo4jContextProviderOptions + { + IndexName = "search_chunks", + IndexType = IndexType.Fulltext, + TopK = 5, + }); +``` + +### Hybrid Search + +```csharp +var provider = new Neo4jContextProvider( + neo4jSettings, + new Neo4jContextProviderOptions + { + IndexName = "chunkEmbeddings", + IndexType = IndexType.Hybrid, + FulltextIndexName = "chunkFulltext", + EmbeddingGenerator = embeddingGenerator, + TopK = 5, + }); +``` + +## Run the Sample + +For the full runnable sample, see the [Neo4j.Samples project](https://github.com/neo4j-labs/neo4j-maf-provider/tree/main/dotnet/samples/Neo4j.Samples). + +## Additional Resources + +- [Neo4j GraphRAG Provider Repository](https://github.com/neo4j-labs/neo4j-maf-provider) +- [Neo4j GraphRAG Python Library](https://neo4j.com/docs/neo4j-graphrag-python/current/) +- [Neo4j Vector Index Documentation](https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes/) diff --git a/dotnet/samples/02-agents/AgentWithNeo4j/README.md b/dotnet/samples/02-agents/AgentWithNeo4j/README.md new file mode 100644 index 0000000000..ba0fc56225 --- /dev/null +++ b/dotnet/samples/02-agents/AgentWithNeo4j/README.md @@ -0,0 +1,23 @@ +# Agent Framework with Neo4j + +Neo4j offers two context providers for the Agent Framework, each serving a different purpose: + +| | Neo4j GraphRAG | Neo4j Memory | +|---|---|---| +| **What it does** | Read-only retrieval from a pre-existing knowledge base with optional graph traversal | Read-write memory — stores conversations, builds knowledge graphs, learns from interactions | +| **Data source** | Pre-loaded documents and indexes | Agent interactions (grows over time) | +| **NuGet package** | [`Neo4j.AgentFramework.GraphRAG`](https://www.nuget.org/packages/Neo4j.AgentFramework.GraphRAG) | — (Python only, see [Neo4j Memory](https://github.com/neo4j-labs/agent-memory)) | +| **Database setup** | Requires pre-indexed documents with vector or fulltext indexes | Empty — creates its own schema | +| **Example use case** | "Search our documents", "What risks does Acme Corp face?" | "Remember my preferences", "What did we discuss last time?" | + +## Samples + +|Sample|Description| +|---|---| +|[Neo4j GraphRAG](./AgentWithNeo4j_Step01_GraphRAG/)|Retrieve context from a Neo4j knowledge base using vector, fulltext, hybrid, or graph-enriched search.| + +## Additional Resources + +- [Neo4j GraphRAG Provider Repository](https://github.com/neo4j-labs/neo4j-maf-provider) +- [Neo4j Agent Memory Repository](https://github.com/neo4j-labs/agent-memory) +- [Python Neo4j Context Provider Samples](../../../python/samples/02-agents/context_providers/neo4j/README.md) diff --git a/dotnet/samples/02-agents/README.md b/dotnet/samples/02-agents/README.md index 5ff0db416d..d1cbd9de68 100644 --- a/dotnet/samples/02-agents/README.md +++ b/dotnet/samples/02-agents/README.md @@ -11,6 +11,7 @@ The getting started samples demonstrate the fundamental concepts and functionali | [Agent Providers](./AgentProviders/README.md) | Getting started with creating agents using various providers | | [Agents With Retrieval Augmented Generation (RAG)](./AgentWithRAG/README.md) | Adding Retrieval Augmented Generation (RAG) capabilities to your agents | | [Agents With Memory](./AgentWithMemory/README.md) | Adding memory capabilities to your agents | +| [Agents With Neo4j](./AgentWithNeo4j/README.md) | Adding Neo4j GraphRAG and memory context providers to your agents | | [Agent Open Telemetry](./AgentOpenTelemetry/README.md) | Getting started with OpenTelemetry for agents | | [Agent With OpenAI exchange types](./AgentWithOpenAI/README.md) | Using OpenAI exchange types with agents | | [Agent With Anthropic](./AgentWithAnthropic/README.md) | Getting started with agents using Anthropic Claude | diff --git a/python/samples/02-agents/context_providers/neo4j/README.md b/python/samples/02-agents/context_providers/neo4j/README.md index 24a29d0f25..60123f341b 100644 --- a/python/samples/02-agents/context_providers/neo4j/README.md +++ b/python/samples/02-agents/context_providers/neo4j/README.md @@ -6,7 +6,8 @@ Neo4j offers two context providers for the Agent Framework, each serving a diffe |---|---|---| | **What it does** | Read-write memory — stores conversations, builds knowledge graphs, learns from interactions | Read-only retrieval from a pre-existing knowledge base with optional graph traversal | | **Data source** | Agent interactions (grows over time) | Pre-loaded documents and indexes | -| **Package** | [`neo4j-agent-memory`](https://pypi.org/project/neo4j-agent-memory/) | [`agent-framework-neo4j`](https://pypi.org/project/agent-framework-neo4j/) | +| **Python package** | [`neo4j-agent-memory`](https://pypi.org/project/neo4j-agent-memory/) | [`agent-framework-neo4j`](https://pypi.org/project/agent-framework-neo4j/) | +| **.NET package** | — | [`Neo4j.AgentFramework.GraphRAG`](https://www.nuget.org/packages/Neo4j.AgentFramework.GraphRAG) | | **Database setup** | Empty — creates its own schema | Requires pre-indexed documents with vector or fulltext indexes | | **Example use case** | "Remember my preferences", "What did we discuss last time?" | "Search our documents", "What risks does Acme Corp face?" | @@ -17,3 +18,7 @@ Neo4j offers two context providers for the Agent Framework, each serving a diffe **Use [Neo4j GraphRAG](../neo4j_graphrag/README.md)** when your agent needs to search an existing knowledge base — documents, articles, product catalogs — and optionally enrich results by traversing graph relationships. The GraphRAG provider is read-only and does not modify your data. You can use both together: GraphRAG for domain knowledge retrieval, Memory for personalization and learning. + +## .NET Support + +The Neo4j GraphRAG provider is also available for .NET. See the [.NET Neo4j samples](../../../../../dotnet/samples/02-agents/AgentWithNeo4j/README.md) for installation, code examples, and runnable samples. diff --git a/python/samples/02-agents/context_providers/neo4j_graphrag/README.md b/python/samples/02-agents/context_providers/neo4j_graphrag/README.md index 3b933ac88d..8b25d09e3e 100644 --- a/python/samples/02-agents/context_providers/neo4j_graphrag/README.md +++ b/python/samples/02-agents/context_providers/neo4j_graphrag/README.md @@ -19,6 +19,8 @@ For full runnable examples, see the [Neo4j GraphRAG Provider samples](https://gi pip install agent-framework-neo4j ``` +For .NET, see the [.NET Neo4j samples](../../../../../dotnet/samples/02-agents/AgentWithNeo4j/README.md). + ## Prerequisites ### Required Resources From 85873a8973ac883b92b0eb50e6efa035bd1e7d8d Mon Sep 17 00:00:00 2001 From: Ryan Knight Date: Tue, 31 Mar 2026 08:25:58 -0700 Subject: [PATCH 4/7] adding dotnot examples --- .../AgentWithNeo4j_Step01_GraphRAG/README.md | 27 ++++++++++++------- .../02-agents/AgentWithNeo4j/README.md | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md b/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md index 42d53635e6..7b27596953 100644 --- a/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md +++ b/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md @@ -45,10 +45,13 @@ $env:AZURE_AI_EMBEDDING_NAME="text-embedding-3-small" # Embedding model deploym ```csharp using Azure.AI.OpenAI; using Azure.Identity; +using Microsoft.Agents.AI; +using Microsoft.Agents.AI.OpenAI; using Microsoft.Extensions.AI; using Neo4j.AgentFramework.GraphRAG; +using Neo4j.Driver; -var neo4jSettings = Neo4jSettings.FromEnvironment(); +var neo4jSettings = new Neo4jSettings(); var azureClient = new AzureOpenAIClient( new Uri(Environment.GetEnvironmentVariable("AZURE_AI_SERVICES_ENDPOINT")!), @@ -58,8 +61,11 @@ var embeddingGenerator = azureClient .GetEmbeddingClient(Environment.GetEnvironmentVariable("AZURE_AI_EMBEDDING_NAME")) .AsIEmbeddingGenerator(); -var provider = new Neo4jContextProvider( - neo4jSettings, +await using var driver = GraphDatabase.Driver( + neo4jSettings.Uri!, AuthTokens.Basic(neo4jSettings.Username!, neo4jSettings.Password!)); + +await using var provider = new Neo4jContextProvider( + driver, new Neo4jContextProviderOptions { IndexName = "chunkEmbeddings", @@ -82,19 +88,22 @@ var agent = chatClient .UseAIContextProviders(provider) .BuildAIAgent(new ChatClientAgentOptions { - Instructions = "You are a financial analyst assistant.", + ChatOptions = new ChatOptions + { + Instructions = "You are a financial analyst assistant.", + }, }); var session = await agent.CreateSessionAsync(); var response = await agent.RunAsync("What risks does Acme Corp face?", session); -Console.WriteLine(response.Text); +Console.WriteLine(response); ``` ### Fulltext Search (No Embedding Generator Required) ```csharp -var provider = new Neo4jContextProvider( - neo4jSettings, +await using var provider = new Neo4jContextProvider( + driver, new Neo4jContextProviderOptions { IndexName = "search_chunks", @@ -106,8 +115,8 @@ var provider = new Neo4jContextProvider( ### Hybrid Search ```csharp -var provider = new Neo4jContextProvider( - neo4jSettings, +await using var provider = new Neo4jContextProvider( + driver, new Neo4jContextProviderOptions { IndexName = "chunkEmbeddings", diff --git a/dotnet/samples/02-agents/AgentWithNeo4j/README.md b/dotnet/samples/02-agents/AgentWithNeo4j/README.md index ba0fc56225..43aebe2ca0 100644 --- a/dotnet/samples/02-agents/AgentWithNeo4j/README.md +++ b/dotnet/samples/02-agents/AgentWithNeo4j/README.md @@ -20,4 +20,4 @@ Neo4j offers two context providers for the Agent Framework, each serving a diffe - [Neo4j GraphRAG Provider Repository](https://github.com/neo4j-labs/neo4j-maf-provider) - [Neo4j Agent Memory Repository](https://github.com/neo4j-labs/agent-memory) -- [Python Neo4j Context Provider Samples](../../../python/samples/02-agents/context_providers/neo4j/README.md) +- [Python Neo4j Context Provider Samples](../../../../python/samples/02-agents/context_providers/neo4j/README.md) From 7c38e4a1846bbc5808e2a2a2067494aacbe476c6 Mon Sep 17 00:00:00 2001 From: Ryan Knight Date: Wed, 1 Apr 2026 07:16:08 -0600 Subject: [PATCH 5/7] merge upstream samples --- .../AgentWithNeo4j_Step01_GraphRAG/README.md | 138 ----------------- .../02-agents/AgentWithNeo4j/README.md | 23 --- dotnet/samples/02-agents/README.md | 1 - .../context_providers/neo4j/README.md | 6 +- .../neo4j_graphrag/README.md | 142 ------------------ .../context_providers/neo4j_memory/README.md | 2 +- 6 files changed, 4 insertions(+), 308 deletions(-) delete mode 100644 dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md delete mode 100644 dotnet/samples/02-agents/AgentWithNeo4j/README.md delete mode 100644 python/samples/02-agents/context_providers/neo4j_graphrag/README.md diff --git a/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md b/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md deleted file mode 100644 index 7b27596953..0000000000 --- a/dotnet/samples/02-agents/AgentWithNeo4j/AgentWithNeo4j_Step01_GraphRAG/README.md +++ /dev/null @@ -1,138 +0,0 @@ -# Agent with Neo4j GraphRAG Context Provider - -This sample demonstrates how to create and run an agent that uses the [Neo4j GraphRAG context provider](https://github.com/neo4j-labs/neo4j-maf-provider) to retrieve relevant documents from Neo4j vector and fulltext indexes, optionally enriching results by traversing graph relationships. - -## Features Demonstrated - -- Vector search with semantic similarity using embeddings -- Fulltext search with BM25 scoring (no embedding generator required) -- Hybrid search combining vector + fulltext for best of both worlds -- Graph-enriched search using custom Cypher `RetrievalQuery` to traverse related entities - -## Prerequisites - -- .NET 10 SDK or later -- Neo4j database with a vector or fulltext index containing your documents - - [Neo4j AuraDB](https://neo4j.com/cloud/auradb/) (managed) or self-hosted -- Azure OpenAI service endpoint with both a chat completion and embedding deployment configured -- Azure CLI installed and authenticated (for Azure credential authentication) -- User has the `Cognitive Services OpenAI Contributor` role for the Azure OpenAI resource - -**Note**: These samples use Azure OpenAI models. For more information, see [how to deploy Azure OpenAI models with Azure AI Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/deploy-models-openai). - -**Note**: These samples use Azure CLI credentials for authentication. Make sure you're logged in with `az login` and have access to the Azure OpenAI resource and have the `Cognitive Services OpenAI Contributor` role. For more information, see the [Azure CLI documentation](https://learn.microsoft.com/cli/azure/authenticate-azure-cli-interactively). - -## Environment Variables - -```powershell -# Neo4j connection -$env:NEO4J_URI="neo4j+s://your-instance.databases.neo4j.io" -$env:NEO4J_USERNAME="neo4j" -$env:NEO4J_PASSWORD="your-password" -$env:NEO4J_VECTOR_INDEX_NAME="chunkEmbeddings" # Required for vector/hybrid search -$env:NEO4J_FULLTEXT_INDEX_NAME="chunkFulltext" # Required for fulltext/hybrid search - -# Azure OpenAI -$env:AZURE_AI_SERVICES_ENDPOINT="https://your-resource.openai.azure.com/" -$env:AZURE_AI_MODEL_NAME="gpt-4o" # Chat model deployment name -$env:AZURE_AI_EMBEDDING_NAME="text-embedding-3-small" # Embedding model deployment name -``` - -## Code Example - -### Vector Search with Graph Enrichment - -```csharp -using Azure.AI.OpenAI; -using Azure.Identity; -using Microsoft.Agents.AI; -using Microsoft.Agents.AI.OpenAI; -using Microsoft.Extensions.AI; -using Neo4j.AgentFramework.GraphRAG; -using Neo4j.Driver; - -var neo4jSettings = new Neo4jSettings(); - -var azureClient = new AzureOpenAIClient( - new Uri(Environment.GetEnvironmentVariable("AZURE_AI_SERVICES_ENDPOINT")!), - new DefaultAzureCredential()); - -var embeddingGenerator = azureClient - .GetEmbeddingClient(Environment.GetEnvironmentVariable("AZURE_AI_EMBEDDING_NAME")) - .AsIEmbeddingGenerator(); - -await using var driver = GraphDatabase.Driver( - neo4jSettings.Uri!, AuthTokens.Basic(neo4jSettings.Username!, neo4jSettings.Password!)); - -await using var provider = new Neo4jContextProvider( - driver, - new Neo4jContextProviderOptions - { - IndexName = "chunkEmbeddings", - IndexType = IndexType.Vector, - EmbeddingGenerator = embeddingGenerator, - TopK = 5, - RetrievalQuery = """ - MATCH (node)-[:FROM_DOCUMENT]->(doc:Document)<-[:FILED]-(company:Company) - RETURN node.text AS text, score, company.name AS company, doc.title AS title - ORDER BY score DESC - """ - }); - -var chatClient = azureClient - .GetChatClient(Environment.GetEnvironmentVariable("AZURE_AI_MODEL_NAME")) - .AsIChatClient(); - -var agent = chatClient - .AsBuilder() - .UseAIContextProviders(provider) - .BuildAIAgent(new ChatClientAgentOptions - { - ChatOptions = new ChatOptions - { - Instructions = "You are a financial analyst assistant.", - }, - }); - -var session = await agent.CreateSessionAsync(); -var response = await agent.RunAsync("What risks does Acme Corp face?", session); -Console.WriteLine(response); -``` - -### Fulltext Search (No Embedding Generator Required) - -```csharp -await using var provider = new Neo4jContextProvider( - driver, - new Neo4jContextProviderOptions - { - IndexName = "search_chunks", - IndexType = IndexType.Fulltext, - TopK = 5, - }); -``` - -### Hybrid Search - -```csharp -await using var provider = new Neo4jContextProvider( - driver, - new Neo4jContextProviderOptions - { - IndexName = "chunkEmbeddings", - IndexType = IndexType.Hybrid, - FulltextIndexName = "chunkFulltext", - EmbeddingGenerator = embeddingGenerator, - TopK = 5, - }); -``` - -## Run the Sample - -For the full runnable sample, see the [Neo4j.Samples project](https://github.com/neo4j-labs/neo4j-maf-provider/tree/main/dotnet/samples/Neo4j.Samples). - -## Additional Resources - -- [Neo4j GraphRAG Provider Repository](https://github.com/neo4j-labs/neo4j-maf-provider) -- [Neo4j GraphRAG Python Library](https://neo4j.com/docs/neo4j-graphrag-python/current/) -- [Neo4j Vector Index Documentation](https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes/) diff --git a/dotnet/samples/02-agents/AgentWithNeo4j/README.md b/dotnet/samples/02-agents/AgentWithNeo4j/README.md deleted file mode 100644 index 43aebe2ca0..0000000000 --- a/dotnet/samples/02-agents/AgentWithNeo4j/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Agent Framework with Neo4j - -Neo4j offers two context providers for the Agent Framework, each serving a different purpose: - -| | Neo4j GraphRAG | Neo4j Memory | -|---|---|---| -| **What it does** | Read-only retrieval from a pre-existing knowledge base with optional graph traversal | Read-write memory — stores conversations, builds knowledge graphs, learns from interactions | -| **Data source** | Pre-loaded documents and indexes | Agent interactions (grows over time) | -| **NuGet package** | [`Neo4j.AgentFramework.GraphRAG`](https://www.nuget.org/packages/Neo4j.AgentFramework.GraphRAG) | — (Python only, see [Neo4j Memory](https://github.com/neo4j-labs/agent-memory)) | -| **Database setup** | Requires pre-indexed documents with vector or fulltext indexes | Empty — creates its own schema | -| **Example use case** | "Search our documents", "What risks does Acme Corp face?" | "Remember my preferences", "What did we discuss last time?" | - -## Samples - -|Sample|Description| -|---|---| -|[Neo4j GraphRAG](./AgentWithNeo4j_Step01_GraphRAG/)|Retrieve context from a Neo4j knowledge base using vector, fulltext, hybrid, or graph-enriched search.| - -## Additional Resources - -- [Neo4j GraphRAG Provider Repository](https://github.com/neo4j-labs/neo4j-maf-provider) -- [Neo4j Agent Memory Repository](https://github.com/neo4j-labs/agent-memory) -- [Python Neo4j Context Provider Samples](../../../../python/samples/02-agents/context_providers/neo4j/README.md) diff --git a/dotnet/samples/02-agents/README.md b/dotnet/samples/02-agents/README.md index d1cbd9de68..5ff0db416d 100644 --- a/dotnet/samples/02-agents/README.md +++ b/dotnet/samples/02-agents/README.md @@ -11,7 +11,6 @@ The getting started samples demonstrate the fundamental concepts and functionali | [Agent Providers](./AgentProviders/README.md) | Getting started with creating agents using various providers | | [Agents With Retrieval Augmented Generation (RAG)](./AgentWithRAG/README.md) | Adding Retrieval Augmented Generation (RAG) capabilities to your agents | | [Agents With Memory](./AgentWithMemory/README.md) | Adding memory capabilities to your agents | -| [Agents With Neo4j](./AgentWithNeo4j/README.md) | Adding Neo4j GraphRAG and memory context providers to your agents | | [Agent Open Telemetry](./AgentOpenTelemetry/README.md) | Getting started with OpenTelemetry for agents | | [Agent With OpenAI exchange types](./AgentWithOpenAI/README.md) | Using OpenAI exchange types with agents | | [Agent With Anthropic](./AgentWithAnthropic/README.md) | Getting started with agents using Anthropic Claude | diff --git a/python/samples/02-agents/context_providers/neo4j/README.md b/python/samples/02-agents/context_providers/neo4j/README.md index 60123f341b..8988f2573f 100644 --- a/python/samples/02-agents/context_providers/neo4j/README.md +++ b/python/samples/02-agents/context_providers/neo4j/README.md @@ -2,7 +2,7 @@ Neo4j offers two context providers for the Agent Framework, each serving a different purpose: -| | [Neo4j Memory](../neo4j_memory/README.md) | [Neo4j GraphRAG](../neo4j_graphrag/README.md) | +| | [Neo4j Memory](../neo4j_memory/README.md) | [Neo4j GraphRAG](../../../../05-end-to-end/neo4j_graphrag/README.md) | |---|---|---| | **What it does** | Read-write memory — stores conversations, builds knowledge graphs, learns from interactions | Read-only retrieval from a pre-existing knowledge base with optional graph traversal | | **Data source** | Agent interactions (grows over time) | Pre-loaded documents and indexes | @@ -15,10 +15,10 @@ Neo4j offers two context providers for the Agent Framework, each serving a diffe **Use [Neo4j Memory](../neo4j_memory/README.md)** when your agent needs to remember things across sessions — user preferences, past conversations, extracted entities, and reasoning traces. The memory provider writes to the database on every interaction, building a knowledge graph that grows over time. -**Use [Neo4j GraphRAG](../neo4j_graphrag/README.md)** when your agent needs to search an existing knowledge base — documents, articles, product catalogs — and optionally enrich results by traversing graph relationships. The GraphRAG provider is read-only and does not modify your data. +**Use [Neo4j GraphRAG](../../../../05-end-to-end/neo4j_graphrag/README.md)** when your agent needs to search an existing knowledge base — documents, articles, product catalogs — and optionally enrich results by traversing graph relationships. The GraphRAG provider is read-only and does not modify your data. You can use both together: GraphRAG for domain knowledge retrieval, Memory for personalization and learning. ## .NET Support -The Neo4j GraphRAG provider is also available for .NET. See the [.NET Neo4j samples](../../../../../dotnet/samples/02-agents/AgentWithNeo4j/README.md) for installation, code examples, and runnable samples. +The Neo4j GraphRAG provider is also available for .NET. See the [.NET Neo4j GraphRAG sample](../../../../../dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step05_Neo4jGraphRAG/README.md) for installation, code examples, and runnable samples. diff --git a/python/samples/02-agents/context_providers/neo4j_graphrag/README.md b/python/samples/02-agents/context_providers/neo4j_graphrag/README.md deleted file mode 100644 index 8b25d09e3e..0000000000 --- a/python/samples/02-agents/context_providers/neo4j_graphrag/README.md +++ /dev/null @@ -1,142 +0,0 @@ -# Neo4j GraphRAG Context Provider Examples - -The [Neo4j GraphRAG context provider](https://github.com/neo4j-labs/neo4j-maf-provider) retrieves relevant documents from Neo4j vector and fulltext indexes and optionally enriches results by traversing graph relationships, giving agents access to connected knowledge that flat document search cannot provide. - -This is a **read-only retrieval provider** — it queries a pre-existing knowledge base and does not modify data. For persistent agent memory that grows from interactions, see the [Neo4j Memory Provider](../neo4j_memory/README.md). For help choosing between the two, see the [Neo4j Context Providers overview](../neo4j/README.md). - -## Examples - -- **Vector search**: Semantic similarity search using embeddings to retrieve conceptually related document chunks -- **Fulltext search**: Keyword search using BM25 scoring — no embedder required -- **Hybrid search**: Vector + fulltext combined for best of both worlds -- **Graph-enriched search**: Any search mode combined with a custom Cypher `retrieval_query` to traverse related entities - -For full runnable examples, see the [Neo4j GraphRAG Provider samples](https://github.com/neo4j-labs/neo4j-maf-provider/tree/main/python/samples). - -## Installation - -```bash -pip install agent-framework-neo4j -``` - -For .NET, see the [.NET Neo4j samples](../../../../../dotnet/samples/02-agents/AgentWithNeo4j/README.md). - -## Prerequisites - -### Required Resources - -1. **Neo4j database** with a vector or fulltext index containing your documents - - [Neo4j AuraDB](https://neo4j.com/cloud/auradb/) (managed) or self-hosted - - Documents must be indexed with a vector or fulltext index -2. **Azure AI Foundry project** with a model deployment (for the agent's chat model) -3. **For vector/hybrid search**: An embedding model endpoint (e.g., Azure AI `text-embedding-ada-002`) - -### Authentication - -- Neo4j: Username/password authentication -- Azure AI: Uses `DefaultAzureCredential` for embeddings and chat model - -Run `az login` for Azure authentication. - -## Configuration - -### Environment Variables - -**Neo4j** (auto-loaded by `Neo4jSettings`): -- `NEO4J_URI`: Neo4j connection URI (e.g., `neo4j+s://your-instance.databases.neo4j.io`) -- `NEO4J_USERNAME`: Database username -- `NEO4J_PASSWORD`: Database password - -**Azure AI** (auto-loaded by `AzureAISettings`): -- `AZURE_AI_PROJECT_ENDPOINT`: Azure AI Foundry project endpoint -- `AZURE_AI_MODEL_DEPLOYMENT_NAME`: Chat model deployment name (e.g., `gpt-4o`) -- `AZURE_AI_EMBEDDING_NAME`: Embedding model name (default: `text-embedding-ada-002`) - -## Code Example - -### Vector Search with Graph Enrichment - -```python -import os - -from agent_framework import Agent -from agent_framework.azure import AzureAIClient -from agent_framework_neo4j import Neo4jContextProvider, Neo4jSettings, AzureAIEmbedder, AzureAISettings -from azure.identity import DefaultAzureCredential -from azure.identity.aio import AzureCliCredential - -neo4j_settings = Neo4jSettings() -azure_settings = AzureAISettings() - -embedder = AzureAIEmbedder( - endpoint=azure_settings.inference_endpoint, - credential=DefaultAzureCredential(), - model=azure_settings.embedding_model, -) - -provider = Neo4jContextProvider( - uri=neo4j_settings.uri, - username=neo4j_settings.username, - password=neo4j_settings.get_password(), - index_name="chunkEmbeddings", - index_type="vector", - embedder=embedder, - top_k=5, - retrieval_query=""" - MATCH (node)-[:FROM_DOCUMENT]->(doc:Document)<-[:FILED]-(company:Company) - RETURN node.text AS text, score, company.name AS company, doc.title AS title - ORDER BY score DESC - """, -) - -async with ( - provider, - AzureAIClient( - credential=AzureCliCredential(), - project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"], - ) as client, - Agent( - client=client, - name="FinancialAnalyst", - instructions="You are a financial analyst assistant.", - context_providers=[provider], - ) as agent, -): - session = agent.create_session() - response = await agent.run("What risks does Acme Corp face?", session=session) - print(response.text) -``` - -### Fulltext Search (No Embedder Required) - -```python -provider = Neo4jContextProvider( - uri=neo4j_settings.uri, - username=neo4j_settings.username, - password=neo4j_settings.get_password(), - index_name="search_chunks", - index_type="fulltext", - top_k=5, -) -``` - -### Hybrid Search - -```python -provider = Neo4jContextProvider( - uri=neo4j_settings.uri, - username=neo4j_settings.username, - password=neo4j_settings.get_password(), - index_name="chunkEmbeddings", - index_type="hybrid", - fulltext_index_name="chunkFulltext", - embedder=embedder, - top_k=5, -) -``` - -## Additional Resources - -- [Neo4j GraphRAG Provider Repository](https://github.com/neo4j-labs/neo4j-maf-provider) -- [Neo4j GraphRAG Python Library](https://neo4j.com/docs/neo4j-graphrag-python/current/) -- [Neo4j Vector Index Documentation](https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes/) diff --git a/python/samples/02-agents/context_providers/neo4j_memory/README.md b/python/samples/02-agents/context_providers/neo4j_memory/README.md index 6dab7465d5..63da97bc65 100644 --- a/python/samples/02-agents/context_providers/neo4j_memory/README.md +++ b/python/samples/02-agents/context_providers/neo4j_memory/README.md @@ -2,7 +2,7 @@ [Neo4j Agent Memory](https://github.com/neo4j-labs/agent-memory) ([PyPI](https://pypi.org/project/neo4j-agent-memory/) · [Documentation](https://neo4j-agent-memory.vercel.app/)) is a graph-native memory system for AI agents that stores conversations, builds knowledge graphs from interactions, and lets agents learn from their own reasoning — all backed by Neo4j. -This is a **read-write memory provider** — it grows over time as the agent interacts with users. For read-only retrieval from an existing knowledge base, see the [Neo4j GraphRAG Provider](../neo4j_graphrag/README.md). For help choosing between the two, see the [Neo4j Context Providers overview](../neo4j/README.md). +This is a **read-write memory provider** — it grows over time as the agent interacts with users. For read-only retrieval from an existing knowledge base, see the [Neo4j GraphRAG Provider](../../../../05-end-to-end/neo4j_graphrag/README.md). For help choosing between the two, see the [Neo4j Context Providers overview](../neo4j/README.md). ## Examples From 2e7b96d3338551b53aeca619ee8d65ff3c04d326 Mon Sep 17 00:00:00 2001 From: Ryan Knight Date: Thu, 2 Apr 2026 18:41:28 -0600 Subject: [PATCH 6/7] fixing docs --- .../context_providers/neo4j/README.md | 7 +- .../context_providers/neo4j_memory/README.md | 106 +----------------- .../05-end-to-end/neo4j_graphrag/README.md | 2 + 3 files changed, 8 insertions(+), 107 deletions(-) diff --git a/python/samples/02-agents/context_providers/neo4j/README.md b/python/samples/02-agents/context_providers/neo4j/README.md index 8988f2573f..2fb91a9e75 100644 --- a/python/samples/02-agents/context_providers/neo4j/README.md +++ b/python/samples/02-agents/context_providers/neo4j/README.md @@ -7,7 +7,6 @@ Neo4j offers two context providers for the Agent Framework, each serving a diffe | **What it does** | Read-write memory — stores conversations, builds knowledge graphs, learns from interactions | Read-only retrieval from a pre-existing knowledge base with optional graph traversal | | **Data source** | Agent interactions (grows over time) | Pre-loaded documents and indexes | | **Python package** | [`neo4j-agent-memory`](https://pypi.org/project/neo4j-agent-memory/) | [`agent-framework-neo4j`](https://pypi.org/project/agent-framework-neo4j/) | -| **.NET package** | — | [`Neo4j.AgentFramework.GraphRAG`](https://www.nuget.org/packages/Neo4j.AgentFramework.GraphRAG) | | **Database setup** | Empty — creates its own schema | Requires pre-indexed documents with vector or fulltext indexes | | **Example use case** | "Remember my preferences", "What did we discuss last time?" | "Search our documents", "What risks does Acme Corp face?" | @@ -17,8 +16,4 @@ Neo4j offers two context providers for the Agent Framework, each serving a diffe **Use [Neo4j GraphRAG](../../../../05-end-to-end/neo4j_graphrag/README.md)** when your agent needs to search an existing knowledge base — documents, articles, product catalogs — and optionally enrich results by traversing graph relationships. The GraphRAG provider is read-only and does not modify your data. -You can use both together: GraphRAG for domain knowledge retrieval, Memory for personalization and learning. - -## .NET Support - -The Neo4j GraphRAG provider is also available for .NET. See the [.NET Neo4j GraphRAG sample](../../../../../dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step05_Neo4jGraphRAG/README.md) for installation, code examples, and runnable samples. +You can use both together: GraphRAG for domain knowledge retrieval, Memory for personalization and learning. \ No newline at end of file diff --git a/python/samples/02-agents/context_providers/neo4j_memory/README.md b/python/samples/02-agents/context_providers/neo4j_memory/README.md index 63da97bc65..78be8f0dbb 100644 --- a/python/samples/02-agents/context_providers/neo4j_memory/README.md +++ b/python/samples/02-agents/context_providers/neo4j_memory/README.md @@ -1,105 +1,9 @@ -# Neo4j Memory Context Provider Examples +# Neo4j Memory Context Provider -[Neo4j Agent Memory](https://github.com/neo4j-labs/agent-memory) ([PyPI](https://pypi.org/project/neo4j-agent-memory/) · [Documentation](https://neo4j-agent-memory.vercel.app/)) is a graph-native memory system for AI agents that stores conversations, builds knowledge graphs from interactions, and lets agents learn from their own reasoning — all backed by Neo4j. +[Neo4j Agent Memory](https://github.com/neo4j-labs/agent-memory) is a graph-native memory system for AI agents that stores conversations, builds knowledge graphs from interactions, and lets agents learn from their own reasoning — all backed by Neo4j. -This is a **read-write memory provider** — it grows over time as the agent interacts with users. For read-only retrieval from an existing knowledge base, see the [Neo4j GraphRAG Provider](../../../../05-end-to-end/neo4j_graphrag/README.md). For help choosing between the two, see the [Neo4j Context Providers overview](../neo4j/README.md). +For full documentation, installation instructions, code examples, and configuration details, see the [Neo4j Memory integration guide on Microsoft Learn](https://learn.microsoft.com/agent-framework/integrations/neo4j-memory). -## Examples +For a runnable example, see the [retail assistant sample](https://github.com/neo4j-labs/agent-memory/tree/main/examples/microsoft_agent_retail_assistant). -- **Basic memory**: Store conversations and recall context across sessions -- **Memory with tools**: Give the agent tools to search memory, remember preferences, and find entity connections in the knowledge graph - -For a full runnable example, see the [retail assistant sample](https://github.com/neo4j-labs/agent-memory/tree/main/examples/microsoft_agent_retail_assistant). - -## Installation - -```bash -pip install neo4j-agent-memory[microsoft-agent] -``` - -## Prerequisites - -### Required Resources - -1. **Neo4j database** (empty — the memory provider creates its own schema) - - [Neo4j AuraDB](https://neo4j.com/cloud/auradb/) (managed) or self-hosted - - No pre-existing indexes or data required -2. **Azure AI Foundry project** with a model deployment (for the agent's chat model) -3. **Embedding model** — supports OpenAI, Azure AI, or other providers for semantic search over memories - -### Authentication - -- Neo4j: Username/password authentication -- Azure AI: Uses `DefaultAzureCredential` - -Run `az login` for Azure authentication. - -## Configuration - -### Environment Variables - -**Neo4j:** -- `NEO4J_URI`: Neo4j connection URI (e.g., `neo4j+s://your-instance.databases.neo4j.io`) -- `NEO4J_USERNAME`: Database username -- `NEO4J_PASSWORD`: Database password - -**Azure AI:** -- `AZURE_AI_PROJECT_ENDPOINT`: Azure AI Foundry project endpoint -- `AZURE_AI_MODEL_DEPLOYMENT_NAME`: Chat model deployment name (e.g., `gpt-4o`) - -**Embeddings (pick one):** -- `OPENAI_API_KEY`: For OpenAI embeddings -- Or configure Azure AI embeddings via `AZURE_AI_PROJECT_ENDPOINT` - -## Code Example - -```python -import os - -from agent_framework import Agent -from agent_framework.azure import AzureAIClient -from azure.identity.aio import AzureCliCredential -from neo4j_agent_memory import MemoryClient, MemorySettings -from neo4j_agent_memory.integrations.microsoft_agent import ( - Neo4jMicrosoftMemory, - create_memory_tools, -) - -settings = MemorySettings(...) -memory_client = MemoryClient(settings) - -async with memory_client: - memory = Neo4jMicrosoftMemory.from_memory_client( - memory_client=memory_client, - session_id="user-123", - ) - tools = create_memory_tools(memory) - - async with ( - AzureAIClient( - credential=AzureCliCredential(), - project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"], - ) as client, - Agent( - client=client, - name="MemoryAssistant", - instructions="You are a helpful assistant with persistent memory.", - tools=tools, - context_providers=[memory.context_provider], - ) as agent, - ): - session = agent.create_session() - response = await agent.run( - "Remember that I prefer window seats on flights.", session=session - ) - print(response.text) -``` - -`create_memory_tools()` returns callable `FunctionTool` instances that the framework auto-invokes during streaming — no manual tool dispatch is needed. The core tools are: `search_memory`, `remember_preference`, `recall_preferences`, `search_knowledge`, `remember_fact`, and `find_similar_tasks`. Optional GDS graph algorithm tools (`find_connection_path`, `find_similar_items`, `find_important_entities`) are included when a `GDSConfig` is provided. - -## Additional Resources - -- [Neo4j Agent Memory Repository](https://github.com/neo4j-labs/agent-memory) -- [Neo4j Agent Memory Documentation](https://neo4j-agent-memory.vercel.app/) -- [Neo4j Agent Memory on PyPI](https://pypi.org/project/neo4j-agent-memory/) -- [Neo4j AuraDB](https://neo4j.com/cloud/auradb/) +For help choosing between the Memory and GraphRAG providers, see the [Neo4j Context Providers overview](../neo4j/README.md). diff --git a/python/samples/05-end-to-end/neo4j_graphrag/README.md b/python/samples/05-end-to-end/neo4j_graphrag/README.md index ab7f5e590e..c721e1538f 100644 --- a/python/samples/05-end-to-end/neo4j_graphrag/README.md +++ b/python/samples/05-end-to-end/neo4j_graphrag/README.md @@ -4,6 +4,8 @@ The [Neo4j GraphRAG context provider](https://github.com/neo4j-labs/neo4j-maf-pr This sample keeps setup lightweight by using a pre-built Neo4j fulltext index plus a graph-enrichment query. +For full documentation, see the [Neo4j GraphRAG integration guide on Microsoft Learn](https://learn.microsoft.com/agent-framework/integrations/neo4j-graphrag). + ## Example | File | Description | From 6f318c37cf9dbd5ff74fda2d9b479988f346f879 Mon Sep 17 00:00:00 2001 From: Ryan Knight Date: Sun, 5 Apr 2026 19:53:34 -0600 Subject: [PATCH 7/7] fix relative paths --- python/samples/02-agents/context_providers/neo4j/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/samples/02-agents/context_providers/neo4j/README.md b/python/samples/02-agents/context_providers/neo4j/README.md index 2fb91a9e75..a1b51a7a97 100644 --- a/python/samples/02-agents/context_providers/neo4j/README.md +++ b/python/samples/02-agents/context_providers/neo4j/README.md @@ -2,7 +2,7 @@ Neo4j offers two context providers for the Agent Framework, each serving a different purpose: -| | [Neo4j Memory](../neo4j_memory/README.md) | [Neo4j GraphRAG](../../../../05-end-to-end/neo4j_graphrag/README.md) | +| | [Neo4j Memory](../neo4j_memory/README.md) | [Neo4j GraphRAG](../../../05-end-to-end/neo4j_graphrag/README.md) | |---|---|---| | **What it does** | Read-write memory — stores conversations, builds knowledge graphs, learns from interactions | Read-only retrieval from a pre-existing knowledge base with optional graph traversal | | **Data source** | Agent interactions (grows over time) | Pre-loaded documents and indexes | @@ -14,6 +14,6 @@ Neo4j offers two context providers for the Agent Framework, each serving a diffe **Use [Neo4j Memory](../neo4j_memory/README.md)** when your agent needs to remember things across sessions — user preferences, past conversations, extracted entities, and reasoning traces. The memory provider writes to the database on every interaction, building a knowledge graph that grows over time. -**Use [Neo4j GraphRAG](../../../../05-end-to-end/neo4j_graphrag/README.md)** when your agent needs to search an existing knowledge base — documents, articles, product catalogs — and optionally enrich results by traversing graph relationships. The GraphRAG provider is read-only and does not modify your data. +**Use [Neo4j GraphRAG](../../../05-end-to-end/neo4j_graphrag/README.md)** when your agent needs to search an existing knowledge base — documents, articles, product catalogs — and optionally enrich results by traversing graph relationships. The GraphRAG provider is read-only and does not modify your data. You can use both together: GraphRAG for domain knowledge retrieval, Memory for personalization and learning. \ No newline at end of file