Skip to contents

Factory function to create an RLMModule that enables LLMs to programmatically explore large contexts through a REPL interface.

Usage

rlm_module(
  signature,
  runner,
  max_iterations = 20L,
  max_llm_calls = 50L,
  max_output_chars = 100000L,
  sub_lm = NULL,
  verbose = FALSE,
  tools = list(),
  ...
)

Arguments

signature

A Signature object or string notation defining inputs/outputs

runner

An RCodeRunner object for code execution. Required.

max_iterations

Maximum REPL iterations before fallback (default 20)

max_llm_calls

Maximum recursive LLM calls allowed (default 50)

max_output_chars

Maximum characters per execution output (default 100000)

sub_lm

Optional ellmer Chat for recursive queries. NULL = disabled.

verbose

Logical. Print execution progress (default FALSE)

tools

Named list of user-defined R functions to inject into REPL. Each tool becomes available as a function in the code execution environment. Non-function values in the list will cause an error.

...

Additional arguments passed to the module

Value

An RLMModule object

Examples

if (FALSE) { # \dontrun{
runner <- r_code_runner(timeout = 30)
rlm <- rlm_module("question -> answer", runner = runner)
result <- run(rlm, question = "What is the 10th Fibonacci number?", .llm = llm)
} # }