Use AI Assistant
The AI Assistant functionality helps you code faster and better with the support of code generation and modification via natural language commands. You can use it when coding in Python, R, and SQL, as well as working in Markdown cells.
You can use the functionality as the following tools:
In-cell Ask AI tool: used to generate code suggestions for the cell you are working on, based on the provided prompt and the data from the previous cells of the notebook
Standalone Autopilot tool: used to generate code suggestions for further cells. The code suggestions are either based on solely notebook content analysis or an 'objective' specified by the user. Additionally, the tool can be used for the next cell only in the same way you use Ask AI.
Before you start
- Check feature accessibility
Visit this page to make sure the AI service for JetBrains is permitted in your country.
- Accept terms and conditions
The step is required to ensure transparency and data protection.
- Limitations
In the cloud version of Datalore, the feature is available to Cloud plan users only. Find the upgrade procedure in this topic.
AI Assistant data security considerations
- What data does AI Assistant send to LLM providers?
Depending on how you use AI Assistant in Datalore, the following types of data are sent to LLM providers:
Your prompts submitted to AI Assistant
Notebook content selected when submitting prompts, including pieces of your code
For the On-Premises version of Datalore, all data is sent directly to LLM providers and not stored by Datalore or by the JetBrains AI service that provides the AI Assistant functionality. For Datalore Cloud, we record users' prompts so they have access to their prompt history.
- Can the data AI Assistant sends to LLM providers be used to train models?
Datalore does not work with LLM providers that use customer data to train models. OpenAI and JetBrains are the LLM providers currently used by AI Assistant in Datalore. Datalore does not retain or use prompts or any other user data to train models. Datalore accesses OpenAI services through its API, so the data submitted is handled as API content according to OpenAI’s Terms of Use. OpenAI does not use data submitted to and generated by the API to train OpenAI models.
- How secure is code suggested by AI Assistant?
AI Assistant does not check code suggested by its LLM providers for security vulnerabilities. Code suggested by AI Assistant is therefore no different in terms of security than code written by a developer and should be further reviewed to identify security vulnerabilities.
- What LLM providers does AI Assistant use?
AI Assistant in Datalore is powered by the JetBrains AI service, an independent LLM provider. Currently, it uses OpenAI’s GPT-4 and GPT-3.5 models, as well as models trained by JetBrains. JetBrains continuously test new models and will add further LLM providers in the future.
Enable AI assistance in Datalore On-Premises
Make sure you whitelist the following endpoints on the firewall:
Perform the following steps on the Admin panel to enable the functionality:
Click the avatar in the upper right corner of the screen and select Admin panel.
On the Admin panel, navigate to Configuration.
On the Configuration tab, select the Turn on AI assistance checkbox.
Read the terms of service and click the Accept button below.
Use Ask AI
The procedures in this chapter describe how to use AI in a selected cell with the help of the Ask AI tool.
Generate code using Ask AI
The procedure below explains how to use the Ask AI tool to generate or modify code or Markdown.
On the toolbar of the cell, click the Ask AI icon. A prompt box will appear in the cell.
Click the Settings icon in the right part of the Ask AI toolbar and use the following options to customize how data is sent for analysis:
Review prompt: select to review and select which cells to send for analysis.
Include outputs: select to send outputs for analysis, which improves suggestion quality but uses more data.
Provide a prompt using natural language and click the Generate icon.
(If Review prompt is selected) Do the following in the Review of generated prompt dialog:
Deselect the cells you do not want to send for analysis.
Click the Submit button to send the reviewed data for analysis.
After the code suggestion is submitted, you have the following options:
Accept and run (for code cells only): to add the code to the cell and run it as-is
Accept: to add the code to the cell and continue working on it
Copy to clipboard: to copy the code suggestion to clipboard
Example of generating code for a new cell
The command provided using Ask AI was 'generate table from player_stats.csv'
Example of modifying code in a cell
The first command provided to Ask AI was 'Show correlation diagram between Pos and AST'. The resulting code produced a heatmap plot diagram.
The next step was modifying the code by prompting Ask AI to change the graph to a bar chart using hues of the red color.
Use Autopilot
Autopilot is an AI-based feature that suggests code based on the analysis of your current notebook content or an objective that you explicitly define. Code suggestions are generated in one of the following scenarios:
You ask the AI assistant for auto-generated prompts and then choose one of them for the AI assistant to generate a code suggestion.
To get better tailored auto-generated prompts from the AI assistant, you set a custom objective, which will persists through the notebook until you change or clear it.
You provide your own prompt for the AI assistant in the same way you would when using Ask AI.
While the in-cell Ask AI tool is used when working on a selected cell, the Autopilot tool works on a larger scale and focuses on the further development of the entire notebook.
Open and set up Autopilot
Open the Autopilot tool by clicking the Open Autopilot icon. This icon is always shown under the current last cell in the notebook or under any other cell when hovering over that cell.
Click the Settings icon in the right part of the Autopilot toolbar and use the following options to set up how to use the tool:
Review prompt: select to review and select which data to send for analysis and modelling.
Auto-mode: select to enable triggering Autopilot after every computation completion.
Include outputs: select to send outputs for analysis and modelling, which improves suggestion quality but uses more data.
Get code suggestions with prompts from Autopilot
This is the general-flow procedure where Autopilot creates prompts (Advice) based on notebook analysis or custom notebook objective and generates code suggestions following the selected prompt.
Click the Get Advice from AI icon in the left corner of the Autopilot toolbar.
(Optional) If you selected Review prompt, select which cells to send for analysis in the Review of generated prompt window.
The AI assistant will offer you a choice of up to four prompts for code suggestions based on the notebook data.
Choose one of the suggested prompts. The selected prompt, combined with notebook data sent for analysis, will be used for code generations.
(Optional>If you selected Review prompt, select which cells to send for analysis in the Review of generated prompt window.
After the code suggestion is submitted, you have the following options:
Accept and run (for code cells only): to add the code to the cell and run it as-is
Accept: to add the code to the cell and continue working on it
Copy to clipboard: to copy the code suggestion to clipboard
Set a custom notebook objective
Specify a notebook objective that the AI assistant will use to generate code suggestions for your next cells. This objective will persist through the notebook, which makes sure your further codes suggestions are based on the same end goal.
Click the Notebook objective icon in the right part of the Autopilot tool. This will open the Notebook objective dialog.
Provide an objective in the text box in the Notebook objective dialog and click the Apply button.
After specifying the custom objective, you can use the Autopilot as described here.
Modify prompts for Autopilot
The steps below show how you can modify your prompts sent to Autopilot to have code suggestions regenerated.
To clear or edit the custom objective, click the Notebook objective icon and do either of the following in the dilog:
To edit the objective, provide a new text and click Apply button.
To clear the objective, click Clear the custom objective.
To get a new choice of Autopilot-generated prompts after specifying or editing the custom objective, click the Regenerate icon in the right part oof the tool.
To use one of the earlier prompts submitted earlier, click the Prompt history icon in the right part of the Autopilot tool and select the prompt from the expanded list.
Use your own prompts for code suggestions
You can use Autopilot for code suggestions in the same way you use the in-cell Ask AI tool. Provide a prompt in the text field in the tool and proceed as described here.
Keywords
artificial intelligence, coding assistance, ai assistance, ai assistant, prompts, coding support