Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/GabrielKaiserQFin/groqR
https://github.com/GabrielKaiserQFin/groqR
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/GabrielKaiserQFin/groqR
- Owner: GabrielKaiserQFin
- License: gpl-3.0
- Created: 2024-08-23T14:27:21.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-10-09T11:24:36.000Z (3 months ago)
- Last Synced: 2024-10-28T17:32:28.414Z (3 months ago)
- Language: R
- Size: 168 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE.md
Awesome Lists containing this project
- jimsghstars - GabrielKaiserQFin/groqR - (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%"
)
```# groqR
[![CRAN status](https://www.r-pkg.org/badges/version/groqR)](https://CRAN.R-project.org/package=groqR)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/groqR)](https://cran.rstudio.com/web/packages/groqR/index.html)
[![R-CMD-check](https://github.com/GabrielKaiserQFin/groqR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/GabrielKaiserQFin/groqR/actions/workflows/R-CMD-check.yaml)
[![R-CMD-check](https://github.com/GabrielKaiserQFin/groqR/actions/workflows/R-CMD-check.yaml/badge.svg)](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 a RStudio addin, enabling seamless interactive integration of 'Groq' prompts.
## 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. At the first run a shiny app will start, and you will be guided through a setup process.
## Examples
### 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.
Just ask anything of you interest and hit the confirm button. The **Done** button let 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 even further.### Ask:
This is a basic example which shows you how to ask any question.
```{r Example ask, cache=TRUE}
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}
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}
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}
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}
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}
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 NULL.
```{r Example roxy, cache=TRUE}
roxy("z <- function(x) scale(x)^2", inLineDocumentation = NULL)
```### coder:
This is a basic example which shows you how to finish your code by 'Groq'.
```{r Example coder, cache=TRUE}
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}
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}
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}
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,
'Groq' 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. Default is "`llama-3.1-70b-versatile`" but other available [models](https://console.groq.com/docs/models) are:
"`llama-3.1-8b-instant`",
"`llama3-groq-70b-8192-tool-use-preview`",
"`llama3-groq-8b-8192-tool-use-preview`",
"`llama-guard-3-8b`",
"`llama3-70b-8192`",
"`llama3-8b-8192`",
"`mixtral-8x7b-32768`",
"`gemma-7b-it`",
"`gemma2-9b-it`",
"`whisper-large-v3`"* `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.