| Title: | R Integration for 'Goose' AI |
|---|---|
| Description: | Seamless integration between R and 'Goose' AI capabilities including memory management, visualization enhancements, and workflow automation. Save R objects to 'Goose' memory, apply Block branding to visualizations, and manage data science project workflows. For more information about 'Goose' AI, see <https://github.com/block/goose>. |
| Authors: | Brandon Theriault [aut, cre] |
| Maintainer: | Brandon Theriault <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2 |
| Built: | 2026-06-06 08:40:48 UTC |
| Source: | https://github.com/blockbtheriault/gooser |
Generate CSS from brand configuration
brand_css(brand = "block", output_file = NULL, minify = FALSE)brand_css(brand = "block", output_file = NULL, minify = FALSE)
brand |
Name of the brand |
output_file |
Path to save CSS file (NULL to return as string) |
minify |
Minify the CSS output (default: FALSE) |
CSS content as string (invisibly if saved to file)
## Not run: # Save to file in temp directory temp_file <- file.path(tempdir(), "block.css") brand_css("block", temp_file) # Get as string css <- brand_css("block") ## End(Not run)## Not run: # Save to file in temp directory temp_file <- file.path(tempdir(), "block.css") brand_css("block", temp_file) # Get as string css <- brand_css("block") ## End(Not run)
Get brand color palette
brand_palette(brand = "block", palette = "categorical", n = NULL)brand_palette(brand = "block", palette = "categorical", n = NULL)
brand |
Name of the brand |
palette |
Type of palette ("categorical", "sequential", "diverging") |
n |
Number of colors to return (NULL for all) |
Character vector of hex colors
## Not run: colors <- brand_palette("block", "categorical") ## End(Not run)## Not run: colors <- brand_palette("block", "categorical") ## End(Not run)
Generate RMarkdown template with brand styling
brand_rmd_template( brand = "block", title = "Report", output_format = "html_document", output_file = NULL )brand_rmd_template( brand = "block", title = "Report", output_format = "html_document", output_file = NULL )
brand |
Name of the brand |
title |
Document title |
output_format |
RMarkdown output format (default: "html_document") |
output_file |
Path to save template (NULL to return as string) |
RMarkdown template content
## Not run: # Create branded RMarkdown template in temp directory temp_file <- file.path(tempdir(), "report.Rmd") brand_rmd_template("block", "My Report", output_file = temp_file) ## End(Not run)## Not run: # Create branded RMarkdown template in temp directory temp_file <- file.path(tempdir(), "report.Rmd") brand_rmd_template("block", "My Report", output_file = temp_file) ## End(Not run)
Format AI response text for better display in R console
format_ai_response( text, width = 80, indent = 0, preserve_code = TRUE, color = TRUE )format_ai_response( text, width = 80, indent = 0, preserve_code = TRUE, color = TRUE )
text |
Character string with AI response |
width |
Integer, line width for wrapping (default 80) |
indent |
Integer, spaces to indent wrapped lines (default 0) |
preserve_code |
Logical, whether to preserve code blocks (default TRUE) |
color |
Logical, whether to use color output (default TRUE) |
Formatted text (invisibly), printed to console
Format and display a gooseR conversation
format_conversation(messages, show_dividers = TRUE)format_conversation(messages, show_dividers = TRUE)
messages |
List of messages (question/response pairs) |
show_dividers |
Logical, show dividers between messages |
Interactive chat interface for AI conversations
goose_addin_chat()goose_addin_chat()
Quick question to Goose (non-interactive)
goose_addin_quick()goose_addin_quick()
Review selected code with AI
goose_addin_review()goose_addin_review()
Generate and insert code snippets
goose_addin_snippet()goose_addin_snippet()
Visual interface for creating prompt templates
goose_addin_template()goose_addin_template()
Send a query to Goose AI and get a beautifully formatted response. This is an enhanced version of goose_ask that formats the output by default.
goose_ask( prompt, format = getOption("goose.auto_format", TRUE), output_format = c("text", "json"), quiet = TRUE, timeout = getOption("goose.timeout", 300), retries = getOption("goose.retries", 1), session_id = NULL, width = getOption("goose.format_width", 80), color = getOption("goose.format_color", TRUE), ... )goose_ask( prompt, format = getOption("goose.auto_format", TRUE), output_format = c("text", "json"), quiet = TRUE, timeout = getOption("goose.timeout", 300), retries = getOption("goose.retries", 1), session_id = NULL, width = getOption("goose.format_width", 80), color = getOption("goose.format_color", TRUE), ... )
prompt |
Character string with the question or prompt |
format |
Logical, whether to format the response (default TRUE) |
output_format |
Character, either "text" or "json" |
quiet |
Logical, suppress status messages |
timeout |
Numeric, timeout in seconds (default 300, i.e., 5 minutes). Complex queries may take longer. Set to Inf for no timeout. |
retries |
Integer, number of retries after the first attempt (default uses
|
session_id |
Optional session ID for context preservation |
width |
Integer, line width for wrapping (default 80) |
color |
Logical, whether to use color output (default TRUE) |
... |
Additional formatting arguments |
If format=TRUE and output_format="text", displays formatted response and returns raw text invisibly. If format=FALSE or output_format="json", returns the raw response.
## Not run: # Get a beautifully formatted response (default) goose_ask("What is the tidyverse?") # Get raw unformatted response raw <- goose_ask("What is R?", format = FALSE) # Get JSON response (never formatted) data <- goose_ask("List 5 R packages", output_format = "json") # Customize formatting goose_ask("Explain ggplot2", width = 100, color = FALSE) # For very complex queries, increase timeout goose_ask("Write a complete Shiny app", timeout = 600) ## End(Not run)## Not run: # Get a beautifully formatted response (default) goose_ask("What is the tidyverse?") # Get raw unformatted response raw <- goose_ask("What is R?", format = FALSE) # Get JSON response (never formatted) data <- goose_ask("List 5 R packages", output_format = "json") # Customize formatting goose_ask("Explain ggplot2", width = 100, color = FALSE) # For very complex queries, increase timeout goose_ask("Write a complete Shiny app", timeout = 600) ## End(Not run)
This is the original goose_ask function without formatting. Use this if you need the raw behavior.
goose_ask_raw( prompt, output_format = c("text", "json"), quiet = TRUE, timeout = getOption("goose.timeout", 300), retries = getOption("goose.retries", 1), session_id = NULL )goose_ask_raw( prompt, output_format = c("text", "json"), quiet = TRUE, timeout = getOption("goose.timeout", 300), retries = getOption("goose.retries", 1), session_id = NULL )
prompt |
Character string with the question or prompt |
output_format |
Character, either "text" or "json" |
quiet |
Logical, suppress status messages |
timeout |
Numeric, timeout in seconds (default 300, i.e., 5 minutes). Complex queries may take longer. Set to Inf for no timeout. |
retries |
Integer, number of retries after the first attempt (default uses
|
session_id |
Optional session ID for context preservation |
Character string with response (text format) or list (json format)
Provides asynchronous and parallel query execution
Run a query in the background and return a promise
goose_async(query, session_id = NULL)goose_async(query, session_id = NULL)
query |
The query to execute |
session_id |
Optional session ID |
A promise that resolves to the response
## Not run: library(promises) # Single async query goose_async("Explain async programming") %...>% { cat("Response:", .) } # Chain multiple async operations goose_async("Write a function") %...>% { goose_async(paste("Optimize this:", .)) } %...>% { cat("Optimized:", .) } ## End(Not run)## Not run: library(promises) # Single async query goose_async("Explain async programming") %...>% { cat("Response:", .) } # Chain multiple async operations goose_async("Write a function") %...>% { goose_async(paste("Optimize this:", .)) } %...>% { cat("Optimized:", .) } ## End(Not run)
Execute query with automatic retry on failure
goose_async_retry(query, max_retries = 3, retry_delay = 2)goose_async_retry(query, max_retries = 3, retry_delay = 2)
query |
The query to execute |
max_retries |
Maximum number of retries |
retry_delay |
Delay between retries in seconds |
Response or error
Execute query with timeout protection
goose_async_timeout(query, timeout = getOption("goose.timeout", 300))goose_async_timeout(query, timeout = getOption("goose.timeout", 300))
query |
The query to execute |
timeout |
Timeout in seconds (default from goose.timeout option, or 300) |
Response or timeout error
Create a backup of all gooseR memory
goose_backup(backup_dir = "goose_backup", timestamp = TRUE)goose_backup(backup_dir = "goose_backup", timestamp = TRUE)
backup_dir |
Character, directory to save backup |
timestamp |
Logical, whether to add timestamp to backup files |
Invisible integer count of backed up items
## Not run: # Create backup with timestamp goose_backup() # Create backup in specific directory goose_backup("my_backups") ## End(Not run)## Not run: # Create backup with timestamp goose_backup() # Create backup in specific directory goose_backup("my_backups") ## End(Not run)
Run multiple queries simultaneously
goose_batch(queries, max_workers = 4, progress = TRUE, cache = TRUE)goose_batch(queries, max_workers = 4, progress = TRUE, cache = TRUE)
queries |
Vector or list of queries |
max_workers |
Maximum number of parallel workers |
progress |
Show progress bar |
cache |
Use caching for responses |
List of responses
## Not run: queries <- c( "Explain R functions", "Write a data analysis script", "Create a visualization" ) results <- goose_batch(queries, max_workers = 3) ## End(Not run)## Not run: queries <- c( "Explain R functions", "Write a data analysis script", "Create a visualization" ) results <- goose_batch(queries, max_workers = 3) ## End(Not run)
Process a file of queries in parallel
goose_batch_file(file, output_file = NULL, max_workers = 4)goose_batch_file(file, output_file = NULL, max_workers = 4)
file |
Path to file with queries (one per line) |
output_file |
Optional output file for results |
max_workers |
Maximum parallel workers |
List of results
Provides intelligent caching of AI responses for performance
Requires Suggests: RSQLite. Functions in this module check for RSQLite availability at runtime.
Clear cache entries based on criteria
goose_cache_clear(older_than = NULL, pattern = NULL, all = FALSE, conn = NULL)goose_cache_clear(older_than = NULL, pattern = NULL, all = FALSE, conn = NULL)
older_than |
Clear entries older than this (seconds) |
pattern |
Clear entries matching this pattern |
all |
Clear all entries |
conn |
Database connection |
Number of entries cleared
Export cache to file for backup or sharing
goose_cache_export(file, format = "json", conn = NULL)goose_cache_export(file, format = "json", conn = NULL)
file |
Path to export file |
format |
Export format (json, csv, rds) |
conn |
Database connection |
Number of entries exported
Retrieve a cached response for a query
goose_cache_get(query, model = NULL, max_age = NULL, conn = NULL)goose_cache_get(query, model = NULL, max_age = NULL, conn = NULL)
query |
The query text |
model |
Optional model identifier |
max_age |
Maximum age in seconds (NULL for no limit) |
conn |
Database connection |
Response text or NULL if not found
Import cache from file
goose_cache_import(file, format = "json", conn = NULL)goose_cache_import(file, format = "json", conn = NULL)
file |
Path to import file |
format |
Import format (json, csv, rds) |
conn |
Database connection |
Number of entries imported
Create or connect to the cache database
goose_cache_init(cache_dir = NULL)goose_cache_init(cache_dir = NULL)
cache_dir |
Directory for cache database (default: tempdir() for CRAN compliance) |
DBI connection object
## Not run: # Initialize cache in temp directory (CRAN compliant) conn <- goose_cache_init() # Or specify custom directory conn <- goose_cache_init(cache_dir = tempdir()) ## End(Not run)## Not run: # Initialize cache in temp directory (CRAN compliant) conn <- goose_cache_init() # Or specify custom directory conn <- goose_cache_init(cache_dir = tempdir()) ## End(Not run)
Store a query-response pair in the cache
goose_cache_set(query, response, model = NULL, metadata = NULL, conn = NULL)goose_cache_set(query, response, model = NULL, metadata = NULL, conn = NULL)
query |
The query text |
response |
The response text |
model |
Optional model identifier |
metadata |
Optional metadata as list |
conn |
Database connection (auto-created if NULL) |
Logical indicating success
Get statistics about cache usage
goose_cache_stats(conn = NULL)goose_cache_stats(conn = NULL)
conn |
Database connection |
List of cache statistics
Visual interface for browsing and managing cache
goose_cache_ui()goose_cache_ui()
Pre-populate cache with common queries
goose_cache_warmup(queries, parallel = FALSE)goose_cache_warmup(queries, parallel = FALSE)
queries |
Vector of queries to cache |
parallel |
Execute in parallel |
Number of queries cached
Execute query with automatic caching
goose_cached(query, use_cache = TRUE, max_age = 86400, force_refresh = FALSE)goose_cached(query, use_cache = TRUE, max_age = 86400, force_refresh = FALSE)
query |
The query to execute |
use_cache |
Whether to use cache |
max_age |
Maximum cache age in seconds |
force_refresh |
Force new execution |
Query response
Check Goose CLI Installation
goose_check_installation()goose_check_installation()
Logical, TRUE if Goose CLI is installed
Removes formatting artifacts and returns clean text for copying
goose_clean_text(text, preserve_markdown = TRUE)goose_clean_text(text, preserve_markdown = TRUE)
text |
Character string with formatted text |
preserve_markdown |
Logical, keep markdown formatting (default TRUE) |
Clean text suitable for copying
## Not run: response <- goose_ask("What is R?") # Copy-friendly version: clean <- goose_clean_text(response) cat(clean) ## End(Not run)## Not run: response <- goose_ask("What is R?") # Copy-friendly version: clean <- goose_clean_text(response) cat(clean) ## End(Not run)
Clear all gooseR memory
goose_clear_all( confirm = TRUE, backup_first = FALSE, backup_dir = "goose_backup" )goose_clear_all( confirm = TRUE, backup_first = FALSE, backup_dir = "goose_backup" )
confirm |
Logical, whether to ask for confirmation (default TRUE) |
backup_first |
Logical, whether to create backup before clearing |
backup_dir |
Character, directory for backup if backup_first is TRUE |
Invisible integer count of deleted items
## Not run: # Clear all memory with confirmation goose_clear_all() # Clear with backup goose_clear_all(backup_first = TRUE) ## End(Not run)## Not run: # Clear all memory with confirmation goose_clear_all() # Clear with backup goose_clear_all(backup_first = TRUE) ## End(Not run)
Clear all items in a category
goose_clear_category(category, confirm = TRUE, verbose = TRUE)goose_clear_category(category, confirm = TRUE, verbose = TRUE)
category |
Character string specifying the category to clear |
confirm |
Logical, whether to ask for confirmation (default TRUE) |
verbose |
Logical, whether to print progress messages |
Invisible integer count of deleted items
## Not run: # Clear all items in "temp" category goose_clear_category("temp") # Clear without confirmation goose_clear_category("temp", confirm = FALSE) ## End(Not run)## Not run: # Clear all items in "temp" category goose_clear_category("temp") # Clear without confirmation goose_clear_category("temp", confirm = FALSE) ## End(Not run)
Clear all items with specified tags
goose_clear_tags(tags, confirm = TRUE, verbose = TRUE)goose_clear_tags(tags, confirm = TRUE, verbose = TRUE)
tags |
Character vector of tags |
confirm |
Logical, whether to ask for confirmation (default TRUE) |
verbose |
Logical, whether to print progress messages |
Invisible integer count of deleted items
## Not run: # Clear all items tagged as "test" goose_clear_tags("test") # Clear multiple tags goose_clear_tags(c("test", "temp", "draft")) ## End(Not run)## Not run: # Clear all items tagged as "test" goose_clear_tags("test") # Clear multiple tags goose_clear_tags(c("test", "temp", "draft")) ## End(Not run)
Set up Goose CLI configuration. Note: If Goose CLI is already configured (e.g., for Block employees), this function is not needed. The package will use the existing CLI configuration automatically.
goose_configure( provider = NULL, model = NULL, api_key = NULL, save_to_renviron = FALSE, check_cli_first = TRUE )goose_configure( provider = NULL, model = NULL, api_key = NULL, save_to_renviron = FALSE, check_cli_first = TRUE )
provider |
Character string specifying the AI provider (e.g., "openai", "anthropic") |
model |
Character string specifying the model (e.g., "gpt-4", "claude-3") |
api_key |
Character string with the API key (stored securely) |
save_to_renviron |
Logical, whether to save to .Renviron file |
check_cli_first |
Logical, check if CLI already works before configuring (default TRUE) |
Invisible TRUE if successful
## Not run: # For Block employees with configured CLI, just check: goose_test_cli() # For external users who need API keys: goose_configure(provider = "openai", model = "gpt-4", api_key = "your-key") ## End(Not run)## Not run: # For Block employees with configured CLI, just check: goose_test_cli() # For external users who need API keys: goose_configure(provider = "openai", model = "gpt-4", api_key = "your-key") ## End(Not run)
Reviews current work and generates a comprehensive continuation prompt with progress tracking, file mapping, and next steps for seamless handoff to the next working session.
goose_continuation_prompt( path = ".", include_files = TRUE, include_todos = TRUE, save_to = NULL )goose_continuation_prompt( path = ".", include_files = TRUE, include_todos = TRUE, save_to = NULL )
path |
Path to review (default: current working directory) |
include_files |
Whether to include file listing (default: TRUE) |
include_todos |
Whether to scan for TODO comments (default: TRUE) |
save_to |
Path to save the continuation prompt (auto-generated if NULL) |
Path to the saved continuation prompt
## Not run: # Generate continuation prompt for current project goose_continuation_prompt() # Generate without file listing goose_continuation_prompt(include_files = FALSE) # Save to specific location goose_continuation_prompt(save_to = "project_docs/continuation.md") ## End(Not run)## Not run: # Generate continuation prompt for current project goose_continuation_prompt() # Generate without file listing goose_continuation_prompt(include_files = FALSE) # Save to specific location goose_continuation_prompt(save_to = "project_docs/continuation.md") ## End(Not run)
Manage and replay AI conversation sessions
goose_conversation_ui()goose_conversation_ui()
Create a new brand configuration interactively
goose_create_brand(brand_name = NULL, template = "default", interactive = TRUE)goose_create_brand(brand_name = NULL, template = "default", interactive = TRUE)
brand_name |
Name for the new brand |
template |
Template to use (default: "default") |
interactive |
Use interactive prompts (default: TRUE) |
Path to created brand configuration
## Not run: goose_create_brand("my_company") ## End(Not run)## Not run: goose_create_brand("my_company") ## End(Not run)
Enhanced brand creation with AI-powered suggestions for colors and typography.
goose_create_brand_ai( brand_name, industry = NULL, style = NULL, use_ai = TRUE, output_dir = NULL )goose_create_brand_ai( brand_name, industry = NULL, style = NULL, use_ai = TRUE, output_dir = NULL )
brand_name |
Name of the brand |
industry |
Optional industry context for better suggestions |
style |
Optional style preference (e.g., "modern", "classic", "playful") |
use_ai |
Whether to use AI for suggestions (requires goose_ask) |
output_dir |
Directory to save brand configuration |
Path to created brand configuration
## Not run: # Create brand with AI assistance goose_create_brand_ai("TechStartup", industry = "fintech", style = "modern") ## End(Not run)## Not run: # Create brand with AI assistance goose_create_brand_ai("TechStartup", industry = "fintech", style = "modern") ## End(Not run)
Generate a complete Quarto document with AI assistance
goose_create_quarto( title, author = Sys.info()["user"], outline, format = "html", output_file = NULL )goose_create_quarto( title, author = Sys.info()["user"], outline, format = "html", output_file = NULL )
title |
Document title |
author |
Document author |
outline |
Topic outline or description |
format |
Output format (html, pdf, docx) |
output_file |
Output file path |
Path to created document
Generate a complete RMarkdown report
goose_create_report( title, data = NULL, analysis_type = "exploratory", output_file = NULL )goose_create_report( title, data = NULL, analysis_type = "exploratory", output_file = NULL )
title |
Report title |
data |
Data frame to analyze |
analysis_type |
Type of analysis |
output_file |
Output file path |
Path to created report
Generate a parameterized Quarto/RMarkdown template
goose_create_template( type = "analysis", parameters = list(), output_file = NULL )goose_create_template( type = "analysis", parameters = list(), output_file = NULL )
type |
Report type (analysis, dashboard, presentation) |
parameters |
List of parameters |
output_file |
Output file path |
Path to template file
Remove a saved R object from Goose's memory system.
goose_delete(name, category = "r_objects", global = TRUE, confirm = TRUE)goose_delete(name, category = "r_objects", global = TRUE, confirm = TRUE)
name |
Character string. Name of the object to delete |
category |
Character string. Category where the object was saved (default: "r_objects") |
global |
Logical. If TRUE (default), deletes from global memory. If FALSE, deletes from project-local memory. |
confirm |
Logical. If TRUE (default), asks for confirmation before deleting. |
Invisibly returns TRUE if successful
## Not run: # Delete an object goose_delete("old_model", category = "models") # Delete without confirmation goose_delete("temp_data", confirm = FALSE) ## End(Not run)## Not run: # Delete an object goose_delete("old_model", category = "models") # Delete without confirmation goose_delete("temp_data", confirm = FALSE) ## End(Not run)
Create a markdown-style divider
goose_divider(char = "-", width = 60)goose_divider(char = "-", width = 60)
char |
Character to use for divider |
width |
Width of divider |
Generate roxygen2 documentation for R functions.
goose_document(func, style = "roxygen2", examples = TRUE)goose_document(func, style = "roxygen2", examples = TRUE)
func |
Function object or function name |
style |
Character, documentation style ("roxygen2", "detailed", "minimal") |
examples |
Logical, whether to generate examples |
Character string with documentation
## Not run: my_func <- function(x, y, method = "pearson") { cor(x, y, method = method) } docs <- goose_document(my_func) cat(docs) ## End(Not run)## Not run: my_func <- function(x, y, method = "pearson") { cor(x, y, method = method) } docs <- goose_document(my_func) cat(docs) ## End(Not run)
Check if an item exists in gooseR memory
goose_exists(name, category = NULL)goose_exists(name, category = NULL)
name |
Character string, name of the item |
category |
Character string, category of the item (optional) |
Logical, TRUE if item exists
## Not run: if (goose_exists("my_data", "analysis")) { data <- goose_load("my_data", "analysis") } ## End(Not run)## Not run: if (goose_exists("my_data", "analysis")) { data <- goose_load("my_data", "analysis") } ## End(Not run)
Get AI-powered explanation and solution for R errors.
goose_explain_error(error = NULL, code = NULL, context = NULL)goose_explain_error(error = NULL, code = NULL, context = NULL)
error |
The error object or error message |
code |
Optional code that caused the error |
context |
Optional context about what you were trying to do |
List with explanation and suggested solutions
## Not run: # Explain last error tryCatch({ data.frame(x = 1:3, y = 1:4) }, error = function(e) { explanation <- goose_explain_error(e) print(explanation) }) ## End(Not run)## Not run: # Explain last error tryCatch({ data.frame(x = 1:3, y = 1:4) }, error = function(e) { explanation <- goose_explain_error(e) print(explanation) }) ## End(Not run)
Set global formatting options for gooseR
goose_format_options( auto_format = TRUE, width = 80, color = TRUE, code_highlight = TRUE )goose_format_options( auto_format = TRUE, width = 80, color = TRUE, code_highlight = TRUE )
auto_format |
Logical, automatically format all AI responses |
width |
Line width for text wrapping |
color |
Use colored output |
code_highlight |
Highlight code blocks |
## Not run: # Enable auto-formatting for all AI responses goose_format_options(auto_format = TRUE, width = 100) # Disable colors for plain text output goose_format_options(color = FALSE) ## End(Not run)## Not run: # Enable auto-formatting for all AI responses goose_format_options(auto_format = TRUE, width = 100) # Disable colors for plain text output goose_format_options(color = FALSE) ## End(Not run)
Generate testthat unit tests for R functions.
goose_generate_tests(func, test_cases = 5, edge_cases = TRUE)goose_generate_tests(func, test_cases = 5, edge_cases = TRUE)
func |
Function object to test |
test_cases |
Number of test cases to generate |
edge_cases |
Logical, include edge case tests |
Character string with testthat code
Get Current Goose Configuration
goose_get_config()goose_get_config()
List with provider, model, and api_key status
Captures the structure and sample values of an R object and saves it in a format that Goose can understand and reference when providing code. This enables Goose to write accurate code that references actual column names and understands data types.
goose_give_sample(object, name = NULL, rows = 5, save_to_memory = TRUE)goose_give_sample(object, name = NULL, rows = 5, save_to_memory = TRUE)
object |
An R object (data.frame, matrix, tibble, list, etc.) |
name |
Optional custom name for the object. Defaults to the object's name. |
rows |
Number of sample rows to include (default: 5) |
save_to_memory |
Whether to save to Goose memory (default: TRUE) |
Invisible NULL. Prints object summary and saves to memory.
## Not run: # Share a data frame with Goose goose_give_sample(mtcars) # Share with custom name goose_give_sample(iris, "flower_data") # Share just structure without saving goose_give_sample(my_model, save_to_memory = FALSE) ## End(Not run)## Not run: # Share a data frame with Goose goose_give_sample(mtcars) # Share with custom name goose_give_sample(iris, "flower_data") # Share just structure without saving goose_give_sample(my_model, save_to_memory = FALSE) ## End(Not run)
Analyzes your actual code and data to provide tailored suggestions and challenges. Reads R scripts, RMarkdown files, and available data objects to give specific, contextual feedback rather than generic advice.
goose_honk(path = ".", focus = NULL, severity = "moderate")goose_honk(path = ".", focus = NULL, severity = "moderate")
path |
Path to script, RMarkdown file, or directory (default: current working directory) |
focus |
Area to focus review on: "statistics", "visualization", "performance", "methodology", NULL for comprehensive |
severity |
Level of critique:
|
List containing review comments, specific code issues, and tailored suggestions
## Not run: # Review current directory with moderate critique goose_honk() # Review specific script with gentle feedback goose_honk("analysis.R", severity = "gentle") # Focus on statistics with harsh critique goose_honk(focus = "statistics", severity = "harsh") # Get brutal honesty about your visualization code goose_honk(focus = "visualization", severity = "brutal") ## End(Not run)## Not run: # Review current directory with moderate critique goose_honk() # Review specific script with gentle feedback goose_honk("analysis.R", severity = "gentle") # Focus on statistics with harsh critique goose_honk(focus = "statistics", severity = "harsh") # Get brutal honesty about your visualization code goose_honk(focus = "visualization", severity = "brutal") ## End(Not run)
Interactive function to insert AI chunk at cursor
goose_insert_chunk()goose_insert_chunk()
List all R objects saved in Goose memory, optionally filtered by category or tags.
goose_list(category = NULL, tags = NULL, global = TRUE)goose_list(category = NULL, tags = NULL, global = TRUE)
category |
Character string. Filter by category (default: NULL shows all) |
tags |
Character vector. Filter by tags (default: NULL shows all) |
global |
Logical. If TRUE (default), lists global memory. If FALSE, lists project-local memory. |
A data.frame with information about saved objects
## Not run: # List all saved objects goose_list() # List objects in a specific category goose_list(category = "models") # List objects with specific tags goose_list(tags = "production") ## End(Not run)## Not run: # List all saved objects goose_list() # List objects in a specific category goose_list(category = "models") # List objects with specific tags goose_list(tags = "production") ## End(Not run)
Retrieve a previously saved R object from Goose's memory system.
goose_load(name, category = "r_objects", global = TRUE)goose_load(name, category = "r_objects", global = TRUE)
name |
Character string. Name of the object to load |
category |
Character string. Category where the object was saved (default: "r_objects") |
global |
Logical. If TRUE (default), loads from global memory. If FALSE, loads from project-local memory. |
The R object that was saved
## Not run: # Load a previously saved model model <- goose_load("mtcars_model", category = "models") # Load a dataset data <- goose_load("iris_data", category = "datasets") ## End(Not run)## Not run: # Load a previously saved model model <- goose_load("mtcars_model", category = "models") # Load a dataset data <- goose_load("iris_data", category = "datasets") ## End(Not run)
Takes a script or code block and converts it to an efficient loop structure based on the specified iteration requirements.
goose_loop_me(code, loop_over, iterator_name = "i", parallel = FALSE)goose_loop_me(code, loop_over, iterator_name = "i", parallel = FALSE)
code |
Character string or file path containing the code to loop |
loop_over |
What to loop over (e.g., "files", "columns", "rows", "list elements") |
iterator_name |
Name for the loop variable (default: "i") |
parallel |
Whether to use parallel processing (default: FALSE) |
Modified code with loop structure
## Not run: # Convert file processing to loop code <- "data <- read.csv('file.csv')\nsummary(data)" goose_loop_me(code, loop_over = "files") # Create parallel loop goose_loop_me("process_data(df)", loop_over = "datasets", parallel = TRUE) ## End(Not run)## Not run: # Convert file processing to loop code <- "data <- read.csv('file.csv')\nsummary(data)" goose_loop_me(code, loop_over = "files") # Create parallel loop goose_loop_me("process_data(df)", loop_over = "datasets", parallel = TRUE) ## End(Not run)
Reviews all objects shared in the current session and generates a comprehensive, phased analysis plan with specific recommendations.
goose_make_a_plan(focus = NULL, output_format = "console")goose_make_a_plan(focus = NULL, output_format = "console")
focus |
Optional focus area: "exploratory", "predictive", "descriptive", "diagnostic" |
output_format |
Format for the plan: "console", "markdown", "html" |
Analysis plan as text or formatted output
## Not run: # Generate comprehensive plan goose_make_a_plan() # Focus on predictive modeling goose_make_a_plan(focus = "predictive") # Save plan as markdown goose_make_a_plan(output_format = "markdown") ## End(Not run)## Not run: # Generate comprehensive plan goose_make_a_plan() # Focus on predictive modeling goose_make_a_plan(focus = "predictive") # Save plan as markdown goose_make_a_plan(output_format = "markdown") ## End(Not run)
Apply an AI query to each element of a dataset
goose_map(data, query_template, max_workers = 4)goose_map(data, query_template, max_workers = 4)
data |
Vector or list of data elements |
query_template |
Query template with {x} placeholder |
max_workers |
Maximum parallel workers |
List of AI responses
## Not run: # Analyze multiple code snippets code_snippets <- c("function(x) x^2", "for(i in 1:10) print(i)") reviews <- goose_map(code_snippets, "Review this R code: {x}") ## End(Not run)## Not run: # Analyze multiple code snippets code_snippets <- c("function(x) x^2", "for(i in 1:10) print(i)") reviews <- goose_map(code_snippets, "Review this R code: {x}") ## End(Not run)
Map-reduce pattern for AI processing
goose_mapreduce(data, map_query, reduce_query, max_workers = 4)goose_mapreduce(data, map_query, reduce_query, max_workers = 4)
data |
Input data |
map_query |
Query template for mapping |
reduce_query |
Query for reduction |
max_workers |
Maximum parallel workers |
Reduced result
Get AI suggestions to improve an existing brand palette.
goose_optimize_palette( brand, goals = c("accessibility", "harmony", "contrast"), constraints = NULL )goose_optimize_palette( brand, goals = c("accessibility", "harmony", "contrast"), constraints = NULL )
brand |
Name of the brand to optimize |
goals |
Character vector of optimization goals |
constraints |
Optional constraints (e.g., "keep primary color") |
List with original and optimized palettes
Get AI suggestions to improve a ggplot2 visualization.
goose_optimize_plot( plot_code, goals = c("aesthetics", "clarity", "accessibility"), data_sample = NULL )goose_optimize_plot( plot_code, goals = c("aesthetics", "clarity", "accessibility"), data_sample = NULL )
plot_code |
Character string or expression with ggplot2 code |
goals |
Character vector of optimization goals |
data_sample |
Optional sample of the data being plotted |
List with optimized code and suggestions
## Not run: plot_code <- " ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() " optimized <- goose_optimize_plot(plot_code, goals = c("aesthetics", "clarity")) ## End(Not run)## Not run: plot_code <- " ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() " optimized <- goose_optimize_plot(plot_code, goals = c("aesthetics", "clarity")) ## End(Not run)
Chain multiple async operations together
goose_pipeline(...)goose_pipeline(...)
... |
Query functions or strings |
A promise chain
## Not run: goose_pipeline( "Write a data analysis function", ~ paste("Add error handling to:", .), ~ paste("Add documentation to:", .), ~ paste("Create tests for:", .) ) %...>% { cat("Final result:", .) } ## End(Not run)## Not run: goose_pipeline( "Write a data analysis function", ~ paste("Add error handling to:", .), ~ paste("Add documentation to:", .), ~ paste("Create tests for:", .) ) %...>% { cat("Final result:", .) } ## End(Not run)
Generate a Quarto chunk that executes AI queries
goose_quarto_chunk( prompt, label = NULL, echo = FALSE, eval = TRUE, cache = TRUE )goose_quarto_chunk( prompt, label = NULL, echo = FALSE, eval = TRUE, cache = TRUE )
prompt |
The AI prompt to execute |
label |
Optional chunk label |
echo |
Whether to show the prompt in output |
eval |
Whether to evaluate the chunk |
cache |
Whether to cache the result |
Quarto chunk text
## Not run: # In a Quarto document goose_quarto_chunk("Explain linear regression", label = "explain-lm") ## End(Not run)## Not run: # In a Quarto document goose_quarto_chunk("Explain linear regression", label = "explain-lm") ## End(Not run)
Send a query to Goose while maintaining session context.
goose_query(prompt, session = NULL, ...)goose_query(prompt, session = NULL, ...)
prompt |
Character string with the query |
session |
Goose session object or session ID |
... |
Additional arguments passed to goose_ask |
Query response
Run a Goose recipe with parameters.
goose_recipe( recipe, params = list(), explain = FALSE, render = FALSE, timeout = getOption("goose.timeout", 300), retries = getOption("goose.retries", 1) )goose_recipe( recipe, params = list(), explain = FALSE, render = FALSE, timeout = getOption("goose.timeout", 300), retries = getOption("goose.retries", 1) )
recipe |
Character, recipe name or path to recipe file |
params |
Named list of parameters to pass to recipe |
explain |
Logical, show recipe explanation instead of running |
render |
Logical, render recipe instead of running |
timeout |
Numeric, timeout in seconds (default uses |
retries |
Integer, number of retries after the first attempt (default uses
|
Recipe output or explanation
Combine multiple results using AI
goose_reduce(results, reduce_prompt = "Summarize these results:")goose_reduce(results, reduce_prompt = "Summarize these results:")
results |
List of results to combine |
reduce_prompt |
Prompt for reduction |
Combined result
Rename an item in gooseR memory
goose_rename(old_name, new_name, category = "general")goose_rename(old_name, new_name, category = "general")
old_name |
Character string, current name |
new_name |
Character string, new name |
category |
Character string, category of the item |
Logical, TRUE if successful
## Not run: goose_rename("old_analysis", "final_analysis", category = "results") ## End(Not run)## Not run: goose_rename("old_analysis", "final_analysis", category = "results") ## End(Not run)
Transforms long survey question text into short, meaningful variable names. Combines janitor::clean_names() functionality with intelligent abbreviation to create readable, consistent column names. Saves a mapping file for reference.
goose_rename_columns( data, max_length = 20, style = c("snake_case", "camelCase", "SCREAMING_SNAKE"), abbreviate = TRUE, save_map = TRUE, map_file = NULL, preview_only = FALSE, custom_dict = NULL )goose_rename_columns( data, max_length = 20, style = c("snake_case", "camelCase", "SCREAMING_SNAKE"), abbreviate = TRUE, save_map = TRUE, map_file = NULL, preview_only = FALSE, custom_dict = NULL )
data |
A data frame with columns to rename (typically survey data) |
max_length |
Maximum length for new column names (default: 20) |
style |
Naming style: "snake_case" (default), "camelCase", "SCREAMING_SNAKE" |
abbreviate |
Logical, whether to use intelligent abbreviation (default: TRUE) |
save_map |
Logical, whether to save the name mapping (default: TRUE) |
map_file |
Path to save the mapping CSV file (auto-generated if NULL) |
preview_only |
Logical, if TRUE only shows proposed changes without applying (default: FALSE) |
custom_dict |
Named vector of custom abbreviations (e.g., c("satisfaction" = "sat")) |
The function performs intelligent renaming by:
Removing special characters and standardizing format (via clean_names)
Detecting common survey patterns (scales, demographics, etc.)
Creating meaningful abbreviations for long questions
Ensuring uniqueness of all column names
Saving a reference map for documentation
Common patterns detected:
Likert scales ("How satisfied...", "To what extent...")
Demographics ("What is your age", "Gender", etc.)
Yes/No questions
Multiple choice questions
Open-ended responses
If preview_only = FALSE: Data frame with renamed columns If preview_only = TRUE: Data frame showing the mapping
## Not run: # Basic usage - rename survey columns survey_clean <- goose_rename_columns(survey_data) # Preview changes first goose_rename_columns(survey_data, preview_only = TRUE) # Use custom abbreviations survey_clean <- goose_rename_columns(survey_data, custom_dict = c( "satisfaction" = "sat", "recommendation" = "rec", "likelihood" = "likely" ) ) # Use camelCase instead of snake_case survey_clean <- goose_rename_columns(survey_data, style = "camelCase") ## End(Not run)## Not run: # Basic usage - rename survey columns survey_clean <- goose_rename_columns(survey_data) # Preview changes first goose_rename_columns(survey_data, preview_only = TRUE) # Use custom abbreviations survey_clean <- goose_rename_columns(survey_data, custom_dict = c( "satisfaction" = "sat", "recommendation" = "rec", "likelihood" = "likely" ) ) # Use camelCase instead of snake_case survey_clean <- goose_rename_columns(survey_data, style = "camelCase") ## End(Not run)
Get AI-powered code review and suggestions for improvement.
goose_review_code( code, focus = c("performance", "style", "bugs", "documentation"), context = NULL, detailed = TRUE )goose_review_code( code, focus = c("performance", "style", "bugs", "documentation"), context = NULL, detailed = TRUE )
code |
Character string or function containing R code to review |
focus |
Character vector of focus areas (e.g., "performance", "style", "bugs") |
context |
Optional context about the code's purpose |
detailed |
Logical, whether to request detailed analysis |
List with review results including suggestions, issues, and improvements
## Not run: # Review a function my_func <- function(x) { for(i in 1:length(x)) { x[i] <- x[i] * 2 } return(x) } review <- goose_review_code(my_func, focus = c("performance", "style")) # Review code string code <- "df$new_col = df$col1 + df$col2" review <- goose_review_code(code, context = "Adding columns in data frame") ## End(Not run)## Not run: # Review a function my_func <- function(x) { for(i in 1:length(x)) { x[i] <- x[i] * 2 } return(x) } review <- goose_review_code(my_func, focus = c("performance", "style")) # Review code string code <- "df$new_col = df$col1 + df$col2" review <- goose_review_code(code, context = "Adding columns in data frame") ## End(Not run)
Generate an RMarkdown section with AI content
goose_rmd_ai(title, prompt, level = 2, include_code = TRUE)goose_rmd_ai(title, prompt, level = 2, include_code = TRUE)
title |
Section title |
prompt |
AI prompt for content |
level |
Heading level (1-6) |
include_code |
Include code examples |
RMarkdown text
Save an R object to Goose's memory system with optional tags and category. Objects are serialized to RDS format and metadata is stored in Goose's text format.
goose_save( object, name, category = "r_objects", tags = NULL, description = NULL, global = TRUE, overwrite = FALSE )goose_save( object, name, category = "r_objects", tags = NULL, description = NULL, global = TRUE, overwrite = FALSE )
object |
The R object to save (can be any R object: data.frame, model, list, etc.) |
name |
Character string. Name for the saved object (will be used as filename) |
category |
Character string. Category for organizing memories (default: "r_objects") |
tags |
Character vector. Optional tags for searching/filtering |
description |
Character string. Optional description of the object |
global |
Logical. If TRUE (default), saves to global Goose memory. If FALSE, saves to project-local memory. |
overwrite |
Logical. If TRUE, overwrites existing object. If FALSE (default), errors if object exists. |
Invisibly returns the path where the object was saved
## Not run: # Save a model model <- lm(mpg ~ wt, data = mtcars) goose_save(model, "mtcars_model", category = "models", tags = c("regression", "mtcars"), description = "Linear model predicting mpg from weight") # Save a data frame goose_save(iris, "iris_data", category = "datasets", tags = "example") ## End(Not run)## Not run: # Save a model model <- lm(mpg ~ wt, data = mtcars) goose_save(model, "mtcars_model", category = "models", tags = c("regression", "mtcars"), description = "Linear model predicting mpg from weight") # Save a data frame goose_save(iris, "iris_data", category = "datasets", tags = "example") ## End(Not run)
Manage Goose sessions for maintaining context across queries.
goose_session( action = c("create", "resume", "list", "remove"), name = NULL, session_id = NULL, timeout = getOption("goose.timeout", 300), retries = getOption("goose.retries", 1) )goose_session( action = c("create", "resume", "list", "remove"), name = NULL, session_id = NULL, timeout = getOption("goose.timeout", 300), retries = getOption("goose.retries", 1) )
action |
Character, one of "create", "resume", "list", "remove" |
name |
Optional session name |
session_id |
Optional session ID |
timeout |
Numeric, timeout in seconds (default uses |
retries |
Integer, number of retries after the first attempt (default uses
|
Session information or query result
Clear all items from current session
goose_session_clear(confirm = TRUE)goose_session_clear(confirm = TRUE)
confirm |
Logical, whether to confirm deletion |
Invisible integer count of deleted items
End the current gooseR session
goose_session_end(cleanup = FALSE)goose_session_end(cleanup = FALSE)
cleanup |
Logical, whether to delete session items |
Invisible NULL
List items saved in current session
goose_session_list()goose_session_list()
Data frame of session items
A wrapper around goose_save that automatically adds the current session tag
goose_session_save(..., tags = NULL)goose_session_save(..., tags = NULL)
... |
Arguments passed to goose_save |
tags |
Additional tags (session tag will be added automatically) |
Same as goose_save
Note: To automatically tag items with the session ID, you need to manually add the session tag when saving, or use the wrapper functions.
goose_session_start(session_id = NULL)goose_session_start(session_id = NULL)
session_id |
Character, optional session identifier |
Character, the session ID
## Not run: # Start a session session_id <- goose_session_start() # Save items (manually tag with session) goose_save(mtcars, "cars_data", category = "analysis", tags = c("myanalysis", getOption("goose.session_id"))) # See what was saved in this session goose_session_list() # Clean up session goose_session_clear() goose_session_end() ## End(Not run)## Not run: # Start a session session_id <- goose_session_start() # Save items (manually tag with session) goose_save(mtcars, "cars_data", category = "analysis", tags = c("myanalysis", getOption("goose.session_id"))) # See what was saved in this session goose_session_list() # Clean up session goose_session_clear() goose_session_end() ## End(Not run)
Execute a query with streaming response handling
goose_stream( query, callback = NULL, error_callback = NULL, complete_callback = NULL, session_id = NULL, max_time = getOption("goose.stream_timeout", Inf), idle_timeout = getOption("goose.stream_idle_timeout", Inf) )goose_stream( query, callback = NULL, error_callback = NULL, complete_callback = NULL, session_id = NULL, max_time = getOption("goose.stream_timeout", Inf), idle_timeout = getOption("goose.stream_idle_timeout", Inf) )
query |
The query to send to Goose |
callback |
Function to call with each chunk (default: cat) |
error_callback |
Function to call on error |
complete_callback |
Function to call on completion |
session_id |
Optional session ID for context |
max_time |
Numeric, maximum runtime in seconds for the stream (default uses
|
idle_timeout |
Numeric, maximum time in seconds without receiving any output
before aborting the stream (default uses |
Invisible NULL (results handled via callbacks)
## Not run: # Simple streaming with default output goose_stream("Explain R functions") # Custom callback for processing chunks goose_stream("Write a function", callback = function(chunk) { message("Received: ", nchar(chunk), " characters") cat(chunk) }) ## End(Not run)## Not run: # Simple streaming with default output goose_stream("Explain R functions") # Custom callback for processing chunks goose_stream("Write a function", callback = function(chunk) { message("Received: ", nchar(chunk), " characters") cat(chunk) }) ## End(Not run)
Stream response that returns a promise for async handling
goose_stream_async(query, show_progress = TRUE)goose_stream_async(query, show_progress = TRUE)
query |
The query to execute |
show_progress |
Show progress during streaming |
A promise that resolves to the complete response
## Not run: library(promises) goose_stream_async("Explain promises") %...>% { cat("Complete response:", .) } ## End(Not run)## Not run: library(promises) goose_stream_async("Explain promises") %...>% { cat("Complete response:", .) } ## End(Not run)
Stream multiple queries sequentially with progress
goose_stream_multi(queries, callback = NULL)goose_stream_multi(queries, callback = NULL)
queries |
Vector of queries to execute |
callback |
Optional callback for each response |
List of responses
Create a persistent streaming session for multiple queries
goose_stream_session(session_name = NULL)goose_stream_session(session_name = NULL)
session_name |
Name for the session |
StreamSession object
Provides real-time streaming responses from Goose AI
Get AI-powered color palette suggestions for data visualization.
goose_suggest_colors(purpose, n_colors = 5, brand = NULL, constraints = NULL)goose_suggest_colors(purpose, n_colors = 5, brand = NULL, constraints = NULL)
purpose |
Character, the purpose of the palette (e.g., "heatmap", "categorical", "diverging") |
n_colors |
Integer, number of colors needed |
brand |
Optional brand name for brand-appropriate colors |
constraints |
Optional constraints (e.g., "colorblind-safe", "print-friendly") |
List with hex colors and rationale
## Not run: # Get heatmap colors colors <- goose_suggest_colors("heatmap", n_colors = 9) # Get brand colors colors <- goose_suggest_colors("categorical", n_colors = 5, brand = "Block") # Get accessible colors colors <- goose_suggest_colors("bar chart", n_colors = 4, constraints = "colorblind-safe") ## End(Not run)## Not run: # Get heatmap colors colors <- goose_suggest_colors("heatmap", n_colors = 9) # Get brand colors colors <- goose_suggest_colors("categorical", n_colors = 5, brand = "Block") # Get accessible colors colors <- goose_suggest_colors("bar chart", n_colors = 4, constraints = "colorblind-safe") ## End(Not run)
Define a reusable prompt template with variables
goose_template( name, template, description = NULL, variables = NULL, examples = NULL )goose_template( name, template, description = NULL, variables = NULL, examples = NULL )
name |
Template name |
template |
Template text with {variable} placeholders |
description |
Optional description |
variables |
List of variable definitions |
examples |
Optional usage examples |
Template object
## Not run: # Create a code review template review_template <- goose_template( name = "code_review", template = "Review this {language} code:\n\n{code}\n\nFocus on: {focus}", variables = list( language = "Programming language", code = "Code to review", focus = "Specific areas to focus on" ) ) ## End(Not run)## Not run: # Create a code review template review_template <- goose_template( name = "code_review", template = "Review this {language} code:\n\n{code}\n\nFocus on: {focus}", variables = list( language = "Programming language", code = "Code to review", focus = "Specific areas to focus on" ) ) ## End(Not run)
Fill in template variables and execute query
goose_template_apply(template, ..., execute = TRUE)goose_template_apply(template, ..., execute = TRUE)
template |
Template object or name |
... |
Variable values |
execute |
Whether to execute the query |
Filled template or query response
## Not run: # Use the template result <- goose_template_apply( review_template, language = "R", code = "function(x) x^2", focus = "efficiency and style" ) ## End(Not run)## Not run: # Use the template result <- goose_template_apply( review_template, language = "R", code = "function(x) x^2", focus = "efficiency and style" ) ## End(Not run)
Access built-in template library
goose_template_builtin(name = NULL)goose_template_builtin(name = NULL)
name |
Optional template name |
Template or list of templates
Create a template from a previous query
goose_template_from_query(query, name, variables = NULL)goose_template_from_query(query, name, variables = NULL)
query |
Previous query text |
name |
Template name |
variables |
Variables to extract |
Template object
Show all available templates
goose_template_list(include_builtin = TRUE)goose_template_list(include_builtin = TRUE)
include_builtin |
Include built-in templates |
Data frame of templates
Load a saved template
goose_template_load(name)goose_template_load(name)
name |
Template name |
Template object
Save a template for future use
goose_template_save(template, overwrite = FALSE, template_dir = NULL)goose_template_save(template, overwrite = FALSE, template_dir = NULL)
template |
Template object |
overwrite |
Overwrite if exists |
template_dir |
Directory to save templates (default: tempdir() for CRAN compliance) |
Logical indicating success
## Not run: # Create and save template in temp directory template <- goose_template("test", "Hello {name}") goose_template_save(template, template_dir = tempdir()) ## End(Not run)## Not run: # Create and save template in temp directory template <- goose_template("test", "Hello {name}") goose_template_save(template, template_dir = tempdir()) ## End(Not run)
Check if template is valid
goose_template_validate(template)goose_template_validate(template)
template |
Template object or text |
List with validation results
Tests if Goose CLI is properly configured and can execute queries. This is especially useful for Block employees who have CLI configured but don't need to provide API keys in R.
goose_test_cli(verbose = TRUE, timeout = 60)goose_test_cli(verbose = TRUE, timeout = 60)
verbose |
Logical, whether to print status messages |
timeout |
Numeric, timeout in seconds for the test query (default 60). Increase this if authentication prompts require more time. |
Logical, TRUE if CLI works, FALSE otherwise
## Not run: # Check if CLI works if (goose_test_cli()) { # Ready to use goose_ask() etc. response <- goose_ask("Hello!") } else { # May need configuration goose_configure(provider = "openai", model = "gpt-4", api_key = "key") } # Allow more time for authentication goose_test_cli(timeout = 120) ## End(Not run)## Not run: # Check if CLI works if (goose_test_cli()) { # Ready to use goose_ask() etc. response <- goose_ask("Hello!") } else { # May need configuration goose_configure(provider = "openai", model = "gpt-4", api_key = "key") } # Allow more time for authentication goose_test_cli(timeout = 120) ## End(Not run)
Shiny-based visual interfaces for cache and conversation management
Get Goose CLI Version
goose_version()goose_version()
Character string with version or NULL if not installed
Display or retrieve the column name mapping from a renamed data frame
goose_view_column_map(data, return_df = FALSE)goose_view_column_map(data, return_df = FALSE)
data |
A data frame that was processed with goose_rename_columns() |
return_df |
Logical, if TRUE returns the mapping as a data frame (default: FALSE) |
If return_df = TRUE: Returns the mapping data frame If return_df = FALSE: Invisibly returns NULL and displays the mapping
## Not run: # View the mapping goose_view_column_map(survey_clean) # Get mapping as data frame map_df <- goose_view_column_map(survey_clean, return_df = TRUE) ## End(Not run)## Not run: # View the mapping goose_view_column_map(survey_clean) # Get mapping as data frame map_df <- goose_view_column_map(survey_clean, return_df = TRUE) ## End(Not run)
Create a pool of workers for processing queries
goose_worker_pool(n_workers = 4)goose_worker_pool(n_workers = 4)
n_workers |
Number of workers |
WorkerPool object
Functions for creating and applying consistent branding across R outputs
Load brand configuration
load_brand(brand = "block")load_brand(brand = "block")
brand |
Name of the brand to load |
List containing brand configuration
## Not run: config <- load_brand("block") ## End(Not run)## Not run: config <- load_brand("block") ## End(Not run)
Generate a preview of brand colors and typography.
preview_brand(brand, output_file = NULL)preview_brand(brand, output_file = NULL)
brand |
Name of the brand to preview |
output_file |
Optional file to save preview |
ggplot object with brand preview
Print Cache Statistics
## S3 method for class 'goose_cache_stats' print(x, ...)## S3 method for class 'goose_cache_stats' print(x, ...)
x |
Cache statistics object |
... |
Additional arguments |
Print method for goose_code_review
## S3 method for class 'goose_code_review' print(x, ...)## S3 method for class 'goose_code_review' print(x, ...)
x |
goose_code_review object |
... |
additional arguments (unused) |
Print method for goose_error_explanation
## S3 method for class 'goose_error_explanation' print(x, ...)## S3 method for class 'goose_error_explanation' print(x, ...)
x |
goose_error_explanation object |
... |
additional arguments (unused) |
Print method for goose_palette
## S3 method for class 'goose_palette' print(x, ...)## S3 method for class 'goose_palette' print(x, ...)
x |
goose_palette object |
... |
additional arguments (unused) |
Print formatted AI response
## S3 method for class 'goose_response' print(x, ...)## S3 method for class 'goose_response' print(x, ...)
x |
AI response object or text |
... |
Additional arguments passed to format_ai_response |
Print method for goose_session
## S3 method for class 'goose_session' print(x, ...)## S3 method for class 'goose_session' print(x, ...)
x |
goose_session object |
... |
additional arguments (unused) |
Print Template
## S3 method for class 'goose_template' print(x, ...)## S3 method for class 'goose_template' print(x, ...)
x |
Template object |
... |
Additional arguments (unused) |
Register custom knitr engine for Goose chunks
register_goose_engine()register_goose_engine()
Stream Handler R6 Class
Stream Handler R6 Class
Manages streaming responses from Goose
processThe processx process object
bufferAccumulated response buffer
callbackChunk callback function
error_callbackError callback function
complete_callbackCompletion callback function
max_timeMaximum runtime in seconds (Inf = no limit)
idle_timeoutMaximum time in seconds without output (Inf = no limit) Initialize stream handler
new()
StreamHandler$new(callback, error_callback, complete_callback)
callbackFunction to call with chunks
error_callbackFunction for errors
complete_callbackFunction for completion Start streaming process
start()
StreamHandler$start( query, session_id = NULL, max_time = Inf, idle_timeout = Inf )
queryThe query to execute
session_idOptional session ID
max_timeNumeric, maximum runtime in seconds (Inf = no limit)
idle_timeoutNumeric, maximum time in seconds without output (Inf = no limit) Monitor streaming process
monitor()
Internal loop that reads stdout/stderr, parses chunks, and enforces
max_time / idle_timeout.
Get accumulated buffer
StreamHandler$monitor()
get_response()
StreamHandler$get_response()
Complete response text Stop streaming
stop()
Kill the underlying streaming process if it is still running.
StreamHandler$stop()
clone()
The objects of this class are cloneable with this method.
StreamHandler$clone(deep = FALSE)
deepWhether to make a deep clone.
Stream Session R6 Class
Stream Session R6 Class
Manages a persistent streaming session
session_idUnique session identifier
historyQuery/response history
activeWhether session is active Initialize session
new()
StreamSession$new(session_id)
session_idSession identifier Send query in session
query()
StreamSession$query(query, show_output = TRUE)
queryQuery to execute
show_outputShow streaming output
Response text Get session history
get_history()
StreamSession$get_history()
Data frame of queries and responses Close session
close()
Mark session inactive (client-side). This does not remove any server-side Goose session.
StreamSession$close()
Invisible NULL
clone()
The objects of this class are cloneable with this method.
StreamSession$clone(deep = FALSE)
deepWhether to make a deep clone.
Generate ggplot2 theme from brand configuration
theme_brand( brand = "block", variant = "light", base_theme = ggplot2::theme_minimal(), base_size = NULL )theme_brand( brand = "block", variant = "light", base_theme = ggplot2::theme_minimal(), base_size = NULL )
brand |
Name of the brand to use |
variant |
Theme variant ("light", "dark", or NULL for default) |
base_theme |
Base ggplot2 theme to build upon (default: theme_minimal()) |
base_size |
Base font size (overrides brand config if specified) |
A ggplot2 theme object
## Not run: library(ggplot2) # Light theme ggplot(mtcars, aes(mpg, wt)) + geom_point() + theme_brand("block", variant = "light") # Dark theme ggplot(mtcars, aes(mpg, wt)) + geom_point() + theme_brand("block", variant = "dark") ## End(Not run)## Not run: library(ggplot2) # Light theme ggplot(mtcars, aes(mpg, wt)) + geom_point() + theme_brand("block", variant = "light") # Dark theme ggplot(mtcars, aes(mpg, wt)) + geom_point() + theme_brand("block", variant = "dark") ## End(Not run)
Validate brand configuration
validate_brand(config)validate_brand(config)
config |
Brand configuration list |
Logical indicating if configuration is valid
Execute code with automatic gooseR session management
with_goose_session(expr, cleanup = TRUE, session_id = NULL)with_goose_session(expr, cleanup = TRUE, session_id = NULL)
expr |
Expression to evaluate |
cleanup |
Logical, whether to clean up after execution |
session_id |
Optional session identifier |
Result of expression
## Not run: # Run analysis with automatic cleanup result <- with_goose_session({ goose_save(mtcars, "cars", category = "temp") goose_save(iris, "flowers", category = "temp") # Do analysis... "Analysis complete" }, cleanup = TRUE) ## End(Not run)## Not run: # Run analysis with automatic cleanup result <- with_goose_session({ goose_save(mtcars, "cars", category = "temp") goose_save(iris, "flowers", category = "temp") # Do analysis... "Analysis complete" }, cleanup = TRUE) ## End(Not run)
Worker Pool R6 Class
Worker Pool R6 Class
Manages a pool of async workers
n_workersNumber of workers
queueQuery queue
resultsResults list
activeWhether pool is active Initialize worker pool
new()
WorkerPool$new(n_workers = 4)
n_workersNumber of workers Add query to queue
add()
WorkerPool$add(query, id = NULL)
queryQuery to add
idOptional query ID Process all queued queries
process()
WorkerPool$process(progress = TRUE)
progressShow progress
List of results Get results
get_results()
WorkerPool$get_results()
Results list Clear queue
clear_queue()
Remove all queued items without processing them.
WorkerPool$clear_queue()
Invisible self Shutdown pool
shutdown()
Shut down the worker pool and reset the future plan to sequential.
WorkerPool$shutdown()
Invisible self
clone()
The objects of this class are cloneable with this method.
WorkerPool$clone(deep = FALSE)
deepWhether to make a deep clone.