DataSpell 2024.1 Help

Use AI in editor

Generate code in editor

Generate code and use prompts right in the editor.

  1. Select a piece of code that you want to modify or place the caret anywhere in the editor and press Ctrl+\.

    Alternatively, right-click to open the context menu, select AI Actions and then Generate code.

  2. In the input field, write your prompt and press Enter.

    Input field in the editor
  3. The generated code opens in a separate AI Diff tab. Wait for the generation to complete. In the upper-right corner, select the way you want to review the suggested changes:

    • The Unified view shows the results in one editor.

    • The Two-Side view shows the results in two editors. The left side displays the original code. The right side displays the code with the suggested changes.

    Generated code in diff tab
  4. If you want to improve the generated code, click Specify, add new requirements, and press Enter.

    New requirements to update the generated code

    AI Assistant will regenerate the code while taking into account the new specifications.

    If you want to regenerate the answer, click Regenerate.

  5. Click Accept all to insert the generated fragment to the rest of the code.

    To accept only part of the suggested changes, click the Accept button Accept in the Two-Side view or the Checkmark icon Accept in the Unified view on the line with the desired changes.

    Otherwise, close the AI Diff tab to discard all changes.

Add Python type annotations

While DataSpell lets you add type hints via intention actions, AI Assistant further extends this functionality by suggesting types based on the context.

  1. Right-click a function or method definition to open the context menu.

    Alternatively, place the caret on it and press Alt+Enter.

  2. Select AI Actions and then Add Type Annotations.

    Adding Python type annotations via AI Assistant
  3. Type annotations are added to the function definition.

    Python type annotations added via AI Assistant

Invoke inline code completion

AI Assistant can autocomplete single lines, entire functions, and even blocks of code in real time based on the project's context. The generated code is similar to how you would write code, matching your style and naming conventions.

  1. While working on your code, press Enter to start a new line and wait for a few seconds to get a suggestion.

    The suggested code will be shown in gray font.

    AI-generated code suggestion
  2. To apply the suggested code, press Tab.

    To reject the suggestion, press Escape. Alternatively, just continue to write your own code.

To disable the inline code completion, go to Settings | Tools | AI Assistant and clear the Enable automatic inline code completion as you type checkbox.

Last modified: 28 May 2024