Skip to contents

Process response class for managing chat processing

Usage

process(
  prompts = list(),
  responses = list(),
  completed = integer(0),
  file = character(0),
  type = NULL,
  progress = logical(0),
  input_type = character(0),
  chunk_size = integer(0),
  workers = integer(0),
  beep = logical(0),
  echo = logical(0),
  state = list()
)

Arguments

prompts

List of prompts to process

responses

List to store responses

completed

Integer indicating number of completed prompts

file

Path to save state file (.rds)

type

Type specification for structured data extraction

progress

Whether to show progress bars (default: TRUE)

input_type

Type of input ("vector" or "list")

chunk_size

Size of chunks for parallel processing

workers

Number of parallel workers

beep

Play sound on completion (default: TRUE)

echo

Whether to echo messages during processing (default: FALSE)

state

Internal state tracking

Value

Returns an S7 class object of class "process" that represents a collection of prompts and their responses from chat models. The object contains all input parameters as properties and provides methods for:

  • Extracting text responses via texts() (includes structured data when a type specification is provided)

  • Accessing full chat objects via chats()

  • Tracking processing progress via progress()

The process object manages prompt processing and tracks completion status.

Examples

if (FALSE) { # ellmer::has_credentials("openai")
# Create a chat processor
chat <- chat_sequential(chat_openai())

# Process a batch of prompts
response <- chat$process(list(
  "What is R?",
  "Explain base R versus tidyverse",
  "Explain vectors, lists, and data frames"
))

# Check the progress if interrupted
response$progress()

# Return the responses as a vector or list
response$texts()

# Return the chat objects
response$chats()
}