{"id":13733765,"url":"https://github.com/mlverse/chattr","last_synced_at":"2025-05-15T18:11:25.027Z","repository":{"id":166904682,"uuid":"617518727","full_name":"mlverse/chattr","owner":"mlverse","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-05T19:20:52.000Z","size":12760,"stargazers_count":229,"open_issues_count":33,"forks_count":23,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-14T07:09:18.644Z","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,"zenodo":null}},"created_at":"2023-03-22T14:58:30.000Z","updated_at":"2025-05-08T13:18:21.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":254394726,"owners_count":22063984,"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":"2024-08-03T03:00:48.619Z","updated_at":"2025-05-15T18:11:25.021Z","avatar_url":"https://github.com/mlverse.png","language":"R","funding_links":[],"categories":["R","UI Components"],"sub_categories":["Chat"],"readme":"# chattr\n\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-   [Using](#using)\n    -   [Available models](#available-models)\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 RStudio and Positron. `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\nTo install the CRAN version of this package use:\n\n``` r\ninstall.packages(\"chattr\")\n```\n\nIf you wish to use the development version use:\n\n``` r\npak::pak(\"mlverse/chattr\")\n```\n\n## Using\n\nStarting with version 0.3, `chattr` integrates with LLM’s via the\n[`ellmer`](https://ellmer.tidyverse.org/) package. `ellmer` has a\ngrowing list of LLM integrations, including\n[OpenAI](https://ellmer.tidyverse.org/reference/chat_openai.html),\n[Gemini](https://ellmer.tidyverse.org/reference/chat_gemini.html),\n[Deepseek](https://ellmer.tidyverse.org/reference/chat_deepseek.html)\nand others.\n\nThere are several ways to let `chattr` know which LLM to use:\n\n-   **Pre-set an R option** - Pass the `ellmer` connection command you\n    wish to use in the `.chattr_chat` option, for example:\n    `options(.chattr_chat = ellmer::chat_claude())`. If you add that\n    code to your *.Rprofile*, `chattr` will use that as the default\n    model and settings to use every time you start an R session. Use the\n    `usethis::edit_r_profile()` command to easily edit your *.Rprofile*\n\n-   **Use an `ellmer` object** - You can pass an `ellmer` chat object\n    directly to `chattr_use()`:\n\n    ``` r\n      my_chat \u003c- ellmer::chat_claude()\n      chattr_use(my_chat)\n    ```\n\n-   **Named model** - You pass one of several pre-defined provider/model\n    setups. These setups are represented by labels set by `chattr`. At\n    this time, the combinations cover 3 providers: OpenAI, Databricks,\n    and Ollama. To use, simply pass the label to `chattr_use`. To see a\n    full list of the available pre-defined combinations and their\n    argument values see [Available models](#available-models). For\n    example, if you wish to use OpenAI’s GPT 4.1 Nano model, you simply\n    pass the corresponding label:\n\n    ``` r\n      chattr_use(\"gpt41-nano\")\n    ```\n\n-   **Select one from a menu (legacy)** - If nothing is passed to\n    `chattr_use()`, and no option is set, `chattr` will try to create\n    the `ellmer` chat for you. It will try to figure if you have\n    authentication tokens for **OpenAI**, **Databricks**, and checks if\n    **Ollama** is running on your machine. `chattr` then returns a menu\n    based on the providers it was able to find:\n\n    ``` r\n      chattr_use()\n\n      ── chattr - Available models \n      Select the number of the model you would like to use:\n\n      1: Databricks - databricks-dbrx-instruct (databricks-dbrx) \n      2: Databricks - databricks-meta-llama-3-3-70b-instruct (databricks-meta-llama31-70b) \n      3: Databricks - databricks-mixtral-8x7b-instruct (databricks-mixtral8x7b) \n      4: OpenAI - Chat Completions - gpt-4.1-mini (gpt41-mini) \n      5: OpenAI - Chat Completions - gpt-4.1-nano (gpt41-nano) \n      6: OpenAI - Chat Completions - gpt-4.1 (gpt41) \n      7: OpenAI - Chat Completions - gpt-4o (gpt4o) \n      8: Ollama - llama3.2 (ollama) \n\n\n      Selection: \n    ```\n\n### Available models\n\nFor convenience, `chattr` contains some provider/model combinations that\nyou can use by passing what is under **Use value** to `chattr_use()`:\n\n\u003c!-- models: start --\u003e\n\n\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr class=\"header\"\u003e\n\u003cth\u003eModel \u0026amp; Provider\u003c/th\u003e\n\u003cth\u003eUse value\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr class=\"odd\"\u003e\n\u003ctd\u003eDBRX (Databricks)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003edatabricks-dbrx\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"even\"\u003e\n\u003ctd\u003eMeta Llama 3.3 70B (Databricks)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003edatabricks-meta-llama31-70b\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"odd\"\u003e\n\u003ctd\u003eMixtral 8x7b (Datbricks)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003edatabricks-mixtral8x7b\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"even\"\u003e\n\u003ctd\u003eGPT 4.1 Mini (OpenAI)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003egpt41-mini\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"odd\"\u003e\n\u003ctd\u003eGPT 4.1 Nano (OpenAI)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003egpt41-nano\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"even\"\u003e\n\u003ctd\u003eGPT 4.1 (OpenAI)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003egpt41\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"odd\"\u003e\n\u003ctd\u003eGPT 4 Omni (OpenAI)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003egpt4o\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr class=\"even\"\u003e\n\u003ctd\u003eLlama 3.2 (Ollama)\u003c/td\u003e\n\u003ctd\u003e\u003ccode\u003eollama\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- 'databricks-dbrx', 'databricks-meta-llama31-70b', 'databricks-mixtral8x7b', 'gpt41-mini', 'gpt41-nano', 'gpt41', 'gpt4o', 'ollama'--\u003e\n\u003c!-- models: end --\u003e\n\nIf the provider and/or model you wish to use is not listed in the table\nabove, you can create an `ellmer` chat connection directly. And then\npass that chat object to `chattr_use()`. Here is a list of the providers\nthat are currently available in that package:\n\n\u003c!-- providers: start --\u003e\n\n-   Anthropic’s Claude:\n    [`ellmer::chat_claude()`](https://ellmer.tidyverse.org/reference/chat_claude.html)\n-   AWS Bedrock:\n    [`ellmer::chat_bedrock()`](https://ellmer.tidyverse.org/reference/chat_bedrock.html)\n-   Azure OpenAI:\n    [`ellmer::chat_azure()`](https://ellmer.tidyverse.org/reference/chat_azure.html)\n-   Databricks:\n    [`ellmer::chat_databricks()`](https://ellmer.tidyverse.org/reference/chat_databricks.html)\n-   DeepSeek:\n    [`ellmer::chat_deepseek()`](https://ellmer.tidyverse.org/reference/chat_deepseek.html)\n-   GitHub model marketplace:\n    [`ellmer::chat_github()`](https://ellmer.tidyverse.org/reference/chat_github.html)\n-   Google Gemini:\n    [`ellmer::chat_gemini()`](https://ellmer.tidyverse.org/reference/chat_gemini.html)\n-   Groq:\n    [`ellmer::chat_groq()`](https://ellmer.tidyverse.org/reference/chat_groq.html)\n-   Ollama:\n    [`ellmer::chat_ollama()`](https://ellmer.tidyverse.org/reference/chat_ollama.html)\n-   OpenAI:\n    [`ellmer::chat_openai()`](https://ellmer.tidyverse.org/reference/chat_openai.html)\n-   OpenRouter:\n    [`ellmer::chat_openrouter()`](https://ellmer.tidyverse.org/reference/chat_openrouter.html)\n-   perplexity.ai:\n    [`ellmer::chat_perplexity()`](https://ellmer.tidyverse.org/reference/chat_perplexity.html)\n-   Snowflake Cortex:\n    [`ellmer::chat_snowflake()`](https://ellmer.tidyverse.org/reference/chat_snowflake.html)\n-   VLLM:\n    [`ellmer::chat_cortex_analyst()`](https://ellmer.tidyverse.org/reference/chat_cortex_analyst.html)\n    \u003c!-- providers: end --\u003e\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.\n\n``` r\nchattr_use(\"ollama\")\nchattr_app()\n```\n\n\u003cfigure\u003e\n\u003cimg src=\"man/figures/readme/chat1.png\"\nalt=\"Screenshot of the Sniny gadget app in a dark mode RStudio theme\" /\u003e\n\u003cfigcaption aria-hidden=\"true\"\u003eScreenshot of the Sniny gadget app in a\ndark mode RStudio theme\u003c/figcaption\u003e\n\u003c/figure\u003e\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\u003cfigure\u003e\n\u003cimg src=\"man/figures/readme/chat2.png\"\nalt=\"Screenshot of the Sniny gadget options\" /\u003e\n\u003cfigcaption aria-hidden=\"true\"\u003eScreenshot of the Sniny gadget\noptions\u003c/figcaption\u003e\n\u003c/figure\u003e\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\u003cfigure\u003e\n\u003cimg src=\"man/figures/readme/chattr-diagram.png\"\nalt=\"Diagram that illustrates how chattr handles model requests\" /\u003e\n\u003cfigcaption aria-hidden=\"true\"\u003eDiagram that illustrates how\n\u003ccode\u003echattr\u003c/code\u003e handles model requests\u003c/figcaption\u003e\n\u003c/figure\u003e\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(\"gpt4o\")\n#\u003e \n#\u003e ── chattr\n#\u003e • Provider: OpenAI - Chat Completions\n#\u003e • Model: gpt-4o\n#\u003e • Label: GPT 4 Omni (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 • Model: gpt-4o\n#\u003e • Label: GPT 4 Omni (OpenAI)\n#\u003e • temperature: 0.01\n#\u003e • max_tokens: 1000\n#\u003e • stream: TRUE\n#\u003e \n#\u003e ── Prompt:\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    \u003cfigure\u003e\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    \u003cfigcaption aria-hidden=\"true\"\u003eScreenshot that shows where to find the\n    option to modify the keyboard shortcuts\u003c/figcaption\u003e\n    \u003c/figure\u003e\n\n-   Search for the `chattr` adding by writing “open chat”, in the search\n    box\n\n    \u003cfigure\u003e\n    \u003cimg src=\"man/figures/readme/addin-find.png\" width=\"500\"\n    alt=\"Screenshot that shows where to input the addin search\" /\u003e\n    \u003cfigcaption aria-hidden=\"true\"\u003eScreenshot that shows where to input the\n    addin search\u003c/figcaption\u003e\n    \u003c/figure\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    \u003cfigure\u003e\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    \u003cfigcaption aria-hidden=\"true\"\u003eScreenshot that shows what the interface\n    looks like when a shortcut has been selected\u003c/figcaption\u003e\n    \u003c/figure\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlverse%2Fchattr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlverse%2Fchattr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlverse%2Fchattr/lists"}