From 82395e5ec325ecfcaf79da17b6f6ea7037b90a8d Mon Sep 17 00:00:00 2001 From: Farouk Adeleke Date: Mon, 19 Jan 2026 16:49:01 -0800 Subject: [PATCH] (no commit message) --- README.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.py | 5 ++-- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e69de29..f7ec398 100644 --- a/README.md +++ b/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 diff --git a/main.py b/main.py index 90a2182..6b3e833 100644 --- a/main.py +++ b/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...")