Skip to contents

Display or return the conversation turns from the active session.

Usage

hal_history(
  role = NULL,
  pattern = NULL,
  format = c("console", "data.frame", "text"),
  n = NULL
)

Arguments

role

Filter by role: "user", "assistant", "system", or NULL for all.

pattern

Optional regex to filter turn content.

format

Output format: "console" (print to screen), "data.frame", or "text" (character vector).

n

Maximum number of turns to return (most recent). NULL for all.

Value

Depends on format: invisible NULL for console, a data.frame, or a character vector.

Examples

# with no active session this returns an empty data frame
hal_history(format = "data.frame")
#> ℹ No active session.
#> data frame with 0 columns and 0 rows
if (FALSE) { # \dontrun{
hal_history()                      # print all turns
hal_history(role = "user", n = 5)  # last five user prompts
hal_history(pattern = "ggplot")    # turns mentioning ggplot
} # }