clean_code_blocks {mergen}R Documentation

Clean code blocks returned by the agent

Description

This function cleans up the response returned by the agent to ensure code blocks can run. It ensures that characters such as 'R' and 'r' are cleaned from code blocks in the agents response, so that the code blocks are able to be extracted by the extractCode() function and ran as expected. It also cleans the response from any install.package calls, and recorded output, so that when code blocks are extracted, the code can run smoothly.

Usage

clean_code_blocks(response)

Arguments

response

response received from the agent

Value

A string holding the response of the agent, cleaned from any unwanted characters.

Examples

{
response <- "To perform PCA, do the following: ```R prcomp(data)``` This funcion will perform PCA."
clean_code <- clean_code_blocks(response)
}

[Package mergen version 0.1.0 Index]