Ragdaemon
Ragdaemon is a Retrieval-Augmented Generation (RAG) system for code. It runs a daemon (background process) to watch your active code, put it in a knowledge graph, and query the knowledge graph to (among other things) generate context for LLM completions.
Three ways to use Ragdaemon:
1. Help me write code
Ragdaemon powers the 'auto-context' feature in Mentat, a command-line coding assistant. You can install Mentat using pip install mentat. Run with the --auto-context-tokens <amount> or -a (default=5000) flag, and ragdaemon-selected context will be added to all of your prompts.
2. Explore the knowledge graph
Install locally to visualize and query the knowledge graph directly.
Install using pip install ragdaemon, and run in your codebase's directory, e.g. ragdaemon. This will start a Daemon on your codebase, and an interface at localhost:5001. Options:
--chunk-extensions <ext>[..<ext>]: Which file extensions to chunk. If not specified, defaults to the top 20 most common code file extensions.--chunk-model: OpenAI'sgpt-4-0215-previewby default.--embeddings-model: OpenAI'stext-embedding-3-largeby default.--diff: A git diff to include in the knowledge graph. By default, the active diff (if any) is included with each code feature.
3. Use ragdaemon Python API
Ragdaemon is released open-source as a standalone RAG system. It includes a library of python classes to generate and query the knowledge graph. The graph itself is a NetworkX MultiDiGraph which saves/loads to a .json file.
import asyncio
from pathlib import Path
from ragdaemon.daemon import Daemon
async def main():
cwd = Path.cwd()
daemon = Daemon(cwd)
await daemon.update()
results = daemon.search("javascript")
for result in results:
print(f"{result['distance']} | {result['id']}")
query = "How do I run the tests?"
context_builder = daemon.get_context(
query,
auto_tokens=5000
)
context = context_builder.render()
messages = [
{"role": "user", "content": query},
{"role": "user", "content": f"CODE CONTEXT\n{context}"}
]
print(messages)
asyncio.run(main())
Release files for ragdaemon 0.8.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ragdaemon-0.8.3.tar.gz | 73.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ragdaemon-0.8.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 151.7 kB
Release files / ragdaemon-0.8.3.tar.gz
| Download URL | ragdaemon-0.8.3.tar.gz |
|---|---|
| Size | 73.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9caf6d9160f850c4e9042fd6e67d60ec3b69ba7b8217e65a111eb3299db1436e
|
|
BLAKE2b-256 checksum How to use checksums |
db668f62c5add7b36530d7dfe338c8507efcaef333d3b8527374c21b5b81dbc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Release files / ragdaemon-0.8.3-py3-none-any.whl
| Download URL | ragdaemon-0.8.3-py3-none-any.whl |
|---|---|
| Size | 78.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a952e7efd3c867d53adc85b2d4637f91a9677866970563bbf7eb05f40636fd4e
|
|
BLAKE2b-256 checksum How to use checksums |
7b3ce3f33a5d15aac576a05c3af7b439ecc878cbadf2ba8f6c20e464fabefa5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|