Skip to main content
Register now for TDX! Join the must-attend event to experience what’s next and learn how to build it.

提示实际操作

学习目标

完成本单元后,您将能够:

  • 使用专业级提示工程技术编写提示。
  • 解释专业级提示工程相较于直接提示的优势。

既然您已具备提示工程师的思维模式,现在可以自己创建提示。您可以从直接或零样本提示模板开始,来处理几个用例,然后编辑您的初始提示,从而发挥专业级工程技术的优势。通过比较模型对每个提示的输出,您应该能够看到一些简单的更改如何增强每个响应。

您需要按照本单元的步骤操作,才能顺利通过最后的挑战并获取徽章。注册开发人员组织后,请先将该组织连接至 Trailhead(见下文说明),再查看挑战任务并获取徽章。

备注

备注

用中文(简体)学习?在中文(简体)Trailhead Playground 中开始挑战,用括号中提供的译文完成挑战。仅复制并粘贴英文值,因为挑战验证基于英文数据。如果在中文(简体)组织中没有成功通过挑战,我们建议您 (1) 将区域设置切换为美国,(2) 按此处说明将语言切换为英文,(3) 再次单击“检查挑战”按钮。

查看 Trailhead 本地化语言徽章详细了解如何利用 Trailhead 译文。

注册 Agentforce 的 Developer Edition 组织

要完成此模块,您需要一个启用了 Agentforce 的专用 Developer Edition 组织。立即获取免费的 Developer Edition 并将其连接到 Trailhead,以便完成此徽章中的挑战。请注意,此 Developer Edition 是为配合此徽章中的挑战而设计的,可能不适用于其他徽章。请务必检查确认您使用的是我们推荐的 Trailhead Playground 或专用的 Developer Edition 组织。

  1. 单击链接,即可免费注册包含 Agentforce 的 Developer Edition 组织
  2. 填写表格。
    • 在 Email(电子邮件)处输入有效的电子邮件地址。
    • 在 Username(用户名)处输入一个看起来像电子邮件地址且唯一的用户名,但不必是一个有效的电子邮件帐户。
  3. 表格填好以后,单击 Sign me up(我要注册)。出现一条确认消息。
  4. 收到激活电子邮件后(这可能需要几分钟),打开它并单击 Verify Account(验证帐户)。
  5. 设置密码和挑战问题,完成注册。
  6. 您已登录 Developer Edition。

现在将新的 Developer Edition 组织连接到 Trailhead。

  1. 确保您已登录 Trailhead 帐户。
  2. 在页面底部的 Challenge(挑战)部分,单击 Playground 名称,然后单击 Connect Org(连接组织)
  3. 在登录屏幕上,输入刚刚设置的 Developer Edition 的用户名(用户名在您刚刚收到的电子邮件中列出)和密码。
  4. 在 Allow Access?(是否允许访问?)屏幕上,单击 Allow(允许)
  5. 在 Want to connect this org for hands-on challenges?(想要连接此组织进行实践挑战?)屏幕上,单击 Yes!(是!) Save it(保存)

您将被重定向回挑战页面,并准备使用新的 Developer Edition 来获得此徽章。

设置 Agentforce

首先,确保 Agentforce 已启用。

  1. 单击 设置
  2. 在 Quick Find(快速查找)字段中,搜索并选择 Einstein Setup(Einstein 设置)
  3. 确保 Turn on Einstein(打开 Einstein)切换开关为 On(打开)
  4. 刷新浏览器重新加载 Setup(设置)。
  5. 在 Quick Find(快速查找)字段中,搜索并选择 Agentforce Agents(Agentforce 智能体)
  6. 确保 Agentforce 切换开关为 On(打开)

创建零样本提示模板

  1. 在 Quick Find(快速查找)字段中,搜索并选择 Prompt Builder(提示生成器)
  2. 单击 New Prompt Template(新建提示模板)
  3. 按以下要求选择并输入提示模板所需的信息。
    • Prompt Template Type(提示模板类型):Flex
    • Prompt Template Name(提示模板名称):Generate Sample Email(生成电子邮件示例)
    • API Name(API 名称):Generate_Sample_Email(自动填充)
    • Template Description(模板描述):Creates a basic email template.(创建一个基础电子邮件模板)。
  4. 在 Define Sources(定义来源)下,输入以下信息:
    • Name(名称):Customer Account(客户账户)
    • API Name(API 名称):Customer_Account(自动填充)
    • Source Type(来源类型):Object(对象)
    • Object(对象):Account(客户)
  5. 单击 Next(下一步)
    接下来,我们从编写简单的活动邀请电子邮件指令开始。我们会为智能体提供一些指令,以及创建邀请所需的详细信息。
  1. 将以下零样本指令复制并粘贴到提示文本区域

Write the introduction and body for a friendly and professional email from the Salesforce marketing
team inviting an example customer to attend an upcoming event. Include the event name, location, and
value of attending.


Event Details:
Name: Salesforce AI Launch Tour
Location: Chicago
Date: June 25
  1. 现在,为模型引用一个特定的客户账户,以便调用相关数据。在 Template Settings(模板设置)上方,单击 Preview Settings(预览设置)(“”)。
  2. 在 Inputs(输入)下方,找到 Customer Account(客户账户)字段,搜索并选择 Burlington Textiles Corp of America
  3. 单击 Inputs(输入)上方的 Save & Preview(保存并预览)(“”),以生成响应并预览。
    您将看到两个输出字段:Resolved Prompt(已解析的提示)和 Generated Response(生成的响应)。Resolved Prompt(已解析的提示)部分显示了所有占位符已被解析后的提示。您可以在 Generated Response(生成的响应)字段中查看已完成的电子邮件示例。

此零样本响应返回的是一封相当普通的电子邮件,但可以作为起点。我们可以添加一些示例供模型学习,从而优化语气和结构。

使用小样本示例编辑提示

我们可以添加几个小样本示例,以便更清楚地引导模型。

  1. 单击 Prompt(提示)(””) 可返回提示。
  2. 替换 Prompt(提示)区域中的文本然后复制粘贴以下文本:

Write the introduction and body for a friendly and professional email from the Salesforce marketing
team inviting an example customer to attend an upcoming event. Include the event name, location,
and value of attending.


Replicate the following format, but make the email body more detailed and evocative:


Event Details:
Name: Salesforce AI Launch Tour
Location: Chicago
Date: June 25


Example 1:
Event: Salesforce AI Launch Tour
Location: Chicago
Customer: Jordan Manning
Company: FutureWorks Industries
Email:
Subject: You’re Invited to the Salesforce AI Launch Tour – Chicago
Hi Jordan,
We’re excited to invite you and your team at FutureWorks Industries to the Salesforce AI Launch Tour
in Chicago on June 25.
Write the introduction and body for a friendly and professional email from the Salesforce marketing
team inviting an example customer to attend an upcoming event. Include the event name, location, and
value of attending.


Replicate the following format and tone, but replace all names with placeholders. Expand on the email
copy to include at least three paragraphs while keeping the tone friendly and the content engaging.


Event Details:
Name: Salesforce AI Launch Tour
Location: Chicago
Date: June 25


Example 1:
Event: Salesforce AI Launch Tour
Location: Chicago
Customer: Jordan Manning
Company: FutureWorks Industries
Email:
Subject: You’re Invited to the Salesforce AI Launch Tour – Chicago
Hi Jordan,
We’re excited to invite you and your team at FutureWorks Industries to the Salesforce AI Launch Tour
in Chicago on June 25.
It’s a great chance to see how Salesforce AI can drive productivity and connect with peers in your
industry.
Hope to see you there!
– Your Salesforce Team


Example 2:
Event: Salesforce Customer Success Summit
Location: New York
Customer: Maya Jones
Company: NextStep Health


Subject: Let’s Meet at the Salesforce Customer Success Summit
Hi Maya,
We’d love to see you at our Customer Success Summit in New York on May 12.
NextStep Health has been doing incredible work, and this event is a great opportunity to explore
new tools to grow faster with Salesforce. We're excited to share the future and out latest innovations
with our fantastic customers.
Let us know if you can make it!
– Your Salesforce Team
  1. 单击 Save & Preview(保存并预览),即可在 Generated Response(生成的响应)字段中生成并预览响应。
    此时,电子邮件应已反映了您示例中包含的语言和风格。

为您的智能体提供期望输出的特定示例,可助其生成更合适的电子邮件。对比两条提示即可发现:即使简单示例就能显著提升效果,尤其是结合如何使用这些示例的提示指令。最重要的是,这项技巧以及您学到的其他方法,适用于各种 LLM 和提示类型。

尝试思维链提示

了解如何改进基础提示后,接下来可以为零样本提示添加另一个类型的专业级工程内容:思维链提示。为证明这些技术适用于不同输出格式,我们将在 Einstein AI-Generated Search Answers(Einstein AI 生成的搜索答案)提示中进行尝试。

创建新提示模板

  1. 若您仍处于上一个部分的提示界面,单击返回箭头,回到 Prompt Builder Setup(提示生成器设置)页面。
  2. 单击 New Prompt Template(新建提示模板)
  3. 填写下列字段:
    • Prompt Template Type(提示模板类型):Einstein AI-Generated Search Answers(Einstein AI 生成的搜索答案)
    • Prompt Template Name(提示模板名称):Resort Package Names(度假村套餐名称)
      API Name(API 名称):Resort_Package_Names(自动填充)
    • Template Description(模板描述):Generates package names for Coral Cloud resort offerings based on the provided details.(根据提供的详细信息生成 Coral Cloud 度假村产品的套餐名称。)
  4. 单击下一步

定义提示指令

  1. 在 Template Settings(模板设置)上方,单击 Preview Settings(预览设置)(””)。
  2. 在页面左侧的 Inputs(输入)下,输入以下信息:
    • Query(查询):Generate 5 Package names(生成 5 个套餐名称)
    • Chunks(区块)(每个单独占用一行):
      • private villas(私人别墅)
      • beachside dining(海滨餐厅)
      • family-friendly atmosphere(家庭友好的氛围)
  3. 在 Prompt(提示)区域粘贴以下文本:
You are a marketing assistant creating luxurious and appealing resort package names.
Based on the following details, generate 5 creative and enticing names for a resort
vacation package.


Resort details:


Coral Cloud Resorts offers private villas, beachside dining, and a family-friendly
atmosphere focused on luxurious comfort.
  1. 单击 Save and Preview(保存并预览),测试提示。
  2. 请在 Response(响应)部分检查生成的套餐名称,看看您的示例如何改变输出。答案将以括号内的编号名称形式呈现,例如:

{"answer":"1. Coral Cloud Escape Package(Coral Cloud 逸境套餐)\n2. Beachside Bliss Family Retreat(海滨悦享家庭度假套餐)\n3. Luxe Villa Getaway(奢华别墅逸居套餐)\n4. Serenity by the Sea Experience(临海谧境体验套餐)\n5. Private Paradise Family Adventure(私享天堂家庭探险套餐)","sources":""}

您的响应可能与此不同,但只要成功创建了新的套餐名称,就表示操作成功!

添加思维链指令

现在,我们来编辑模板,添加思维链指令。

  1. 单击 Prompt(提示)(””) 可返回提示。
  2. 复制粘贴以下文本替换当前的提示文本:
You are a marketing assistant creating luxurious and appealing resort package names.
Based on the following details, generate 5 creative and enticing names for a resort
vacation package.


Resort details:
Coral Cloud Resorts offers private villas, beachside dining, and a family-friendly
atmosphere focused on luxurious comfort. Make the names concise, elegant, and themed
to match the details. Avoid generic phrases like “Special Deal” or “Vacation Offer.”
Aim for names that evoke emotion and curiosity. Explain your thought process for each
package step-by-step.

通过添加“explain your thought process for each package step-by-step(请逐步解释您为每个套餐命名的思考过程)”这一短语,为您的提示添加思维链逻辑 LLM 能够理解上下文,因此您可以将这些指令添加在任何合理的位置。

  1. 保持查询与区块内容不变。
  2. 单击 Save & Preview(保存并预览),以生成更新后的响应。

现在,您将看到这样的内容:

{"answer":"1. **Serenity Shores Retreat** - This name conveys a sense of peace and tranquility, appealing to those seeking relaxation in luxurious surroundings.(**宁静海岸度假套餐** — 此名称传递出平和宁静的意境,能吸引那些在奢华环境中寻求放松的客人。)\n\n2. **Coral Haven Escape** - The use of 'Haven' suggests a safe and welcoming space, while 'Escape' evokes a desire to leave daily stress behind for a luxurious getaway.(**Coral 港湾逸境套餐** —“港湾”一词暗示了一个安全温馨的空间,“逸境”则唤起人们远离日常压力、享受奢华假期的向往。)\n\n3. **Azure Bliss Villas** - 'Azure' reflects the beautiful ocean colors, and 'Bliss' communicates a feeling of happiness and contentment associated with a luxurious stay.(**蔚蓝悦景别墅套餐** —“蔚蓝”映照美丽的海色,“悦景”传递出与奢华住宿相伴的愉悦与满足感。)\n\n4. **Tropical Tranquility Experience** - This name emphasizes the serene environment of the resort, inviting guests to immerse themselves in a calm and luxurious atmosphere.(**热带静谧体验套餐** — 此名称突出度假村的宁静环境,邀请客人沉浸于平和而奢华的氛围中。)\n\n5. **Family Oasis Retreat** - This name highlights the family-friendly aspect of the resort while suggesting a luxurious and comfortable environment for all ages.(**家庭绿洲度假套餐** — 该名称强调度假村适合家庭的特性,为所有年龄段客人营造出奢华舒适的环境。)","sources":""}

注意到差别了吗?更新后的响应能帮助您理解智能体为何提出这些套餐方案。通过思维链提示,您可以提供 AI 智能体指令,解释它生成每个套餐名称的原因。在这个示例中,您与智能体协作构思了不同的套餐名称。在这个过程中,智能体为您提供了带有相关上下文的示例。使您能透过它生成的内容,洞察其背后的推理过程。随着经验积累,这种洞察将帮助您从每次提示中获得更多价值!

现在,是时候运用思维链提示技巧亲自实践提示生成器了。完成挑战中的步骤后,单击 Check Challenge(检查挑战)即可获得徽章。

祝贺您!您已经能够运用更专业级提示技巧来帮您获得更好的效果。

资源

在 Salesforce 帮助中分享 Trailhead 反馈

我们很想听听您使用 Trailhead 的经验——您现在可以随时从 Salesforce 帮助网站访问新的反馈表单。

了解更多 继续分享反馈