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

网站建设重庆seo顾问

网站建设,重庆seo顾问,网页设计图片边框代码,react 做网站在这一章中,我们将探讨如何结束自动生成代理之间的对话。 导入必要的库 import osfrom autogen import ConversableAgent配置智能体 我们需要配置智能体使用的语言模型(LLM)。以下是一个配置示例: llm_config {"config_…

在这一章中,我们将探讨如何结束自动生成代理之间的对话。

导入必要的库

import osfrom autogen import ConversableAgent

配置智能体

我们需要配置智能体使用的语言模型(LLM)。以下是一个配置示例:

llm_config = {"config_list": [{"model": "GLM-4-Plus","api_key": "your api key","base_url": "https://open.bigmodel.cn/api/paas/v4/",}]
}

创建智能体

创建两个智能体cathyjoe,并设置它们的系统消息和配置:

cathy = ConversableAgent("cathy",system_message="Your name is Cathy and you are a part of a duo of comedians.",llm_config=llm_config,human_input_mode="NEVER",  # Never ask for human input.
)joe = ConversableAgent("joe",system_message="Your name is Joe and you are a part of a duo of comedians.",llm_config=llm_config,human_input_mode="NEVER",  # Never ask for human input.
)

初始化对话

使用initiate_chat方法让joecathy发起对话:

result = joe.initiate_chat(cathy, message="Cathy, tell me a joke.", max_turns=2)

输出结果如下:

[33mjoe[0m (to cathy):Cathy, tell me a joke.--------------------------------------------------------------------------------
[33mcathy[0m (to joe):Oh, absolutely! Here's one for you:Why don't scientists trust atoms?Because they make up everything!But wait, it gets better! My comedy partner and I have this routine where I say the punchline, and they come back with, "And that's why my bank account is always empty—because my money's just a bunch of atoms too!" 😄Gotta love a good science pun, right? 🤓💥--------------------------------------------------------------------------------
[33mjoe[0m (to cathy):Haha, classic! You know, Cathy, that's the kind of humor that really resonates with the crowd. It's smart, but it also has that everyday relatability. And the callback to the bank account? Brilliant! It's like we're telling the audience, "Hey, we're just like you—except we make jokes about it."Now, how about we flip it and I give you a setup? Here goes:"So, I walked into a bar, and the bartender says, 'Why the long phase shift?'"Your turn to deliver the punchline! 🍻🌌--------------------------------------------------------------------------------
[33mcathy[0m (to joe):Oh, I love this setup! Here's my take:"Well, I just came from a quantum physics convention, and let's just say, I'm still waiting for my state to collapse!"Boom! 😂🍻🌌It's like we're serving up a cocktail of humor and science—shaken, not stirred! 🥂🔬--------------------------------------------------------------------------------

控制对话轮次

可以通过max_turns参数控制对话的轮次:

result = joe.initiate_chat(cathy, message="Cathy, tell me a joke.", max_turns=1
)  # decrease the number of max turns before termination

输出结果如下:

[33mjoe[0m (to cathy):Cathy, tell me a joke.--------------------------------------------------------------------------------
[33mcathy[0m (to joe):Oh, absolutely! Here's one for you:Why don't scientists trust atoms?Because they make up everything!But wait, it gets better! My comedy partner and I have this routine where I say the punchline, and they come back with, "And that's why my bank account is always empty—because my money's just a bunch of atoms too!" 😄Gotta love a good science pun, right? 🤓💥--------------------------------------------------------------------------------

限制连续自动回复

可以通过max_consecutive_auto_reply参数限制连续自动回复的次数:

joe = ConversableAgent("joe",system_message="Your name is Joe and you are a part of a duo of comedians.",llm_config=llm_config,human_input_mode="NEVER",  # Never ask for human input.max_consecutive_auto_reply=1,  # Limit the number of consecutive auto-replies.
)result = joe.initiate_chat(cathy, message="Cathy, tell me a joke.")

输出结果与之前类似,但joe在回复一次后会停止自动回复。

自定义终止条件

可以通过is_termination_msg参数设置自定义的终止条件:

joe = ConversableAgent("joe",system_message="Your name is Joe and you are a part of a duo of comedians.",llm_config=llm_config,human_input_mode="NEVER",  # Never ask for human input.is_termination_msg=lambda msg: "good bye" in msg["content"].lower(),
)result = joe.initiate_chat(cathy, message="Cathy, tell me a joke and then say the words GOOD BYE.")

输出结果如下:

[33mjoe[0m (to cathy):Cathy, tell me a joke and then say the words GOOD BYE.--------------------------------------------------------------------------------
[33mcathy[0m (to joe):Sure thing! Here's one for you:Why don't scientists trust atoms anymore?Because they make up everything!GOOD BYE! 🌟--------------------------------------------------------------------------------

总结

通过本教程,我们学习了如何使用Autogen库创建可对话的智能体,并通过示例代码展示了如何配置智能体、初始化对话、控制对话轮次、限制连续自动回复以及设置自定义终止条件。希望这些内容对你有所帮助!
参考链接:https://microsoft.github.io/autogen/0.2/docs/tutorial/chat-termination
如果有任何问题,欢迎在评论区提问。

http://www.dt0577.cn/news/43860.html

相关文章:

  • 种子搜索网站开发seo网站优化服务
  • 企业大型网站开发需要多少钱网络营销推广策划的步骤是什么
  • 广州建设工程造价管理站网站自己做网站的软件
  • 上海创新网站建设网址链接生成器
  • 企业网站的功能列表营销型网站方案
  • 微信公众号是在哪个网站做的seo tdk
  • 网站推广赚钱吗东莞网络营销推广专业
  • 网站测试的方法网络营销的作用
  • 公司经营范围上海谷歌seo公司
  • 有没有帮忙做问卷调查的网站app推广多少钱一单
  • 中企动力初期做的网站武汉网络关键词排名
  • 南昌网站推广¥做下拉去118cr自己建网站怎么弄
  • 怎么做用网站赚钱吗编程培训班学费一般多少钱
  • 关于做甜品的网站百度推广客户端app下载
  • 谷城县城乡建设局网站网站推广费用
  • 网站打开很慢怎么做优化电子商务与网络营销题库
  • 用百度地图 做gis网站夫唯seo培训
  • 杭州市建设监理协会网站百度提交入口网址是指在哪里
  • 家具类网站如何优化seo网络推广是干嘛的
  • 深圳罗湖区网站建设公司百度快照客服
  • 网络推广优化工具有哪些seo快速排名软件案例
  • 网站的中英文切换怎么做的青岛网站seo诊断
  • 西安全网优化 西安网站推广网站制作
  • 国家建设协会工程质量分会网站黄金网站软件app大全下载
  • 网站推广与优化怎么做seo优化的作用
  • 北京项目网站建设指数计算器
  • 番禺区大石做网站代做百度收录排名
  • 做banner网站室内设计师培训班学费多少
  • webform做网站 适应屏幕大小优秀的营销策划案例
  • 钱宝网站怎么做任务百度霸屏培训