Type: | Package |
Title: | A Coding Assistant using the Fast AI Inference 'Groq' |
Version: | 0.0.3 |
Maintainer: | Gabriel Kaiser <quantresearch.gk@gmail.com> |
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. |
License: | GPL (≥ 3) |
URL: | https://github.com/GabrielKaiserQFin/groqR |
BugReports: | https://github.com/GabrielKaiserQFin/groqR/issues |
Imports: | clipr, httr, jsonlite, miniUI, rstudioapi, shiny, shinyWidgets, utils |
Encoding: | UTF-8 |
Language: | en-US |
RoxygenNote: | 7.3.1 |
NeedsCompilation: | no |
Packaged: | 2025-02-12 20:09:52 UTC; Gabriel |
Author: | Gabriel Kaiser [aut, cre] |
Repository: | CRAN |
Date/Publication: | 2025-02-13 17:50:03 UTC |
groqR: 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.
Author(s)
Maintainer: Gabriel Kaiser quantresearch.gk@gmail.com
See Also
Useful links:
Report bugs at https://github.com/GabrielKaiserQFin/groqR/issues
'Groq': Support Functions
Description
Runs when attached such as by library() or require()
Usage
.onAttach(libname, pkgname)
Arguments
libname |
The name of the library where this add-on is located. |
pkgname |
The name of the package that is being attached. |
Details
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
Description
Get 'Groq' Completions Endpoint
Usage
APIcall(prompt, ...)
Arguments
prompt |
The prompt to generate completions for. |
... |
Following arguments can be set manually or in .Renviron:
|
Ask 'Groq'
Description
Note: See also clearChatSession
.
Usage
ask(text = NULL, ...)
Arguments
text |
The question to ask 'Groq'. |
... |
Following arguments can be set manually or in .Renviron:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
cat(ask("What do you think about Large language models?"))
## End(Not run)
'Groq': Comment code
Description
'Groq': Comment code
Usage
codeComment(code = NULL, ...)
Arguments
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:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
cat(codeComment("z <- function(x) scale(x)^2"))
## End(Not run)
Translate Code from One Language to Another
Description
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.
Usage
codeConverter(code = NULL, from = "R", to = "Python", ...)
Arguments
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:
|
Value
A string containing the translated code.
Examples
## Not run:
codeConverter("z <- function(x) scale(x)^2", from = "R", to = "Python")
## End(Not run)
'Groq': Finish code
Description
'Groq': Finish code
Usage
coder(code = NULL, language = "R", ...)
Arguments
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:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
cat(coder("# A function to square a vector\nsquare_each <- function("))
## End(Not run)
'Groq': Find Issues in Code
Description
'Groq': Find Issues in Code
Usage
debug(code = NULL, ...)
Arguments
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:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
cat(debug("z <- function(x) scale(x)2"))
## End(Not run)
Run a 'Groq' RStudio Addin
Description
Run a 'Groq' RStudio Addin
Usage
execAddin(FUN)
Arguments
FUN |
The function to be executed. |
Ask 'Groq'
Description
Opens an interactive chat session with 'Groq'
Usage
execAddin_ask()
Function to query current models
Description
The modelCall
function is designed to query current models from Groq.
Usage
modelCall(api_key = Sys.getenv("GROQ_API_KEY"))
Arguments
api_key |
The Groq API key. |
Details
The function checks the following environment variables:
-
GROQ_API_KEY
Value
model table
'Groq': Create a Function or Variable Name
Description
'Groq': Create a Function or Variable Name
Usage
nameIt(code = NULL, namingConvention = "camelCase", ...)
Arguments
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:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
cat(nameIt("sapply(1:10, function(i) i ** 2)"))
## End(Not run)
Function to Handle Package Startup Logic
Description
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.
Usage
on_startup(uiStartup = uiInit, serverStartup = serverInit)
Arguments
uiStartup |
Shiny user interface. |
serverStartup |
Shiny server. |
Details
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.
Value
None
See Also
shinyApp
'Groq': Optimize Code
Description
'Groq': Optimize Code
Usage
optimizer(code = NULL, ...)
Arguments
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:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
cat(optimizer("z <- function(x) scale(x)^2"))
## End(Not run)
responseReturn
Description
responseReturn
Usage
responseReturn(raw)
Arguments
raw |
the chatresponse to return |
Value
A character value with the response generated by the LLM.
'Groq': Rewrite Text
Description
'Groq': Rewrite Text
Usage
rewriter(text = NULL, ...)
Arguments
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:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
rewriter("Dear Recipient, I hope this message finds you well.")
## End(Not run)
'Groq': Code Documentation in roxygen2 style or any other
Description
'Groq': Code Documentation in roxygen2 style or any other
Usage
roxy(code = NULL, inLineDocumentation = "roxygen2", ...)
Arguments
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:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
cat(roxy("z <- function(x) scale(x)^2"))
## End(Not run)
Set GROQ Parameters Server Logic
Description
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.
Usage
serverInit(input, output, session)
Arguments
input |
The input values as they are submitted by the user. |
output |
The output values. |
session |
The Shiny session object. |
'Groq': Translate Text
Description
'Groq': Translate Text
Usage
translater(text = NULL, toLanguage = "German", ...)
Arguments
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:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
translater("Dear Recipient, I hope this message finds you well.")
## End(Not run)
User Interface
Description
It creates a fluidPage with a title and an action button for triggering the input event.
Usage
uiInit
Format
An object of class shiny.tag.list
(inherits from list
) of length 4.
'Groq': Create Unit Tests
Description
Create {testthat}
test cases for the code.
Usage
unitTests(code = NULL, ...)
Arguments
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:
|
Value
A character value with the response generated by 'Groq'.
Examples
## Not run:
cat(unitTests("squared_numbers <- function(numbers) {\n numbers ^ 2\n}"))
## End(Not run)