Chat
The Chat pane has access to your R and Python Console sessions, so you can interact with code, outputs, and in-memory objects such as dataframes. You can run code generated by Assistant in the Console, copy it to the clipboard, or send it to an Editor. Controls attached to code output blocks enable these actions. The Chat pane can also access the Variables and Plots panes when needed.
Use the Chat pane to ask questions, edit and debug your code. Assistant responds based on the context from your active session, making it easier to troubleshoot issues or learn new techniques.
Getting started with chat
Open the Chat pane in the side panel by doing one of the following:
- Click on the chat robot icon in the sidebar; or
- Open the Command Palette and run the command Chat: Open Chat; or
- Press
If you’re not already signed in to a language model provider, you’ll be prompted to do so. See Getting started for more details on configuring language model providers.
Once signed in, chat with Assistant by typing your question or request in the chat input box at the bottom of the Chat pane, then pressing EnterEnter or the send button.
Chat pane
Chat modes
Positron Assistant offers four chat modes: Ask, Edit, Agent, and Plan. Each mode guides Assistant to specific tasks by providing unique instructions and enabling different tools.
Switching chat modes
Click the mode selector dropdown at the bottom of the Chat pane.
Select Ask, Edit, Agent, or Plan as needed.
Ask mode
Use this mode to ask questions, get help with debugging, or request code generation. Ask mode may provide code you can apply in your Editor or run in the Console, but it will not edit or run code automatically.
Here are some example prompts for Ask mode:
- “How do I plot a histogram in Python?”
- “Why am I getting a syntax error in my R script?”
- “Can you explain what this function does?”
Edit mode
Use this mode to make code changes with the model’s help. The model suggests code changes based on your prompts, and you can apply those changes to your code.
Here are some example prompts for Edit mode:
- “Refactor this function to improve readability.”
- “Convert this R code to Python.”
- “Add error handling to this script.”
Agent mode
Use this mode if you want Positron Assistant to determine the steps needed for your request and autonomously carry out the work. Positron Assistant can execute code in the Console, create and modify files, and identify the next steps based on previous results.
Here are some example prompts for Agent mode:
- “Create a new Python file and set up a basic data analysis workflow.”
- “Install the required packages and run the code in the Console.”
- “Generate a summary report from my current dataset.”
Plan mode
Use this mode to have Positron Assistant create a step-by-step plan to accomplish your request. Assistant will take some time to retrieve relevant context and develop a plan, which it will present to you for review before proceeding with execution.
Here are some example prompts for Plan mode:
- “Outline the steps needed to analyze a dataset and generate visualizations.”
- “Plan how to test and debug this R script.”
- “Create a plan to display my data in an interactive Shiny app.”
The mode selector updates to reflect the selected mode.
Custom chat modes
You can create custom chat modes by defining custom prompt files. Custom prompt files allow you to specify unique instructions, tools, and behaviors for the model in chat sessions. See Customization for more details on creating and using custom chat modes.
Attach context
Providing context to the model is crucial for getting accurate and relevant responses. To attach specific files or directories as context for your prompts, you can either:
- Click the paperclip button in the Chat pane and choose “Files & Folders…” in the quickpick to select relevant items; or
- Drag files to the Chat pane to attach them as context.
For more information on attaching context to your chat message, refer to the Add context to your prompt VS Code documentation.
Interpreter session context
By default, Positron Assistant can see the active R or Python interpreter session in the Chat pane. The chat input box displays the active Console session as an attachment.
When an interpreter session is attached, Positron Assistant can access:
- Code inputs and outputs in that session
- In-memory objects and dataframes in the Variables pane
- The active plot in the Plots pane
- Tool calls that require the interpreter session
You can manage the attached interpreter session context in the following ways:
Switch the attached interpreter session for chat
- Click the interpreter session in the Console pane to make it active.
- Positron Assistant automatically updates to use the newly active interpreter session.
Attach more than one interpreter session
- Click the paperclip button in the Chat pane
- Choose “Interpreter Sessions…” to select additional interpreter sessions.
Toggle the visibility of the active Console session
- Click the eye button on the Console session attachment in the Chat pane.
- When the eye icon appears without a slash through it, the Console session is visible.
- When the eye icon has a slash through it, the Console session is hidden.
Change the default visibility of the active interpreter session
- Open the Command Palette and run the Preferences: Open User Settings command.
- Search for the setting
chat.implicitSessionContext.enabled. - Modify the setting as needed:
- By default, the
panelsetting isalways, which always attaches the Console session in the Chat pane. - To disable the Console session context in the Chat pane, change the
panelsetting tonever.
- By default, the
Slash commands
Slash commands provide quick access to common tasks without writing long prompts.
Using slash commands
- In the Chat input box, type
/to open the slash command popup - Continue typing the command name or select the command from the popup
- Optionally, add any additional instructions after the command
- Press EnterEnter to send the command to the model
- Positron Assistant will execute the command and respond accordingly
Available slash commands
Slash commands are provided by Positron Assistant and other installed extensions.
Some built-in slash commands include:
/exportQuarto: Generate a Quarto document from the current chat conversation./fix: Ask the model to fix a piece of code./explain: Ask the model to explain a piece of code or concept./doc: Ask the model to generate documentation for a piece of code.
Chat participants
Chat participants provide specialized knowledge to Positron Assistant. If you want help with a specific topic, you can add a chat participant to your conversation.
Adding chat participants
- In the Chat pane, enter
@to bring up the chat participant popup - Continue typing the chat participant name or select the participant from the popup
Available chat participants
Chat participants are provided by Positron Assistant and other installed extensions.
Shiny Assistant
Shiny Assistant is a chat participant available within Positron Assistant that provides context-aware assistance for developing Shiny applications in Python or R. It can help you with tasks such as generating Shiny UI components, server logic, and reactive expressions.
Shiny Assistant is available in the chat once you have installed the Shiny extension. Like other chat participants, Shiny Assistant can be invoked by typing @shiny in the Chat pane or Inline Chat, followed by your question or request related to Shiny development.
Shiny Assistant enhances the default prompt with additional information about Shiny that we have found improves the quality of generated apps and Shiny components. It is also kept up to date with the latest Shiny features and best practices, in a way that is not practical with foundation models or fine-tuning.
GitHub Copilot
If you are authenticated with GitHub Copilot as a language model provider in Positron, you can use chat participants provided by GitHub Copilot when chatting with GitHub Copilot models in Positron Assistant.
Refer to the GitHub Copilot Chat participants documentation for more information on available chat participants and how to use them.
Inline chat
Inline chat is a mini chat interface that can be opened directly within your code Editor, Notebook, or Terminal. It allows you to ask questions, get suggestions, and apply changes without leaving your current context.
To use the inline chat interface in an Editor or Notebook:
- In an Editor or Notebook, place your cursor where you want to open the inline chat interface.
- Open the inline chat interface using the default keybinding ; or, by running the command Inline Chat: Open Inline Chat from the Command Palette.
- Type your question or request in the inline chat input box and press EnterEnter to send it to the model.
Learn more about how to Use editor inline chat in the VS Code documentation.
To use the inline chat interface in a Terminal:
- In a Terminal, place your cursor where you want to open the inline chat interface.
- Open the inline chat interface using the default keybinding ; or, by running the command Terminal: Open Inline Chat from the Command Palette.
- Type your question or request in the inline chat input box and press EnterEnter to send it to the model.
Learn more about how to Use terminal inline chat in the VS Code documentation.
Console actions
Positron Assistant provides quick assistance for errors in the Console. When you see an error, you can choose Fix or Explain to send your Console session to Assistant for immediate help.
Fix: Assistant diagnoses the error and suggests a corrected version of your code. Use Fix to resolve errors quickly or apply recommended changes.
Explain: Assistant describes what your code does, analyzes the error, and suggests possible solutions. Use Explain to learn more about your code or get advice on complex issues.
Fix and Explain inherit these options from the Chat pane:
- Selected model
- Files added or removed from context
- Console session visibility
Console actions chat history
To review your Fix and Explain chat history for the current chat session:
- Open the Command Palette and run the Chat: Open Quick Chat command.
- Your chat history will appear in the Quick Chat overlay
Disabling Console actions
Console actions are enabled by default when Assistant is active and you are authenticated with a model provider.
To disable Console actions:
- Open the Command Palette and run the Preferences: Open User Settings command.
- Search for the setting
positron.assistant.consoleActions.enable. - Uncheck the setting to disable Console actions.