OpenAI官方吴达恩《ChatGPT Prompt Engineering 提示词工程师》(6)扩写 / Expanding

扩写 / Expanding

扩展是将短的文本片段,比如一组说明或一系列主题,并让大型语言模型生成更长的文本,比如生成文章,或者电子邮件。

环境准备

和(①指南)一样需要搭建一个环境

自动回复邮件

举例,在推理中,能提取用户情绪,现在我们将根据情绪定制回复。下面是用户的评论。

given the sentiment from the lesson on "inferring",
and the original customer message, customize the email
sentiment = "negative"

review for a blender
review = f"""
So, they still had the 17 piece system on seasonal \
sale for around $49 in the month of November, about \
half off, but for some reason (call it price gouging) \
around the second week of December the prices all went \
up to about anywhere from between $70-$89 for the same \
system. And the 11 piece system went up around $10 or \
so in price also from the earlier sale price of $29. \
So it looks okay, but if you look at the base, the part \
where the blade locks into place doesn’t look as good \
as in previous editions from a few years ago, but I \
plan to be very gentle with it (example, I crush \
very hard items like beans, ice, rice, etc. in the \ 
blender first then pulverize them in the serving size \
I want in the blender then switch to the whipping \
blade for a finer flour, and use the cross cutting blade \
first when making smoothies, then use the flat blade \
if I need them finer/less pulpy). Special tip when making \
smoothies, finely cut and freeze the fruits and \
vegetables (if using spinach-lightly stew soften the \ 
spinach then freeze until ready for use-and if making \
sorbet, use a small to medium sized food processor) \ 
that you plan to use that way you can avoid adding so \
much ice if at all-when making your smoothie. \
After about a year, the motor was making a funny noise. \
I called customer service but the warranty expired \
already, so I had to buy another one. FYI: The overall \
quality has gone done in these types of products, so \
they are kind of counting on brand recognition and \
consumer loyalty to maintain sales. Got it in about \
two days.
"""

下面是prompt“这里的说明是您是一名客户服务AI助理,您的任务是发送一封关于您的客户的电子邮件回复,给定由三个反引号分隔的客户电子邮件,生成回复以感谢客户的评论。如果情绪是积极或中立的,感谢他们的评论。如果情绪是消极的,道歉并建议他们可以联系客户服务。确保使用评论中的具体细节,以简洁和专业的语气书写,并以客户代理AI身份签署电子邮件。”

prompt = f"""
You are a customer service AI assistant.
Your task is to send an email reply to a valued customer.
Given the customer email delimited by ```, \
Generate a reply to thank the customer for their review.
If the sentiment is positive or neutral, thank them for \
their review.
If the sentiment is negative, apologize and suggest that \
they can reach out to customer service. 
Make sure to use specific details from the review.
Write in a concise and professional tone.
Sign the email as AI customer agent.
Customer review: ``{review}``
Review sentiment: {sentiment}
"""
response = get_completion(prompt)
print(response)

"""
Dear Valued Customer,

Thank you for taking the time to leave a review about our product. We are sorry to hear that you experienced an increase in price and that the quality of the product did not meet your expectations. We apologize for any inconvenience this may have caused you.

We would like to assure you that we take all feedback seriously and we will be sure to pass your comments along to our team. If you have any further concerns, please do not hesitate to reach out to our customer service team for assistance.

Thank you again for your review and for choosing our product. We hope to have the opportunity to serve you better in the future.

Best regards,

AI customer agent
"""

接下来,我们将使用语言模型中的一个参数,称为温度,你可以将温度视为模型的探索程度或随机性。温度值越高,创意性越高。参考文章《ChatGPT怎样提升创意性?》

prompt = f"""
You are a customer service AI assistant.
Your task is to send an email reply to a valued customer.
Given the customer email delimited by ```, \
Generate a reply to thank the customer for their review.
If the sentiment is positive or neutral, thank them for \
their review.
If the sentiment is negative, apologize and suggest that \
they can reach out to customer service. 
Make sure to use specific details from the review.
Write in a concise and professional tone.
Sign the email as AI customer agent.
Customer review: ``{review}``
Review sentiment: {sentiment}
"""
response = get_completion(prompt, temperature=0.7)
print(response)
"""
Dear valued customer,

Thank you for taking the time to leave a review about our product. We are sorry to hear that you experienced an increase in price for the system you were interested in, and that you also experienced an issue with the motor after a year of use. We apologize for any inconvenience this may have caused you.

Please know that our company strives to provide excellent customer service and we would like to assist you with this matter. Please feel free to reach out to our customer service team at any time for assistance.

Thank you again for your feedback and for choosing our product. 

Best regards,
AI customer agent
"""

你可能感兴趣的:(提示词工程,chatgpt,prompt,人工智能)