| hal_chat | R Documentation |
Creates a new HalChat instance for conversing with GitHub Copilot
models. This is the recommended entry point – equivalent to
HalChat$new() but follows tidyverse naming conventions.
hal_chat(
model = NULL,
system_prompt = NULL,
client = NULL,
echo = NULL,
on_text = NULL,
on_tool_call = NULL,
on_thought = NULL,
mode = NULL,
permission_policy = "auto-allow",
quiet = FALSE
)
model |
Model identifier (e.g., |
system_prompt |
System prompt string. Defaults to hal's built-in R
assistant prompt. Pass a string to override, or set via
|
client |
An existing HalClient instance, or |
echo |
Echo mode: |
on_text |
Callback for streaming text chunks: |
on_tool_call |
Callback for tool call events: |
on_thought |
Callback for thought chunks: |
mode |
Session mode: |
permission_policy |
Permission policy for tool calls. One of
|
quiet |
Logical; suppress informational messages (default |
A HalChat object.
hal_models(), hal_client(), hal_available()
## Not run:
# Default model
chat <- hal_chat()
chat$chat("Explain the pipe operator in R")
# Specific model
chat <- hal_chat(model = "gpt-5.2")
chat$chat("Hello!")
# With system prompt
chat <- hal_chat(
model = "claude-haiku-4.5",
system_prompt = "Reply concisely in one sentence."
)
chat$chat("What is R?")
# Plan mode
chat <- hal_chat(mode = "plan")
chat$chat("Create an analysis plan for this dataset")
# With streaming callbacks
chat <- hal_chat(
on_text = function(chunk) cat(chunk),
on_tool_call = function(tc) message("Tool: ", tc$title)
)
# Read-only mode (deny file writes and shell commands)
chat <- hal_chat(permission_policy = "auto-deny")
chat$chat("What files are in R/?")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.