Nothing
#' 'Groq': Rewrite Text
#'
#' @param text The text to be rewritten by 'Groq'. If not provided,
#' it will use what's copied on the clipboard.
#' @param ... Following arguments can be set manually or in .Renviron:
#' `GROQ_API_KEY`is the 'Groq API' key.
#' `model` Model choice. Default is mistral-7b-instruct.
#' `systemRole` System role; Default is: "You are a helpful assistant
#' with extensive knowledge of R programming."
#' `maxTokens` The maximum integer of completion tokens returned.
#' `temperature` The amount of randomness in the response,
#' valued between 0 inclusive and 2 exclusive. Higher values are more
#' random, and lower values are more deterministic.
#' `top_p` Nucleus sampling threshold, valued between 0 and 1.
#' `proxy` Default value is NULL.
#'
#'
#' @examples
#' \dontrun{
#' rewriter("Dear Recipient, I hope this message finds you well.")
#' }
#'
#' @importFrom clipr read_clip
#'
#' @return A character value with the response generated by 'Groq'.
#'
#' @export
#'
rewriter <- function(text = NULL, ...) {
if (is.null(text)) text <- clipr::read_clip(allow_non_interactive = TRUE)
# Replace all double strings with single string
code <- gsub('"', "'", text)
# Collapse the modified 'text' into a character vector
code <- paste(text, collapse = "\n")
# Create a prompt string by concatenating the input code
prompt <- paste0('Rewrite the following text such that it is
professionally written, grammatically correct,
and efficiently communicated.
Keep the original language: "', text, '"')
return(APIcall(prompt, ...))
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.