https://gabrielkaiserqfin.github.io/groqR
https://gabrielkaiserqfin.github.io/groqR
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://gabrielkaiserqfin.github.io/groqR
- Owner: GabrielKaiserQFin
- License: gpl-3.0
- Created: 2024-08-23T14:27:21.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-12T20:03:06.000Z (2 months ago)
- Last Synced: 2025-03-17T13:15:33.486Z (29 days ago)
- Language: R
- Size: 1.91 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-generative-ai-data-scientist - groqR - fast LPU (Language Processing Unit) technology directly to your R workflow. | [Website](https://gabrielkaiserqfin.github.io/groqR) | (Other Popular Interfaces to LLM Models in R)
README
---
output: github_document
---```{r, include = FALSE}
library(groqR)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "",
fig.path = "man/figures/README-",
out.width = "100%"
)```
[](https://CRAN.R-project.org/package=groqR)
[](https://cran.rstudio.com/web/packages/groqR/index.html)
[](https://github.com/GabrielKaiserQFin/groqR/actions/workflows/R-CMD-check.yaml)
[](https://github.com/GabrielKaiserQFin/groqR/actions/workflows/R-CMD-check.yaml)The objective of `groqR` is to offer R users an intuitive interface for leveraging the capabilities of the ['Groq API'](https://groq.com/). 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?**
- ⚡ **10x faster** than GPU-based solutions
- 🔒 Enterprise-grade data privacy
- 📚 Supports multiple LLMs (DeepSeek-R1, Llama-3, Mixtral)
- 🆓 Free tier available## Installation
You can install the development version of groqR from [GitHub](https://github.com/GabrielKaiserQFin/groqR) with:
```{r eval = FALSE}
# install.packages("devtools")
devtools::install_github("GabrielKaiserQFin/groqR")
```## Requirements
You need to create a free account and a free 'API' key by accessing ['Groq API' page](https://console.groq.com/keys), otherwise you can not use `{groqR}`.
To use your 'API' key in `{groqR}`, you need to configure the function parameters in the .Renviron file.## Initial Steps
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.
```{r echo = FALSE}
knitr::include_graphics("man/figures/output.gif")
```## Addins
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.```{r, echo=FALSE, out.width="100%"}
knitr::include_graphics("man/figures/Addin.png")
```## How It Works
**ask:**
This is a basic example which shows you how to ask any question.
```{r Example ask, cache=TRUE, eval=F}
ask("What do you think about Large language models?")
```**rewriter:**
This is a basic example which shows you how to rewrite text.
```{r Example rewriter, cache=TRUE, eval=F}
rewriter("Dear Recipient, I hope this message finds you well.")
```**translater:**
This is a basic example which shows you how to translate text.
```{r Example translater, cache=TRUE, eval=F}
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.
```{r Example codeComment, cache=TRUE, eval=F}
codeComment("z <- function(x) scale(x)^2")
```**unitTests:**
This is a basic example which shows you how to build Unit Tests for your function.
```{r Example unitTests, cache=TRUE, eval=F}
unitTests("z <- function(x) scale(x)^2")
```**debug:**
This is a basic example which shows you how to find bugs in your code.
```{r Example debug, cache=TRUE, eval=F}
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.
```{r Example roxy, cache=TRUE, eval=F}
roxy("z <- function(x) scale(x)^2")
```**coder:**
This is a basic example which shows you how to finish your code by 'Groq'.
```{r Example coder, cache=TRUE, eval=F}
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.
```{r Example optimizer, cache=TRUE, eval=F}
optimizer("z <- function(x) scale(x)^2")
```**codeConverter:**
This is a basic example which shows you how to translate your code.
```{r Example codeConverter, cache=TRUE, eval=F}
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.
```{r Example nameIt, cache=TRUE, eval=F}
nameIt("function(x) scale(x)^2")
```## Groq Model Arguments
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](https://console.groq.com/docs/models) and add it to your .Renviron file or as argument within the function in mind.
```{r , cache=TRUE}
modelCall()[,1:5]
```* `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.