Title: | A Coding Assistant using the Fast AI Inference 'Groq' |
---|---|
Description: | A comprehensive suite of functions and 'RStudio' Add-ins leveraging the capabilities of open-source Large Language Models (LLMs) to support R developers. These functions offer a range of utilities, including text rewriting, translation, and general query capabilities. Additionally, the programming-focused functions provide assistance with debugging, translating, commenting, documenting, and unit testing code, as well as suggesting variable and function names, thereby streamlining the development process. |
Authors: | Gabriel Kaiser [aut, cre] |
Maintainer: | Gabriel Kaiser <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.0.3 |
Built: | 2025-02-12 20:25:33 UTC |
Source: | https://github.com/gabrielkaiserqfin/groqr |
Runs when attached such as by library() or require()
.onAttach(libname, pkgname)
.onAttach(libname, pkgname)
libname |
The name of the library where this add-on is located. |
pkgname |
The name of the package that is being attached. |
This function is an attachment point for the 'onAttach' event in R packages. It is called when this package is attached to the R session."
Get 'Groq' Completions Endpoint
APIcall(prompt, ...)
APIcall(prompt, ...)
prompt |
The prompt to generate completions for. |
... |
Following arguments can be set manually or in .Renviron:
|
Note: See also clearChatSession
.
ask(text = NULL, ...)
ask(text = NULL, ...)
text |
The question to ask 'Groq'. |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: cat(ask("What do you think about Large language models?")) ## End(Not run)
## Not run: cat(ask("What do you think about Large language models?")) ## End(Not run)
'Groq': Comment code
codeComment(code = NULL, ...)
codeComment(code = NULL, ...)
code |
The code to be commented by 'Groq'. If not provided, it will use what's copied on the clipboard. |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: cat(codeComment("z <- function(x) scale(x)^2")) ## End(Not run)
## Not run: cat(codeComment("z <- function(x) scale(x)^2")) ## End(Not run)
This function takes a snippet of code and translates it from one programming language to another using 'Groq API'. The default behavior is to read the code from the clipboard and translate from R to Python.
codeConverter(code = NULL, from = "R", to = "Python", ...)
codeConverter(code = NULL, from = "R", to = "Python", ...)
code |
A string containing the code to be translated. If not provided, the function will attempt to read from the clipboard. |
from |
any programming language. Defaults to "R". |
to |
any programming language. Defaults to "Python". |
... |
Following arguments can be set manually or in .Renviron:
|
A string containing the translated code.
## Not run: codeConverter("z <- function(x) scale(x)^2", from = "R", to = "Python") ## End(Not run)
## Not run: codeConverter("z <- function(x) scale(x)^2", from = "R", to = "Python") ## End(Not run)
'Groq': Finish code
coder(code = NULL, language = "R", ...)
coder(code = NULL, language = "R", ...)
code |
The code to be completed by 'Groq'. If not provided, it will use what's copied on the clipboard. |
language |
The programming language to code in. Defaults to R. |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: cat(coder("# A function to square a vector\nsquare_each <- function(")) ## End(Not run)
## Not run: cat(coder("# A function to square a vector\nsquare_each <- function(")) ## End(Not run)
'Groq': Find Issues in Code
debug(code = NULL, ...)
debug(code = NULL, ...)
code |
The code to be analyzed by 'Groq'. If not provided, it will use what's copied on the clipboard. |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: cat(debug("z <- function(x) scale(x)2")) ## End(Not run)
## Not run: cat(debug("z <- function(x) scale(x)2")) ## End(Not run)
Run a 'Groq' RStudio Addin
execAddin(FUN)
execAddin(FUN)
FUN |
The function to be executed. |
Opens an interactive chat session with 'Groq'
execAddin_ask()
execAddin_ask()
The modelCall
function is designed to query current models from Groq.
modelCall(api_key = Sys.getenv("GROQ_API_KEY"))
modelCall(api_key = Sys.getenv("GROQ_API_KEY"))
api_key |
The Groq API key. |
The function checks the following environment variables:
GROQ_API_KEY
model table
'Groq': Create a Function or Variable Name
nameIt(code = NULL, namingConvention = "camelCase", ...)
nameIt(code = NULL, namingConvention = "camelCase", ...)
code |
The code for which to give a variable name to its result. If not provided, it will use what's copied on the clipboard. |
namingConvention |
Defaults to "camelCase". |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: cat(nameIt("sapply(1:10, function(i) i ** 2)")) ## End(Not run)
## Not run: cat(nameIt("sapply(1:10, function(i) i ** 2)")) ## End(Not run)
The on_startup
function is designed to execute certain actions when the package is loaded.
Specifically, it checks for the presence of required environment variables related to the GROQ system.
If any of these variables are missing, it will launch a Shiny application.
on_startup(uiStartup = uiInit, serverStartup = serverInit)
on_startup(uiStartup = uiInit, serverStartup = serverInit)
uiStartup |
Shiny user interface. |
serverStartup |
Shiny server. |
The function checks the following environment variables:
GROQ_model
GROQ_systemRole
GROQ_API_KEY
GROQ_maxTokens
GROQ_temperature
GROQ_top_p
GROQ_proxy
If any of these variables are not set (i.e., are empty strings), the function triggers the
launch of a Shiny application defined by the ui
and server
components.
None
shinyApp
'Groq': Optimize Code
optimizer(code = NULL, ...)
optimizer(code = NULL, ...)
code |
The code to be optimized by 'Groq'. If not provided, it will use what's copied on the clipboard. |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: cat(optimizer("z <- function(x) scale(x)^2")) ## End(Not run)
## Not run: cat(optimizer("z <- function(x) scale(x)^2")) ## End(Not run)
responseReturn
responseReturn(raw)
responseReturn(raw)
raw |
the chatresponse to return |
A character value with the response generated by the LLM.
'Groq': Rewrite Text
rewriter(text = NULL, ...)
rewriter(text = NULL, ...)
text |
The text to be rewritten by 'Groq'. If not provided, it will use what's copied on the clipboard. |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: rewriter("Dear Recipient, I hope this message finds you well.") ## End(Not run)
## Not run: rewriter("Dear Recipient, I hope this message finds you well.") ## End(Not run)
'Groq': Code Documentation in roxygen2 style or any other
roxy(code = NULL, inLineDocumentation = "roxygen2", ...)
roxy(code = NULL, inLineDocumentation = "roxygen2", ...)
code |
The code to be documented by 'Groq'. If not provided, it will use what's copied on the clipboard. |
inLineDocumentation |
any documentation style. Defaults to roxygen2. |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: cat(roxy("z <- function(x) scale(x)^2")) ## End(Not run)
## Not run: cat(roxy("z <- function(x) scale(x)^2")) ## End(Not run)
This function handles the server logic for the UI, including the observeEvent for the action button. It asks the user to prompt various GROQ inputs. Once the 'proxy' parameter is set, the parameters are written to the environment as environment variables and a notification message is displayed.
serverInit(input, output, session)
serverInit(input, output, session)
input |
The input values as they are submitted by the user. |
output |
The output values. |
session |
The Shiny session object. |
'Groq': Translate Text
translater(text = NULL, toLanguage = "German", ...)
translater(text = NULL, toLanguage = "German", ...)
text |
The text to be translated by 'Groq'. If not provided, it will use what's copied on the clipboard. |
toLanguage |
The language to be translated into. |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: translater("Dear Recipient, I hope this message finds you well.") ## End(Not run)
## Not run: translater("Dear Recipient, I hope this message finds you well.") ## End(Not run)
It creates a fluidPage with a title and an action button for triggering the input event.
uiInit
uiInit
An object of class shiny.tag.list
(inherits from list
) of length 4.
Create {testthat}
test cases for the code.
unitTests(code = NULL, ...)
unitTests(code = NULL, ...)
code |
The code for which to create unit tests by 'Groq'. If not provided, it will use what's copied on the clipboard. |
... |
Following arguments can be set manually or in .Renviron:
|
A character value with the response generated by 'Groq'.
## Not run: cat(unitTests("squared_numbers <- function(numbers) {\n numbers ^ 2\n}")) ## End(Not run)
## Not run: cat(unitTests("squared_numbers <- function(numbers) {\n numbers ^ 2\n}")) ## End(Not run)