An open API service indexing awesome lists of open source software.

https://github.com/sonsoleslp/rlmstudio

An R package for prompting LM studio
https://github.com/sonsoleslp/rlmstudio

Last synced: 2 months ago
JSON representation

An R package for prompting LM studio

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dpi = 300
)
```

# `rlmstudio`: An R package for prompting LM studio from R

## Installation

You can install the development version of `rlmstudio`` from [GitHub](https://github.com/) with:

```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("sonsoleslp/rlmstudio")
```

## Example

Load the library
```{r}
library("rlmstudio")
```

Don't forget to have your LM studio server running!

Ask for a single response
```{r, eval = F}
prompt_lm("Tell me a joke!")
```
```{r, echo = F}
print("Why don't scientists trust atoms? Because they make up everything!")
```

Iterate a vector using the same prompt with variable input
```{r, eval = F}
country_vector <-c("Spain", "Finland", "Egypt", "Sweden")
prompt_vector <- paste("What is the capital of", country_vector,"?")
sapply(prompt_vector, prompt_lm)
```

```{r, echo = F}
country_vector <-c("Spain", "Finland", "Egypt", "Sweden")
prompt_vector <- paste("What is the capital of", country_vector,"?")
resp <- c("Madrid","Helsinki","Cairo","Stockholm")
names(resp) <- prompt_vector
sapply(prompt_vector, \(x) resp[[x]])
```

Iterate through a dataframe using the same prompt with variable input

```{r, eval = F}
library(dplyr)
countries = data.frame(Country = c("Spain", "Finland", "Egypt", "Sweden")) %>%
rowwise %>% mutate(Capital = prompt_lm(paste0("What is the capital of ", Country, "?")))
countries
```

```{r, echo = F, message=FALSE, warning=FALSE}
library(dplyr)
data.frame(Country = c("Spain", "Finland", "Egypt", "Sweden"),
Capital = c("Madrid", "Helsinki", "Cairo", "Stockholm"))
```