This guide will help you get started with RLM-REPL, from installation to your first query.
- Python 3.9 or higher
- A language model API endpoint (OpenAI-compatible)
pip install rlm-replgit clone https://github.com/labKnowledge/rlm-repl-sql.git
cd rlm-repl-sql
pip install -e .rlm-repl --versionRLM-REPL works with any OpenAI-compatible API. Here are some common setups:
- Install Ollama from ollama.ai
- Pull a model:
ollama pull qwen2.5-coder
- Start Ollama (usually runs automatically)
- Use in RLM-REPL:
config = RLMConfig( base_url="http://localhost:11434/v1", api_key="ollama", model="qwen2.5-coder", )
config = RLMConfig(
base_url="https://api.openai.com/v1",
api_key="sk-your-api-key-here",
model="gpt-4",
)- Install and start LMStudio
- Load a model and start the local server
- Use:
config = RLMConfig( base_url="http://localhost:1234/v1", api_key="lm-studio", model="your-model-name", )
Set these environment variables to use defaults:
export RLM_BASE_URL="http://localhost:11434/v1"
export RLM_API_KEY="ollama"
export RLM_MODEL="qwen2.5-coder"Then create config from environment:
from rlm_repl import RLMConfig
config = RLMConfig.from_env()-
Create a text file (
document.txt):# Introduction to Python Python is a high-level programming language known for its simplicity. ## Features - Easy to learn - Versatile - Large standard library -
Run RLM-REPL:
rlm-repl document.txt
-
In interactive mode, ask questions:
> What are Python's features?
from rlm_repl import RLMREPL, RLMConfig
# Create configuration
config = RLMConfig(
base_url="http://localhost:11434/v1",
api_key="ollama",
model="qwen2.5-coder",
)
# Create REPL instance
with RLMREPL(config) as repl:
# Load document
repl.load_document("document.txt")
# Ask a question
result = repl.ask("What are Python's features?")
# Print answer
print(result.answer)
print(f"Read {result.total_words} words in {result.elapsed_time:.1f}s")You can also load text directly without a file:
text = """
# My Document
This is some content.
"""
with RLMREPL(config) as repl:
repl.load_text(text, "my_document")
result = repl.ask("What is this document about?")
print(result.answer)When you ask a question, RLM-REPL will:
- Load the document (if not already loaded)
- Perform reading iterations:
- Iteration 1: Overview (read beginning)
- Iteration 2: Search (find keywords)
- Iteration 3+: Deep read (extract details)
- Synthesize the answer from gathered information
With verbose mode enabled, you'll see:
- Each iteration's strategy
- SQL queries being executed
- Results retrieved
- Final answer
For cleaner output:
config = RLMConfig(
base_url="http://localhost:11434/v1",
api_key="ollama",
model="qwen2.5-coder",
verbose=False, # Disable verbose output
)Or in CLI:
rlm-repl document.txt -q --question "Your question"- Read the API Reference for detailed API documentation
- Check out Examples for more use cases
- Learn about Configuration options
- Understand the Architecture behind RLM-REPL
Make sure to call load_document() or load_text() before asking questions:
repl.load_document("file.txt") # Must load first!
result = repl.ask("Question?")If you see connection errors:
- Verify your model API is running
- Check the
base_urlis correct - Test the API endpoint directly (e.g.,
curl http://localhost:11434/v1/models)
Ensure:
- The model name matches exactly (case-sensitive)
- The model is installed/pulled (for local models)
- You have access to the model (for cloud APIs)
For more troubleshooting, see Troubleshooting Guide.