Skip to contents

claude

Usage

claude(
  source,
  input,
  output = "output",
  prompt,
  model = "claude-3-haiku-20240307",
  return_invisible = FALSE,
  iterations = 1,
  repair = FALSE,
  progress = TRUE,
  temperature = 1,
  top_p = NULL,
  top_k = NULL,
  anthropic_version = "2023-06-01",
  max_tokens = 4096,
  parentInfo = NULL,
  anthropic_api_key = Sys.getenv("ANTHROPIC_API_KEY")
)

Arguments

source

required; A source dataframe or llm-completion object.

input

required; A column name in the source dataframe

output

optional; A string of a column name (Or a vector of strings) to be created in the source dataframe storing the output of the models. Defaults to output.

prompt

required; A string (Or vector of Strings for handling multiple operations at the same time) of a system message to be sent to the AI model.

model

required; a length one character vector.

return_invisible

optional; A boolean to return just the output (TRUE) or an llm object containing model metadata (FALSE). Defaults to FALSE.

iterations

optional; An integer. Number of completions to generate for each row. Defaults to 1.

repair

optional; A boolean to repair NA's in the output column and keep values already present in the output column if the output column has already been created. False overrides the data already in an output column if it exists. Useful to continue a computation if you have been rate limited. Defaults to FALSE.

progress

optional; a length one logical vector. Defaults to TRUE. Determines whether to show a progress bar in the console.

temperature

optional; defaults to 1; a length one numeric vector with the value between 0 (More analytical) and 1 (More creative).

top_p

optional; a length one numeric vector with the value between 0 and 1. Only specify a temperature or a top_p, never both. Not recommended, for most use cases use temperature instead.

top_k

optional; a length one numeric vector with the integer value greater than 0. Only sample from the top_k options for each subsequent token. Not recommended, for most use cases use temperature instead.

anthropic_version

optional; defaults to 2023-06-01; a length one character vector. Specifies the version of the Anthropic's models.

max_tokens

optional; defaults to (4096 - prompt tokens); a length one numeric vector with the integer value greater than 0.

anthropic_api_key

required; defaults to Sys.getenv("ANTHROPIC_API_KEY") (i.e., the value is retrieved from the .Renviron file); a length one character vector. Specifies Anthropic API key.

Value

A dataframe with the output column(s) created