In-editor code generation
Generate code and use inline AI prompts right in the editor.
To generate code in the editor, do one of the following:
Place the caret anywhere in the editor and press . Write your prompt in the input field and press .
Right-click anywhere in the editor to open the context menu, select AI Actions, and then Generate Code. Write your prompt in the input field and press .
Type your prompt right in the editor where you want to make adjustments and press .
Wait for the generation to complete. The generated code will be shown in the same editor tab where you have written your prompt.
If you want to improve the generated code, write a follow-up message with the new requirements in the input field on top of the editor and press .
AI Assistant will regenerate the code while taking into account the new specifications.
If you want to regenerate the answer, click
Regenerate or press .
Click Accept All to insert the generated fragment.
If you want to revert some of the suggested changes, in the gutter, click
Revert.
To discard all the suggested changes, click Discard All.
Not available in: DataGrip, DataSpell
When you rename () a symbol inline, AI Assistant suggests name options for it based on its contents.

This feature is enabled by default. To switch it on and off, check the AI Assistant settings.
Press to open settings and then select Tools | AI Assistant.
Use the Provide AI-generated name suggestions checkbox.
Only available in: PyCharm, DataSpell
While AI Assistant lets you add type hints via intention actions, AI Assistant further extends this functionality by suggesting types based on the context.
Right-click a function or method definition to open the context menu.
Alternatively, place the caret on it and press .
Select AI Actions and then Add Type Annotations.
Type annotations are added to the function definition.