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/alexh-scrt/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.2.0.tar.gz (46.5 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.2.0-py3-none-any.whl (52.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neuroweave_python-0.2.0.tar.gz
  • Upload date:
  • Size: 46.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 00dff9868b9f3a0c950465db83cf324835f5e41c5de0377d5ecc21b88ca2e2b6
MD5 1ea5b1d4706c0d41a0b9cc7857414d4e
BLAKE2b-256 8b1e56f1779e72dfee4c50c7a87d633ba64e5017b3821aac97666f497d6ddd97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for neuroweave_python-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5c0af15ac1d1a05d96d392bcd3c3db78b26711cfa4b98806fb3dca4a138914f
MD5 38581eaa4fc9dbee739512158954a257
BLAKE2b-256 d480b4811900b84fbd59253114da8ea645c84e191dbd2f4e77bd535dedc9727c

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