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
- Host: GitHub
- URL: https://github.com/sonsoleslp/rlmstudio
- Owner: sonsoleslp
- License: gpl-3.0
- Created: 2024-07-06T13:06:25.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-07-06T17:33:37.000Z (11 months ago)
- Last Synced: 2025-02-12T07:04:13.372Z (4 months ago)
- Language: R
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
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"))
```