Skip to main content

Neo4j Context Provider for Microsoft Agent Framework - RAG with knowledge graphs

Project description

agent-framework-neo4j

Neo4j Context Provider for Microsoft Agent Framework - RAG with knowledge graphs.

Quick Install

pip install agent-framework-neo4j --pre

# With Azure AI embeddings support
pip install agent-framework-neo4j[azure] --pre

Supported Platforms

  • Python 3.10+
  • Windows, macOS, Linux

Setup

Configure Neo4j credentials via environment variables or constructor parameters:

# Environment variables
export NEO4J_URI="neo4j+s://xxx.databases.neo4j.io"
export NEO4J_USERNAME="neo4j"
export NEO4J_PASSWORD="your-password"

Quick Start

Basic Fulltext Search

from agent_framework_neo4j import Neo4jContextProvider, Neo4jSettings

settings = Neo4jSettings()  # Loads from environment

provider = Neo4jContextProvider(
    uri=settings.uri,
    username=settings.username,
    password=settings.get_password(),
    index_name="search_chunks",
    index_type="fulltext",
)

async with provider:
    # Use with Microsoft Agent Framework agent
    pass

Vector Search with Azure AI Embeddings

from agent_framework_neo4j import Neo4jContextProvider, AzureAIEmbedder, AzureAISettings
from azure.identity.aio import AzureCliCredential

credential = AzureCliCredential()
ai_settings = AzureAISettings()  # Loads from AZURE_AI_* env vars

embedder = AzureAIEmbedder(
    endpoint=ai_settings.project_endpoint,
    model_name=ai_settings.embedding_model,
    credential=credential,
)

provider = Neo4jContextProvider(
    uri="neo4j+s://xxx.databases.neo4j.io",
    username="neo4j",
    password="your-password",
    index_name="chunkEmbeddings",
    index_type="vector",
    embedder=embedder,
    top_k=5,
)

Graph-Enriched Retrieval

provider = Neo4jContextProvider(
    uri=settings.uri,
    username=settings.username,
    password=settings.get_password(),
    index_name="chunkEmbeddings",
    index_type="vector",
    mode="graph_enriched",
    retrieval_query="""
        MATCH (node)-[:FROM_DOCUMENT]->(doc:Document)
        RETURN node.text AS text, score, doc.title AS title
        ORDER BY score DESC
    """,
    embedder=embedder,
)

Features

  • Vector Search - Semantic similarity using embeddings
  • Fulltext Search - Keyword matching with Lucene
  • Hybrid Search - Combined vector + fulltext
  • Graph Enrichment - Custom Cypher queries for relationship traversal
  • Message History - Configurable conversation context windowing
  • Pydantic Settings - Environment-based configuration

Environment Variables

Variable Description
NEO4J_URI Neo4j connection URI
NEO4J_USERNAME Database username
NEO4J_PASSWORD Database password
NEO4J_VECTOR_INDEX_NAME Vector index name (default: chunkEmbeddings)
NEO4J_FULLTEXT_INDEX_NAME Fulltext index name (default: search_chunks)
AZURE_AI_PROJECT_ENDPOINT Azure AI project endpoint (for embeddings)
AZURE_AI_EMBEDDING_NAME Embedding model name

More Examples

See the samples directory for complete working examples.

Documentation

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_framework_neo4j-0.1.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_framework_neo4j-0.1.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file agent_framework_neo4j-0.1.0.tar.gz.

File metadata

File hashes

Hashes for agent_framework_neo4j-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3f90adeb89b2d3d4b80435870fdd6a444287c851b06c654c916163334475828
MD5 ef48906c85cd909ba20ccad8bb3b02e4
BLAKE2b-256 31bbf79bd8a634f7321fa0a884b92b0045da0722af595b4cef1935e786764352

See more details on using hashes here.

File details

Details for the file agent_framework_neo4j-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_framework_neo4j-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87c35b8c5130d8cef11fbba8cb25c1201e7b1a1ac1a02dc1e85987c6313caaf2
MD5 4ab7d4dbb1ed36e4412861d2ec3b9d06
BLAKE2b-256 1367a34de2ba48985df8d7c1b5980a0f94371f3569da98f80a7ec91b705f922f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page