$ show MichelNivard/gptstudio
gptstudio is an R package that integrates Large Language Models (LLMs) directly into the RStudio development environment. It functions as both a standalone Shiny application and a suite of RStudio add-ins. The core architecture relies on the {ellmer} package for LLM interactions, abstracting various providers (OpenAI, Anthropic, HuggingFace, etc.) through a unified S3 interface. Key features include a chat interface with conversation history, code commenting, and spelling/grammar checking add-ins. The package demonstrates strong engineering practices with comprehensive testing (shinytest2, testthat), modern UI theming (bslib), and support for streaming responses and audio input. It effectively bridges the gap between RStudio's IDE capabilities and external AI services.
The LLM identified 4 files worth highlighting for reuse:
Implements the core request dispatching logic using ellmer_chat S3 methods. It handles streaming via coro::loop and Shiny sessions, providing a reusable pattern for integrating different LLM providers through a unified interface.
Implements a feature to parse package::function calls in prompts and fetch R documentation (rvest, utils::help) to provide context to the LLM. This is a clever, domain-specific feature for R developers.
Implements a custom Shiny input binding for audio recording (input_audio_clip). This involves custom JavaScript (inst/assets/js/audio-recorder.js) and HTML widgets, demonstrating non-trivial integration of browser media APIs into Shiny.
Contains style_chat_history and style_chat_message. It handles the UI rendering of chat bubbles, including dynamic theming based on the RStudio IDE theme (dark/light mode). This is a high-quality UI component that adapts to the environment.