Skip to contents

The function attempts to correct the code returned by the agent by re-feeding to the agent with the error message. If there are no error messages function returns the original response.

Usage

selfcorrect(
  agent,
  prompt,
  context = rbionfoExp,
  attempts = 3,
  output.file = NULL,
  responseWithError = NULL,
  history = NULL,
  ...
)

Arguments

agent

An object containing the agent's information (e.g., type and model).

prompt

The prompt text to send to the language model.

context

Optional context to provide alongside the prompt (default is rbionfoExp).

attempts

Numeric value denoting how many times the code should be sent back for fixing.

output.file

Optional output file created holding parsed code

responseWithError

a list of response and errors returned from executeCode().

history

a list of previous response and prompts. Default is NULL and should be stayed as is for most use cases. First element is expected to be the response and the second element is the error list returned by executeCode().

...

Additional arguments to be passed to the sendPrompt function.

Value

A list containing the following elements:

init.response

A character vector representing the initial prompt response.

init.blocks

A list of initial blocks.

final.blocks

A list of final blocks.

code.works

A boolean value indicating whether the code works.

exec.result

A character string representing the execution results.

tried.attempts

An integer representing the number of attempts.

See also

promptContext for predefined contexts to use.

Examples

if (FALSE) { # \dontrun{

response <- selfcorrect(agent,prompt,context=rbionfoExp, max_tokens = 500)
} # }