Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: inline autocomplete and TCG #5263

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4d10d99
docs: inline autocomplete
sbudhirajadoc Dec 7, 2023
477f4d3
Merge branch 'develop' into sonal/inlineauto
sbudhirajadoc Dec 7, 2023
d51d2de
Update einstein-inline.md
sbudhirajadoc Dec 7, 2023
38135e3
Update einstein-inline.md
sbudhirajadoc Dec 7, 2023
adc947a
Update docs/_articles/en/einstein/einstein-inline.md
sbudhirajadoc Dec 11, 2023
55e1ff9
Update sidebar.yml
sbudhirajadoc Dec 11, 2023
f47a933
Merge branch 'develop' into sonal/inlineauto
sbudhirajadoc Dec 11, 2023
486a3f3
Update einstein-setup.md
sbudhirajadoc Dec 12, 2023
59cb318
Merge branch 'develop' into sonal/inlineauto
sbudhirajadoc Dec 15, 2023
7653208
Merge branch 'develop' into sonal/inlineauto
sbudhirajadoc Dec 15, 2023
884d623
Merge branch 'develop' into sonal/inlineauto
gbockus-sf Dec 18, 2023
28a01c8
Merge branch 'develop' into sonal/inlineauto
sbudhirajadoc Jan 4, 2024
68088f9
Update einstein-setup.md
sbudhirajadoc Jan 4, 2024
be14765
Update einstein-inline.md
sbudhirajadoc Jan 4, 2024
350fb24
Update docs/_articles/en/einstein/einstein-overview.md
sbudhirajadoc Jan 4, 2024
8a5b18e
Update docs/_articles/en/einstein/einstein-overview.md
sbudhirajadoc Jan 4, 2024
4625d68
Update einstein-example-prompts.md
sbudhirajadoc Jan 9, 2024
373937d
Merge branch 'develop' into sonal/inlineauto
sbudhirajadoc Jan 29, 2024
c3a8bb1
Merge branch 'develop' into sonal/inlineauto
sbudhirajadoc Feb 7, 2024
da21608
docs: inline auto and TCG
sbudhirajadoc Feb 21, 2024
9128359
Merge branch 'develop' into sonal/inlineauto
sbudhirajadoc Feb 21, 2024
002f0e1
Merge branch 'develop' into sonal/inlineauto
sbudhirajadoc Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/_articles/en/einstein/einstein-apex.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: Apex Code Generation
title: Natural Language to Code Generation
lang: en
---

## Generate Apex Code
## Generate Apex Code from Natural Language Prompts

Use the Einstein for Developers side bar to write a question or an instruction that describes the task for which you'd like to receive an Apex code suggestion and press **Ask**. Copy the code suggestion you received and paste it into an Apex file to use as "starter" code.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update the screenshot within this section and make it a bit smaller? It has the original issue with the backticks and we've updated the icon recently. Let me know if you need any help grabbing it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I get an updated screenshot @AnanyaJha ? Thank you!


Expand Down
2 changes: 1 addition & 1 deletion docs/_articles/en/einstein/einstein-example-prompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lang: en

## Overview

A prompt is natural language text that you craft to communicate with an AI. The response that’s generated depends on the quality of the prompt. Use prompt engineering to define the prompt and then refine it until you get a response that works for you. For E4D responses, prompt quality determines the quality of the Apex code that’s generated.
A prompt is natural language text that you craft to communicate with an AI. The response that’s generated depends on the quality of the prompt. Use prompt engineering to define the prompt and then refine it until you get a response that works for you. For Einstein for Developer responses, prompt quality determines the quality of the Apex code that’s generated.

## About Generated Code Quality

Expand Down
33 changes: 33 additions & 0 deletions docs/_articles/en/einstein/einstein-inline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Automatic Inline Completions
lang: en
---

## Overview

Use AI-based autocomplete to accept suggestions for code as you write it right inside your editor. Inline autocompletions can currently be triggered in Apex, Javascript and HTML files.

## Enable or Disable Inline Autocomplete

To enable or disable the Inline autocomplete feature:

1. Select **File** > **Preferences** > **Settings** (Windows or Linux) or **Code** > **Preferences** > **Settings** (macOS).
sbudhirajadoc marked this conversation as resolved.
Show resolved Hide resolved
2. Under **Einstein for Developers**, select **Enable Einstein Auto Completions** then select the language for which to enable the feature.

Inline autocomplete is enabled by default.

## Receive your First Inline Completions

Einstein for Developers automatically generates code and suggests completions for you as you type. When writing apex code, you are often doing things like assigning variable values to an `Sobject` such as `Account.name = abc`, or `Account.type = Business`. Pause the cursor after the variable value and watch Einstein for Developers complete your code for you and fill out the remaining fields.

![Inline Suggestions](./images/einstein-inline-create-account.png)

To accept an entire suggestion, press Tab. If you have VS Code's **Inline Suggest** enabled, you can accept the next word of the suggestion using one of the following keyboard shortcuts:

| Operating System | Accept Next Word |
| ---------------- | ---------------- |
| macOS | ⌘→ |
| Windows | ⌥→ |
| Linux | ⌥→ |

**Note**: If you don't see a suggestion, make sure Einstein Auto Completions are enabled. Also, you can always trigger inline suggestions even if you don't have the Auto Completions enabled using the Option (⌥)\ hotkeys to manually generate autocomplete suggestions.
8 changes: 5 additions & 3 deletions docs/_articles/en/einstein/einstein-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ Einstein for Developers assists you throughout the Salesforce development proces

## Current Capabilities

This release of Einstein for Developers focuses on boilerplate Apex code generation from natural language prompts. This feature, used along with IntelliSense, makes Apex development tooling in Visual Studio Code even richer. Familiarity with Visual Studio Code is assumed.
Einstein for Developers generates Apex code from natural language prompts and automatically suggests code completions for you as you type. When enabled along with IntelliSense, this feature makes Apex development tooling in Visual Studio Code even richer. Familiarity with Visual Studio Code is assumed.

Use the extension in this release to generate boilerplate code from natural language instructions in a sidebar, so you can work with your editor and the tool side by side, without any interruptions to your workflow. You can also get code suggestions within an existing Apex class, trigger, or anonymous Apex file. Use the VS Code Command Palette to enter a prompt describing what you'd like to build and then generate code suggestions within your editor.
Enter natural language instructions in a sidebar, so you can work with your editor and the tool side by side, without any interruptions to your workflow. You can also get code suggestions within an existing Apex class, trigger, or anonymous Apex file. Use the VS Code Command Palette to enter a prompt describing what you'd like to build and then generate code suggestions within your editor.

**Note**: This tool uses generative AI, which can produce inaccurate or harmful responses. The output generated by AI is often nondeterministic. Before using the generated output, review it for accuracy and safety. You assume responsibility for how the outcomes of Einstein are applied to your organization.
Enable inline autocompletion to automatically receive suggestions as you code.

**Note**: Einstein for Developers uses generative AI, which can produce inaccurate or harmful responses. The output generated by AI is often nondeterministic. Before using the generated output, review it for accuracy and safety. You assume responsibility for how the outcomes of Einstein are applied to your organization.

## Trusted Generative AI at Salesforce

Expand Down
24 changes: 24 additions & 0 deletions docs/_articles/en/einstein/einstein-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ The Einstein logo on the activity bar and in the status bar confirms that the ex

![einstein installed](./images/einstein-installed.png)

## Enable or Disable Einstein For Developers

You can enable or disable Einstein for Developers from within Visual Studio Code. The Einstein for Developers status icon in the bottom panel of the Visual Studio Code window indicates whether Einstein for Developers is enabled or disabled. When enabled, the background color of the icon will match the color of the status bar. When disabled, the background color of the icon is brown. The background color of the icon is red when you're connected to an org that doesn't have Einstein for Developers enabled.

**Note**: Run **Developer:Reload Window** or manually toggle the icon to the correct state if you change the state of the Einstein for Developers preference in your Salesforce org.

To enable or disable Einstein for Developers, click the status icon in the bottom panel of the Visual Studio Code window and then click **Disable**.

![einstein icon](./images/einstein-icon.png)

### Use Einstein for Developers in a Scratch Org

Einstein for Developers is only available in scratch org editions that can author Apex:
Expand Down Expand Up @@ -116,3 +126,17 @@ Create a scratch org using the `SFDX: Create a Default Scratch Org...` command r
Run **Einstein: Show Prompt History** from the Command Palette to open the Feedback console. When opened, you can view a running history of your prompts and associated responses. Use 👍, 👎, and comments for each response to provide us with feedback about the quality of the generated code. Your feedback during this beta is key to helping us improve AI model quality and overall product.

![feedback panel](./images/einstein-feedback.png)

## Keyboard Shortcuts for Einstein for Developers

You can use the default keyboard shortcuts in Visual Studio Code when using Einstein for Developers. You can rebind the shortcuts in the Keyboard Shortcuts editor using your preferred keyboard shortcuts for each specific command. For more information see [Key Bindings for Visual Studio Code](https://code.visualstudio.com/docs/getstarted/keybindings).

You can search for each keyboard shortcut by command name in the Keyboard Shortcuts editor.

| Command | Key Binding |
| ---------------------------------------- | ----------- |
| Accept | ⌘Enter |
| Accept | Tab |
| Clear | Escape |
| Einstein:Generate Code | ⇧⌘R |
| Trigger Inline Suggestion | ⌥\ |
39 changes: 39 additions & 0 deletions docs/_articles/en/einstein/einstein-testcasegen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: Test Case Generation
lang: en
---

## Overview

Unit tests must cover at least 75% of your Apex code, and all of those tests must complete successfully for your code to be deployed or packaged for the Salesforce AppExchange. Use Einstein for Developers to quickly generate unit tests for your Apex classes.

## Enable or Disable Test Case Generation

To enable or disable the test case generation feature:

1. Select **File** > **Preferences** > **Settings** (Windows or Linux) or **Code** > **Preferences** > **Settings** (macOS).
2. Under **Einstein for Developers**, select **Enable Test Case Generation**.

Test case generation is enabled by default.

## Receive your First Unit Test

Use Einstein for Developers to quickly generate Apex unit tests.

1. From within a method in an Apex class, right-click and select **Einstein: Generate A Test**.
2. Select the method for which you want to generate unit tests. Note that your Apex class must contain at least one method aside from the constructor, for this command to work.
3. When prompted, choose to create new test class file or select an existing test class to which to add the test.
If you choose to create a new file, the command uses the naming convention, `<ApexClassFileName>Test.cls` for the new file. The command adds the test method to the new file.
4. Review the generated unit test method and choose to `Accept`, `Try Again`, or `Clear`.
5. To generate another test method, right-click within the class file or the test class file and again select **Einstein: Generate A Test**.
6. Again review the generated unit test method and choose to `Accept`, `Try Again`, or `Clear`.

## Hotkeys

You can generate a test using one of the following keyboard shortcuts:

| Operating System | Generate Test |
| ---------------- | ------------- |
| macOS | ⌥ ⌘ T |
| Windows | ⌥ ⌘ T |
| Linux | ⌥ ⌘ T |
35 changes: 35 additions & 0 deletions docs/_articles/ja/einstein/einstein-inline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Inline Automatic Completions
lang: en
---

## Overview

## Set Up Inline Autocomplete

To use inline autocomplete, you first activate the feature

1. Select **File** > **Preferences** > **Settings** (Windows or Linux) or **Code** > **Preferences** > **Settings** (macOS).
2. Under Einstein for Developers, select **Enable Einstein Auto Completions**.

## Receive your First Inline Completions

Einstein for Developers autogenerates inline completions suggestions. To start receiving inline completions:

1. In Visual Studio Code, create a new Apex class (\*.cls) file, or open an existing one.

2. In the Apex file, place your cursor inside a method. Einstein for Developers automatically suggests an entire method body in grayed text, as shown below. The exact suggestion may vary.

![Inline Suggestions](./images/einstein-inline-create-account.png)

To accept the entire suggestion, press Tab. If you have VS Code's **Inline Suggest** enabled, you can accept the next word of the suggestion using one of the following keyboard shortcuts:

| Operating System | Accept Next Word |
| ---------------- | ---------------- |
| macOS | ⌘→ |
| Windows | ⌥→ |
| Linux | ⌥→ |

Note: If you don't see a suggestion, make sure Einstein Auto Completions are enabled.

**_Note_**: Use the Option (⌥)\ hotkeys to manually generate autocomplete suggestions if you don't have the auto completions setting enabled.
12 changes: 10 additions & 2 deletions docs/_data/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,17 @@
ja: Set Up Einstein for Developers
url: /einstein/einstein-setup
- title:
en: Use Einstein for Apex Programming
ja: Set Up Einstein for Developers
en: Natural Language to Code Generation
ja: Natural Language to Code Generation
url: /einstein/einstein-apex
- title:
en: Inline Auto Completion
ja: Inline Auto Completion
url: /einstein/einstein-inline
- title:
en: Test Case Generation
ja: Test Case Generation
url: /einstein/einstein-testcasegen
- title:
en: Effective Prompt Writing
ja: Effective Prompt Writing
Expand Down
Binary file added docs/images/einstein-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.