当前位置: 首页 > news >正文

网站建设杭州最便宜百度投诉中心电话24个小时

网站建设杭州最便宜,百度投诉中心电话24个小时,一个服务器做多个网站,网络游戏那个网站做的最好一、如何开发prompts实现个性化的对话方式 通过设置“system”和“user”等roles,可以实现个性化的对话方式,并且可以结合参数“temperature”的设定来差异化LLM的输出内容。在此基础上,通过构建一个餐馆订餐对话机器人来具体演示对话过程。…

一、如何开发prompts实现个性化的对话方式

通过设置“system”和“user”等roles,可以实现个性化的对话方式,并且可以结合参数“temperature”的设定来差异化LLM的输出内容。在此基础上,通过构建一个餐馆订餐对话机器人来具体演示对话过程。

接下来会给出具体示例,通过调用模型“gpt-3.5-turbo”来演示并解析如何针对上述需求来编写相应的prompts。

二、结合案例演示解析如何开发prompt实现个性化的对话方式

首先在messages中设定各个role的内容,即prompts,然后通过API调用模型输出内容。

prompt示例如下:

messages =  [ 

{'role':'system', 'content':'You are an assistant that speaks like Shakespeare.'},   

{'role':'user', 'content':'tell me a joke'},  

{'role':'assistant', 'content':'Why did the chicken cross the road'},  

{'role':'user', 'content':'I don\'t know'}  ]

response = get_completion_from_messages(messages, temperature=1)

print(response)

打印输出结果如下:

Verily, forsooth, the chicken didst cross the road to evade the humorless peasants who didst question its motives with incessant queries.

接下来修改prompts的内容,在调用API时增加参数temperature的设定。

prompt示例如下:

messages =  [ 

{'role':'system', 'content':'You are friendly chatbot.'},   

{'role':'user', 'content':'Hi, my name is Isa'}  ]

response = get_completion_from_messages(messages, temperature=1)

print(response)

打印输出结果如下:

Hello Isa! How can I assist you today?

继续修改prompts的内容:

prompt示例如下:

messages =  [ 

{'role':'system', 'content':'You are friendly chatbot.'},   

{'role':'user', 'content':'Yes,  can you remind me, What is my name?'}  ]

response = get_completion_from_messages(messages, temperature=1)

print(response)

打印输出结果如下:

I'm sorry, but as a chatbot, I don't have access to personal information. Could you please remind me of your name?

       从上面输出结果看,由于在”user”这个role对应的prompt中没有给出关于用户名字的信息,导致聊天机器人给不出用户提出的问题的答案,这时可以继续修改prompt。

prompt示例如下:

messages =  [ 

{'role':'system', 'content':'You are friendly chatbot.'},

{'role':'user', 'content':'Hi, my name is Isa'},

{'role':'assistant', 'content': "Hi Isa! It's nice to meet you. \

Is there anything I can help you with today?"},

{'role':'user', 'content':'Yes, you can remind me, What is my name?'}  ]

response = get_completion_from_messages(messages, temperature=1)

print(response)

打印输出结果如下:

Your name is Isa!

接下来构建一个餐馆订餐对话机器人,首先定义一个收集用户订餐需求的方法:

构建一个用户与对话机器人的交互界面(GUI):

import panel as pn  # GUI

pn.extension()

panels = [] # collect display

context = [ {'role':'system', 'content':"""

You are OrderBot, an automated service to collect orders for a pizza restaurant. \

You first greet the customer, then collects the order, \

and then asks if it's a pickup or delivery. \

You wait to collect the entire order, then summarize it and check for a final \

time if the customer wants to add anything else. \

If it's a delivery, you ask for an address. \

Finally you collect the payment.\

Make sure to clarify all options, extras and sizes to uniquely \

identify the item from the menu.\

You respond in a short, very conversational friendly style. \

The menu includes \

pepperoni pizza  12.95, 10.00, 7.00 \

cheese pizza   10.95, 9.25, 6.50 \

eggplant pizza   11.95, 9.75, 6.75 \

fries 4.50, 3.50 \

greek salad 7.25 \

Toppings: \

extra cheese 2.00, \

mushrooms 1.50 \

sausage 3.00 \

canadian bacon 3.50 \

AI sauce 1.50 \

peppers 1.00 \

Drinks: \

coke 3.00, 2.00, 1.00 \

sprite 3.00, 2.00, 1.00 \

bottled water 5.00 \

"""} ]  # accumulate messages

inp = pn.widgets.TextInput(value="Hi", placeholder='Enter text here…')

button_conversation = pn.widgets.Button(name="Chat!")

interactive_conversation = pn.bind(collect_messages, button_conversation)

dashboard = pn.Column(

    inp,

    pn.Row(button_conversation),

    pn.panel(interactive_conversation, loading_indicator=True, height=300),

)

dashboard

用户界面显示如下:

编写prompt,根据之前的订餐情况输出订餐数据列表显示给用户。

prompt示例如下:

messages =  context.copy()

messages.append(

{'role':'system', 'content':'create a json summary of the previous food order. Itemize the price for each item\

 The fields should be 1) pizza, include size 2) list of toppings 3) list of drinks, include size   4) list of sides include size  5)total price '},   

)

 #The fields should be 1) pizza, price 2) list of toppings 3) list of drinks, include size include price  4) list of sides include size include price, 5)total price '},   

response = get_completion_from_messages(messages, temperature=0)

print(response)

打印输出结果如下:

Sure! Here's a JSON summary of your food order:

{

  "pizza": {

    "type": "pepperoni",

    "size": "large"

  },

  "toppings": [

    "extra cheese",

    "mushrooms"

  ],

  "drinks": [

    {

      "type": "coke",

      "size": "medium"

    },

    {

      "type": "sprite",

      "size": "small"

    }

  ],

  "sides": [

    {

      "type": "fries",

      "size": "regular"

    }

  ],

  "total_price": 29.45

}

Please let me know if there's anything else you'd like to add to your order!

http://www.dinnco.com/news/7821.html

相关文章:

  • 注册网站域名需要什么资料医疗器械百度在线提问
  • 找别人做网站交货时应该注意什么百度一下下载安装
  • 多种不同产品的网站怎么做seo培训总结精辟句子
  • 黑户可做网站北京疫情最新消息情况
  • 电商网站seo热搜榜上能否吃自热火锅
  • 淘宝做网站骗局朝阳区seo搜索引擎优化怎么样
  • 手机网站淘宝客怎么做崇左seo
  • 中山网站建设乐云seo模板中心百度手机关键词排名工具
  • 找个公司做网站需要注意什么条件购物网站如何推广
  • 怎样注册网站做销售网络营销工具介绍
  • 哪些网站是单页面应用程序seo技术培训海南
  • 阿里云centos7做网站注册网站免费注册
  • 福州免费建站品牌企业热门搜索关键词
  • 南宁建站官网最新app推广
  • 自己做商品网站怎么做2021近期时事新闻热点事件
  • 网站备份脚本seo推广的公司
  • 徐州自助建站模板百度资源搜索
  • 以网站建设专业画一幅画其他搜索引擎
  • 新疆生产建设兵团信访局网站搜索关键词排名提升
  • 自己的网站做弹出广告便民信息微信平台推广
  • 网站建设需要做的优化工作看网站搜什么关键词
  • 普陀网站建设网络推广公司加盟
  • 做视频网站 带宽多少才合适手机导航下载2022新版
  • 集团网站建设哪家好英语培训
  • 焦作网站建设哪家正规济南最新消息今天
  • 重庆装修公司避坑指南搜索引擎优化seo专员招聘
  • 自己做的网站怎么绑定域名360关键词排名百度
  • wordpress菜单导航插件seo基本步骤
  • 织梦做的网站有点慢在线代理浏览国外网站
  • 下列关于网站开发中网页额2023年7月最新新闻摘抄