diff --git a/LICENSE.html b/LICENSE.html index d90d484..d516e8a 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -37,7 +37,7 @@
diff --git a/articles/backend-databricks.html b/articles/backend-databricks.html index 7a8865a..034202b 100644 --- a/articles/backend-databricks.html +++ b/articles/backend-databricks.html @@ -69,7 +69,7 @@

Interact with Databricks foundation models

- Source: vignettes/backend-databricks.Rmd + Source: vignettes/backend-databricks.Rmd
backend-databricks.Rmd
diff --git a/articles/backend-llamagpt.html b/articles/backend-llamagpt.html index 34a0a77..6238db1 100644 --- a/articles/backend-llamagpt.html +++ b/articles/backend-llamagpt.html @@ -69,7 +69,7 @@

Interact with local models

- Source: vignettes/backend-llamagpt.Rmd + Source: vignettes/backend-llamagpt.Rmd
backend-llamagpt.Rmd
diff --git a/articles/copilot-chat.html b/articles/copilot-chat.html index d52d1db..d42f334 100644 --- a/articles/copilot-chat.html +++ b/articles/copilot-chat.html @@ -69,7 +69,7 @@

Interact with GitHub Copilot Chat

- Source: vignettes/copilot-chat.Rmd + Source: vignettes/copilot-chat.Rmd
copilot-chat.Rmd
diff --git a/articles/openai-gpt.html b/articles/openai-gpt.html index a1589b2..4ada3e3 100644 --- a/articles/openai-gpt.html +++ b/articles/openai-gpt.html @@ -69,7 +69,7 @@

Interact with OpenAI GPT models

- Source: vignettes/openai-gpt.Rmd + Source: vignettes/openai-gpt.Rmd
openai-gpt.Rmd
diff --git a/articles/other-interfaces.html b/articles/other-interfaces.html index d1f49c2..7239290 100644 --- a/articles/other-interfaces.html +++ b/articles/other-interfaces.html @@ -69,7 +69,7 @@

Other interfaces

- Source: vignettes/other-interfaces.Rmd + Source: vignettes/other-interfaces.Rmd
other-interfaces.Rmd
diff --git a/articles/prompt_defaults.html b/articles/prompt_defaults.html index 8308075..c8d898a 100644 --- a/articles/prompt_defaults.html +++ b/articles/prompt_defaults.html @@ -69,7 +69,7 @@

Modify prompt enhancements

- Source: vignettes/prompt_defaults.Rmd + Source: vignettes/prompt_defaults.Rmd
prompt_defaults.Rmd
diff --git a/authors.html b/authors.html index 495d59a..e57cf74 100644 --- a/authors.html +++ b/authors.html @@ -54,7 +54,7 @@

Authors

Citation

-

Source: DESCRIPTION

+

Source: DESCRIPTION

Ruiz E (2024). chattr: Interact with Large Language Models in 'RStudio'. diff --git a/news/index.html b/news/index.html index e045a8c..7cd7bdb 100644 --- a/news/index.html +++ b/news/index.html @@ -37,11 +37,11 @@

-

chattr 0.2.0

+

chattr 0.2.0

CRAN release: 2024-07-29

General

  • Fixes how it identifies the user’s current UI (console, app, notebook) and appropriately outputs the response from the model end-point (#92)
  • diff --git a/pkgdown.yml b/pkgdown.yml index c89b5e5..6d61022 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -8,7 +8,7 @@ articles: openai-gpt: openai-gpt.html other-interfaces: other-interfaces.html prompt_defaults: prompt_defaults.html -last_built: 2024-07-29T15:04Z +last_built: 2024-07-29T15:51Z urls: reference: https://mlverse.github.io/chattr/reference article: https://mlverse.github.io/chattr/articles diff --git a/reference/ch_history.html b/reference/ch_history.html index ca85592..c943bd1 100644 --- a/reference/ch_history.html +++ b/reference/ch_history.html @@ -37,7 +37,7 @@
    diff --git a/reference/ch_submit.html b/reference/ch_submit.html index 920867c..92ddfcd 100644 --- a/reference/ch_submit.html +++ b/reference/ch_submit.html @@ -37,7 +37,7 @@
    diff --git a/reference/chattr.html b/reference/chattr.html index 33ccb2e..bc81e49 100644 --- a/reference/chattr.html +++ b/reference/chattr.html @@ -37,7 +37,7 @@
    diff --git a/reference/chattr_app.html b/reference/chattr_app.html index e407377..41d80b4 100644 --- a/reference/chattr_app.html +++ b/reference/chattr_app.html @@ -37,7 +37,7 @@
    diff --git a/reference/chattr_defaults.html b/reference/chattr_defaults.html index 7180f0c..44de52d 100644 --- a/reference/chattr_defaults.html +++ b/reference/chattr_defaults.html @@ -37,7 +37,7 @@
    diff --git a/reference/chattr_defaults_save.html b/reference/chattr_defaults_save.html index 6f3b09a..ffb9923 100644 --- a/reference/chattr_defaults_save.html +++ b/reference/chattr_defaults_save.html @@ -39,7 +39,7 @@
    diff --git a/reference/chattr_test.html b/reference/chattr_test.html index d5de60a..81924ff 100644 --- a/reference/chattr_test.html +++ b/reference/chattr_test.html @@ -37,7 +37,7 @@
    diff --git a/reference/chattr_use.html b/reference/chattr_use.html index 42e1855..b97be7b 100644 --- a/reference/chattr_use.html +++ b/reference/chattr_use.html @@ -37,7 +37,7 @@
    diff --git a/search.json b/search.json index a0589de..23160f6 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://mlverse.github.io/chattr/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 chattr authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"intro","dir":"Articles","previous_headings":"","what":"Intro","title":"Interact with Databricks foundation models","text":"Databricks customers access foundation model APIs like DBRX, Meta Llama 3 70B, Mixtral 8x7B. Databricks also provides ability train deploy custom models. chattr supports following models Databricks default: Supported Databricks pay-per-token foundation models","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"authentication","dir":"Articles","previous_headings":"","what":"Authentication","title":"Interact with Databricks foundation models","text":"Databricks requires host (workspace URL) token authenticate. required non-Databricks application, chattr, interact models Databricks workspace. token can generated user workspace developer settings (docs) host can found workspaces URL (docs). default, chattr look credentials environment variables: DATABRICKS_HOST DATABRICKS_TOKEN Use Sys.setenv() set variable. downside using method variable available current R session: preferred method save secret key .Renviron file. way, need load environment variable every time start new R session. .Renviron file available home directory. example entry:","code":"Sys.setenv(\"DATABRICKS_HOST\" = \"https://xxxxx.cloud.databricks.com\") Sys.setenv(\"DATABRICKS_TOKEN\" = \"####################\") DATABRICKS_HOST = https://xxxxx.cloud.databricks.com DATABRICKS_TOKEN = ####################"},{"path":[]},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"supported-models","dir":"Articles","previous_headings":"Change the model","what":"Supported Models","title":"Interact with Databricks foundation models","text":"default, chattr setup interact GPT 4 (gpt-4). switch Meta Llama 3 70B can run:","code":"library(chattr) chattr_use(\"databricks-meta-llama3-70b\") #> #> ── chattr #> • Provider: Databricks #> • Path/URL: serving-endpoints #> • Model: databricks-meta-llama-3-70b-instruct #> • Label: Meta Llama 3 70B (Databricks)"},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"custom-models","dir":"Articles","previous_headings":"Change the model > Supported Models","what":"Custom Models","title":"Interact with Databricks foundation models","text":"model doesn’t appear supported table deployed Databricks model serving OpenAI-compatible (configured llm/v1/chat mlflow) can specify model name explicitly chattr_use() example deployed fine-tuned version LLM endpoint name \"CustomLLM\":","code":"library(chattr) # use any existing databricks foundation model name (e.g. datarbicks-dbrx) # then adjust the default model name to 'CustomMixtral' chattr_use(x = \"databricks-dbrx\", model = \"CustomLLM\") #> #> ── chattr #> • Provider: Databricks #> • Path/URL: serving-endpoints #> • Model: CustomLLM #> • Label: DBRX (Databricks)"},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"data-files-and-data-frames","dir":"Articles","previous_headings":"","what":"Data files and data frames","title":"Interact with Databricks foundation models","text":"information environment work space, default chattr avoids sending data files, data frame information Databricks. Sending information convenient creates shorthand requests. wish submit information part prompts, use chattr_defaults(), example: chattr_defaults(max_data_files = 10) chattr_defaults(max_data_frames = 10) two commands send 10 data frames, 10 data files part prompt. can decide number limit . send, larger prompt. set anything 0, warning show every time start Shiny app:","code":"• Provider: Databricks • Path/URL: serving-endpoints • Model: databricks-dbrx-instruct • Label: DBRX (Databricks) ! A list of the top 10 files will be sent externally to Databricks with every request To avoid this, set the number of files to be sent to 0 using chattr::chattr_defaults(max_data_files = 0)Î"},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"intro","dir":"Articles","previous_headings":"","what":"Intro","title":"Interact with local models","text":"LlamaGPT-Chat command line chat application. integrates LLM via C++. means work LLM’s language. available today free download use. C++, models able run locally computer, even GPU available. models quite fast responses. integrating LlamaGPT-Chat, able access multiple types LLM’s one additional back-end within chattr.","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Interact with local models","text":"get LlamaGPT-Chat working machine need two things: version LlamaGPT-Chat works computer LLM file works chat program","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"install-llamagpt-chat","dir":"Articles","previous_headings":"Installation","what":"Install LLamaGPT-Chat","title":"Interact with local models","text":"LlamaGPT-Chat need “compiled binary” specific Operating System. example, Windows, compiled binary .exe file. GitHub repository offers pre-compiled binaries can download use: Releases. Depending system’s security, pre-compiled program may blocked running. case, need “build” program computer. instructions .","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"llm-file","dir":"Articles","previous_headings":"Installation","what":"LLM file","title":"Interact with local models","text":"GitHub repository contains list compatible models. Download least one models, make note saved computer.","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"setup","dir":"Articles","previous_headings":"","what":"Setup","title":"Interact with local models","text":"start, instruct chattr switch LLamaGPT back-end using chattr_use() first time use interface, confirm path compiled program, model matches machine. check use chattr_defaults() either, , paths incorrect, correct updating path, model arguments chattr_defaults() need change defaults every time start new R session, use chattr_defaults_save(). create YAML file working directory. chattr use file override defaults. Use chattr_test() confirm chattr able communicate LLamaGPT-Chat, model use R session accessible","code":"library(chattr) chattr_use(\"llamagpt\") #> #> ── chattr #> • Provider: LlamaGPT #> • Path/URL: ~/LlamaGPTJ-chat/build/bin/chat #> • Model: ~/ggml-gpt4all-j-v1.3-groovy.bin #> • Label: GPT4ALL 1.3 (LlamaGPT) chattr_defaults() #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Defaults for: Default ── #> #> ── Prompt: #> • Use the R language, the tidyverse, and tidymodels #> #> ── Model #> • Provider: LlamaGPT #> • Path/URL: ~/LlamaGPTJ-chat/build/bin/chat #> • Model: ~/ggml-gpt4all-j-v1.3-groovy.bin #> • Label: GPT4ALL 1.3 (LlamaGPT) #> #> ── Model Arguments: #> • threads: 4 #> • temp: 0.01 #> • n_predict: 1000 #> #> ── Context: #> Max Data Files: 0 #> Max Data Frames: 0 #> ✖ Chat History #> ✖ Document contents chattr_defaults(path = \"[path to compiled program]\", model = \"[path to model]\") #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Defaults for: Default ── #> #> ── Prompt: #> • Use the R language, the tidyverse, and tidymodels #> #> ── Model #> • Provider: LlamaGPT #> • Path/URL: [path to compiled program] #> • Model: [path to model] #> • Label: GPT4ALL 1.3 (LlamaGPT) #> #> ── Model Arguments: #> • threads: 4 #> • temp: 0.01 #> • n_predict: 1000 #> #> ── Context: #> Max Data Files: 0 #> Max Data Frames: 0 #> ✖ Chat History #> ✖ Document contents chattr_defaults_save() chattr_test() #> ✔ Model started sucessfully #> ✔ Model session closed sucessfully"},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"model-arguments","dir":"Articles","previous_headings":"","what":"Model Arguments","title":"Interact with local models","text":"arguments sent model can modified chattr_defaults() modifying model_arguments argument. expects list object. arguments sets default: example adding batch_size defaults: see current list available model arguments go : Detailed command list. IMPORTANT - chattr passes arguments directly LLamaGPT-chat command line flag, except model. chattr use value chattr_defaults(model = \"[path model]\") instead.","code":"chattr_defaults()$model_arguments #> $threads #> [1] 4 #> #> $temp #> [1] 0.01 #> #> $n_predict #> [1] 1000 chattr_defaults(model_arguments = list(batch_size = 40)) #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Defaults for: Default ── #> #> ── Prompt: #> • Use the R language, the tidyverse, and tidymodels #> #> ── Model #> • Provider: LlamaGPT #> • Path/URL: [path to compiled program] #> • Model: [path to model] #> • Label: GPT4ALL 1.3 (LlamaGPT) #> #> ── Model Arguments: #> • batch_size: 40 #> • threads: 4 #> • temp: 0.01 #> • n_predict: 1000 #> #> ── Context: #> Max Data Files: 0 #> Max Data Frames: 0 #> ✖ Chat History #> ✖ Document contents"},{"path":"https://mlverse.github.io/chattr/articles/copilot-chat.html","id":"intro","dir":"Articles","previous_headings":"","what":"Intro","title":"Interact with GitHub Copilot Chat","text":"introduction docs.github.com: GitHub Copilot Chat chat interface lets interact GitHub Copilot, ask receive answers coding-related questions within GitHub.com supported IDEs. chat interface provides access coding information support without requiring navigate documentation search online forums.","code":""},{"path":"https://mlverse.github.io/chattr/articles/copilot-chat.html","id":"rstudio","dir":"Articles","previous_headings":"","what":"RStudio","title":"Interact with GitHub Copilot Chat","text":"RStudio’s integration Copilot needs enabled, setup, order chattr work. due complexity authenticating Copilot Chat. yet setup GitHub Copilot RStudio IDE, instructions: https://docs.posit.co/ide/user/ide/guide/tools/copilot.html","code":""},{"path":"https://mlverse.github.io/chattr/articles/copilot-chat.html","id":"test-connection","dir":"Articles","previous_headings":"","what":"Test connection","title":"Interact with GitHub Copilot Chat","text":"Use chattr_test() function confirm connection works:","code":"library(chattr) chattr_use(\"copilot\") chattr_test() #> ── Testing chattr #> • Provider: OpenAI - Copilot Chat #> • Path/URL: https://api.githubcopilot.com/chat/completions #> • Model: #> ✔ Connection with GitHub Copilot cofirmed #> |--Prompt: Hi! #> |--Response: Hello! How can I assist you today?"},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"intro","dir":"Articles","previous_headings":"","what":"Intro","title":"Interact with OpenAI GPT models","text":"OpenAI’s GPT models possibly widely used LLM today. Typically, interaction models via chatting inside OpenAI’s web portal. also offer REST API endpoint can use communicate LLM’s. chattr able send receive correct API calls make “chatting” experience GPT models seamless.","code":""},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"secret-key","dir":"Articles","previous_headings":"","what":"Secret key","title":"Interact with OpenAI GPT models","text":"OpenAI requires secret key authenticate user. required application non-OpenAI application, chattr, one order function. key long alphanumeric sequence. sequence created OpenAI portal. default, chattr look secret key inside Environment Variable called OPENAI_API_KEY. packages integrate OpenAI use variable name. Use Sys.setenv() set variable. downside using method variable available current R session: preferred method save secret key .Renviron file. way, need load environment variable every time start new R session. .Renviron file available home directory. example entry:","code":"Sys.setenv(\"OPENAI_API_KEY\" = \"####################\") OPENAI_API_KEY=####################"},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"test-connection","dir":"Articles","previous_headings":"","what":"Test connection","title":"Interact with OpenAI GPT models","text":"Use chattr_test() function confirm connection works:","code":"library(chattr) chattr_test() ✔ Connection with OpenAI cofirmed ✔ Access to models confirmed"},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"change-the-model","dir":"Articles","previous_headings":"","what":"Change the model","title":"Interact with OpenAI GPT models","text":"default, chattr setup interact GPT 4 (gpt-4). switch 3.5, use: switch back GPT 4, run:","code":"library(chattr) chattr_use(\"gpt35\") #> #> ── chattr #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-3.5-turbo #> • Label: GPT 3.5 (OpenAI) chattr_use(\"gpt4\") #> #> ── chattr #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI)"},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"data-files-and-data-frames","dir":"Articles","previous_headings":"","what":"Data files and data frames","title":"Interact with OpenAI GPT models","text":"information environment work space, default chattr avoids sending data files, data frame information OpenAI. Sending information convenient creates shorthand requests. wish submit information part prompts, use chattr_defaults(), example: chattr_defaults(max_data_files = 10) chattr_defaults(max_data_frames = 10) two commands send 10 data frames, 10 data files part prompt. can decide number limit . send, larger prompt. set anything 0, warning show every time start Shiny app:","code":"• Provider: Open AI - Chat Completions • Path/URL: https://api.openai.com/v1/chat/completions • Model: gpt-3.5-turbo ! A list of the top 10 files will be sent externally to OpenAI with every request To avoid this, set the number of files to be sent to 0 using chattr::chattr_defaults(max_data_files = 0)Î"},{"path":"https://mlverse.github.io/chattr/articles/other-interfaces.html","id":"output","dir":"Articles","previous_headings":"","what":"Output","title":"Other interfaces","text":"Based making request , chattr return response appropriately following manner: request made R console, response returned console message, R code (cat()). way, can decide copy-paste code run. also prevent comments LLM cause error. request made script, code chunk Quarto (Visual editor), output inserted right prompt document.","code":""},{"path":"https://mlverse.github.io/chattr/articles/other-interfaces.html","id":"using-the-chattr-function","dir":"Articles","previous_headings":"","what":"Using the chattr() function","title":"Other interfaces","text":"fastest way interact LLM simply calling chattr() function enter request . example request made OpenAI:","code":"library(chattr) chattr(\"show me a simple recipe\") # Load required packages library(tidymodels) # Create a simple recipe for the iris dataset iris_recipe <- recipe(Species ~ ., data = iris) # Print the recipe iris_recipe"},{"path":"https://mlverse.github.io/chattr/articles/other-interfaces.html","id":"highlight-the-request-in-a-script","dir":"Articles","previous_headings":"","what":"Highlight the request in a script","title":"Other interfaces","text":"script, chattr process current line, highlighted line(s), prompt. assume request going code, chattr comment line lines highlighted. mentioned Output section, response inserted document. example request submitted OpenAI: results:","code":"Create a function that: - Removes specified variables - Behaves like dplyr's select function # Create a function that: # - Removes specified variables # - Behaves like dplyr's select function # This function removes specified variables and behaves like dplyr's select function # It uses the tidyverse packages: dplyr and tidyr remove_vars <- function(data, ...) { data %>% select(-one_of(...)) } }"},{"path":"https://mlverse.github.io/chattr/articles/prompt_defaults.html","id":"support-for-glue","dir":"Articles","previous_headings":"","what":"Support for glue","title":"Modify prompt enhancements","text":"prompt argument supports glue. means can pass current values variables, current output functions within current R session. Make sure output, value, character readable LLM. simple example function passes variables currently R session contain “x”: my_list() function passed prompt argument enclosed braces: Now can test , setting two variables start “x” see sent LLM, can use chattr(preview = TRUE). two variables listed part prompt: can see adding new variable modify prompt us modify chattr_defaults():","code":"my_list <- function() { return(ls(pattern = \"x\", envir = globalenv())) } chattr_defaults(prompt = \"{ my_list() }\") #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Defaults for: Default ── #> #> ── Prompt: #> • {{ my_list() }} #> #> ── Model #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) #> #> ── Model Arguments: #> • temperature: 0.01 #> • max_tokens: 1000 #> • stream: TRUE #> #> ── Context: #> Max Data Files: 0 #> Max Data Frames: 0 #> ✔ Chat History #> ✖ Document contents x1 <- 1 x2 <- 2 chattr(preview = TRUE) #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Preview for: Console #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) #> • temperature: 0.01 #> • max_tokens: 1000 #> • stream: TRUE #> #> ── Prompt: #> role: system #> content: You are a helpful coding assistant #> role: user #> content: #> * x1 #> * x2 #> [Your future prompt goes here] x3 <- 3 chattr(preview = TRUE) #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Preview for: Console #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) #> • temperature: 0.01 #> • max_tokens: 1000 #> • stream: TRUE #> #> ── Prompt: #> role: system #> content: You are a helpful coding assistant #> role: user #> content: #> * x1 #> * x2 #> * x3 #> [Your future prompt goes here]"},{"path":"https://mlverse.github.io/chattr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Edgar Ruiz. Author, maintainer. Posit Software, PBC. Copyright holder, funder.","code":""},{"path":"https://mlverse.github.io/chattr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Ruiz E (2024). chattr: Interact Large Language Models 'RStudio'. R package version 0.2.0, https://mlverse.github.io/chattr/, https://github.com/mlverse/chattr.","code":"@Manual{, title = {chattr: Interact with Large Language Models in 'RStudio'}, author = {Edgar Ruiz}, year = {2024}, note = {R package version 0.2.0, https://mlverse.github.io/chattr/}, url = {https://github.com/mlverse/chattr}, }"},{"path":"https://mlverse.github.io/chattr/index.html","id":"chattr","dir":"","previous_headings":"","what":"Interact with Large Language Models in RStudio","title":"Interact with Large Language Models in RStudio","text":"Intro Install Available models App Additional ways interact works setup keyboard shortcut","code":""},{"path":"https://mlverse.github.io/chattr/index.html","id":"intro","dir":"","previous_headings":"","what":"Intro","title":"Interact with Large Language Models in RStudio","text":"chattr interface LLMs (Large Language Models). enables interaction model directly RStudio IDE. chattr allows submit prompt LLM script, using provided Shiny Gadget. package’s main goal aid exploratory data analysis (EDA) tasks. additional information appended request, provides sort “guard rails”, packages techniques usually recommend best practice, used model’s responses.","code":""},{"path":"https://mlverse.github.io/chattr/index.html","id":"install","dir":"","previous_headings":"","what":"Install","title":"Interact with Large Language Models in RStudio","text":"Since early version package install package GitHub:","code":"remotes::install_github(\"mlverse/chattr\")"},{"path":"https://mlverse.github.io/chattr/index.html","id":"available-models","dir":"","previous_headings":"","what":"Available models","title":"Interact with Large Language Models in RStudio","text":"chattr provides two main integration two main LLM back-ends. back-end provides access multiple LLM types. plan add back-ends time goes :","code":""},{"path":[]},{"path":"https://mlverse.github.io/chattr/index.html","id":"the-app","dir":"","previous_headings":"Using","what":"The App","title":"Interact with Large Language Models in RStudio","text":"main way use chattr Shiny Gadget app. default, RStudio app run inside Viewer pane. chattr prompt select model back-end use. list actual models depend setup . model setup found, return error. receive error, please refer previous section learn setup model back-end machine. example selection prompt look like: prompt occurs first time call chattr_app(), chattr(). close app, open , app use model initially selected. selection set rest R session, manually change . Please note , example, chattr find setup OpenAI, lines show options actual prompt. wish avoid interactive prompt, call chattr_use() designate model wish use calling app. can also use chattr_use() change model back-end interacting R session: LLM finishes response, chattr app processes markdown code chunks. place three convenience buttons: Copy clipboard - write code inside chunk clipboard. Copy document - copy-paste code directly app called . app started working script, chattr copy code script. Copy new script - creates new R script RStudio IDE, copies content chunk directly . useful LLM writes Shiny app lot effort put make app’s appearance close possible IDE. way feels integrated work space. includes switching color scheme based current RStudio theme light, dark. settings screen can accessed clicking “gear” button. screen opens contain following: Save Open chats - early experiment allow us save retrieve past chats. chattr save file RDS format. main objective feature, able see past chats, continue previous conversations LLM. Prompt settings - section can change additional information attached prompt. Including number max data files, data frames sent LLM.","code":"chattr::chattr_app() #> ── chattr - Available models #> #> 1: GitHub - Copilot Chat - (copilot) #> 2: OpenAI - Chat Completions - gpt-3.5-turbo (gpt35) #> 3: OpenAI - Chat Completions - gpt-4 (gpt4) #> 4: LlamaGPT - ~/ggml-gpt4all-j-v1.3-groovy.bin (llamagpt) #> #> Select the number of the model you would like to use: chattr_use(\"gpt35\") chattr_app()"},{"path":"https://mlverse.github.io/chattr/index.html","id":"additional-ways-to-interact","dir":"","previous_headings":"Using","what":"Additional ways to interact","title":"Interact with Large Language Models in RStudio","text":"Apart Shiny app, chattr provides two ways interact LLM. details, see: interfaces","code":""},{"path":"https://mlverse.github.io/chattr/index.html","id":"how-it-works","dir":"","previous_headings":"","what":"How it works","title":"Interact with Large Language Models in RStudio","text":"chattr enriches request additional instructions, name structure data frames currently environment, path data files working directory. supported model, chattr include current chat history. see chattr send model, set preview argument TRUE:","code":"library(chattr) data(mtcars) data(iris) chattr_use(\"gpt4\") #> #> ── chattr #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) chattr(preview = TRUE) #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Preview for: Console #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) #> • temperature: 0.01 #> • max_tokens: 1000 #> • stream: TRUE #> #> ── Prompt: #> role: system #> content: You are a helpful coding assistant #> role: user #> content: #> * Use the 'Tidy Modeling with R' (https://www.tmwr.org/) book as main reference #> * Use the 'R for Data Science' (https://r4ds.had.co.nz/) book as main reference #> * Use tidyverse packages: readr, ggplot2, dplyr, tidyr #> * For models, use tidymodels packages: recipes, parsnip, yardstick, workflows, #> broom #> * Avoid explanations unless requested by user, expecting code only #> * For any line that is not code, prefix with a: # #> * Keep each line of explanations to no more than 80 characters #> * DO NOT use Markdown for the code #> [Your future prompt goes here]"},{"path":"https://mlverse.github.io/chattr/index.html","id":"keyboard-shortcut","dir":"","previous_headings":"","what":"Keyboard Shortcut","title":"Interact with Large Language Models in RStudio","text":"best way access chattr’s app setting keyboard shortcut . package includes RStudio Addin gives us direct access app, turn, allows keyboard shortcut assigned addin. name addin : “Open Chat”. familiar assign keyboard shortcut see next section.","code":""},{"path":"https://mlverse.github.io/chattr/index.html","id":"how-to-setup-the-keyboard-shortcut","dir":"","previous_headings":"Keyboard Shortcut","what":"How to setup the keyboard shortcut","title":"Interact with Large Language Models in RStudio","text":"Select Tools top menu, select Modify Keyboard Shortcuts Search chattr adding writing “open chat”, search box select key combination shortcut, click Shortcut box type press key combination keyboard. case, chose Ctrl+Shift+C","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_history.html","id":null,"dir":"Reference","previous_headings":"","what":"Displays the current session' chat history — ch_history","title":"Displays the current session' chat history — ch_history","text":"Displays current session' chat history","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_history.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Displays the current session' chat history — ch_history","text":"","code":"ch_history(x = NULL)"},{"path":"https://mlverse.github.io/chattr/reference/ch_history.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Displays the current session' chat history — ch_history","text":"x list object contains chat history. Use argument override current history.","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_history.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Displays the current session' chat history — ch_history","text":"list object current chat history","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":null,"dir":"Reference","previous_headings":"","what":"Method to easily integrate to new LLM API's — ch_submit","title":"Method to easily integrate to new LLM API's — ch_submit","text":"Method easily integrate new LLM API's","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Method to easily integrate to new LLM API's — ch_submit","text":"","code":"ch_submit( defaults, prompt = NULL, stream = NULL, prompt_build = TRUE, preview = FALSE, ... )"},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Method to easily integrate to new LLM API's — ch_submit","text":"defaults Defaults object, generally puled chattr_defaults() prompt prompt send LLM stream output response LLM happens, wait response complete. Defaults TRUE. prompt_build Include context additional prompt part request preview Primarily used debugging. indicates send prompt LLM (FALSE), print resulting prompt (TRUE) ... Optional arguments; currently unused.","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Method to easily integrate to new LLM API's — ch_submit","text":"output model currently use.","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Method to easily integrate to new LLM API's — ch_submit","text":"Use function integrate LLM API. requirements get work properly: output function needs parsed response LLM support streaming, make sure use cat() function output response LLM API happening. preview set TRUE, send LLM API. Simply return resulting prompt. defaults argument controls method use. can use chattr_defaults() function, set provider. provider value creates R class name. pre-pend cl_ class name. See examples clarity.","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Method to easily integrate to new LLM API's — ch_submit","text":"","code":"if (FALSE) { # \\dontrun{ library(chattr) ch_submit.ch_my_llm <- function(defaults, prompt = NULL, stream = NULL, prompt_build = TRUE, preview = FALSE, ...) { # Use `prompt_build` to append the prompts you with to append if (prompt_build) prompt <- paste0(\"Use the tidyverse\\n\", prompt) # If `preview` is true, return the resulting prompt back if (preview) { return(prompt) } llm_response <- paste0(\"You said this: \\n\", prompt) if (stream) { cat(\"streaming:\\n\") for (i in seq_len(nchar(llm_response))) { # If `stream` is true, make sure to `cat()` the current output cat(substr(llm_response, i, i)) Sys.sleep(0.1) } } # Make sure to return the entire output from the LLM at the end llm_response } chattr_defaults(\"console\", provider = \"my llm\") chattr(\"hello\") chattr(\"hello\", stream = FALSE) chattr(\"hello\", prompt_build = FALSE) chattr(\"hello\", preview = TRUE) } # }"},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":null,"dir":"Reference","previous_headings":"","what":"Submits prompt to LLM — chattr","title":"Submits prompt to LLM — chattr","text":"Submits prompt LLM","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Submits prompt to LLM — chattr","text":"","code":"chattr(prompt = NULL, preview = FALSE, prompt_build = TRUE, stream = NULL)"},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Submits prompt to LLM — chattr","text":"prompt Request send LLM. Defaults NULL preview Primarily used debugging. indicates send prompt LLM (FALSE), print resulting prompt (TRUE) prompt_build Include context additional prompt part request stream output response LLM happens, wait response complete. Defaults TRUE.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Submits prompt to LLM — chattr","text":"output LLM console, document script.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Submits prompt to LLM — chattr","text":"","code":"library(chattr) chattr_use(\"test\") #> #> ── chattr #> • Provider: test backend #> • Path/URL: #> • Model: Test model #> • Label: Test chattr(\"hello\") #> hello chattr(\"hello\", preview = TRUE) #> hello #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Preview for: Console #> • Provider: test backend #> • Path/URL: #> • Model: Test model #> • Label: Test #> • n_predict: 1000 #> #> ── Prompt: #> hello"},{"path":"https://mlverse.github.io/chattr/reference/chattr_app.html","id":null,"dir":"Reference","previous_headings":"","what":"Starts a Shiny app interface to the LLM — chattr_app","title":"Starts a Shiny app interface to the LLM — chattr_app","text":"Starts Shiny app interface LLM","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_app.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Starts a Shiny app interface to the LLM — chattr_app","text":"","code":"chattr_app( viewer = c(\"viewer\", \"dialog\"), as_job = getOption(\"chattr.as_job\", FALSE), as_job_port = getOption(\"shiny.port\", 7788), as_job_host = getOption(\"shiny.host\", \"127.0.0.1\") )"},{"path":"https://mlverse.github.io/chattr/reference/chattr_app.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Starts a Shiny app interface to the LLM — chattr_app","text":"viewer Specifies Shiny app going display as_job App runs RStudio IDE Job. Defaults FALSE. set TRUE, Shiny app able transfer code blocks directly document, console, IDE. as_job_port Port use Shiny app. Applicable as_job set TRUE. as_job_host Host IP use Shiny app. Applicable as_job set TRUE.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_app.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Starts a Shiny app interface to the LLM — chattr_app","text":"chat interface inside 'RStudio' IDE","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":null,"dir":"Reference","previous_headings":"","what":"Default arguments to use when making requests to the LLM — chattr_defaults","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"Default arguments use making requests LLM","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"","code":"chattr_defaults( type = \"default\", prompt = NULL, max_data_files = NULL, max_data_frames = NULL, include_doc_contents = NULL, include_history = NULL, provider = NULL, path = NULL, model = NULL, model_arguments = NULL, system_msg = NULL, yaml_file = \"chattr.yml\", force = FALSE, label = NULL, ... )"},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"type Entry point interact model. Accepted values: 'notebook', chat' prompt Request send LLM. Defaults NULL max_data_files Sets maximum number data files send model. defaults 20. send , set NULL max_data_frames Sets maximum number data frames loaded current R session send model. defaults 20. send , set NULL include_doc_contents Send current code document include_history Indicates whether include chat history every time new prompt submitted provider name provider LLM. Today, \"openai\" available path location model. URL file path. model name path model use. model_arguments Additional arguments pass model part request, requires list. Examples arguments: temperature, top_p, max_tokens system_msg OpenAI GPT 3.5 , system message send part request yaml_file path valid config YAML file contains defaults use session force Re-process base work space level file defaults label Label display Shiny app, locations ... Additional model arguments standard models/backends","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"'ch_model' object contains current defaults used communicate LLM.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"idea use addin shortcut execute request, arguments can controlled via function. default, try load defaults config YAML file, none found, defaults GPT 3.5 used. defaults can modified calling function, even interactive session started.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults_save.html","id":null,"dir":"Reference","previous_headings":"","what":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","title":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","text":"Saves current defaults yaml file compatible config package","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults_save.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","text":"","code":"chattr_defaults_save(path = \"chattr.yml\", overwrite = FALSE, type = NULL)"},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults_save.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","text":"path Path file save configuration overwrite Indicates replace file exists type type UI save defaults . defaults NULL save whatever types used current R session","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults_save.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","text":"creates YAML file defaults set current R session.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_test.html","id":null,"dir":"Reference","previous_headings":"","what":"Confirms connectivity to LLM interface — chattr_test","title":"Confirms connectivity to LLM interface — chattr_test","text":"Confirms connectivity LLM interface","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confirms connectivity to LLM interface — chattr_test","text":"","code":"chattr_test(defaults = NULL) ch_test(defaults = NULL)"},{"path":"https://mlverse.github.io/chattr/reference/chattr_test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confirms connectivity to LLM interface — chattr_test","text":"defaults Defaults object, generally puled chattr_defaults()","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confirms connectivity to LLM interface — chattr_test","text":"returns console massages status test.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":null,"dir":"Reference","previous_headings":"","what":"Sets the LLM model to use in your session — chattr_use","title":"Sets the LLM model to use in your session — chattr_use","text":"Sets LLM model use session","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sets the LLM model to use in your session — chattr_use","text":"","code":"chattr_use(x = NULL, ...)"},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Sets the LLM model to use in your session — chattr_use","text":"x label LLM model use, path valid YAML default file . Valid values 'copilot', 'gpt4', 'gpt35', 'llamagpt', 'databricks-dbrx', 'databricks-meta-llama3-70b', 'databricks-mixtral8x7b'. value 'test' also acceptable, meant package examples, internal testing. ... Default values modify.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Sets the LLM model to use in your session — chattr_use","text":"returns console messages allow user select model use.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Sets the LLM model to use in your session — chattr_use","text":"error \"model setup found\" returned, none expected setup Copilot, OpenAI LLama automatically detected. setup model: OpenAI - main thing chattr checks presence R user's OpenAI PAT (Personal Access Token). looks 'OPENAI_API_KEY' environment variable. Get PAT OpenAI website, save environment variable. restart R, try . GitHub Copilot - Setup GitHub Copilot RStudio IDE, restart R. chattr look default location RStudio saves Copilot authentication information. Databricks - chattr checks presence R user's Databricks host token ('DATABRICKS_HOST' 'DATABRICKS TOKEN' environment variables). Use 'CHATTR_MODEL' environment variable set R session, create YAML file named 'chattr.yml' working directory control model, defaults use communicate model.","code":""},{"path":[]},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"general-0-2-0","dir":"Changelog","previous_headings":"","what":"General","title":"chattr 0.2.0","text":"Fixes identifies user’s current UI (console, app, notebook) appropriately outputs response model end-point (#92)","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"databricks-0-2-0","dir":"Changelog","previous_headings":"","what":"Databricks","title":"chattr 0.2.0","text":"Adding support Databricks foundation model API (DBRX, Meta Llama 3 70B, Mixtral 8x7B) (#99)","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"openai-0-2-0","dir":"Changelog","previous_headings":"","what":"OpenAI","title":"chattr 0.2.0","text":"Fixes displays error model end-point used notebook app Fixes errors OpenAI parsed processed. make easier users determine downstream issue .","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"copilot-0-2-0","dir":"Changelog","previous_headings":"","what":"Copilot","title":"chattr 0.2.0","text":"Adds model defaults Improves token discovery","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"chattr-010","dir":"Changelog","previous_headings":"","what":"chattr 0.1.0","title":"chattr 0.1.0","text":"CRAN release: 2024-04-27 Initial CRAN submission.","code":""}] +[{"path":"https://mlverse.github.io/chattr/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 chattr authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"intro","dir":"Articles","previous_headings":"","what":"Intro","title":"Interact with Databricks foundation models","text":"Databricks customers access foundation model APIs like DBRX, Meta Llama 3 70B, Mixtral 8x7B. Databricks also provides ability train deploy custom models. chattr supports following models Databricks default: Supported Databricks pay-per-token foundation models","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"authentication","dir":"Articles","previous_headings":"","what":"Authentication","title":"Interact with Databricks foundation models","text":"Databricks requires host (workspace URL) token authenticate. required non-Databricks application, chattr, interact models Databricks workspace. token can generated user workspace developer settings (docs) host can found workspaces URL (docs). default, chattr look credentials environment variables: DATABRICKS_HOST DATABRICKS_TOKEN Use Sys.setenv() set variable. downside using method variable available current R session: preferred method save secret key .Renviron file. way, need load environment variable every time start new R session. .Renviron file available home directory. example entry:","code":"Sys.setenv(\"DATABRICKS_HOST\" = \"https://xxxxx.cloud.databricks.com\") Sys.setenv(\"DATABRICKS_TOKEN\" = \"####################\") DATABRICKS_HOST = https://xxxxx.cloud.databricks.com DATABRICKS_TOKEN = ####################"},{"path":[]},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"supported-models","dir":"Articles","previous_headings":"Change the model","what":"Supported Models","title":"Interact with Databricks foundation models","text":"default, chattr setup interact GPT 4 (gpt-4). switch Meta Llama 3 70B can run:","code":"library(chattr) chattr_use(\"databricks-meta-llama3-70b\") #> #> ── chattr #> • Provider: Databricks #> • Path/URL: serving-endpoints #> • Model: databricks-meta-llama-3-70b-instruct #> • Label: Meta Llama 3 70B (Databricks)"},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"custom-models","dir":"Articles","previous_headings":"Change the model > Supported Models","what":"Custom Models","title":"Interact with Databricks foundation models","text":"model doesn’t appear supported table deployed Databricks model serving OpenAI-compatible (configured llm/v1/chat mlflow) can specify model name explicitly chattr_use() example deployed fine-tuned version LLM endpoint name \"CustomLLM\":","code":"library(chattr) # use any existing databricks foundation model name (e.g. datarbicks-dbrx) # then adjust the default model name to 'CustomMixtral' chattr_use(x = \"databricks-dbrx\", model = \"CustomLLM\") #> #> ── chattr #> • Provider: Databricks #> • Path/URL: serving-endpoints #> • Model: CustomLLM #> • Label: DBRX (Databricks)"},{"path":"https://mlverse.github.io/chattr/articles/backend-databricks.html","id":"data-files-and-data-frames","dir":"Articles","previous_headings":"","what":"Data files and data frames","title":"Interact with Databricks foundation models","text":"information environment work space, default chattr avoids sending data files, data frame information Databricks. Sending information convenient creates shorthand requests. wish submit information part prompts, use chattr_defaults(), example: chattr_defaults(max_data_files = 10) chattr_defaults(max_data_frames = 10) two commands send 10 data frames, 10 data files part prompt. can decide number limit . send, larger prompt. set anything 0, warning show every time start Shiny app:","code":"• Provider: Databricks • Path/URL: serving-endpoints • Model: databricks-dbrx-instruct • Label: DBRX (Databricks) ! A list of the top 10 files will be sent externally to Databricks with every request To avoid this, set the number of files to be sent to 0 using chattr::chattr_defaults(max_data_files = 0)Î"},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"intro","dir":"Articles","previous_headings":"","what":"Intro","title":"Interact with local models","text":"LlamaGPT-Chat command line chat application. integrates LLM via C++. means work LLM’s language. available today free download use. C++, models able run locally computer, even GPU available. models quite fast responses. integrating LlamaGPT-Chat, able access multiple types LLM’s one additional back-end within chattr.","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Interact with local models","text":"get LlamaGPT-Chat working machine need two things: version LlamaGPT-Chat works computer LLM file works chat program","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"install-llamagpt-chat","dir":"Articles","previous_headings":"Installation","what":"Install LLamaGPT-Chat","title":"Interact with local models","text":"LlamaGPT-Chat need “compiled binary” specific Operating System. example, Windows, compiled binary .exe file. GitHub repository offers pre-compiled binaries can download use: Releases. Depending system’s security, pre-compiled program may blocked running. case, need “build” program computer. instructions .","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"llm-file","dir":"Articles","previous_headings":"Installation","what":"LLM file","title":"Interact with local models","text":"GitHub repository contains list compatible models. Download least one models, make note saved computer.","code":""},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"setup","dir":"Articles","previous_headings":"","what":"Setup","title":"Interact with local models","text":"start, instruct chattr switch LLamaGPT back-end using chattr_use() first time use interface, confirm path compiled program, model matches machine. check use chattr_defaults() either, , paths incorrect, correct updating path, model arguments chattr_defaults() need change defaults every time start new R session, use chattr_defaults_save(). create YAML file working directory. chattr use file override defaults. Use chattr_test() confirm chattr able communicate LLamaGPT-Chat, model use R session accessible","code":"library(chattr) chattr_use(\"llamagpt\") #> #> ── chattr #> • Provider: LlamaGPT #> • Path/URL: ~/LlamaGPTJ-chat/build/bin/chat #> • Model: ~/ggml-gpt4all-j-v1.3-groovy.bin #> • Label: GPT4ALL 1.3 (LlamaGPT) chattr_defaults() #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Defaults for: Default ── #> #> ── Prompt: #> • Use the R language, the tidyverse, and tidymodels #> #> ── Model #> • Provider: LlamaGPT #> • Path/URL: ~/LlamaGPTJ-chat/build/bin/chat #> • Model: ~/ggml-gpt4all-j-v1.3-groovy.bin #> • Label: GPT4ALL 1.3 (LlamaGPT) #> #> ── Model Arguments: #> • threads: 4 #> • temp: 0.01 #> • n_predict: 1000 #> #> ── Context: #> Max Data Files: 0 #> Max Data Frames: 0 #> ✖ Chat History #> ✖ Document contents chattr_defaults(path = \"[path to compiled program]\", model = \"[path to model]\") #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Defaults for: Default ── #> #> ── Prompt: #> • Use the R language, the tidyverse, and tidymodels #> #> ── Model #> • Provider: LlamaGPT #> • Path/URL: [path to compiled program] #> • Model: [path to model] #> • Label: GPT4ALL 1.3 (LlamaGPT) #> #> ── Model Arguments: #> • threads: 4 #> • temp: 0.01 #> • n_predict: 1000 #> #> ── Context: #> Max Data Files: 0 #> Max Data Frames: 0 #> ✖ Chat History #> ✖ Document contents chattr_defaults_save() chattr_test() #> ✔ Model started sucessfully #> ✔ Model session closed sucessfully"},{"path":"https://mlverse.github.io/chattr/articles/backend-llamagpt.html","id":"model-arguments","dir":"Articles","previous_headings":"","what":"Model Arguments","title":"Interact with local models","text":"arguments sent model can modified chattr_defaults() modifying model_arguments argument. expects list object. arguments sets default: example adding batch_size defaults: see current list available model arguments go : Detailed command list. IMPORTANT - chattr passes arguments directly LLamaGPT-chat command line flag, except model. chattr use value chattr_defaults(model = \"[path model]\") instead.","code":"chattr_defaults()$model_arguments #> $threads #> [1] 4 #> #> $temp #> [1] 0.01 #> #> $n_predict #> [1] 1000 chattr_defaults(model_arguments = list(batch_size = 40)) #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Defaults for: Default ── #> #> ── Prompt: #> • Use the R language, the tidyverse, and tidymodels #> #> ── Model #> • Provider: LlamaGPT #> • Path/URL: [path to compiled program] #> • Model: [path to model] #> • Label: GPT4ALL 1.3 (LlamaGPT) #> #> ── Model Arguments: #> • batch_size: 40 #> • threads: 4 #> • temp: 0.01 #> • n_predict: 1000 #> #> ── Context: #> Max Data Files: 0 #> Max Data Frames: 0 #> ✖ Chat History #> ✖ Document contents"},{"path":"https://mlverse.github.io/chattr/articles/copilot-chat.html","id":"intro","dir":"Articles","previous_headings":"","what":"Intro","title":"Interact with GitHub Copilot Chat","text":"introduction docs.github.com: GitHub Copilot Chat chat interface lets interact GitHub Copilot, ask receive answers coding-related questions within GitHub.com supported IDEs. chat interface provides access coding information support without requiring navigate documentation search online forums.","code":""},{"path":"https://mlverse.github.io/chattr/articles/copilot-chat.html","id":"rstudio","dir":"Articles","previous_headings":"","what":"RStudio","title":"Interact with GitHub Copilot Chat","text":"RStudio’s integration Copilot needs enabled, setup, order chattr work. due complexity authenticating Copilot Chat. yet setup GitHub Copilot RStudio IDE, instructions: https://docs.posit.co/ide/user/ide/guide/tools/copilot.html","code":""},{"path":"https://mlverse.github.io/chattr/articles/copilot-chat.html","id":"test-connection","dir":"Articles","previous_headings":"","what":"Test connection","title":"Interact with GitHub Copilot Chat","text":"Use chattr_test() function confirm connection works:","code":"library(chattr) chattr_use(\"copilot\") chattr_test() #> ── Testing chattr #> • Provider: OpenAI - Copilot Chat #> • Path/URL: https://api.githubcopilot.com/chat/completions #> • Model: #> ✔ Connection with GitHub Copilot cofirmed #> |--Prompt: Hi! #> |--Response: Hello! How can I assist you today?"},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"intro","dir":"Articles","previous_headings":"","what":"Intro","title":"Interact with OpenAI GPT models","text":"OpenAI’s GPT models possibly widely used LLM today. Typically, interaction models via chatting inside OpenAI’s web portal. also offer REST API endpoint can use communicate LLM’s. chattr able send receive correct API calls make “chatting” experience GPT models seamless.","code":""},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"secret-key","dir":"Articles","previous_headings":"","what":"Secret key","title":"Interact with OpenAI GPT models","text":"OpenAI requires secret key authenticate user. required application non-OpenAI application, chattr, one order function. key long alphanumeric sequence. sequence created OpenAI portal. default, chattr look secret key inside Environment Variable called OPENAI_API_KEY. packages integrate OpenAI use variable name. Use Sys.setenv() set variable. downside using method variable available current R session: preferred method save secret key .Renviron file. way, need load environment variable every time start new R session. .Renviron file available home directory. example entry:","code":"Sys.setenv(\"OPENAI_API_KEY\" = \"####################\") OPENAI_API_KEY=####################"},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"test-connection","dir":"Articles","previous_headings":"","what":"Test connection","title":"Interact with OpenAI GPT models","text":"Use chattr_test() function confirm connection works:","code":"library(chattr) chattr_test() ✔ Connection with OpenAI cofirmed ✔ Access to models confirmed"},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"change-the-model","dir":"Articles","previous_headings":"","what":"Change the model","title":"Interact with OpenAI GPT models","text":"default, chattr setup interact GPT 4 (gpt-4). switch 3.5, use: switch back GPT 4, run:","code":"library(chattr) chattr_use(\"gpt35\") #> #> ── chattr #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-3.5-turbo #> • Label: GPT 3.5 (OpenAI) chattr_use(\"gpt4\") #> #> ── chattr #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI)"},{"path":"https://mlverse.github.io/chattr/articles/openai-gpt.html","id":"data-files-and-data-frames","dir":"Articles","previous_headings":"","what":"Data files and data frames","title":"Interact with OpenAI GPT models","text":"information environment work space, default chattr avoids sending data files, data frame information OpenAI. Sending information convenient creates shorthand requests. wish submit information part prompts, use chattr_defaults(), example: chattr_defaults(max_data_files = 10) chattr_defaults(max_data_frames = 10) two commands send 10 data frames, 10 data files part prompt. can decide number limit . send, larger prompt. set anything 0, warning show every time start Shiny app:","code":"• Provider: Open AI - Chat Completions • Path/URL: https://api.openai.com/v1/chat/completions • Model: gpt-3.5-turbo ! A list of the top 10 files will be sent externally to OpenAI with every request To avoid this, set the number of files to be sent to 0 using chattr::chattr_defaults(max_data_files = 0)Î"},{"path":"https://mlverse.github.io/chattr/articles/other-interfaces.html","id":"output","dir":"Articles","previous_headings":"","what":"Output","title":"Other interfaces","text":"Based making request , chattr return response appropriately following manner: request made R console, response returned console message, R code (cat()). way, can decide copy-paste code run. also prevent comments LLM cause error. request made script, code chunk Quarto (Visual editor), output inserted right prompt document.","code":""},{"path":"https://mlverse.github.io/chattr/articles/other-interfaces.html","id":"using-the-chattr-function","dir":"Articles","previous_headings":"","what":"Using the chattr() function","title":"Other interfaces","text":"fastest way interact LLM simply calling chattr() function enter request . example request made OpenAI:","code":"library(chattr) chattr(\"show me a simple recipe\") # Load required packages library(tidymodels) # Create a simple recipe for the iris dataset iris_recipe <- recipe(Species ~ ., data = iris) # Print the recipe iris_recipe"},{"path":"https://mlverse.github.io/chattr/articles/other-interfaces.html","id":"highlight-the-request-in-a-script","dir":"Articles","previous_headings":"","what":"Highlight the request in a script","title":"Other interfaces","text":"script, chattr process current line, highlighted line(s), prompt. assume request going code, chattr comment line lines highlighted. mentioned Output section, response inserted document. example request submitted OpenAI: results:","code":"Create a function that: - Removes specified variables - Behaves like dplyr's select function # Create a function that: # - Removes specified variables # - Behaves like dplyr's select function # This function removes specified variables and behaves like dplyr's select function # It uses the tidyverse packages: dplyr and tidyr remove_vars <- function(data, ...) { data %>% select(-one_of(...)) } }"},{"path":"https://mlverse.github.io/chattr/articles/prompt_defaults.html","id":"support-for-glue","dir":"Articles","previous_headings":"","what":"Support for glue","title":"Modify prompt enhancements","text":"prompt argument supports glue. means can pass current values variables, current output functions within current R session. Make sure output, value, character readable LLM. simple example function passes variables currently R session contain “x”: my_list() function passed prompt argument enclosed braces: Now can test , setting two variables start “x” see sent LLM, can use chattr(preview = TRUE). two variables listed part prompt: can see adding new variable modify prompt us modify chattr_defaults():","code":"my_list <- function() { return(ls(pattern = \"x\", envir = globalenv())) } chattr_defaults(prompt = \"{ my_list() }\") #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Defaults for: Default ── #> #> ── Prompt: #> • {{ my_list() }} #> #> ── Model #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) #> #> ── Model Arguments: #> • temperature: 0.01 #> • max_tokens: 1000 #> • stream: TRUE #> #> ── Context: #> Max Data Files: 0 #> Max Data Frames: 0 #> ✔ Chat History #> ✖ Document contents x1 <- 1 x2 <- 2 chattr(preview = TRUE) #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Preview for: Console #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) #> • temperature: 0.01 #> • max_tokens: 1000 #> • stream: TRUE #> #> ── Prompt: #> role: system #> content: You are a helpful coding assistant #> role: user #> content: #> * x1 #> * x2 #> [Your future prompt goes here] x3 <- 3 chattr(preview = TRUE) #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Preview for: Console #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) #> • temperature: 0.01 #> • max_tokens: 1000 #> • stream: TRUE #> #> ── Prompt: #> role: system #> content: You are a helpful coding assistant #> role: user #> content: #> * x1 #> * x2 #> * x3 #> [Your future prompt goes here]"},{"path":"https://mlverse.github.io/chattr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Edgar Ruiz. Author, maintainer. Posit Software, PBC. Copyright holder, funder.","code":""},{"path":"https://mlverse.github.io/chattr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Ruiz E (2024). chattr: Interact Large Language Models 'RStudio'. R package version 0.2.0, https://mlverse.github.io/chattr/, https://github.com/mlverse/chattr.","code":"@Manual{, title = {chattr: Interact with Large Language Models in 'RStudio'}, author = {Edgar Ruiz}, year = {2024}, note = {R package version 0.2.0, https://mlverse.github.io/chattr/}, url = {https://github.com/mlverse/chattr}, }"},{"path":"https://mlverse.github.io/chattr/index.html","id":"chattr","dir":"","previous_headings":"","what":"Interact with Large Language Models in RStudio","title":"Interact with Large Language Models in RStudio","text":"Intro Install Available models App Additional ways interact works setup keyboard shortcut","code":""},{"path":"https://mlverse.github.io/chattr/index.html","id":"intro","dir":"","previous_headings":"","what":"Intro","title":"Interact with Large Language Models in RStudio","text":"chattr interface LLMs (Large Language Models). enables interaction model directly RStudio IDE. chattr allows submit prompt LLM script, using provided Shiny Gadget. package’s main goal aid exploratory data analysis (EDA) tasks. additional information appended request, provides sort “guard rails”, packages techniques usually recommend best practice, used model’s responses.","code":""},{"path":"https://mlverse.github.io/chattr/index.html","id":"install","dir":"","previous_headings":"","what":"Install","title":"Interact with Large Language Models in RStudio","text":"Since early version package install package GitHub:","code":"remotes::install_github(\"mlverse/chattr\")"},{"path":"https://mlverse.github.io/chattr/index.html","id":"available-models","dir":"","previous_headings":"","what":"Available models","title":"Interact with Large Language Models in RStudio","text":"chattr provides two main integration two main LLM back-ends. back-end provides access multiple LLM types. plan add back-ends time goes :","code":""},{"path":[]},{"path":"https://mlverse.github.io/chattr/index.html","id":"the-app","dir":"","previous_headings":"Using","what":"The App","title":"Interact with Large Language Models in RStudio","text":"main way use chattr Shiny Gadget app. default, RStudio app run inside Viewer pane. chattr prompt select model back-end use. list actual models depend setup . model setup found, return error. receive error, please refer previous section learn setup model back-end machine. example selection prompt look like: prompt occurs first time call chattr_app(), chattr(). close app, open , app use model initially selected. selection set rest R session, manually change . Please note , example, chattr find setup OpenAI, lines show options actual prompt. wish avoid interactive prompt, call chattr_use() designate model wish use calling app. can also use chattr_use() change model back-end interacting R session: LLM finishes response, chattr app processes markdown code chunks. place three convenience buttons: Copy clipboard - write code inside chunk clipboard. Copy document - copy-paste code directly app called . app started working script, chattr copy code script. Copy new script - creates new R script RStudio IDE, copies content chunk directly . useful LLM writes Shiny app lot effort put make app’s appearance close possible IDE. way feels integrated work space. includes switching color scheme based current RStudio theme light, dark. settings screen can accessed clicking “gear” button. screen opens contain following: Save Open chats - early experiment allow us save retrieve past chats. chattr save file RDS format. main objective feature, able see past chats, continue previous conversations LLM. Prompt settings - section can change additional information attached prompt. Including number max data files, data frames sent LLM.","code":"chattr::chattr_app() #> ── chattr - Available models #> #> 1: GitHub - Copilot Chat - (copilot) #> 2: OpenAI - Chat Completions - gpt-3.5-turbo (gpt35) #> 3: OpenAI - Chat Completions - gpt-4 (gpt4) #> 4: LlamaGPT - ~/ggml-gpt4all-j-v1.3-groovy.bin (llamagpt) #> #> Select the number of the model you would like to use: chattr_use(\"gpt35\") chattr_app()"},{"path":"https://mlverse.github.io/chattr/index.html","id":"additional-ways-to-interact","dir":"","previous_headings":"Using","what":"Additional ways to interact","title":"Interact with Large Language Models in RStudio","text":"Apart Shiny app, chattr provides two ways interact LLM. details, see: interfaces","code":""},{"path":"https://mlverse.github.io/chattr/index.html","id":"how-it-works","dir":"","previous_headings":"","what":"How it works","title":"Interact with Large Language Models in RStudio","text":"chattr enriches request additional instructions, name structure data frames currently environment, path data files working directory. supported model, chattr include current chat history. see chattr send model, set preview argument TRUE:","code":"library(chattr) data(mtcars) data(iris) chattr_use(\"gpt4\") #> #> ── chattr #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) chattr(preview = TRUE) #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Preview for: Console #> • Provider: OpenAI - Chat Completions #> • Path/URL: https://api.openai.com/v1/chat/completions #> • Model: gpt-4 #> • Label: GPT 4 (OpenAI) #> • temperature: 0.01 #> • max_tokens: 1000 #> • stream: TRUE #> #> ── Prompt: #> role: system #> content: You are a helpful coding assistant #> role: user #> content: #> * Use the 'Tidy Modeling with R' (https://www.tmwr.org/) book as main reference #> * Use the 'R for Data Science' (https://r4ds.had.co.nz/) book as main reference #> * Use tidyverse packages: readr, ggplot2, dplyr, tidyr #> * For models, use tidymodels packages: recipes, parsnip, yardstick, workflows, #> broom #> * Avoid explanations unless requested by user, expecting code only #> * For any line that is not code, prefix with a: # #> * Keep each line of explanations to no more than 80 characters #> * DO NOT use Markdown for the code #> [Your future prompt goes here]"},{"path":"https://mlverse.github.io/chattr/index.html","id":"keyboard-shortcut","dir":"","previous_headings":"","what":"Keyboard Shortcut","title":"Interact with Large Language Models in RStudio","text":"best way access chattr’s app setting keyboard shortcut . package includes RStudio Addin gives us direct access app, turn, allows keyboard shortcut assigned addin. name addin : “Open Chat”. familiar assign keyboard shortcut see next section.","code":""},{"path":"https://mlverse.github.io/chattr/index.html","id":"how-to-setup-the-keyboard-shortcut","dir":"","previous_headings":"Keyboard Shortcut","what":"How to setup the keyboard shortcut","title":"Interact with Large Language Models in RStudio","text":"Select Tools top menu, select Modify Keyboard Shortcuts Search chattr adding writing “open chat”, search box select key combination shortcut, click Shortcut box type press key combination keyboard. case, chose Ctrl+Shift+C","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_history.html","id":null,"dir":"Reference","previous_headings":"","what":"Displays the current session' chat history — ch_history","title":"Displays the current session' chat history — ch_history","text":"Displays current session' chat history","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_history.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Displays the current session' chat history — ch_history","text":"","code":"ch_history(x = NULL)"},{"path":"https://mlverse.github.io/chattr/reference/ch_history.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Displays the current session' chat history — ch_history","text":"x list object contains chat history. Use argument override current history.","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_history.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Displays the current session' chat history — ch_history","text":"list object current chat history","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":null,"dir":"Reference","previous_headings":"","what":"Method to easily integrate to new LLM API's — ch_submit","title":"Method to easily integrate to new LLM API's — ch_submit","text":"Method easily integrate new LLM API's","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Method to easily integrate to new LLM API's — ch_submit","text":"","code":"ch_submit( defaults, prompt = NULL, stream = NULL, prompt_build = TRUE, preview = FALSE, ... )"},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Method to easily integrate to new LLM API's — ch_submit","text":"defaults Defaults object, generally puled chattr_defaults() prompt prompt send LLM stream output response LLM happens, wait response complete. Defaults TRUE. prompt_build Include context additional prompt part request preview Primarily used debugging. indicates send prompt LLM (FALSE), print resulting prompt (TRUE) ... Optional arguments; currently unused.","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Method to easily integrate to new LLM API's — ch_submit","text":"output model currently use.","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Method to easily integrate to new LLM API's — ch_submit","text":"Use function integrate LLM API. requirements get work properly: output function needs parsed response LLM support streaming, make sure use cat() function output response LLM API happening. preview set TRUE, send LLM API. Simply return resulting prompt. defaults argument controls method use. can use chattr_defaults() function, set provider. provider value creates R class name. pre-pend cl_ class name. See examples clarity.","code":""},{"path":"https://mlverse.github.io/chattr/reference/ch_submit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Method to easily integrate to new LLM API's — ch_submit","text":"","code":"if (FALSE) { # \\dontrun{ library(chattr) ch_submit.ch_my_llm <- function(defaults, prompt = NULL, stream = NULL, prompt_build = TRUE, preview = FALSE, ...) { # Use `prompt_build` to append the prompts you with to append if (prompt_build) prompt <- paste0(\"Use the tidyverse\\n\", prompt) # If `preview` is true, return the resulting prompt back if (preview) { return(prompt) } llm_response <- paste0(\"You said this: \\n\", prompt) if (stream) { cat(\"streaming:\\n\") for (i in seq_len(nchar(llm_response))) { # If `stream` is true, make sure to `cat()` the current output cat(substr(llm_response, i, i)) Sys.sleep(0.1) } } # Make sure to return the entire output from the LLM at the end llm_response } chattr_defaults(\"console\", provider = \"my llm\") chattr(\"hello\") chattr(\"hello\", stream = FALSE) chattr(\"hello\", prompt_build = FALSE) chattr(\"hello\", preview = TRUE) } # }"},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":null,"dir":"Reference","previous_headings":"","what":"Submits prompt to LLM — chattr","title":"Submits prompt to LLM — chattr","text":"Submits prompt LLM","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Submits prompt to LLM — chattr","text":"","code":"chattr(prompt = NULL, preview = FALSE, prompt_build = TRUE, stream = NULL)"},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Submits prompt to LLM — chattr","text":"prompt Request send LLM. Defaults NULL preview Primarily used debugging. indicates send prompt LLM (FALSE), print resulting prompt (TRUE) prompt_build Include context additional prompt part request stream output response LLM happens, wait response complete. Defaults TRUE.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Submits prompt to LLM — chattr","text":"output LLM console, document script.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Submits prompt to LLM — chattr","text":"","code":"library(chattr) chattr_use(\"test\") #> #> ── chattr #> • Provider: test backend #> • Path/URL: #> • Model: Test model #> • Label: Test chattr(\"hello\") #> hello chattr(\"hello\", preview = TRUE) #> hello #> #> ── chattr ────────────────────────────────────────────────────────────────────── #> #> ── Preview for: Console #> • Provider: test backend #> • Path/URL: #> • Model: Test model #> • Label: Test #> • n_predict: 1000 #> #> ── Prompt: #> hello"},{"path":"https://mlverse.github.io/chattr/reference/chattr_app.html","id":null,"dir":"Reference","previous_headings":"","what":"Starts a Shiny app interface to the LLM — chattr_app","title":"Starts a Shiny app interface to the LLM — chattr_app","text":"Starts Shiny app interface LLM","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_app.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Starts a Shiny app interface to the LLM — chattr_app","text":"","code":"chattr_app( viewer = c(\"viewer\", \"dialog\"), as_job = getOption(\"chattr.as_job\", FALSE), as_job_port = getOption(\"shiny.port\", 7788), as_job_host = getOption(\"shiny.host\", \"127.0.0.1\") )"},{"path":"https://mlverse.github.io/chattr/reference/chattr_app.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Starts a Shiny app interface to the LLM — chattr_app","text":"viewer Specifies Shiny app going display as_job App runs RStudio IDE Job. Defaults FALSE. set TRUE, Shiny app able transfer code blocks directly document, console, IDE. as_job_port Port use Shiny app. Applicable as_job set TRUE. as_job_host Host IP use Shiny app. Applicable as_job set TRUE.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_app.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Starts a Shiny app interface to the LLM — chattr_app","text":"chat interface inside 'RStudio' IDE","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":null,"dir":"Reference","previous_headings":"","what":"Default arguments to use when making requests to the LLM — chattr_defaults","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"Default arguments use making requests LLM","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"","code":"chattr_defaults( type = \"default\", prompt = NULL, max_data_files = NULL, max_data_frames = NULL, include_doc_contents = NULL, include_history = NULL, provider = NULL, path = NULL, model = NULL, model_arguments = NULL, system_msg = NULL, yaml_file = \"chattr.yml\", force = FALSE, label = NULL, ... )"},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"type Entry point interact model. Accepted values: 'notebook', chat' prompt Request send LLM. Defaults NULL max_data_files Sets maximum number data files send model. defaults 20. send , set NULL max_data_frames Sets maximum number data frames loaded current R session send model. defaults 20. send , set NULL include_doc_contents Send current code document include_history Indicates whether include chat history every time new prompt submitted provider name provider LLM. Today, \"openai\" available path location model. URL file path. model name path model use. model_arguments Additional arguments pass model part request, requires list. Examples arguments: temperature, top_p, max_tokens system_msg OpenAI GPT 3.5 , system message send part request yaml_file path valid config YAML file contains defaults use session force Re-process base work space level file defaults label Label display Shiny app, locations ... Additional model arguments standard models/backends","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"'ch_model' object contains current defaults used communicate LLM.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Default arguments to use when making requests to the LLM — chattr_defaults","text":"idea use addin shortcut execute request, arguments can controlled via function. default, try load defaults config YAML file, none found, defaults GPT 3.5 used. defaults can modified calling function, even interactive session started.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults_save.html","id":null,"dir":"Reference","previous_headings":"","what":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","title":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","text":"Saves current defaults yaml file compatible config package","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults_save.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","text":"","code":"chattr_defaults_save(path = \"chattr.yml\", overwrite = FALSE, type = NULL)"},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults_save.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","text":"path Path file save configuration overwrite Indicates replace file exists type type UI save defaults . defaults NULL save whatever types used current R session","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_defaults_save.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Saves the current defaults in a yaml file that is compatible with the config package — chattr_defaults_save","text":"creates YAML file defaults set current R session.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_test.html","id":null,"dir":"Reference","previous_headings":"","what":"Confirms connectivity to LLM interface — chattr_test","title":"Confirms connectivity to LLM interface — chattr_test","text":"Confirms connectivity LLM interface","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confirms connectivity to LLM interface — chattr_test","text":"","code":"chattr_test(defaults = NULL) ch_test(defaults = NULL)"},{"path":"https://mlverse.github.io/chattr/reference/chattr_test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confirms connectivity to LLM interface — chattr_test","text":"defaults Defaults object, generally puled chattr_defaults()","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confirms connectivity to LLM interface — chattr_test","text":"returns console massages status test.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":null,"dir":"Reference","previous_headings":"","what":"Sets the LLM model to use in your session — chattr_use","title":"Sets the LLM model to use in your session — chattr_use","text":"Sets LLM model use session","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sets the LLM model to use in your session — chattr_use","text":"","code":"chattr_use(x = NULL, ...)"},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Sets the LLM model to use in your session — chattr_use","text":"x label LLM model use, path valid YAML default file . Valid values 'copilot', 'gpt4', 'gpt35', 'llamagpt', 'databricks-dbrx', 'databricks-meta-llama3-70b', 'databricks-mixtral8x7b'. value 'test' also acceptable, meant package examples, internal testing. ... Default values modify.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Sets the LLM model to use in your session — chattr_use","text":"returns console messages allow user select model use.","code":""},{"path":"https://mlverse.github.io/chattr/reference/chattr_use.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Sets the LLM model to use in your session — chattr_use","text":"error \"model setup found\" returned, none expected setup Copilot, OpenAI LLama automatically detected. setup model: OpenAI - main thing chattr checks presence R user's OpenAI PAT (Personal Access Token). looks 'OPENAI_API_KEY' environment variable. Get PAT OpenAI website, save environment variable. restart R, try . GitHub Copilot - Setup GitHub Copilot RStudio IDE, restart R. chattr look default location RStudio saves Copilot authentication information. Databricks - chattr checks presence R user's Databricks host token ('DATABRICKS_HOST' 'DATABRICKS TOKEN' environment variables). Use 'CHATTR_MODEL' environment variable set R session, create YAML file named 'chattr.yml' working directory control model, defaults use communicate model.","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"chattr-020","dir":"Changelog","previous_headings":"","what":"chattr 0.2.0","title":"chattr 0.2.0","text":"CRAN release: 2024-07-29","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"general-0-2-0","dir":"Changelog","previous_headings":"","what":"General","title":"chattr 0.2.0","text":"Fixes identifies user’s current UI (console, app, notebook) appropriately outputs response model end-point (#92)","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"databricks-0-2-0","dir":"Changelog","previous_headings":"","what":"Databricks","title":"chattr 0.2.0","text":"Adding support Databricks foundation model API (DBRX, Meta Llama 3 70B, Mixtral 8x7B) (#99)","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"openai-0-2-0","dir":"Changelog","previous_headings":"","what":"OpenAI","title":"chattr 0.2.0","text":"Fixes displays error model end-point used notebook app Fixes errors OpenAI parsed processed. make easier users determine downstream issue .","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"copilot-0-2-0","dir":"Changelog","previous_headings":"","what":"Copilot","title":"chattr 0.2.0","text":"Adds model defaults Improves token discovery","code":""},{"path":"https://mlverse.github.io/chattr/news/index.html","id":"chattr-010","dir":"Changelog","previous_headings":"","what":"chattr 0.1.0","title":"chattr 0.1.0","text":"CRAN release: 2024-04-27 Initial CRAN submission.","code":""}]