recallgraph 0.0.2__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.
- recallgraph-0.0.2/LICENSE +21 -0
- recallgraph-0.0.2/MANIFEST.in +4 -0
- recallgraph-0.0.2/PKG-INFO +330 -0
- recallgraph-0.0.2/README.md +267 -0
- recallgraph-0.0.2/pyproject.toml +257 -0
- recallgraph-0.0.2/recallgraph/__init__.py +5 -0
- recallgraph-0.0.2/recallgraph/cli.py +192 -0
- recallgraph-0.0.2/recallgraph/core/__init__.py +5 -0
- recallgraph-0.0.2/recallgraph/core/assistant.py +120 -0
- recallgraph-0.0.2/recallgraph/core/compressor.py +21 -0
- recallgraph-0.0.2/recallgraph/core/enums.py +8 -0
- recallgraph-0.0.2/recallgraph/core/graph.py +74 -0
- recallgraph-0.0.2/recallgraph/core/indexer.py +173 -0
- recallgraph-0.0.2/recallgraph/core/kernel.py +128 -0
- recallgraph-0.0.2/recallgraph/core/node.py +35 -0
- recallgraph-0.0.2/recallgraph/core/parser.py +58 -0
- recallgraph-0.0.2/recallgraph/core/retriever.py +81 -0
- recallgraph-0.0.2/recallgraph/py.typed +0 -0
- recallgraph-0.0.2/recallgraph.egg-info/PKG-INFO +330 -0
- recallgraph-0.0.2/recallgraph.egg-info/SOURCES.txt +29 -0
- recallgraph-0.0.2/recallgraph.egg-info/dependency_links.txt +1 -0
- recallgraph-0.0.2/recallgraph.egg-info/entry_points.txt +2 -0
- recallgraph-0.0.2/recallgraph.egg-info/requires.txt +31 -0
- recallgraph-0.0.2/recallgraph.egg-info/top_level.txt +1 -0
- recallgraph-0.0.2/requirements.txt +35 -0
- recallgraph-0.0.2/setup.cfg +4 -0
- recallgraph-0.0.2/setup.py +4 -0
- recallgraph-0.0.2/tests/test_assistant.py +82 -0
- recallgraph-0.0.2/tests/test_indexer.py +43 -0
- recallgraph-0.0.2/tests/test_kernel.py +47 -0
- recallgraph-0.0.2/tests/test_parser.py +50 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Mnemo Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: recallgraph
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: A graph-based memory system for LLMs with intelligent retrieval using knowledge graphs, hybrid search, and semantic embeddings
|
|
5
|
+
Author-email: RecallGraph Contributors <author@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Indhar01/RecallGraph
|
|
8
|
+
Project-URL: Documentation, https://github.com/Indhar01/RecallGraph#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/Indhar01/RecallGraph
|
|
10
|
+
Project-URL: Issues, https://github.com/Indhar01/RecallGraph/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/Indhar01/RecallGraph/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: llm,memory,knowledge-graph,rag,retrieval,ai,machine-learning,graph-database,semantic-search,vector-embeddings,chatgpt,claude,ollama,langchain,llamaindex,markdown,note-taking,personal-knowledge-management,pkm,second-brain
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Intended Audience :: Information Technology
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
23
|
+
Classifier: Operating System :: OS Independent
|
|
24
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
25
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
26
|
+
Classifier: Operating System :: MacOS
|
|
27
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
28
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
29
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
30
|
+
Classifier: Topic :: Database
|
|
31
|
+
Classifier: Topic :: Office/Business
|
|
32
|
+
Classifier: Framework :: AsyncIO
|
|
33
|
+
Classifier: Typing :: Typed
|
|
34
|
+
Requires-Python: >=3.10
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
License-File: LICENSE
|
|
37
|
+
Requires-Dist: PyYAML>=6.0
|
|
38
|
+
Requires-Dist: requests>=2.31.0
|
|
39
|
+
Provides-Extra: openai
|
|
40
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
41
|
+
Requires-Dist: tiktoken>=0.5.0; extra == "openai"
|
|
42
|
+
Provides-Extra: anthropic
|
|
43
|
+
Requires-Dist: anthropic>=0.39.0; extra == "anthropic"
|
|
44
|
+
Provides-Extra: ollama
|
|
45
|
+
Requires-Dist: ollama>=0.3.0; extra == "ollama"
|
|
46
|
+
Provides-Extra: embeddings
|
|
47
|
+
Requires-Dist: sentence-transformers>=2.2.0; extra == "embeddings"
|
|
48
|
+
Requires-Dist: numpy>=1.24.0; extra == "embeddings"
|
|
49
|
+
Provides-Extra: all
|
|
50
|
+
Requires-Dist: recallgraph[anthropic,embeddings,ollama,openai]; extra == "all"
|
|
51
|
+
Provides-Extra: dev
|
|
52
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
53
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
54
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
55
|
+
Requires-Dist: ruff>=0.7.0; extra == "dev"
|
|
56
|
+
Requires-Dist: mypy>=1.7.0; extra == "dev"
|
|
57
|
+
Requires-Dist: pre-commit>=3.5.0; extra == "dev"
|
|
58
|
+
Requires-Dist: black>=23.11.0; extra == "dev"
|
|
59
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
60
|
+
Requires-Dist: types-PyYAML>=6.0; extra == "dev"
|
|
61
|
+
Requires-Dist: types-requests>=2.31.0; extra == "dev"
|
|
62
|
+
Dynamic: license-file
|
|
63
|
+
|
|
64
|
+
# RecallGraph 🧠
|
|
65
|
+
|
|
66
|
+
[](https://pypi.org/project/recallgraph/)
|
|
67
|
+
[](https://pypi.org/project/recallgraph/)
|
|
68
|
+
[](https://github.com/Indhar01/RecallGraph/blob/main/LICENSE)
|
|
69
|
+
[](https://github.com/astral-sh/ruff)
|
|
70
|
+
[](https://github.com/pre-commit/pre-commit)
|
|
71
|
+
|
|
72
|
+
A graph-based memory system for LLMs with intelligent retrieval. RecallGraph provides a powerful solution to the LLM memory problem by combining knowledge graphs, hybrid retrieval, and semantic search.
|
|
73
|
+
|
|
74
|
+
## ✨ Features
|
|
75
|
+
|
|
76
|
+
- **Graph-Based Memory**: Navigate knowledge using bidirectional wikilinks and backlinks
|
|
77
|
+
- **Hybrid Retrieval**: Combines keyword matching, graph traversal, and optional vector embeddings
|
|
78
|
+
- **Markdown-Native**: Human-readable markdown files with YAML frontmatter
|
|
79
|
+
- **Memory Types**: Support for episodic, semantic, procedural, and fact-based memories
|
|
80
|
+
- **Smart Indexing**: Efficient caching system that only re-indexes changed files
|
|
81
|
+
- **CLI & Python API**: Use via command line or integrate into your Python applications
|
|
82
|
+
- **Multiple LLM Providers**: Works with Ollama, Claude, and OpenAI
|
|
83
|
+
- **Context Compression**: Intelligent token budgeting for optimal context windows
|
|
84
|
+
- **Salience Scoring**: Memory importance ranking for better retrieval
|
|
85
|
+
|
|
86
|
+
## 🚀 Quick Start
|
|
87
|
+
|
|
88
|
+
### Installation
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install recallgraph
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Install with optional dependencies:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# For OpenAI support
|
|
98
|
+
pip install recallgraph[openai]
|
|
99
|
+
|
|
100
|
+
# For Anthropic Claude support
|
|
101
|
+
pip install recallgraph[anthropic]
|
|
102
|
+
|
|
103
|
+
# For Ollama support
|
|
104
|
+
pip install recallgraph[ollama]
|
|
105
|
+
|
|
106
|
+
# For embedding support
|
|
107
|
+
pip install recallgraph[embeddings]
|
|
108
|
+
|
|
109
|
+
# Install everything
|
|
110
|
+
pip install recallgraph[all]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Python Usage
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from recallgraph import MemoryKernel, MemoryType
|
|
117
|
+
|
|
118
|
+
# Initialize the kernel attached to your vault path
|
|
119
|
+
kernel = MemoryKernel("~/my-vault")
|
|
120
|
+
|
|
121
|
+
# Ingest all notes in the vault
|
|
122
|
+
stats = kernel.ingest()
|
|
123
|
+
print(f"Indexed {stats['indexed']} memories.")
|
|
124
|
+
|
|
125
|
+
# Programmatically add a new memory
|
|
126
|
+
kernel.remember(
|
|
127
|
+
title="Meeting Note",
|
|
128
|
+
content="Decided to use BFS graph traversal for retrieval.",
|
|
129
|
+
memory_type=MemoryType.EPISODIC,
|
|
130
|
+
tags=["design", "retrieval"]
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# Retrieve context for an LLM query
|
|
134
|
+
context = kernel.context_window(
|
|
135
|
+
query="how does retrieval work?",
|
|
136
|
+
tags=["retrieval"],
|
|
137
|
+
depth=2,
|
|
138
|
+
top_k=8
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
print(context)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 🎯 CLI Usage
|
|
145
|
+
|
|
146
|
+
RecallGraph comes with a powerful CLI for managing your vault and chatting with it.
|
|
147
|
+
|
|
148
|
+
### Ingest
|
|
149
|
+
|
|
150
|
+
Index your markdown files into the graph database:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
recallgraph --vault ~/my-vault ingest
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Force re-indexing all files:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
recallgraph --vault ~/my-vault ingest --force
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Remember
|
|
163
|
+
|
|
164
|
+
Quickly add a memory from the command line:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
recallgraph --vault ~/my-vault remember \
|
|
168
|
+
--title "Team Sync" \
|
|
169
|
+
--content "Discussed Q3 goals." \
|
|
170
|
+
--tags planning q3
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Context Window
|
|
174
|
+
|
|
175
|
+
Generate context for a query:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
recallgraph --vault ~/my-vault context \
|
|
179
|
+
--query "What did we decide about the database?" \
|
|
180
|
+
--tags architecture \
|
|
181
|
+
--depth 2 \
|
|
182
|
+
--top-k 5
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Ask (Interactive Chat)
|
|
186
|
+
|
|
187
|
+
Start an interactive chat session with your vault context:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
recallgraph --vault ~/my-vault ask --chat --provider ollama --model llama3
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Or ask a single question:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
recallgraph --vault ~/my-vault ask \
|
|
197
|
+
--query "Summarize our design decisions" \
|
|
198
|
+
--provider claude \
|
|
199
|
+
--model claude-3-5-sonnet-20240620
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Diagnostics
|
|
203
|
+
|
|
204
|
+
Check your environment and connection to LLM providers:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
recallgraph --vault ~/my-vault doctor
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 📖 Core Concepts
|
|
211
|
+
|
|
212
|
+
### Memory Types
|
|
213
|
+
|
|
214
|
+
RecallGraph supports different types of memories inspired by cognitive science:
|
|
215
|
+
|
|
216
|
+
- **Episodic**: Personal experiences and events (e.g., meeting notes)
|
|
217
|
+
- **Semantic**: Facts and general knowledge (e.g., documentation)
|
|
218
|
+
- **Procedural**: How-to knowledge and processes (e.g., tutorials)
|
|
219
|
+
- **Fact**: Discrete factual information (e.g., configuration values)
|
|
220
|
+
|
|
221
|
+
### Graph Traversal
|
|
222
|
+
|
|
223
|
+
The library uses BFS (Breadth-First Search) to traverse your knowledge graph:
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
# Retrieve nodes with depth=2 (2 hops from seed nodes)
|
|
227
|
+
nodes = kernel.retrieve_nodes(
|
|
228
|
+
query="graph algorithms",
|
|
229
|
+
depth=2, # Traverse up to 2 levels deep
|
|
230
|
+
top_k=10 # Return top 10 relevant memories
|
|
231
|
+
)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Salience Scoring
|
|
235
|
+
|
|
236
|
+
Each memory has a salience score (0.0-1.0) that represents its importance:
|
|
237
|
+
|
|
238
|
+
```yaml
|
|
239
|
+
---
|
|
240
|
+
title: "Critical Architecture Decision"
|
|
241
|
+
salience: 0.9
|
|
242
|
+
memory_type: semantic
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
We decided to use PostgreSQL for better ACID guarantees...
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## 🏗️ Project Structure
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
RecallGraph/
|
|
252
|
+
├── recallgraph/ # Main package
|
|
253
|
+
│ ├── core/ # Core functionality
|
|
254
|
+
│ │ ├── kernel.py # Memory kernel
|
|
255
|
+
│ │ ├── graph.py # Graph implementation
|
|
256
|
+
│ │ ├── retriever.py # Hybrid retrieval
|
|
257
|
+
│ │ ├── indexer.py # File indexing
|
|
258
|
+
│ │ └── parser.py # Markdown parsing
|
|
259
|
+
│ ├── adapters/ # LLM and embedding adapters
|
|
260
|
+
│ │ ├── embeddings/ # Embedding providers
|
|
261
|
+
│ │ ├── frameworks/ # Framework integrations
|
|
262
|
+
│ │ └── llm/ # LLM providers
|
|
263
|
+
│ ├── storage/ # Storage and caching
|
|
264
|
+
│ └── cli.py # CLI implementation
|
|
265
|
+
├── tests/ # Test suite
|
|
266
|
+
└── examples/ # Example usage
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## 🤝 Contributing
|
|
270
|
+
|
|
271
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
272
|
+
|
|
273
|
+
### Development Setup
|
|
274
|
+
|
|
275
|
+
1. Clone the repository:
|
|
276
|
+
```bash
|
|
277
|
+
git clone https://github.com/Indhar01/RecallGraph.git
|
|
278
|
+
cd RecallGraph
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
2. Install in development mode:
|
|
282
|
+
```bash
|
|
283
|
+
pip install -e ".[all,dev]"
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
3. Install pre-commit hooks:
|
|
287
|
+
```bash
|
|
288
|
+
pre-commit install
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
4. Run tests:
|
|
292
|
+
```bash
|
|
293
|
+
pytest
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## 📚 Documentation
|
|
297
|
+
|
|
298
|
+
- **[Contributing Guide](CONTRIBUTING.md)** - How to contribute to the project
|
|
299
|
+
- **[Code of Conduct](CODE_OF_CONDUCT.md)** - Community guidelines
|
|
300
|
+
- **[Security Policy](SECURITY.md)** - Security reporting and best practices
|
|
301
|
+
- **[Changelog](CHANGELOG.md)** - Version history and changes
|
|
302
|
+
|
|
303
|
+
## 🔒 Security
|
|
304
|
+
|
|
305
|
+
See our [Security Policy](SECURITY.md) for reporting vulnerabilities.
|
|
306
|
+
|
|
307
|
+
## 📄 License
|
|
308
|
+
|
|
309
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
310
|
+
|
|
311
|
+
## 🌟 Acknowledgments
|
|
312
|
+
|
|
313
|
+
Inspired by the need for better memory management in LLM applications. Built with:
|
|
314
|
+
|
|
315
|
+
- Graph-based knowledge representation
|
|
316
|
+
- Hybrid retrieval strategies
|
|
317
|
+
- Cognitive science principles
|
|
318
|
+
|
|
319
|
+
## 📬 Contact & Support
|
|
320
|
+
|
|
321
|
+
- **Issues**: [GitHub Issues](https://github.com/Indhar01/RecallGraph/issues)
|
|
322
|
+
- **Discussions**: [GitHub Discussions](https://github.com/Indhar01/RecallGraph/discussions)
|
|
323
|
+
|
|
324
|
+
## 🚦 Status
|
|
325
|
+
|
|
326
|
+
This project is in active development. While the core functionality is stable, the API may change in minor versions until we reach v1.0.0.
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
Made with ❤️ for better LLM memory management
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# RecallGraph 🧠
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/recallgraph/)
|
|
4
|
+
[](https://pypi.org/project/recallgraph/)
|
|
5
|
+
[](https://github.com/Indhar01/RecallGraph/blob/main/LICENSE)
|
|
6
|
+
[](https://github.com/astral-sh/ruff)
|
|
7
|
+
[](https://github.com/pre-commit/pre-commit)
|
|
8
|
+
|
|
9
|
+
A graph-based memory system for LLMs with intelligent retrieval. RecallGraph provides a powerful solution to the LLM memory problem by combining knowledge graphs, hybrid retrieval, and semantic search.
|
|
10
|
+
|
|
11
|
+
## ✨ Features
|
|
12
|
+
|
|
13
|
+
- **Graph-Based Memory**: Navigate knowledge using bidirectional wikilinks and backlinks
|
|
14
|
+
- **Hybrid Retrieval**: Combines keyword matching, graph traversal, and optional vector embeddings
|
|
15
|
+
- **Markdown-Native**: Human-readable markdown files with YAML frontmatter
|
|
16
|
+
- **Memory Types**: Support for episodic, semantic, procedural, and fact-based memories
|
|
17
|
+
- **Smart Indexing**: Efficient caching system that only re-indexes changed files
|
|
18
|
+
- **CLI & Python API**: Use via command line or integrate into your Python applications
|
|
19
|
+
- **Multiple LLM Providers**: Works with Ollama, Claude, and OpenAI
|
|
20
|
+
- **Context Compression**: Intelligent token budgeting for optimal context windows
|
|
21
|
+
- **Salience Scoring**: Memory importance ranking for better retrieval
|
|
22
|
+
|
|
23
|
+
## 🚀 Quick Start
|
|
24
|
+
|
|
25
|
+
### Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install recallgraph
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Install with optional dependencies:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# For OpenAI support
|
|
35
|
+
pip install recallgraph[openai]
|
|
36
|
+
|
|
37
|
+
# For Anthropic Claude support
|
|
38
|
+
pip install recallgraph[anthropic]
|
|
39
|
+
|
|
40
|
+
# For Ollama support
|
|
41
|
+
pip install recallgraph[ollama]
|
|
42
|
+
|
|
43
|
+
# For embedding support
|
|
44
|
+
pip install recallgraph[embeddings]
|
|
45
|
+
|
|
46
|
+
# Install everything
|
|
47
|
+
pip install recallgraph[all]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Python Usage
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from recallgraph import MemoryKernel, MemoryType
|
|
54
|
+
|
|
55
|
+
# Initialize the kernel attached to your vault path
|
|
56
|
+
kernel = MemoryKernel("~/my-vault")
|
|
57
|
+
|
|
58
|
+
# Ingest all notes in the vault
|
|
59
|
+
stats = kernel.ingest()
|
|
60
|
+
print(f"Indexed {stats['indexed']} memories.")
|
|
61
|
+
|
|
62
|
+
# Programmatically add a new memory
|
|
63
|
+
kernel.remember(
|
|
64
|
+
title="Meeting Note",
|
|
65
|
+
content="Decided to use BFS graph traversal for retrieval.",
|
|
66
|
+
memory_type=MemoryType.EPISODIC,
|
|
67
|
+
tags=["design", "retrieval"]
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Retrieve context for an LLM query
|
|
71
|
+
context = kernel.context_window(
|
|
72
|
+
query="how does retrieval work?",
|
|
73
|
+
tags=["retrieval"],
|
|
74
|
+
depth=2,
|
|
75
|
+
top_k=8
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
print(context)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 🎯 CLI Usage
|
|
82
|
+
|
|
83
|
+
RecallGraph comes with a powerful CLI for managing your vault and chatting with it.
|
|
84
|
+
|
|
85
|
+
### Ingest
|
|
86
|
+
|
|
87
|
+
Index your markdown files into the graph database:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
recallgraph --vault ~/my-vault ingest
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Force re-indexing all files:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
recallgraph --vault ~/my-vault ingest --force
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Remember
|
|
100
|
+
|
|
101
|
+
Quickly add a memory from the command line:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
recallgraph --vault ~/my-vault remember \
|
|
105
|
+
--title "Team Sync" \
|
|
106
|
+
--content "Discussed Q3 goals." \
|
|
107
|
+
--tags planning q3
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Context Window
|
|
111
|
+
|
|
112
|
+
Generate context for a query:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
recallgraph --vault ~/my-vault context \
|
|
116
|
+
--query "What did we decide about the database?" \
|
|
117
|
+
--tags architecture \
|
|
118
|
+
--depth 2 \
|
|
119
|
+
--top-k 5
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Ask (Interactive Chat)
|
|
123
|
+
|
|
124
|
+
Start an interactive chat session with your vault context:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
recallgraph --vault ~/my-vault ask --chat --provider ollama --model llama3
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Or ask a single question:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
recallgraph --vault ~/my-vault ask \
|
|
134
|
+
--query "Summarize our design decisions" \
|
|
135
|
+
--provider claude \
|
|
136
|
+
--model claude-3-5-sonnet-20240620
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Diagnostics
|
|
140
|
+
|
|
141
|
+
Check your environment and connection to LLM providers:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
recallgraph --vault ~/my-vault doctor
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 📖 Core Concepts
|
|
148
|
+
|
|
149
|
+
### Memory Types
|
|
150
|
+
|
|
151
|
+
RecallGraph supports different types of memories inspired by cognitive science:
|
|
152
|
+
|
|
153
|
+
- **Episodic**: Personal experiences and events (e.g., meeting notes)
|
|
154
|
+
- **Semantic**: Facts and general knowledge (e.g., documentation)
|
|
155
|
+
- **Procedural**: How-to knowledge and processes (e.g., tutorials)
|
|
156
|
+
- **Fact**: Discrete factual information (e.g., configuration values)
|
|
157
|
+
|
|
158
|
+
### Graph Traversal
|
|
159
|
+
|
|
160
|
+
The library uses BFS (Breadth-First Search) to traverse your knowledge graph:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
# Retrieve nodes with depth=2 (2 hops from seed nodes)
|
|
164
|
+
nodes = kernel.retrieve_nodes(
|
|
165
|
+
query="graph algorithms",
|
|
166
|
+
depth=2, # Traverse up to 2 levels deep
|
|
167
|
+
top_k=10 # Return top 10 relevant memories
|
|
168
|
+
)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Salience Scoring
|
|
172
|
+
|
|
173
|
+
Each memory has a salience score (0.0-1.0) that represents its importance:
|
|
174
|
+
|
|
175
|
+
```yaml
|
|
176
|
+
---
|
|
177
|
+
title: "Critical Architecture Decision"
|
|
178
|
+
salience: 0.9
|
|
179
|
+
memory_type: semantic
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
We decided to use PostgreSQL for better ACID guarantees...
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## 🏗️ Project Structure
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
RecallGraph/
|
|
189
|
+
├── recallgraph/ # Main package
|
|
190
|
+
│ ├── core/ # Core functionality
|
|
191
|
+
│ │ ├── kernel.py # Memory kernel
|
|
192
|
+
│ │ ├── graph.py # Graph implementation
|
|
193
|
+
│ │ ├── retriever.py # Hybrid retrieval
|
|
194
|
+
│ │ ├── indexer.py # File indexing
|
|
195
|
+
│ │ └── parser.py # Markdown parsing
|
|
196
|
+
│ ├── adapters/ # LLM and embedding adapters
|
|
197
|
+
│ │ ├── embeddings/ # Embedding providers
|
|
198
|
+
│ │ ├── frameworks/ # Framework integrations
|
|
199
|
+
│ │ └── llm/ # LLM providers
|
|
200
|
+
│ ├── storage/ # Storage and caching
|
|
201
|
+
│ └── cli.py # CLI implementation
|
|
202
|
+
├── tests/ # Test suite
|
|
203
|
+
└── examples/ # Example usage
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## 🤝 Contributing
|
|
207
|
+
|
|
208
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
209
|
+
|
|
210
|
+
### Development Setup
|
|
211
|
+
|
|
212
|
+
1. Clone the repository:
|
|
213
|
+
```bash
|
|
214
|
+
git clone https://github.com/Indhar01/RecallGraph.git
|
|
215
|
+
cd RecallGraph
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
2. Install in development mode:
|
|
219
|
+
```bash
|
|
220
|
+
pip install -e ".[all,dev]"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
3. Install pre-commit hooks:
|
|
224
|
+
```bash
|
|
225
|
+
pre-commit install
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
4. Run tests:
|
|
229
|
+
```bash
|
|
230
|
+
pytest
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 📚 Documentation
|
|
234
|
+
|
|
235
|
+
- **[Contributing Guide](CONTRIBUTING.md)** - How to contribute to the project
|
|
236
|
+
- **[Code of Conduct](CODE_OF_CONDUCT.md)** - Community guidelines
|
|
237
|
+
- **[Security Policy](SECURITY.md)** - Security reporting and best practices
|
|
238
|
+
- **[Changelog](CHANGELOG.md)** - Version history and changes
|
|
239
|
+
|
|
240
|
+
## 🔒 Security
|
|
241
|
+
|
|
242
|
+
See our [Security Policy](SECURITY.md) for reporting vulnerabilities.
|
|
243
|
+
|
|
244
|
+
## 📄 License
|
|
245
|
+
|
|
246
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
247
|
+
|
|
248
|
+
## 🌟 Acknowledgments
|
|
249
|
+
|
|
250
|
+
Inspired by the need for better memory management in LLM applications. Built with:
|
|
251
|
+
|
|
252
|
+
- Graph-based knowledge representation
|
|
253
|
+
- Hybrid retrieval strategies
|
|
254
|
+
- Cognitive science principles
|
|
255
|
+
|
|
256
|
+
## 📬 Contact & Support
|
|
257
|
+
|
|
258
|
+
- **Issues**: [GitHub Issues](https://github.com/Indhar01/RecallGraph/issues)
|
|
259
|
+
- **Discussions**: [GitHub Discussions](https://github.com/Indhar01/RecallGraph/discussions)
|
|
260
|
+
|
|
261
|
+
## 🚦 Status
|
|
262
|
+
|
|
263
|
+
This project is in active development. While the core functionality is stable, the API may change in minor versions until we reach v1.0.0.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
Made with ❤️ for better LLM memory management
|