Common issues and solutions when using RLM-REPL.
- Installation Issues
- Configuration Problems
- Document Loading Errors
- API Connection Issues
- Query Problems
- Performance Issues
- Error Messages
Problem: Python can't find the rlm_repl module.
Solutions:
-
Verify installation:
pip show rlm-repl
-
Reinstall:
pip install --upgrade rlm-repl
-
Check Python version (requires 3.9+):
python --version
-
Use virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install rlm-repl
Problem: DuckDB dependency fails to install.
Solutions:
-
Update pip:
pip install --upgrade pip
-
Install system dependencies (Linux):
sudo apt-get install build-essential
-
Install from source:
pip install duckdb --no-binary duckdb
Problem: Configuration missing required parameter.
Solution:
config = RLMConfig(
base_url="http://localhost:11434/v1", # Must provide
api_key="ollama",
model="qwen2.5-coder",
)Problem: Persistent database enabled but no path provided.
Solution:
db_config = DatabaseConfig(
persistent=True,
db_path="./cache.db", # Must provide path
)Problem: Temperature outside valid range (0-2).
Solution:
config = RLMConfig(
...,
temperature=0.5, # Must be 0 <= value <= 2
)Problem: Document file doesn't exist.
Solutions:
-
Check file path:
import os print(os.path.exists("document.txt")) # Should be True
-
Use absolute path:
repl.load_document("/full/path/to/document.txt")
-
Check current directory:
import os print(os.getcwd())
Problem: Document has no content.
Solution:
- Verify file has content
- Check file encoding (should be UTF-8)
- Ensure file is not just whitespace
Problem: File contains only empty lines.
Solution:
- Check file has actual text content
- Verify file encoding
Problem: Special characters not displaying correctly.
Solution:
# Ensure UTF-8 encoding
with open("document.txt", "r", encoding="utf-8") as f:
content = f.read()
repl.load_text(content, "document")Problem: Can't connect to model API.
Solutions:
-
Verify API is running:
# For Ollama curl http://localhost:11434/v1/models # For OpenAI curl https://api.openai.com/v1/models \ -H "Authorization: Bearer $OPENAI_API_KEY"
-
Check base_url:
# Ollama default base_url="http://localhost:11434/v1" # LMStudio default base_url="http://localhost:1234/v1"
-
Check firewall/network settings
-
Verify API key:
# For Ollama, any string works api_key="ollama" # For OpenAI, must be valid key api_key="sk-..."
Problem: Model name doesn't exist.
Solutions:
-
List available models:
# Ollama ollama list # Or via API curl http://localhost:11434/v1/models
-
Use exact model name (case-sensitive):
model="qwen2.5-coder" # Exact name from ollama list
-
Pull model if missing (Ollama):
ollama pull qwen2.5-coder
Problem: Invalid API key or insufficient permissions.
Solutions:
- Verify API key is correct
- Check API key has necessary permissions
- For OpenAI, ensure account has credits
- Check API key format:
# OpenAI format api_key="sk-..." # Ollama (any string) api_key="ollama"
Problem: Too many API requests.
Solutions:
-
Reduce
max_iterations:config = RLMConfig(..., max_iterations=3)
-
Add delays between requests:
import time # Add delay in event handler
-
Use persistent database to cache results
Problem: Trying to query before loading document.
Solution:
repl.load_document("file.txt") # Load first!
result = repl.ask("Question?")Problem: LLM generates invalid SQL.
Solutions:
-
RLM-REPL auto-fixes common issues, but some may slip through
-
Use direct SQL queries for debugging:
result = repl.query("SELECT * FROM documents LIMIT 10")
-
Check table name matches:
schema = repl.get_schema() table_name = schema["table_name"]
Problem: Answers are incomplete or inaccurate.
Solutions:
-
Increase
max_iterations:config = RLMConfig(..., max_iterations=8)
-
Lower temperature for more focused reading:
config = RLMConfig(..., temperature=0.1)
-
Ask more specific questions:
# Instead of: "Tell me about this" # Use: "What are the main topics discussed in chapters 1-3?"
-
Check document quality (well-structured documents work better)
Problem: LLM queries return only headers, not content.
Solution:
- RLM-REPL includes auto-fixing for this, but if it persists:
- Check document has actual content (not just headers)
- Increase
max_iterationsto allow more reading - The system should auto-fix queries that return only headers
Problem: Queries take too long.
Solutions:
-
Use persistent database:
db_config = DatabaseConfig( persistent=True, db_path="./cache.db", )
-
Reduce
max_iterations:config = RLMConfig(..., max_iterations=4)
-
Use faster model (if available)
-
Disable verbose mode:
config = RLMConfig(..., verbose=False)
Problem: System using too much memory.
Solutions:
-
Use persistent database instead of in-memory:
db_config = DatabaseConfig( persistent=True, db_path="./cache.db", )
-
Process documents in smaller chunks
-
Close REPL when done:
with RLMREPL(config) as repl: # Use repl # Automatically closed
Problem: Multiple processes accessing same database.
Solution:
- Use separate database files per process
- Or use in-memory database for concurrent access
Cause: Calling ask() before loading document.
Fix:
repl.load_document("file.txt") # Load first
repl.ask("Question?")Cause: Invalid max_iterations value.
Fix:
config = RLMConfig(..., max_iterations=6) # Must be >= 1Cause: Database file corruption or invalid SQL.
Fix:
-
Delete database file and reload:
import os os.remove("cache.db")
-
Check SQL query syntax
Cause: LLM response not in expected JSON format.
Fix:
- Usually auto-handled, but if persistent:
- Try different model
- Lower temperature
- Check model supports structured output
Enable verbose output to see what's happening:
config = RLMConfig(
...,
verbose=True, # See all iterations and SQL
)Subscribe to events for debugging:
def debug_handler(event):
print(f"[{event.type.value}] {event.data}")
config = RLMConfig(
...,
on_event=debug_handler,
)Inspect document structure:
schema = repl.get_schema()
print(schema)Test queries manually:
result = repl.query("SELECT COUNT(*) FROM documents")
print(result.dataframe)Check what happened:
stats = repl.session_stats()
print(stats)
repl.print_stats()import time
def ask_with_retry(repl, question, max_retries=3):
for attempt in range(max_retries):
try:
return repl.ask(question)
except Exception as e:
if attempt < max_retries - 1:
print(f"Retry {attempt + 1}/{max_retries}")
time.sleep(1)
else:
raisedef safe_ask(repl, question):
if not repl.is_loaded:
raise RuntimeError("Load document first")
return repl.ask(question)try:
with RLMREPL(config) as repl:
repl.load_document("file.txt")
result = repl.ask("Question?")
print(result.answer)
except FileNotFoundError:
print("Document not found")
except RuntimeError as e:
print(f"Runtime error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")If you continue to experience issues, please:
- Check the API Reference for correct usage
- Review Examples for working code
- Open an issue on GitHub with:
- Error message
- Code snippet
- Configuration details
- Python version