--- title: "Modify prompt enhancements" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Modify prompt enhancements} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` There are a lot of parameters that need to be set or sent when communicating with the LLM. To reduce the complexity of every single request, `chattr` processes and stores those parameters in an R object. The object can be accessed via the function `chattr_defaults()`: ```{r} library(chattr) chattr_use("gpt4") chattr_defaults() ``` **NOTE:** - For most users, this change will not work because accessing GPT 4 via the REST API endpoints is currently restricted to a few developers. ### Support for `glue` The `prompt` argument supports `glue`. This means that you can pass current values of variables, or current output from functions within your current R session. Make sure that such output, or value, is a character that is readable by the LLM. Here is a simple example of a function that passes the variables currently in your R session that contain "x": ```{r} my_list <- function() { return(ls(pattern = "x", envir = globalenv())) } ``` The `my_list()` function is passed to the `prompt` argument enclosed in braces: ```{r} chattr_defaults(prompt = "{ my_list() }") ``` Now we can test it, by setting two variables that start with "x" ```{r} x1 <- 1 x2 <- 2 ``` To see what will be sent to the LLM, you can use `chattr(preview = TRUE)`. The two variables will be listed as part of the prompt: ```{r} chattr(preview = TRUE) ``` We can see how the adding a new variable will modify the prompt with out us having to modify `chattr_defaults()`: ```{r} x3 <- 3 chattr(preview = TRUE) ```