Welcome to the Einstein GPT for Developers Pilot
Congratulations! Your team has been nominated to participate in the Einstein GPT for
Developers pilot. We thank you for taking the time to use Einstein GPT for Developers and
provide feedback. Your input is instrumental to improving the product and user experience.
This guide shows you how to set up the Einstein GPT extension in Visual Studio Code, and
generate your first lines of code using AI. We also show you some sample prompts and
responses and share known issues and troubleshooting tips.
A Reminder About Pilot Software
Pilot software isn’t yet feature complete and is at an early stage of development. You should use
the Einstein GPT for Developers product to evaluate how it could possibly be used for your
team and to provide us with feedback on your experience as we continue its development.
As with all LLM-based products, the technology behind this product is still new. The generated
output will often require editing to be customized for your individual project. We'd love to hear
feedback from you on the generated output through the History & Feedback Panel in the IDE -
this will be instrumental in the continuous training of our large language model (LLM) during the
Pilot program.
Product Overview
Einstein GPT for Developers is an AI-powered developer tool that is available as an
easy-to-install VS Code extension built using CodeGen, Salesforce’s secure, custom AI model.
Use the tool to enhance developer productivity by quickly generating code using natural
language instructions.
Einstein GPT for Developers assists you throughout the Salesforce development process with
expertise learned from anonymized code patterns. The long-term goals of our suite of
AI-powered developer tools are to increase productivity and provide helpful assistance for
complex coding tasks. We aim to enforce development best practices with our code generation
and just-in-time code completion features eventually. AI-assisted tooling will also make it easier
for new developers to onboard to the Salesforce Platform.
Current Capabilities
The initial release of this pilot focuses on natural language to Apex code generation. This
feature, used along with IntelliSense, makes Apex development tooling in Visual Studio Code
even richer. Familiarity with Visual Studio Code is assumed.
At this point of time, the Einstein GPT for Devs extension can:
● Generate code from natural language instructions within an existing Apex class, trigger,
or anonymous Apex file. A new command in the VS Code Command Palette, SFDX:
Generate Code with Einstein GPT, lets you enter in a prompt describing what you'd like
to build and then generate Apex code within your editor.
At this time, the tool does not:
● Create new Apex class files through natural language prompts. Apex files must already
be created to trigger the command.
● Take into account any metadata (or context) from your local project or Salesforce org.
Generated code is determined by your prompt only.
We plan to follow up with inline code completion and LWC code generation in the coming
months.
About Trusted Generative AI at Salesforce
Salesforce’s Einstein GPT solutions are designed, developed, and delivered based on five
principles for trusted generative AI.
Accuracy: We prioritize accuracy, precision, and recall in our models, and we back our model
outputs up with explanations and sources whenever possible. We recommend that a human
check model output before sharing with end users.
Safety: We work to mitigate bias, toxicity, and harmful outputs in our models using
industry-leading techniques. We protect the privacy of personally identifiable information (PII) in
our data by adding guardrails around this data.
Honesty: We ensure that the data we use in our models respects data provenance and we that
have consent to use the data.
Empowerment: Whenever possible, we design models to include human involvement as part of
the workflow.
Sustainability: We strive to build right-sized models that prioritize accuracy and to reduce our
carbon footprint.
Learn more at Salesforce AI Research: Trusted AI.
About the CodeGen Model
CodeGen is a powerful language model capable of generating text and code. The release of
CodeGen 1.0 as an open-source project in 2022 could generate code in six different
programming languages. Since then, the CodeGen model, integrated into Einstein GPT for
Developers and Flow GPT, has been re-trained and fine-tuned to address specific Salesforce
use cases, including Apex and LWC. This refinement significantly enhances the model’s ability
to customize and tailor Salesforce solutions.
Before you begin
User Permissions
For the pilot, Einstein GPT for Developers permissions are activated for you in a given sandbox
or Dev Hub org. Your team has been added to this Trailblazer Community Group, which is
where you can download the latest version of the Einstein GPT for Developers extension, and
where you can give us feedback.
Install Visual Studio Code
Skip this section if you already have Visual Studio Code installed on your desktop. If not, go to
code.visualstudio.com, follow the instructions for your operating system, and install VS Code.
NOTE: VS Code releases a new version each month with new features and important bug fixes.
You must be on VS Code Version 1.76 or higher to run the Einstein GPT for Developers
extension. You can manually check for updates from Help > Check for Updates on Linux and
Windows or Code > Check for Updates on macOS.
Install Salesforce CLI
Skip this section if you already have Salesforce CLI installed on your desktop. If not, go to
Salesforce CLI, follow the instructions for your operating system and install Salesforce CLI.
Install Einstein GPT for Developers Extensions
Einstein GPT for Developers can be downloaded as three VS Code extension files, available
from this Google Drive. If you see this User Guide, you have access to this Google Drive folder
containing the associated vsixes. During this pilot, you can download the latest versions of
these extensions from this Google Drive. To see the vsixes, jump into the main folder.
Download and install these three files:
* salesforcedx-vscode-core-<version>.vsix
* salesforcedx-vscode-apex-<version>.vsix and
* salesforcedx-einstein-gpt-<version>.vsix
Note: If you don’t have a GitHub account, it’s easy (and free) to sign up for one.
To install the extensions:
1. Launch Visual Studio Code.
2. Run the Install from VSIX… command in the Extensions view command dropdown, or
run the Extensions: Install from VSIX command in the Command Palette, and install
each .vsix file.
3. Confirm that the extension is installed.
Project Setup
The Einstein GPT for Developers tool is run in the context of a Salesforce org, in Salesforce DX
project. To use this tool:
1. Go to File > Open Folder in the menu and open an existing Salesforce DX project in VS
Code, or set up a new project.
2. Run the SFDX: Authorize an Org command to connect to a Salesforce sandbox org or
scratch org. You work on Einstein GPT for Developers in this environment.
If you're using scratch orgs, activate Einstein GPT for Developers by turning on an add-on
scratch org feature.
Edit and save the config/project-scratch-def.json file in your DX project to add the
“EinsteinGPTForDevelopers” feature to your existing feature list.
For example:
{
"orgName": "Acme Company",
"edition": "Developer",
"features":[“Communities”, “ServiceCloud”, "EinsteinGPTForDevelopers"]
}
Show Einstein Feedback Console View
Run SFDX: Show GPT 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 feedback about the
quality of the generated code. Your feedback during this pilot is key to helping us improve AI
model quality and overall product.
Use Einstein GPT for Apex Programming
Generate Apex Code
Einstein GPT for Developers runs in an Apex file in the VS Code Editor.
1. Open an existing Apex (.cls) file, or create one from the command palette by running the
SFDX: Create Apex Class command. You can also use the Org Browser to retrieve an
Apex class from your org.
2. Place your cursor on the line in the file where you want the generated code to be placed.
3. From the Command Palette, run SFDX: Generate Code with Einstein GPT.
4. For your query, enter text that describes the code that you want to generate. For
example, “Write a method that takes an account as a parameter and returns all contacts
associated with that account.”
5. Accept, Try Again, or Clear the code that Einstein GPT generates.
You successfully received your first code suggestion, but that is just the beginning! Use our
example prompts to exercise your code generation muscle and learn how to get the most out of
the generative AI tool.
Note: You can also access the SFDX: Generate Code with Einstein GPT command through
hotkeys. Keyboard shortcuts are the following across environments:
● macOS - Cmd+R
● Windows & Linux - Ctrl+R
You may also customize these shortcuts. See Keyboard Shortcuts editor for more info.
Example Prompts and Responses
Prompt writing is key to quality code generation. Here’s some tips for improved prompt writing
and a selection of sample prompts to start you on your generative AI code assistance journey.
Original Prompt Improved Prompt
Write Apex code that sorts the Write Apex code that sorts the list of contacts
list of contacts. alphabetically by last name.
Write a method that adds two Write a method that adds two numbers and
numbers. returns the result.
Write an apex method that Write an apex method that accepts an
returns fields for an object. SObject and returns a list of its fields.
Prompt: Write an apex method that accepts a List of sObjects and a field name and returns a
Set of non null field values.
Response:
Unset
public Set<String> getFieldValues(List<sObject> records, String fieldName) {
Set<String> fieldValues = new Set<String>();
for (sObject record : records) {
try {
Object fieldValue = record.get(fieldName);
if (fieldValue != null) {
fieldValues.add((String) fieldValue);
}
} catch (Exception e) {
system.debug('Error: ' + e.getMessage());
}
}
return fieldValues;
}
Prompt: Create an @invocable method that serializes an input list of sObjects and returns
JSON.
Response:
Unset
@InvocableMethod(label='Create Account' description='Creates a new account with the
specified name, number and symbol.' category='Account')
public static List<String> createAccounts(List<Account> accounts) {
List<String> response = new List<String>();
for (Account account : accounts) {
String jsonAccount = JSON.serialize(account);
response.add(jsonAccount);
}
return response;
}
Prompt: Write an apex method that accepts product name as input and retrieves orderitems
filtered on product name.
Response:
Unset
public List<OrderItem> getOrderItemsByProductName(String productName) {
List<OrderItem> orderItems = [SELECT Description FROM OrderItem WHERE ProductCode =
:productName LIMIT 50];
return orderItems;
}
Prompt: Write an Apex trigger to add the number of contacts associated with an account.
Unset
trigger gptcontacttrigger on Account (after insert, after update) {
List<Contact> listContacts = new List<Contact>();
for (Account acc : Trigger.new) {
List<Contact> listaccContacts = [SELECT Id, Name, AccountId FROM Contact WHERE
AccountId = :acc.Id];
if (acc.Contacts.size() < listaccContacts.size()) {
acc.addError('Not enough contacts');
}
}
}
Edit a Prompt and Regenerate Output
A well designed prompt is key to getting a good response from Einstein GPT. We encourage
you to modify your prompts until you get Apex code that helps you complete your task at hand.
For example, the prompt, "Write code to provide the ability to update the FirstName for a list of
users" generates the following response:
Unset
public with sharing class AccountService {
public Account createAccount( String accountName, String
accountNumber, String tickerSymbol ) {
Account newAcct = new Account(
Name = accountName,
AccountNumber = accountNumber,
TickerSymbol = accountNumber
);
return newAcct;
}
//This is a method that allows updating the FirstName for a list of
users
public static void updateFirstName(List users) {
for (User usr : users) {
if (usr.FirstName != null) {
usr.FirstName = 'New First Name';
}
}
}
Click Accept if you like this output or Retry again to update your prompt and regenerate a new
output.
Generated Code Quality Feedback
As with all LLM-based products, the technology behind this product is still new. The generated
output will often require editing to be customized for your individual project and responses may
not be optimal. We'd love to hear feedback from you on the generated output through the
History & Feedback Panel in the IDE - your feedback will be critical to the continuous training of
our large language model (LLM) during the Pilot program.
We strongly encourage you to let us know when you see examples of less optimal code, so that
we can continue to improve generated responses. Please use tools such as Apex PMD (already
in your Salesforce Extension Pack) and Salesforce Code Analyzer to ensure the quality of your
generated code.
Create a new Salesforce DX Project for AI-assisted
development
Complete these steps if you don’t want to use an existing Salesforce DX project for
development using Einstein GPT for Developers:
1. In Visual Studio Code, from the Command Palette run, SFDX: Create Project.
2. Click New Project to create a new Salesforce DX project.
3. Choose Standard for project type, and give your project a name.
You now have a directory structure with files and folders that make up an SFDX project. You
can:
● Connect your project to an org that has Einstein GPT enabled by using the SFDX: Open
Default Org command and logging into the org. Or
● Create scratch orgs to test drive Einstein GPT.
Troubleshooting Einstein Responses
Generative AI uses large language models (LLMs) to generate the output. Because LLMs are
trained by other organizations, the output isn’t always what you expect, and the code that’s
generated isn’t perfect. If the output doesn’t meet your expectations, you can generate a new
output by starting over. The generated output from the previous attempt isn’t saved, and the
new output replaces it.
We encourage you to provide feedback about the output using the 👍 👎and buttons. You can
also comment on why the output wasn’t helpful. Thumb responses and additional feedback are
shared only with Salesforce and are used for pilot feedback. To keep track of all known issues
and potential workarounds, use the Issues tab in this repo.
FAQ
What is Einstein GPT for Developers?
Einstein GPT for Developers is an AI-assisted tooling that is available as an easy-to-install VS
Code extension built using Einstein GPT, Salesforce’s secure, custom AI model.
What data has Einstein GPT for Developers been trained on?
Einstein GPT for Developers uses Salesforce’s trusted generative AI, CodeGen, to assist you
through Salesforce development. CodeGen uses expertise that’s learned from anonymized
code patterns.
Where can I learn more about Einstein GPT for Developers Privacy and Data Protection?
See Salesforce’s Trusted AI.
I'm unable to use the Einstein GPT for Developers extension in the IDE
Make sure that you followed the Install Einstein GPT for Developers Extensions. If you still need
help, log an issue.
Will my code ever be shared outside of my development environment?
In short, no! Salesforce treats your code as confidential information under your Main Service
Agreement (MSA) and doesn't disclose it to other Salesforce customers or anyone outside of
Salesforce. Your code and entity schema may be used to improve Einstein GPT for Developers
and train CodeGen. Due to the nature of machine learning, Einstein GPT for Devs can generate
output that resembles code that was used to train the model.
I still have some security concerns, what if my code contains proprietary info?
Before using any code to label or build models, the research team scrubs all personally
identifiable information (PII) and secrets info from the code. This information includes names,
company names, phone numbers, address, and hard-coded API tokens. The data is encrypted
at rest using customer-managed encryption keys. For more information see Customer-managed
encryption keys (CMEK). We also ensure that only Salesforce employees handle your code,
and not contractors.
Feedback
👍👎
From the Command Palette run View: Show GPT Prompt History to open the Feedback
console. Use , and comments for each prompt to provide feedback during this pilot. To ask
questions, request features, and post feedback, use the Discussions tab.
Support
If you need support during the pilot, file an issue in the GitHub repo. Our team triages all
incoming pilot issues and gets back to you as fast as we can.
Glossary
Here’s a list of some commonly used generative AI terms in context of our tooling.
Generative Pre-Trained Transformer (GPT): A family of language models developed by
OpenAI generally trained on a large corpus of text data such that they can generate human-like
text.
Grounding: The process through which domain-specific knowledge and customer information is
injected into the prompt. Human In the Loop (HITL): a model that requires human interaction.
Intent: A user’s goal for interacting with the AI-Assistant.
Large Language Model (LLM): A language model consisting of a neural network with many
parameters trained on large quantities of text.
Prompt: A natural language description of the task to be accomplished. An input to the LLM.
Prompt Management: The suite of tools used to build, manage, package, and share prompts,
including the prompt templates and the prompt template store.
Prompt Template: A string with placeholders/tags that can be replaced with custom values to
generate a final prompt. The template includes the hyperparameters associated with that
prompt, and model/vendor choice if not using default values.
Prompt Chaining: The method to select the right prompt engineering, which is a break-up of
complex tasks into several intermediate steps, and then tie it back together in the hope that the
AI generates a more concrete, customized, and thus better result. To get the best prompt in this
pilot, use the “Retry” option to regenerate code.
Semantic Retrieval: A scenario that allows a large language model to utilize all the knowledge
that exists in a customer's CRM data. Each CRM user has access to a personalized generative
AI.
Telemetry & Data Collection
For this smaller pilot, you contributed your Apex and LWC code and Salesforce organization
schema to help train our generative large language model. Salesforce doesn’t consider code
and entity schema that you sent us Customer Data under your Main Service Agreement (MSA).
with Salesforce treats it as Confidential Information under your MSA and doesn’t disclose it to
other Salesforce customers. Salesforce uses your code and entity schema to develop and train
Einstein GPT for Developer Productivity, and by sending them, you grant Salesforce a license to
use your code for such purposes. You retain ownership of your code, and Salesforce retains
sole ownership of Einstein GPT for Developer Productivity.
Due to the nature of machine learning, Einstein GPT for Developer Productivity can generate
output that resembles code used to train the model. Neither you nor Salesforce own output
generated for parties other than themselves.
Additional Terms of Use for the Einstein for
Developers Extension
The Salesforce Extensions for Visual Studio Code include a set of extensions built using
Salesforce’s LLM Gateway and CodeGen global model (the “Einstein GPT for Developers
Extensions”). The Einstein GPT for Developers Extensions provide generative AI capabilities
directly within your standard Salesforce IDE tooling and include, but are not limited to, the
following use cases:
● Code Auto-Completion - Intelligent inline code suggestions; and
● Code Generation from Natural Language - Ability to describe code logic or objectives in
plain English and generate a piece of code using AI.
Use of the Einstein GPT for Developers Extensions is subject to the following additional terms:
1. “Submitted Code” is defined as (a) prompts submitted to the Einstein GPT for
Developers Extensions, (b) response code generated by the Einstein GPT for
Developers Extensions, and (c) feedback and associated code within your project that
are used to provide additional context to the model (i.e., grounding).
2. Salesforce will use Submitted Code to develop and train the CodeGen global model, and
you are granting Salesforce a license to use Submitted Code for such purposes.
3. You will retain ownership of your Submitted Code, and Salesforce will retain sole
ownership of the Einstein GPT for Developers Extensions, LLM Gateway, and CodeGen
global model.
4. The Einstein GPT for Developers Extensions may generate output that resembles code
used to train the model. For the avoidance of doubt, neither you nor Salesforce will own
output generated for parties other than themselves.
5. Submitted Code will not be shared with any parties other than Salesforce.
6. No Warranty. THE EINSTEIN GPT FOR DEVELOPERS EXTENSIONS ARE PROVIDED
“AS-IS,” EXCLUSIVE OF ANY WARRANTY WHATSOEVER, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHERWISE. SALESFORCE DISCLAIMS ALL IMPLIED
WARRANTIES, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE OR
NON-INFRINGEMENT, TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE
LAW. The Einstein GPT for Developers Extensions and/or generated code may contain
bugs or errors, and their use is at your sole risk. You acknowledge that Salesforce may
discontinue the Einstein GPT for Developers Extensions at any time in its sole discretion,
and may never make them generally available.
7. No Damages. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY
DAMAGES WHATSOEVER, INCLUDING BUT NOT LIMITED TO DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR
DAMAGES BASED ON LOST PROFITS, DATA, OR USE, HOWEVER CAUSED AND,
WHETHER IN CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
_Last Updated: June 2023 _