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

做防水怎样注册网站广州网站设计服务商

做防水怎样注册网站,广州网站设计服务商,网络营销策略包括,那个网站建设在这一章中,我们将探讨如何结束自动生成代理之间的对话。 导入必要的库 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.yayakq.cn/news/243329/

相关文章:

  • asp在网站开发中的作用seo排名如何
  • 银川网站建设nx110青岛网站开发设计
  • 泉州企业建站模板国外素材网站
  • 宁波哪家做网站好装修网站怎么做
  • 中国网站制作 第一个成都市建设工程质量协会网站
  • dedecms网站栏目管理成立公司协议
  • 教育网站制作视频wordpress原创培训主题
  • 前端网站开发流程图免费的建手机网站
  • 网站建设的不足广州网站设计制作报价
  • 大连建站企业电子商务网站开发技术和工具有哪些
  • 南通优化网站公司哪家好ui设计一般用什么软件
  • 适合个人做的网站有哪些东西吉林省吉林市永吉县
  • 无为住建设局网站深圳做网站公司那家比较好
  • 重庆网站制作企业网站建设 实施计划
  • 如何用ps制作网站wordpress加速会主题曲
  • 罗定微网站建设南漳县建设局网站
  • 网站建设方案策划书ppt模板下载怎么做网站截图
  • 网站建设新闻发布招商网站建设免费
  • 首都农村医学人才培养体系建设与农村医学人才培养的研究与实践 网站重庆营销型网站
  • seo网站怎么做wordpress怎么开启
  • 公司做网站最低需用多少钱画图标网站
  • 漳州最便宜的网站建设价格服装公司网站模板
  • 推广公司网站有哪些方式邯郸建网站公司
  • 云谷系统网站开发网站建设的设立方式
  • 徐州网站建设百度引擎搜索推广
  • 建一个网站的手机电脑做农产品网站
  • 组建网站 多少钱大型集团公司网站建设方案
  • wordpress响应式网站模板下载wordpress 移动分享
  • 江苏中南建设集团网站是多少钱洛阳网站建设的公司哪家好
  • 网上做石材去哪个网站山东省东营市建设局网站