(no commit message)
This commit is contained in:
73
README.md
73
README.md
@@ -0,0 +1,73 @@
|
||||
# Ruby Rails Documentation Generator
|
||||
|
||||
A DSPy program that generates documentation for Rails applications using Recursive Language Models (RLMs).
|
||||
|
||||
## What are RLMs?
|
||||
|
||||
Recursive Language Models are an inference strategy where language models can decompose and recursively interact with input context of unbounded length through REPL environments. Instead of processing huge contexts in a single call, an RLM allows the model to programmatically partition, grep, and recursively sub-query the context—avoiding context rot while handling arbitrarily large inputs.
|
||||
|
||||
Key benefits:
|
||||
- Near-infinite effective context length
|
||||
- Reduced context rot degradation
|
||||
- Cost-efficient processing of large codebases
|
||||
|
||||
For more details, see the [RLM paper](https://arxiv.org/abs/2512.24601v1).
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
uv add modaic dspy
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Load with AutoProgram
|
||||
|
||||
```python
|
||||
from modaic import AutoProgram
|
||||
|
||||
# Load the program from Modaic Hub
|
||||
doc_writer = AutoProgram.from_precompiled("farouk1/ruby-rails-doc-generator")
|
||||
|
||||
# Generate documentation for a Rails project
|
||||
result = doc_writer(source_root="./my-rails-app")
|
||||
print(result.documentation)
|
||||
```
|
||||
|
||||
### Override Config
|
||||
|
||||
```python
|
||||
from modaic import AutoProgram
|
||||
|
||||
doc_writer = AutoProgram.from_precompiled(
|
||||
"farouk1/ruby-rails-doc-generator",
|
||||
config={"max_iterations": 15, "lm": "openai/gpt-5"}
|
||||
)
|
||||
```
|
||||
|
||||
### Load a Specific Revision
|
||||
|
||||
```python
|
||||
from modaic import AutoProgram
|
||||
|
||||
# By branch
|
||||
doc_writer = AutoProgram.from_precompiled("farouk1/ruby-rails-doc-generator", rev="dev")
|
||||
|
||||
# By tag
|
||||
doc_writer = AutoProgram.from_precompiled("farouk1/ruby-rails-doc-generator", rev="v1.0")
|
||||
|
||||
# By commit hash
|
||||
doc_writer = AutoProgram.from_precompiled("farouk1/ruby-rails-doc-generator", rev="918ad95")
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
| Parameter | Default | Description |
|
||||
|-----------|---------|-------------|
|
||||
| `max_iterations` | 10 | Maximum RLM iterations |
|
||||
| `lm` | `openai/gpt-5-mini` | Primary language model |
|
||||
| `sub_lm` | `openai/gpt-5-mini` | Model for recursive sub-calls |
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
5
main.py
5
main.py
@@ -37,8 +37,9 @@ class DocWriterProgram(PrecompiledProgram):
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
def forward(self, source_root: str, source_tree: dict[str, Any]) -> dspy.Prediction:
|
||||
def forward(self, source_root: str) -> dspy.Prediction:
|
||||
source_tree = load_source_tree(source_root)
|
||||
print(f"Loaded source tree with {len(source_tree)} entries")
|
||||
return self.doc_writer(source_tree=source_tree)
|
||||
|
||||
|
||||
@@ -62,7 +63,7 @@ SOURCE_ROOT = "."
|
||||
def main():
|
||||
"""
|
||||
print("Starting documentation generation...")
|
||||
result = doc_writer(source_root=SOURCE_ROOT, source_tree=None)
|
||||
result = doc_writer(source_root=SOURCE_ROOT)
|
||||
|
||||
with open("generated_documentation.md", "w", encoding="utf-8") as f:
|
||||
print("Writing documentation to file...")
|
||||
|
||||
Reference in New Issue
Block a user