The objective of groqR is to offer R users an intuitive interface for
leveraging the capabilities of the ‘Groq API’.
Utilizing the supplied functions, users can enhance their programming
productivity by incorporating Large Language Models. Furthermore,
groqR includes an RStudio addin, enabling seamless interactive
integration of ‘Groq’ prompts.
Why Choose groqR?
You can install the development version of groqR from GitHub with:
# install.packages("devtools")
# devtools::install_github("GabrielKaiserQFin/groqR")
install.packages("groqR", repos = c('https://gabrielkaiserqfin.r-universe.dev', 'https://cloud.r-project.org'))
You need to create a free account and a free ‘API’ key by accessing
‘Groq API’ page, otherwise you can not
use {groqR}. To use your ‘API’ key in {groqR}, you need to configure
the function parameters in the .Renviron file.
When you run it for the first time, a Shiny app will launch to guide you through the initial steps, setting up the necessary environment variables for the GROQ system.

In your RStudio go to Addins and select Ask ‘Groq’, which will open an interactive prompt in your Viewer, where you can choose between different models and adjust the temperature and the number of tokens to be used. Simply ask anything of your interest and hit the confirm button. The Done button lets you close the App. Similarly, you can mark or copy any text or code and use the other Addins as described below. Addin shortcuts will improve your efficiency.

ask:
This is a basic example which shows you how to ask any question.
ask("What do you think about Large language models?")
rewriter:
This is a basic example which shows you how to rewrite text.
rewriter("Dear Recipient, I hope this message finds you well.")
translater:
This is a basic example which shows you how to translate text.
translater("Dear Recipient, I hope this message finds you well.", toLanguage = "Spanish")
codeComment:
This is a basic example which shows you how to document code.
codeComment("z <- function(x) scale(x)^2")
unitTests:
This is a basic example which shows you how to build Unit Tests for your function.
unitTests("z <- function(x) scale(x)^2")
debug:
This is a basic example which shows you how to find bugs in your code.
debug("z <- function(x) scale(x)2")
roxy:
This is a basic example which shows you how to document your code.
Formatting style is Roxygen2 but can be set to anything.
roxy("z <- function(x) scale(x)^2")
coder:
This is a basic example which shows you how to finish your code by ‘Groq’.
coder("# A function to scale a vector and square the resulting z-score z2 <- function(")
optimizer:
This is a basic example which shows you how to optimize your code.
optimizer("z <- function(x) scale(x)^2")
codeConverter:
This is a basic example which shows you how to translate your code.
codeConverter("z <- function(x) scale(x)^2", from = "R", to = "Python")
nameIt:
This is a basic example which shows you how to create a function or variable name.
nameIt("function(x) scale(x)^2")
The model parameters can be adjusted by passing functional arguments.
text or code: The text or code input required for processing by
‘Groq’. If omitted, the function will utilize the content currently
held in the clipboard.
GROQ_API_KEY: The ‘Groq API’ key. By default it is set to
Sys.getenv("GROQ_API_KEY").
model: model choice. Choose any
model and add it to your
.Renviron file or as argument within the function in mind.
modelCall()[,1:5]
NULL
systemRole: System role for model. Default is set to “You are a
helpful assistant”.
maxTokens: The maximum integer of completion tokens returned by the
‘API’. The total number of tokens requested in max_tokens plus the
number of prompt tokens sent in messages must not exceed the context
window token limit of model requested. If left unspecified, then the
model will generate tokens until either it reaches its stop token or
the end of its context window.
temperatur: 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. You should either set temperature or
top_p, but not both.
top_p: The nucleus sampling threshold, valued between 0 and 1
inclusive. For each subsequent token, the model considers the results
of the tokens with top_p probability mass. You should either alter
temperature or top_p, but not both.
proxy: Default value is NULL. To execute ‘Groq’ queries via a proxy
server, specify the proxy address and port as an argument to the
function instance. Use the following format:
"proxy_address:proxy_port". An example would be:
"81.94.255.13:8080"
returnType: Default is 3, which returns the output to the clipboard
and returns TRUE, type 2 is unchanged and type 1 cats the output.