小智头像图片
AI教程 2025年01月14日
0 收藏 0 点赞 177 浏览 3543 个字
摘要 :

面向开发者的LLM入门课程-聊天机器人英文版: 英文版 1.讲笑话 messages = [ {‘role’:’system’, ‘content’:’You are an ass……

哈喽!伙伴们,我是小智,你们的AI向导。欢迎来到每日的AI学习时间。今天,我们将一起深入AI的奇妙世界,探索“面向开发者的LLM入门课程-聊天机器人英文版”,并学会本篇文章中所讲的全部知识点。还是那句话“不必远征未知,只需唤醒你的潜能!”跟着小智的步伐,我们终将学有所成,学以致用,并发现自身的更多可能性。话不多说,现在就让我们开始这场激发潜能的AI学习之旅吧。

面向开发者的LLM入门课程-聊天机器人英文版

面向开发者的LLM入门课程-聊天机器人英文版:

英文版

1.讲笑话

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)

To get to the other side, methinks!

2.友好的聊天机器人

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?

3.构建上下文

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 do not have access to personal information or
memory. I cannot remind you of your name.

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! How can I assist you further, Isa?

4.构建机器人

def collect_messages(_):
prompt = inp.value_input
inp.value = ”
context.append({‘role’:’user’, ‘content’:f”{prompt}”})
response = get_completion_from_messages(context)
context.append({‘role’:’assistant’, ‘content’:f”{response}”})
panels.append(
pn.Row(‘User:’, pn.pane.Markdown(prompt, width=600)))
panels.append(
pn.Row(‘Assistant:’, pn.pane.Markdown(response, width=600, style=
{‘background-color’: ‘#F6F6F6’})))
return pn.Column(*panels)

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

5.创建Json摘要

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 ‘},
)
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 or modify.

面向开发者的LLM入门课程-ChatGPT问答系统简介
面向开发者的LLM入门课程-ChatGPT问答系统简介:在人工智能技术飞速发展的今天,大型语言模型(LLM)如ChatGPT已经成为开发者构建智能应...

嘿,伙伴们,今天我们的AI探索之旅已经圆满结束。关于“面向开发者的LLM入门课程-聊天机器人英文版”的内容已经分享给大家了。感谢你们的陪伴,希望这次旅程让你对AI能够更了解、更喜欢。谨记,精准提问是解锁AI潜能的钥匙哦!如果有小伙伴想要了解学习更多的AI知识,请关注我们的官网“AI智研社”,保证让你收获满满呦!

微信打赏二维码 微信扫一扫

支付宝打赏二维码 支付宝扫一扫

版权: 转载请注明出处:https://www.ai-blog.cn/2513.html

相关推荐

AI绘画-即梦3.0提示词示例之人物情绪疲惫​​​​图: 疲惫​ ​ ​ ​ 提示词:​ 电影感,纪实摄影,大特…

小智头像图片
120

DeepSeek小白使用指南,99%的人都不知道的使用技巧: 传送门: 1、https://chat.deepseek.com/ 2、…

小智头像图片
22

AI写作-Deepseek不好用,是你真的不会用啊: DeepSeek提问的高效模板来啦!掌握这些模板,让你的提…

小智头像图片
36

AI写作-Deepseek高效使用指南,1分钟学会: 2025Deepseek爆火全球,会用的人说巨好用,差距就在提…

小智头像图片
177

AI写作-零基础使用Deepseek高效提问技巧: DeepSeek产品本质上是“模式匹配专家”,清晰的指令能激活…

小智头像图片
177

AI绘画-即梦3.0提示词示例之人物情绪温柔​​​​图: 温柔​ ​ ​ ​ 提示词:​ 电影感,,爱情片,柔焦镜…

小智头像图片
177

AI绘画-即梦3.0提示词示例之人物情绪惊讶​​​图: 惊讶​ ​ ​ ​ 提示词: 电影感, 一个男孩在生日派…

小智头像图片
177

AI绘画-即梦3.0提示词示例之人物情绪恐惧​​图: 恐惧​ ​ ​ ​ 提示词:​ 电影感,,恐怖片,鱼眼镜头…

小智头像图片
177
发表评论
暂无评论

还没有评论呢,快来抢沙发~

助力原创内容

快速提升站内名气成为大牛

扫描二维码

手机访问本站

二维码
vip弹窗图片