neuroweave-python 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- neuroweave_python-0.1.0/.gitignore +39 -0
- neuroweave_python-0.1.0/CHANGELOG.md +96 -0
- neuroweave_python-0.1.0/LICENSE +191 -0
- neuroweave_python-0.1.0/PKG-INFO +336 -0
- neuroweave_python-0.1.0/README.md +287 -0
- neuroweave_python-0.1.0/config/.gitkeep +0 -0
- neuroweave_python-0.1.0/config/default.yaml +23 -0
- neuroweave_python-0.1.0/pyproject.toml +109 -0
- neuroweave_python-0.1.0/src/neuroweave/__init__.py +14 -0
- neuroweave_python-0.1.0/src/neuroweave/api.py +494 -0
- neuroweave_python-0.1.0/src/neuroweave/config.py +87 -0
- neuroweave_python-0.1.0/src/neuroweave/events.py +203 -0
- neuroweave_python-0.1.0/src/neuroweave/extraction/__init__.py +0 -0
- neuroweave_python-0.1.0/src/neuroweave/extraction/llm_client.py +123 -0
- neuroweave_python-0.1.0/src/neuroweave/extraction/pipeline.py +346 -0
- neuroweave_python-0.1.0/src/neuroweave/graph/__init__.py +29 -0
- neuroweave_python-0.1.0/src/neuroweave/graph/ingest.py +125 -0
- neuroweave_python-0.1.0/src/neuroweave/graph/nl_query.py +305 -0
- neuroweave_python-0.1.0/src/neuroweave/graph/query.py +203 -0
- neuroweave_python-0.1.0/src/neuroweave/graph/store.py +314 -0
- neuroweave_python-0.1.0/src/neuroweave/logging.py +85 -0
- neuroweave_python-0.1.0/src/neuroweave/main.py +187 -0
- neuroweave_python-0.1.0/src/neuroweave/py.typed +0 -0
- neuroweave_python-0.1.0/src/neuroweave/server/__init__.py +0 -0
- neuroweave_python-0.1.0/src/neuroweave/server/app.py +185 -0
- neuroweave_python-0.1.0/static/.gitkeep +0 -0
- neuroweave_python-0.1.0/static/index.html +368 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Claude
|
|
2
|
+
.claude/
|
|
3
|
+
|
|
4
|
+
# Python
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.eggs/
|
|
11
|
+
|
|
12
|
+
# Virtual environment
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
|
|
16
|
+
# IDE
|
|
17
|
+
.idea/
|
|
18
|
+
.vscode/
|
|
19
|
+
*.swp
|
|
20
|
+
*.swo
|
|
21
|
+
|
|
22
|
+
# Testing
|
|
23
|
+
.pytest_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
htmlcov/
|
|
26
|
+
|
|
27
|
+
# Environment
|
|
28
|
+
.env
|
|
29
|
+
|
|
30
|
+
# OS
|
|
31
|
+
.DS_Store
|
|
32
|
+
Thumbs.db
|
|
33
|
+
|
|
34
|
+
# Documentation build
|
|
35
|
+
site/
|
|
36
|
+
|
|
37
|
+
# Distribution
|
|
38
|
+
*.whl
|
|
39
|
+
*.tar.gz
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to NeuroWeave will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] — 2026-02-17
|
|
9
|
+
|
|
10
|
+
### Summary
|
|
11
|
+
|
|
12
|
+
First public release. NeuroWeave is an async Python library that transforms AI
|
|
13
|
+
conversations into a live knowledge graph. This release includes the full
|
|
14
|
+
extraction pipeline, graph store, structured and natural language queries,
|
|
15
|
+
event subscription, and an optional real-time visualization server.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
**Public API (`neuroweave.api`)**
|
|
20
|
+
|
|
21
|
+
- `NeuroWeave` facade class — the single entry point for library consumers.
|
|
22
|
+
- `async process(message)` — extract entities and relations, update the graph.
|
|
23
|
+
- `async query(...)` — structured or natural language graph queries.
|
|
24
|
+
- `async get_context(message)` — process + query combined (the primary integration point).
|
|
25
|
+
- `subscribe()` / `unsubscribe()` — event-driven notifications on graph mutations.
|
|
26
|
+
- `from_config(path)` — YAML-based configuration.
|
|
27
|
+
- Async context manager support (`async with NeuroWeave(...) as nw:`).
|
|
28
|
+
- `ProcessResult` — extraction details and graph delta.
|
|
29
|
+
- `ContextResult` — extraction + relevant graph context in one response.
|
|
30
|
+
- `QueryResult` — structured query results with nodes, edges, and metadata.
|
|
31
|
+
- `EventType` — event type enum for subscription filtering.
|
|
32
|
+
|
|
33
|
+
**Extraction Pipeline (`neuroweave.extraction`)**
|
|
34
|
+
|
|
35
|
+
- LLM-powered entity and relation extraction from conversational messages.
|
|
36
|
+
- `LLMClient` protocol — supports Anthropic (Claude) and mock implementations.
|
|
37
|
+
- JSON repair layer — handles markdown fences, trailing commas, truncated output.
|
|
38
|
+
- Defensive parsing — malformed LLM output never crashes the pipeline.
|
|
39
|
+
|
|
40
|
+
**Graph Store (`neuroweave.graph`)**
|
|
41
|
+
|
|
42
|
+
- In-memory knowledge graph backed by NetworkX `MultiDiGraph`.
|
|
43
|
+
- Node deduplication by name (case-insensitive).
|
|
44
|
+
- `query_subgraph()` — structured queries with entity resolution, hop traversal,
|
|
45
|
+
relation filtering, and confidence thresholds.
|
|
46
|
+
- `NLQueryPlanner` — translates natural language questions into structured queries
|
|
47
|
+
via LLM, with schema injection and fallback to broad search.
|
|
48
|
+
- `ingest_extraction()` — bridges extraction results into graph mutations.
|
|
49
|
+
|
|
50
|
+
**Event System (`neuroweave.events`)**
|
|
51
|
+
|
|
52
|
+
- `EventBus` — async pub/sub with type filtering, timeout monitoring, and error isolation.
|
|
53
|
+
- Non-blocking emission via `asyncio.create_task()`.
|
|
54
|
+
- Graph store emits `NODE_ADDED`, `NODE_UPDATED`, `EDGE_ADDED`, `EDGE_UPDATED` events.
|
|
55
|
+
|
|
56
|
+
**Visualization Server (`neuroweave.server`)**
|
|
57
|
+
|
|
58
|
+
- FastAPI-based Cytoscape.js graph visualizer at `localhost:8787`.
|
|
59
|
+
- WebSocket live updates — graph re-layouts with animation as nodes/edges are added.
|
|
60
|
+
- Full graph snapshot on WebSocket connect.
|
|
61
|
+
- Can be started standalone or mounted alongside agent routes via `create_visualization_app()`.
|
|
62
|
+
|
|
63
|
+
**Configuration (`neuroweave.config`)**
|
|
64
|
+
|
|
65
|
+
- Three-tier configuration: field defaults → YAML → environment variables.
|
|
66
|
+
- Pydantic-based validation with typed settings.
|
|
67
|
+
- `NEUROWEAVE_` prefixed env vars override all settings.
|
|
68
|
+
|
|
69
|
+
**Logging (`neuroweave.logging`)**
|
|
70
|
+
|
|
71
|
+
- Structured logging via structlog.
|
|
72
|
+
- Console (colored, human-readable) and JSON (machine-parseable) output modes.
|
|
73
|
+
|
|
74
|
+
**CLI**
|
|
75
|
+
|
|
76
|
+
- `neuroweave` command — interactive terminal conversation loop with live visualization.
|
|
77
|
+
|
|
78
|
+
**Demo & Examples**
|
|
79
|
+
|
|
80
|
+
- `examples/demo_agent.py` — self-contained demo showing NeuroWeave integration.
|
|
81
|
+
Runs with mock LLM (no API key needed) or Anthropic. Includes canned demo and
|
|
82
|
+
interactive modes.
|
|
83
|
+
|
|
84
|
+
**Testing**
|
|
85
|
+
|
|
86
|
+
- ~308 tests across 16 test files covering all components.
|
|
87
|
+
- Integration tests verify the full flow: 5-message corpus → graph with 9 nodes,
|
|
88
|
+
9 edges → structured and NL queries return expected results.
|
|
89
|
+
|
|
90
|
+
### Dependencies
|
|
91
|
+
|
|
92
|
+
- Python 3.11+
|
|
93
|
+
- anthropic ≥0.42, networkx ≥3.2, fastapi ≥0.115, structlog ≥25.5
|
|
94
|
+
- Full list in `pyproject.toml`
|
|
95
|
+
|
|
96
|
+
[0.1.0]: https://github.com/neuroweave/neuroweave/releases/tag/v0.1.0
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2025 NeuroWeave Contributors
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: neuroweave-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Real-time knowledge graph memory for agentic AI platforms
|
|
5
|
+
Project-URL: Homepage, https://github.com/alexh-scrt/neuroweave
|
|
6
|
+
Project-URL: Documentation, https://neuroweave.readthedocs.io
|
|
7
|
+
Project-URL: Repository, https://github.com/alexh-scrt/neuroweave
|
|
8
|
+
Project-URL: Changelog, https://github.com/alexh-scrt/neuroweave/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/alexh-scrt/neuroweave/issues
|
|
10
|
+
Author: NeuroWeave Contributors
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: agentic-ai,ai-memory,anthropic,claude,extraction,graph-database,knowledge-graph,llm,networkx
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Framework :: FastAPI
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.11
|
|
27
|
+
Requires-Dist: anthropic>=0.42.0
|
|
28
|
+
Requires-Dist: fastapi>=0.115
|
|
29
|
+
Requires-Dist: networkx>=3.2
|
|
30
|
+
Requires-Dist: pydantic-settings>=2.7
|
|
31
|
+
Requires-Dist: pyyaml>=6.0
|
|
32
|
+
Requires-Dist: structlog>=25.5.0
|
|
33
|
+
Requires-Dist: uvicorn[standard]>=0.34
|
|
34
|
+
Requires-Dist: websockets>=16.0
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: httpx>=0.27; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest-asyncio>=1.3.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest-cov>=7.0.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest>=9.0.2; extra == 'dev'
|
|
40
|
+
Requires-Dist: ruff>=0.8; extra == 'dev'
|
|
41
|
+
Provides-Extra: docs
|
|
42
|
+
Requires-Dist: mkdocs-gen-files>=0.5; extra == 'docs'
|
|
43
|
+
Requires-Dist: mkdocs-literate-nav>=0.6; extra == 'docs'
|
|
44
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
45
|
+
Requires-Dist: mkdocs-section-index>=0.3; extra == 'docs'
|
|
46
|
+
Requires-Dist: mkdocs>=1.6; extra == 'docs'
|
|
47
|
+
Requires-Dist: mkdocstrings[python]>=0.27; extra == 'docs'
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<img src="assets/image.png" alt="NeuroWeave" width="200"/>
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<h1 align="center">NeuroWeave</h1>
|
|
55
|
+
|
|
56
|
+
<p align="center">
|
|
57
|
+
<strong>Real-time knowledge graph memory for agentic AI platforms.</strong>
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
<p align="center">
|
|
61
|
+
<em>Agents that learn. Memory that compounds. Privacy that's provable.</em>
|
|
62
|
+
</p>
|
|
63
|
+
|
|
64
|
+
<p align="center">
|
|
65
|
+
<a href="#installation">Installation</a> •
|
|
66
|
+
<a href="#quickstart">Quickstart</a> •
|
|
67
|
+
<a href="https://neuroweave.readthedocs.io">Documentation</a> •
|
|
68
|
+
<a href="ARCHITECTURE.md">Architecture</a> •
|
|
69
|
+
<a href="CHANGELOG.md">Changelog</a>
|
|
70
|
+
</p>
|
|
71
|
+
|
|
72
|
+
<p align="center">
|
|
73
|
+
<a href="https://python.org"><img src="https://img.shields.io/badge/python-3.11%2B-blue?style=flat-square" alt="Python 3.11+"></a>
|
|
74
|
+
<a href="https://neuroweave.readthedocs.io"><img src="https://img.shields.io/badge/docs-readthedocs-blue?style=flat-square" alt="Docs"></a>
|
|
75
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache_2.0-green?style=flat-square" alt="License"></a>
|
|
76
|
+
<a href="https://pypi.org/project/neuroweave-python/"><img src="https://img.shields.io/pypi/v/neuroweave-python?style=flat-square" alt="PyPI"></a>
|
|
77
|
+
</p>
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## What This Is
|
|
82
|
+
|
|
83
|
+
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.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from neuroweave import NeuroWeave
|
|
87
|
+
|
|
88
|
+
async with NeuroWeave(llm_provider="anthropic") as nw:
|
|
89
|
+
# Agent feeds user messages — graph builds automatically
|
|
90
|
+
await nw.process("My wife Lena and I are going to Tokyo in March")
|
|
91
|
+
await nw.process("She loves sushi but I prefer ramen")
|
|
92
|
+
|
|
93
|
+
# Query for relevant context
|
|
94
|
+
result = await nw.query("what does my wife like?")
|
|
95
|
+
# → nodes: [Lena, sushi] edges: [Lena --prefers--> sushi]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Open `http://localhost:8787` to watch the graph build in real time:
|
|
99
|
+
|
|
100
|
+
```mermaid
|
|
101
|
+
graph LR
|
|
102
|
+
User((User)) -->|married_to| Lena((Lena))
|
|
103
|
+
User -->|traveling_to| Tokyo((Tokyo))
|
|
104
|
+
Lena -->|traveling_to| Tokyo
|
|
105
|
+
User -->|named| Alex((Alex))
|
|
106
|
+
User -->|prefers| ramen((ramen))
|
|
107
|
+
Lena -->|prefers| sushi((sushi))
|
|
108
|
+
User -->|experienced_with| Python((Python))
|
|
109
|
+
User -->|has_children| children((children))
|
|
110
|
+
|
|
111
|
+
style User fill:#6c63ff,color:#fff
|
|
112
|
+
style Lena fill:#6c63ff,color:#fff
|
|
113
|
+
style Alex fill:#6c63ff,color:#fff
|
|
114
|
+
style Tokyo fill:#6c63ff,color:#fff
|
|
115
|
+
style children fill:#6c63ff,color:#fff
|
|
116
|
+
style Python fill:#4ade80,color:#000
|
|
117
|
+
style sushi fill:#4ade80,color:#000
|
|
118
|
+
style ramen fill:#4ade80,color:#000
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Installation
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install neuroweave-python
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Or install from source:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
git clone https://github.com/neuroweave/neuroweave.git
|
|
133
|
+
cd neuroweave
|
|
134
|
+
make install # pip install -e ".[dev]"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Quickstart
|
|
140
|
+
|
|
141
|
+
### As a Library (recommended)
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
import asyncio
|
|
145
|
+
from neuroweave import NeuroWeave
|
|
146
|
+
|
|
147
|
+
async def main():
|
|
148
|
+
async with NeuroWeave(
|
|
149
|
+
llm_provider="anthropic",
|
|
150
|
+
llm_api_key="sk-ant-...",
|
|
151
|
+
) as nw:
|
|
152
|
+
# Write path — extract knowledge, update the graph
|
|
153
|
+
result = await nw.process("My wife Lena loves Malbec")
|
|
154
|
+
print(f"Extracted {result.entity_count} entities")
|
|
155
|
+
|
|
156
|
+
# Read path — structured query
|
|
157
|
+
result = await nw.query(["Lena"], relations=["prefers"], max_hops=1)
|
|
158
|
+
print(result.node_names()) # ['Lena', 'Malbec']
|
|
159
|
+
|
|
160
|
+
# Read path — natural language (LLM translates to graph query)
|
|
161
|
+
result = await nw.query("what does my wife like?")
|
|
162
|
+
|
|
163
|
+
# Combined — process + query in one call (primary agent integration)
|
|
164
|
+
context = await nw.get_context("remind me about dinner")
|
|
165
|
+
print(context.relevant.node_names())
|
|
166
|
+
|
|
167
|
+
asyncio.run(main())
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Mock Mode (no API key needed)
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
async with NeuroWeave(llm_provider="mock") as nw:
|
|
174
|
+
...
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### As a CLI
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# With real LLM
|
|
181
|
+
export NEUROWEAVE_LLM_API_KEY=sk-ant-...
|
|
182
|
+
neuroweave
|
|
183
|
+
|
|
184
|
+
# With mock LLM (no API key needed)
|
|
185
|
+
NEUROWEAVE_LLM_PROVIDER=mock neuroweave
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Demo Agent
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
python examples/demo_agent.py # Canned demo (mock, no API key)
|
|
192
|
+
python examples/demo_agent.py -i # Interactive mode
|
|
193
|
+
python examples/demo_agent.py --provider anthropic # With real LLM
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## API Overview
|
|
199
|
+
|
|
200
|
+
### Three Methods
|
|
201
|
+
|
|
202
|
+
| Method | Purpose | Returns |
|
|
203
|
+
|--------|---------|---------|
|
|
204
|
+
| `process(message)` | Extract knowledge, update graph | `ProcessResult` |
|
|
205
|
+
| `query(...)` | Query the graph (structured or NL) | `QueryResult` |
|
|
206
|
+
| `get_context(message)` | Process + query combined | `ContextResult` |
|
|
207
|
+
|
|
208
|
+
### Event Subscription
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
from neuroweave import EventType
|
|
212
|
+
|
|
213
|
+
async def on_new_entity(event):
|
|
214
|
+
print(f"Discovered: {event.data['name']}")
|
|
215
|
+
|
|
216
|
+
nw.subscribe(on_new_entity, event_types={EventType.NODE_ADDED})
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Visualization
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
nw = NeuroWeave(enable_visualization=True, server_port=8787)
|
|
223
|
+
# Graph visible at http://127.0.0.1:8787 with WebSocket live updates
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Full documentation: **[neuroweave.readthedocs.io](https://neuroweave.readthedocs.io)**
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Configuration
|
|
231
|
+
|
|
232
|
+
Three-tier system: **field defaults → YAML → environment variables** (highest priority).
|
|
233
|
+
|
|
234
|
+
```yaml
|
|
235
|
+
# config/default.yaml
|
|
236
|
+
llm_provider: "anthropic"
|
|
237
|
+
llm_model: "claude-haiku-4-5-20251001"
|
|
238
|
+
graph_backend: "memory"
|
|
239
|
+
server_host: "127.0.0.1"
|
|
240
|
+
server_port: 8787
|
|
241
|
+
log_level: "INFO"
|
|
242
|
+
log_format: "console"
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Environment variable overrides
|
|
247
|
+
NEUROWEAVE_LLM_PROVIDER=mock
|
|
248
|
+
NEUROWEAVE_LLM_API_KEY=sk-ant-...
|
|
249
|
+
NEUROWEAVE_LOG_FORMAT=json
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Project Structure
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
neuroweave/
|
|
258
|
+
├── src/neuroweave/
|
|
259
|
+
│ ├── __init__.py # Public exports: NeuroWeave, ProcessResult, ...
|
|
260
|
+
│ ├── api.py # NeuroWeave facade class (the public API)
|
|
261
|
+
│ ├── config.py # Pydantic settings: YAML + env vars
|
|
262
|
+
│ ├── events.py # EventBus async pub/sub
|
|
263
|
+
│ ├── logging.py # structlog: console or JSON output
|
|
264
|
+
│ ├── main.py # CLI entry point
|
|
265
|
+
│ ├── extraction/
|
|
266
|
+
│ │ ├── llm_client.py # LLMClient protocol + Mock + Anthropic
|
|
267
|
+
│ │ └── pipeline.py # Message → ExtractionResult
|
|
268
|
+
│ ├── graph/
|
|
269
|
+
│ │ ├── store.py # NetworkX graph + event emission
|
|
270
|
+
│ │ ├── ingest.py # ExtractionResult → graph nodes and edges
|
|
271
|
+
│ │ ├── query.py # Structured query engine
|
|
272
|
+
│ │ └── nl_query.py # NL → structured query via LLM
|
|
273
|
+
│ └── server/
|
|
274
|
+
│ └── app.py # FastAPI: REST + WebSocket + Cytoscape.js
|
|
275
|
+
├── tests/ # ~308 tests across 16 files
|
|
276
|
+
├── examples/
|
|
277
|
+
│ └── demo_agent.py # Self-contained demo agent
|
|
278
|
+
├── docs/ # MkDocs documentation (readthedocs.io)
|
|
279
|
+
├── config/default.yaml
|
|
280
|
+
├── static/index.html # Cytoscape.js visualizer
|
|
281
|
+
├── pyproject.toml
|
|
282
|
+
├── mkdocs.yml
|
|
283
|
+
├── .readthedocs.yaml
|
|
284
|
+
├── LICENSE # Apache 2.0
|
|
285
|
+
└── CHANGELOG.md
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Testing
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
make test # All ~308 tests
|
|
294
|
+
make test-cov # With coverage report
|
|
295
|
+
make lint # Ruff linting
|
|
296
|
+
make format # Auto-format
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
| Test File | Tests | Coverage |
|
|
300
|
+
|-----------|-------|----------|
|
|
301
|
+
| `test_smoke.py` | 2 | Package imports, wiring |
|
|
302
|
+
| `test_config.py` | 9 | Defaults, YAML, env overrides |
|
|
303
|
+
| `test_logging.py` | 8 | Console/JSON output, filtering |
|
|
304
|
+
| `test_graph.py` | 30 | Node/edge CRUD, events, factories |
|
|
305
|
+
| `test_extraction.py` | 30 | JSON repair, mock LLM, resilience |
|
|
306
|
+
| `test_ingest.py` | 13 | Dedup, type mapping, growth |
|
|
307
|
+
| `test_server.py` | 10 | REST, WebSocket, health |
|
|
308
|
+
| `test_e2e.py` | 22 | Full POC proof: 5-msg → graph |
|
|
309
|
+
| `test_live_updates.py` | 12 | Event emission, server reflects graph |
|
|
310
|
+
| `test_query.py` | 37 | Structured queries, hop traversal |
|
|
311
|
+
| `test_nl_query.py` | 38 | NL query planner, parsing, fallback |
|
|
312
|
+
| `test_events.py` | 33 | EventBus lifecycle, timeout, errors |
|
|
313
|
+
| `test_api.py` | 36 | Facade lifecycle, process, query |
|
|
314
|
+
| `test_integration.py` | 28 | Full end-to-end with corpus |
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Dependencies
|
|
319
|
+
|
|
320
|
+
**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
|
|
321
|
+
|
|
322
|
+
**Dev:** pytest, pytest-asyncio, pytest-cov, httpx, ruff
|
|
323
|
+
|
|
324
|
+
**Docs:** mkdocs-material, mkdocstrings
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## License
|
|
329
|
+
|
|
330
|
+
[Apache 2.0](LICENSE)
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
<p align="center">
|
|
335
|
+
<strong>NeuroWeave</strong> — Agents that learn. Memory that compounds. Privacy that's provable.
|
|
336
|
+
</p>
|