Learn R Programming

aisdk (version 1.1.0)

create_file_agent: Create a FileAgent

Description

Creates an agent specialized in file system operations using fs and readr. The agent can read, write, and manage files with safety guardrails.

Usage

create_file_agent(
  name = "FileAgent",
  allowed_dirs = ".",
  allowed_extensions = c("csv", "tsv", "txt", "json", "rds", "rda", "xlsx", "xls")
)

Value

An Agent object configured for file operations.

Arguments

name

Agent name. Default "FileAgent".

allowed_dirs

Character vector of allowed directories. Default current dir.

allowed_extensions

Character vector of allowed file extensions.

Examples

Run this code
# \donttest{
if (interactive()) {
  file_agent <- create_file_agent(
    allowed_dirs = c("./data", "./output"),
    allowed_extensions = c("csv", "json", "txt", "rds")
  )
  result <- file_agent$run(
    "Read the sales.csv file and store it as 'sales_data'",
    session = session,
    model = "openai:gpt-4o"
  )
}
# }

Run the code above in your browser using DataLab