{"id":27081095,"url":"https://mlverse.github.io/chattr/","last_synced_at":"2025-04-06T02:06:51.886Z","repository":{"id":166904682,"uuid":"617518727","full_name":"mlverse/chattr","owner":"mlverse","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-30T19:52:46.000Z","size":12886,"stargazers_count":224,"open_issues_count":34,"forks_count":23,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-31T23:34:26.115Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://mlverse.github.io/chattr/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mlverse.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-22T14:58:30.000Z","updated_at":"2025-03-24T21:41:17.000Z","dependencies_parsed_at":"2024-02-07T22:44:49.986Z","dependency_job_id":"cfe6e698-dafd-4bac-8ef8-9a19ef605fba","html_url":"https://github.com/mlverse/chattr","commit_stats":null,"previous_names":["edgararuiz/tidychat","mlverse/chattr"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Fchattr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Fchattr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Fchattr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Fchattr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlverse","download_url":"https://codeload.github.com/mlverse/chattr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423512,"owners_count":20936626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-06T02:01:44.969Z","updated_at":"2025-04-06T02:06:51.880Z","avatar_url":"https://github.com/mlverse.png","language":"R","funding_links":[],"categories":["mlverse"],"sub_categories":[],"readme":"# chattr\n\n\u003c!-- badges: start --\u003e\n\n[![R-CMD-check](https://github.com/mlverse/chattr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mlverse/chattr/actions/workflows/R-CMD-check.yaml)\n[![Codecov test\ncoverage](https://codecov.io/gh/mlverse/chattr/branch/main/graph/badge.svg)](https://app.codecov.io/gh/mlverse/chattr?branch=main)\n[![CRAN\nstatus](https://www.r-pkg.org/badges/version/chattr.png)](https://CRAN.R-project.org/package=chattr)\n[![](man/figures/lifecycle-experimental.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n\n\u003c!-- badges: end --\u003e\n\u003c!-- toc: start --\u003e\n\n-   [Intro](#intro)\n-   [Install](#install)\n-   [Available models](#available-models)\n-   [Using](#using)\n    -   [The App](#the-app)\n    -   [Additional ways to interact](#additional-ways-to-interact)\n-   [How it works](#how-it-works)\n-   [Keyboard Shortcut](#keyboard-shortcut)\n    -   [How to setup the keyboard\n        shortcut](#how-to-setup-the-keyboard-shortcut)\n\n\u003c!-- toc: end --\u003e\n\n## Intro\n\n`chattr` is an interface to LLMs (Large Language Models). It enables\ninteraction with the model directly from the RStudio IDE. `chattr`\nallows you to submit a prompt to the LLM from your script, or by using\nthe provided Shiny Gadget.\n\nThis package’s main goal is to aid in exploratory data analysis (EDA)\ntasks. The additional information appended to your request, provides a\nsort of “guard rails”, so that the packages and techniques we usually\nrecommend as best practice, are used in the model’s responses.\n\n## Install\n\nSince this is a very early version of the package install the package\nfrom GitHub:\n\n``` r\nremotes::install_github(\"mlverse/chattr\")\n```\n\n## Available models\n\n`chattr` provides two main integration with two main LLM back-ends. Each\nback-end provides access to multiple LLM types. The plan is to add more\nback-ends as time goes by:\n\n\u003ctable style=\"width:100%;\"\u003e\n\u003ccolgroup\u003e\n\u003ccol style=\"width: 28%\" /\u003e\n\u003ccol style=\"width: 46%\" /\u003e\n\u003ccol style=\"width: 24%\" /\u003e\n\u003c/colgroup\u003e\n\u003cthead\u003e\n\u003ctr class=\"header\"\u003e\n\u003cth style=\"text-align: center;\"\u003eProvider\u003c/th\u003e\n\u003cth style=\"text-align: center;\"\u003eModels\u003c/th\u003e\n\u003cth style=\"text-align: center;\"\u003eSetup Instructions\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr class=\"odd\"\u003e\n\u003ctd style=\"text-align: center;\"\u003eOpenAI\u003c/td\u003e\n\u003ctd style=\"text-align: center;\"\u003eGPT Models accessible via the OpenAI’s\nREST API. \u003ccode\u003echattr\u003c/code\u003e provides a convenient way to interact with\nGPT 4, and 3.5.\u003c/td\u003e\n\u003ctd style=\"text-align: center;\"\u003e\u003ca\nhref=\"https://mlverse.github.io/chattr/articles/openai-gpt.html\"\u003eInteract\nwith OpenAI GPT models\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"even\"\u003e\n\u003ctd style=\"text-align: center;\"\u003e\u003ca\nhref=\"https://github.com/kuvaus/LlamaGPTJ-chat\"\u003eLLamaGPT-Chat\u003c/a\u003e\u003c/td\u003e\n\u003ctd style=\"text-align: center;\"\u003eLLM models available in your computer.\nIncluding GPT-J, LLaMA, and MPT. Tested on a \u003ca\nhref=\"https://gpt4all.io/index.html\"\u003eGPT4ALL\u003c/a\u003e model.\n\u003cstrong\u003eLLamaGPT-Chat\u003c/strong\u003e is a command line chat program for models\nwritten in C++.\u003c/td\u003e\n\u003ctd style=\"text-align: center;\"\u003e\u003ca\nhref=\"https://mlverse.github.io/chattr/articles/backend-llamagpt.html\"\u003eInteract\nwith local models\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"odd\"\u003e\n\u003ctd style=\"text-align: center;\"\u003e\u003ca\nhref=\"https://docs.posit.co/ide/user/ide/guide/tools/copilot.html\"\u003eGitHub\nCopilot\u003c/a\u003e\u003c/td\u003e\n\u003ctd style=\"text-align: center;\"\u003eAI pair programmer that offers\nautocomplete-style suggestions as you code\u003c/td\u003e\n\u003ctd style=\"text-align: center;\"\u003e\u003ca\nhref=\"https://mlverse.github.io/chattr/articles/copilot-chat.html\"\u003eInteract\nwith GitHub Copilot Chat\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"even\"\u003e\n\u003ctd style=\"text-align: center;\"\u003e\u003ca\nhref=\"https://docs.databricks.com/en/machine-learning/foundation-models/index.html#databricks-foundation-model-apis\"\u003eDatabricks\u003c/a\u003e\u003c/td\u003e\n\u003ctd style=\"text-align: center;\"\u003eDBRX, Meta Llama 3 70B, and Mixtral 8x7B\nvia \u003ca\nhref=\"https://docs.databricks.com/en/machine-learning/foundation-models/index.html#pay-per-token-foundation-model-apis\"\u003eDatabricks\nfoundational model REST API\u003c/a\u003e.\u003c/td\u003e\n\u003ctd style=\"text-align: center;\"\u003e\u003ca\nhref=\"https://mlverse.github.io/chattr/articles/backend-databricks.html\"\u003eInteract\nwith Databricks foundation chat models\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n## Using\n\n### The App\n\nThe main way to use `chattr` is through the Shiny Gadget app. By\ndefault, in RStudio the app will run inside the Viewer pane. `chattr`\nwill prompt you to select the model back-end you with to use. The list\nof the actual models will depend on which of them you have a setup for.\nIf no model setup is found, it will return an error. If you receive the\nerror, please refer to the previous section to learn how to setup a\nmodel back-end in your machine. Here is an example of what the selection\nprompt will look like:\n\n``` r\nchattr::chattr_app()\n\n#\u003e ── chattr - Available models \n#\u003e \n#\u003e 1: GitHub - Copilot Chat -  (copilot) \n#\u003e 2: OpenAI - Chat Completions - gpt-3.5-turbo (gpt35) \n#\u003e 3: OpenAI - Chat Completions - gpt-4 (gpt4) \n#\u003e 4: LlamaGPT - ~/ggml-gpt4all-j-v1.3-groovy.bin (llamagpt) \n#\u003e \n#\u003e Select the number of the model you would like to use:\n```\n\nThis prompt only occurs the first time you call `chattr_app()`, or\n`chattr()`. If you close the app, and open it again, the app will use\nthe model you initially selected. The selection is set for the rest of\nyour R session, or until you manually change it. Please note that if,\nfor example, `chattr` cannot find the setup for OpenAI, then those lines\nwould not show up as options in your actual prompt.\n\nIf you wish to avoid the interactive prompt, then call `chattr_use()` to\ndesignate the model you wish to use before calling the app. You can also\nuse `chattr_use()` to change the model back-end you are interacting with\nduring your R session:\n\n``` r\nchattr_use(\"gpt35\")\nchattr_app()\n```\n\n![Screenshot of the Sniny gadget app in a dark mode RStudio\ntheme](man/figures/readme/chat1.png)\n\n\u003cbr\u003e\n\nAfter the LLM finishes its response, the `chattr` app processes all\nmarkdown code chunks. It will place three convenience buttons:\n\n-   **Copy to clipboard** - It will write the code inside the chunk to\n    your clipboard.\n\n-   **Copy to document** - It will copy-paste the code directly to where\n    the app was called from. If the app is started while working on a\n    script, `chattr` will copy the code to that same script.\n\n-   **Copy to new script** - It creates a new R script in the RStudio\n    IDE, and copies the content of the chunk directly to it. Very useful\n    when the LLM writes a Shiny app for you\n\nA lot of effort was put in to make the app’s appearance as close as\npossible to the IDE. This way it feels more integrated with your work\nspace. This includes switching the color scheme based on the current\nRStudio theme being light, or dark.\n\nThe settings screen can be accessed by clicking on the “gear” button.\nThe screen that opens will contain the following:\n\n-   Save and Open chats - This is an early experiment to allow us to\n    save and retrieve past chats. `chattr` will save the file in an RDS\n    format. The main objective of this feature, is to be able to see\n    past chats, not to continue previous conversations with the LLM.\n\n-   Prompt settings - In this section you can change the additional\n    information attached to your prompt. Including the number of max\n    data files, and data frames sent to the LLM.\n\n![Screenshot of the Sniny gadget options](man/figures/readme/chat2.png)\n\n### Additional ways to interact\n\nApart from the Shiny app, `chattr` provides two more ways to interact\nwith the LLM. For details, see: [Other\ninterfaces](https://mlverse.github.io/chattr/articles/other-interfaces.html)\n\n## How it works\n\n`chattr` enriches your request with additional instructions, name and\nstructure of data frames currently in your environment, the path for the\ndata files in your working directory. If supported by the model,\n`chattr` will include the current chat history.\n\n![Diagram that illustrates how `chattr` handles model\nrequests](man/figures/readme/chattr-diagram.png)\n\nTo see what `chattr` will send to the model, set the `preview` argument\nto `TRUE`:\n\n``` r\nlibrary(chattr)\n\ndata(mtcars)\ndata(iris)\n\nchattr_use(\"gpt4\")\n#\u003e \n#\u003e ── chattr\n#\u003e • Provider: OpenAI - Chat Completions\n#\u003e • Path/URL: https://api.openai.com/v1/chat/completions\n#\u003e • Model: gpt-4\n#\u003e • Label: GPT 4 (OpenAI)\n\nchattr(preview = TRUE)\n#\u003e \n#\u003e ── chattr ──────────────────────────────────────────────────────────────────────\n#\u003e \n#\u003e ── Preview for: Console\n#\u003e • Provider: OpenAI - Chat Completions\n#\u003e • Path/URL: https://api.openai.com/v1/chat/completions\n#\u003e • Model: gpt-4\n#\u003e • Label: GPT 4 (OpenAI)\n#\u003e • temperature: 0.01\n#\u003e • max_tokens: 1000\n#\u003e • stream: TRUE\n#\u003e \n#\u003e ── Prompt:\n#\u003e role: system\n#\u003e content: You are a helpful coding assistant\n#\u003e role: user\n#\u003e content:\n#\u003e * Use the 'Tidy Modeling with R' (https://www.tmwr.org/) book as main reference\n#\u003e * Use the 'R for Data Science' (https://r4ds.had.co.nz/) book as main reference\n#\u003e * Use tidyverse packages: readr, ggplot2, dplyr, tidyr\n#\u003e * For models, use tidymodels packages: recipes, parsnip, yardstick, workflows,\n#\u003e broom\n#\u003e * Avoid explanations unless requested by user, expecting code only\n#\u003e * For any line that is not code, prefix with a: #\n#\u003e * Keep each line of explanations to no more than 80 characters\n#\u003e * DO NOT use Markdown for the code\n#\u003e [Your future prompt goes here]\n```\n\n## Keyboard Shortcut\n\nThe best way to access `chattr`’s app is by setting up a keyboard\nshortcut for it. This package includes an RStudio Addin that gives us\ndirect access to the app, which in turn, allows a **keyboard shortcut**\nto be assigned to the addin. The name of the addin is: “Open Chat”. If\nyou are not familiar with how to assign a keyboard shortcut see the next\nsection.\n\n### How to setup the keyboard shortcut\n\n-   Select *Tools* in the top menu, and then select *Modify Keyboard\n    Shortcuts*\n\n    \u003cimg src=\"man/figures/readme/keyboard-shortcuts.png\" width=\"700\"\n    alt=\"Screenshot that shows where to find the option to modify the keyboard shortcuts\" /\u003e\n\n-   Search for the `chattr` adding by writing “open chat”, in the search\n    box\n\n    \u003cimg src=\"man/figures/readme/addin-find.png\" width=\"500\"\n    alt=\"Screenshot that shows where to input the addin search\" /\u003e\n\n-   To select a key combination for your shortcut, click on the Shortcut\n    box and then type *press* the key combination in your keyboard. In\n    my case, I chose *Ctrl+Shift+C*\n\n    \u003cimg src=\"man/figures/readme/addin-assign.png\" width=\"500\"\n    alt=\"Screenshot that shows what the interface looks like when a shortcut has been selected\" /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/mlverse.github.io%2Fchattr%2F","html_url":"https://awesome.ecosyste.ms/projects/mlverse.github.io%2Fchattr%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/mlverse.github.io%2Fchattr%2F/lists"}