Skip to main content

Real-time knowledge graph memory for agentic AI platforms

Project description

NeuroWeave

NeuroWeave

Real-time knowledge graph memory for agentic AI platforms.

Agents that learn. Memory that compounds. Privacy that's provable.

InstallationQuickstartDocumentationArchitectureChangelog

Python 3.11+ Docs License PyPI


What This Is

NeuroWeave is an async Python library that transforms AI conversations into a live knowledge graph. As a user chats with an AI agent, NeuroWeave extracts entities and relationships from each message, materializes them into a graph, and lets the agent query that graph to recall facts, preferences, and connections.

from neuroweave import NeuroWeave

async with NeuroWeave(llm_provider="anthropic") as nw:
    # Agent feeds user messages — graph builds automatically
    await nw.process("My wife Lena and I are going to Tokyo in March")
    await nw.process("She loves sushi but I prefer ramen")

    # Query for relevant context
    result = await nw.query("what does my wife like?")
    # → nodes: [Lena, sushi]  edges: [Lena --prefers--> sushi]

Open http://localhost:8787 to watch the graph build in real time:

graph LR
    User((User)) -->|married_to| Lena((Lena))
    User -->|traveling_to| Tokyo((Tokyo))
    Lena -->|traveling_to| Tokyo
    User -->|named| Alex((Alex))
    User -->|prefers| ramen((ramen))
    Lena -->|prefers| sushi((sushi))
    User -->|experienced_with| Python((Python))
    User -->|has_children| children((children))

    style User fill:#6c63ff,color:#fff
    style Lena fill:#6c63ff,color:#fff
    style Alex fill:#6c63ff,color:#fff
    style Tokyo fill:#6c63ff,color:#fff
    style children fill:#6c63ff,color:#fff
    style Python fill:#4ade80,color:#000
    style sushi fill:#4ade80,color:#000
    style ramen fill:#4ade80,color:#000

Installation

pip install neuroweave-python

Or install from source:

git clone https://github.com/neuroweave/neuroweave.git
cd neuroweave
make install    # pip install -e ".[dev]"

Quickstart

As a Library (recommended)

import asyncio
from neuroweave import NeuroWeave

async def main():
    async with NeuroWeave(
        llm_provider="anthropic",
        llm_api_key="sk-ant-...",
    ) as nw:
        # Write path — extract knowledge, update the graph
        result = await nw.process("My wife Lena loves Malbec")
        print(f"Extracted {result.entity_count} entities")

        # Read path — structured query
        result = await nw.query(["Lena"], relations=["prefers"], max_hops=1)
        print(result.node_names())  # ['Lena', 'Malbec']

        # Read path — natural language (LLM translates to graph query)
        result = await nw.query("what does my wife like?")

        # Combined — process + query in one call (primary agent integration)
        context = await nw.get_context("remind me about dinner")
        print(context.relevant.node_names())

asyncio.run(main())

Mock Mode (no API key needed)

async with NeuroWeave(llm_provider="mock") as nw:
    ...

As a CLI

# With real LLM
export NEUROWEAVE_LLM_API_KEY=sk-ant-...
neuroweave

# With mock LLM (no API key needed)
NEUROWEAVE_LLM_PROVIDER=mock neuroweave

Demo Agent

python examples/demo_agent.py              # Canned demo (mock, no API key)
python examples/demo_agent.py -i           # Interactive mode
python examples/demo_agent.py --provider anthropic  # With real LLM

API Overview

Three Methods

Method Purpose Returns
process(message) Extract knowledge, update graph ProcessResult
query(...) Query the graph (structured or NL) QueryResult
get_context(message) Process + query combined ContextResult

Event Subscription

from neuroweave import EventType

async def on_new_entity(event):
    print(f"Discovered: {event.data['name']}")

nw.subscribe(on_new_entity, event_types={EventType.NODE_ADDED})

Visualization

nw = NeuroWeave(enable_visualization=True, server_port=8787)
# Graph visible at http://127.0.0.1:8787 with WebSocket live updates

Full documentation: neuroweave.readthedocs.io


Configuration

Three-tier system: field defaults → YAML → environment variables (highest priority).

# config/default.yaml
llm_provider: "anthropic"
llm_model: "claude-haiku-4-5-20251001"
graph_backend: "memory"
server_host: "127.0.0.1"
server_port: 8787
log_level: "INFO"
log_format: "console"
# Environment variable overrides
NEUROWEAVE_LLM_PROVIDER=mock
NEUROWEAVE_LLM_API_KEY=sk-ant-...
NEUROWEAVE_LOG_FORMAT=json

Project Structure

neuroweave/
├── src/neuroweave/
│   ├── __init__.py              # Public exports: NeuroWeave, ProcessResult, ...
│   ├── api.py                   # NeuroWeave facade class (the public API)
│   ├── config.py                # Pydantic settings: YAML + env vars
│   ├── events.py                # EventBus async pub/sub
│   ├── logging.py               # structlog: console or JSON output
│   ├── main.py                  # CLI entry point
│   ├── extraction/
│   │   ├── llm_client.py        # LLMClient protocol + Mock + Anthropic
│   │   └── pipeline.py          # Message → ExtractionResult
│   ├── graph/
│   │   ├── store.py             # NetworkX graph + event emission
│   │   ├── ingest.py            # ExtractionResult → graph nodes and edges
│   │   ├── query.py             # Structured query engine
│   │   └── nl_query.py          # NL → structured query via LLM
│   └── server/
│       └── app.py               # FastAPI: REST + WebSocket + Cytoscape.js
├── tests/                       # ~308 tests across 16 files
├── examples/
│   └── demo_agent.py            # Self-contained demo agent
├── docs/                        # MkDocs documentation (readthedocs.io)
├── config/default.yaml
├── static/index.html            # Cytoscape.js visualizer
├── pyproject.toml
├── mkdocs.yml
├── .readthedocs.yaml
├── LICENSE                      # Apache 2.0
└── CHANGELOG.md

Testing

make test           # All ~308 tests
make test-cov       # With coverage report
make lint           # Ruff linting
make format         # Auto-format
Test File Tests Coverage
test_smoke.py 2 Package imports, wiring
test_config.py 9 Defaults, YAML, env overrides
test_logging.py 8 Console/JSON output, filtering
test_graph.py 30 Node/edge CRUD, events, factories
test_extraction.py 30 JSON repair, mock LLM, resilience
test_ingest.py 13 Dedup, type mapping, growth
test_server.py 10 REST, WebSocket, health
test_e2e.py 22 Full POC proof: 5-msg → graph
test_live_updates.py 12 Event emission, server reflects graph
test_query.py 37 Structured queries, hop traversal
test_nl_query.py 38 NL query planner, parsing, fallback
test_events.py 33 EventBus lifecycle, timeout, errors
test_api.py 36 Facade lifecycle, process, query
test_integration.py 28 Full end-to-end with corpus

Dependencies

Core: anthropic ≥0.42, networkx ≥3.2, fastapi ≥0.115, structlog ≥25.5, pydantic-settings ≥2.7, uvicorn ≥0.34, websockets ≥16.0, pyyaml ≥6.0

Dev: pytest, pytest-asyncio, pytest-cov, httpx, ruff

Docs: mkdocs-material, mkdocstrings


License

Apache 2.0


NeuroWeave — Agents that learn. Memory that compounds. Privacy that's provable.

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

neuroweave_python-0.1.0.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

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

neuroweave_python-0.1.0-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neuroweave_python-0.1.0.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for neuroweave_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a89ff9b53f42f92e712a42413f427ae90e8359cdb831901688b93238c62112b2
MD5 e0658b373fa4a70d9cb076ceea6e83cb
BLAKE2b-256 7dab50545e3dfa319fd1836c1a05c855054c84fb40a75f5d91190646bad04185

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroweave_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4da12d64a2e9c637673a801e98449cb27b424ef83569b99d5bb5d161bffe15c9
MD5 9530fa8708737086458ad4b7f607d7df
BLAKE2b-256 f3f41fb5f2b9cff03b9683e801a80d09a4482650aff8f093cd0c4d7128f29140

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