The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

llmflow

R-CMD-check CRAN status r-universe

Overview

llmflow provides a framework for automated data analysis through the integration of Large Language Models (LLMs) with R. Built on the ReAct (Reasoning and Acting) architecture, the package enables iterative problem-solving by alternating between reasoning steps and code execution, allowing LLMs to autonomously analyze data, handle errors, and refine solutions.

Key Features

Installation

From R-universe:

install.packages("llmflow", repos = c("https://zaoqu-liu.r-universe.dev", "https://cloud.r-project.org"))

From GitHub:

# install.packages("pak")
pak::pak("Zaoqu-Liu/llmflow")

Requirements

The package requires ellmer for LLM communication:

install.packages("ellmer")

Quick Start

library(llmflow)
library(ellmer)

# Initialize LLM client
llm <- chat_openai(model = "gpt-4o")

# Automated analysis with ReAct workflow
result <- AutoFlow(
 react_llm = llm,
 task_prompt = "Perform linear regression of mpg on hp and wt using mtcars"
)

Core Functions

Function Description
AutoFlow() Complete workflow combining RAG and ReAct
react_r() ReAct loop for iterative problem solving
response_to_r() Execute LLM-generated R code
response_as_json() Structured JSON output with schema validation
retrieve_docs() Retrieve R function documentation for RAG

Usage Examples

ReAct Workflow

result <- react_r(
 chat_obj = llm,
 task = "Calculate correlation matrix for iris numeric columns",
 max_turns = 10,
 verbose = TRUE
)

# Access results
result$final_answer
result$code_summary$complete_script

JSON Response with Schema Validation

schema <- list(
 type = "object",
 properties = list(
   analysis_type = list(type = "string"),
   findings = list(type = "array", items = list(type = "string"))
 ),
 required = c("analysis_type", "findings")
)

response <- response_as_json(
 chat_obj = llm,
 prompt = "Summarize the iris dataset",
 schema = schema,
 schema_strict = TRUE
)

Code Generation and Execution

result <- response_to_r(
 chat_obj = llm,
 prompt = "Create a scatter plot of mpg vs hp from mtcars",
 pkgs_to_use = c("ggplot2"),
 return_mode = "full"
)

License

GPL (>= 3)

Citation

Liu Z (2026). llmflow: Reasoning and Acting Workflow for Automated Data Analysis.
R package version 3.0.1, https://github.com/Zaoqu-Liu/llmflow

Author

Zaoqu Liu

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.