Generate and render a call graph for a Python project.
Project description
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-preview
by default.--embeddings-model
: OpenAI'stext-embedding-3-large
by 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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ragdaemon-0.8.2.tar.gz
.
File metadata
- Download URL: ragdaemon-0.8.2.tar.gz
- Upload date:
- Size: 91.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a7b7c3af242497edcf50fc6c59aa9574e9f47b2e9713476c7c702c6c4d94762 |
|
MD5 | 779035df12623394ea07d1780b14934c |
|
BLAKE2b-256 | 1ff55f80047a099db4d1309972a2f71d06178331859f45844bac384753070f26 |
File details
Details for the file ragdaemon-0.8.2-py3-none-any.whl
.
File metadata
- Download URL: ragdaemon-0.8.2-py3-none-any.whl
- Upload date:
- Size: 78.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7230754d13b93ccc4ee9eb3413487c276fe34c5d0c1a6413d498e4d8b34fea58 |
|
MD5 | 432ad0ac4b92a7b7525a983fa2696dd9 |
|
BLAKE2b-256 | f03e9dcb56446b6b194fa6d9831ee2ae0a5a3421ba7b3b29ba18a6b4448d5788 |