The function extracts and executes the code in the response. If required it can try to correct errors in the code via different strategies.
runCodeInResponse(
response,
prompt = NULL,
agent = NULL,
context = NULL,
correction = c("none", "selfcorrect", "sampleMore", "sampleThenCorrect",
"correctThenSample"),
attempts = 3,
output.file = NULL,
...
)
A list containing the following elements:
A character vector representing the initial prompt response.
A list of initial blocks.
A list of final blocks.
A boolean value indicating whether the code works.
A character string representing the execution results.
An integer representing the number of attempts.
response to be parsed for code and executed
prompt for the response, if correction="none" it is not needed
AI agent, if correction="none" it is not needed
context for the prompt, if correction="none" it is not needed
"none" no code correction is needed. "selfcorrect" feedback the errors to LLM and ask for fix. "sampleMore" sample responses for the #prompt until an executable code is returned or number of attempts reached. "correctThenSample" first try self-correct "attempt" number of times. If no executable code is returned. It will sample new responses "attempt" number of times or until executable code
Numeric value denoting how many times the code should be sent back for fixing.
Optional output file created holding parsed code
arguments to sendPrompt()
selfcorrect
,sampleResponse
if (FALSE) {
resp.list <- runCodeInResponse(agent,prompt,context=rbionfoExp,correction="sampleMore",attempt=2)
}
Run the code above in your browser using DataLab