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

淘客做的领券网站网站开发外包维护合同范本

淘客做的领券网站,网站开发外包维护合同范本,杭州做模板网站,360免费自助建站why autogen The whole is greater than the sum of its parts.(整体的功能或价值往往超过单独部分简单相加的总和。) -Aristotle autogen 例子 1. 导入必要的库 首先,导入os库和autogen库中的ConversableAgent类。 import os from autogen import Conversable…

why autogen

The whole is greater than the sum of its parts.(整体的功能或价值往往超过单独部分简单相加的总和。)
-Aristotle

autogen 例子

1. 导入必要的库

首先,导入os库和autogen库中的ConversableAgent类。

import os
from autogen import ConversableAgent

2. 配置LLM(大型语言模型)

接下来,配置LLM的参数。这里我们使用GLM-4-Plus模型,并提供了API密钥和基础URL。

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

3. 创建对话代理

使用ConversableAgent类创建一个对话代理。这里我们创建一个名为chatbot的代理,并关闭代码执行功能和人类输入模式。

agent = ConversableAgent("chatbot",llm_config=llm_config,code_execution_config=False,  # 关闭代码执行,默认为关闭。function_map=None,  # 没有注册函数,默认为None。human_input_mode="NEVER",  # 从不请求人类输入。
)

4. 生成回复

我们可以通过调用generate_reply方法来生成对话回复。这里我们传入一个包含用户消息的列表。

reply = agent.generate_reply(messages=[{"content": "Tell me a joke.", "role": "user"}])
print(reply)

输出结果如下:

[autogen.oai.client: 11-24 16:28:32] {351} WARNING - Model GLM-4-Plus is not found. The cost will be 0. In your config_list, add field {"price" : [prompt_price_per_1k, completion_token_price_per_1k]} for customized pricing.
Sure! Here's one for you:Why don't skeletons fight each other?Because they don't have the guts! 🦴😄

5. 创建多个对话代理

创建多个对话代理,并为它们设置不同的系统消息。这里创建两个喜剧演员代理:Cathy和Joe。

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",  # 从不请求人类输入。
)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",  # 从不请求人类输入。
)

6. 初始化对话

使用initiate_chat方法初始化对话。这里我们让Joe向Cathy发起对话,并设置最大对话轮数为2。

result = joe.initiate_chat(cathy, message="Cathy, tell me a simple and easy-to-understand joke.", max_turns=2)

输出结果如下:

[33mjoe[0m (to cathy):Cathy, tell me a simple and easy-to-understand joke.--------------------------------------------------------------------------------
[autogen.oai.client: 11-24 16:40:20] {351} WARNING - Model GLM-4-Plus is not found. The cost will be 0. In your config_list, add field {"price" : [prompt_price_per_1k, completion_token_price_per_1k]} for customized pricing.
[33mcathy[0m (to joe):Sure thing! Here's one for you:Why don't eggs tell jokes?Because they might crack up! 🥚😂--------------------------------------------------------------------------------
[autogen.oai.client: 11-24 16:40:23] {351} WARNING - Model GLM-4-Plus is not found. The cost will be 0. In your config_list, add field {"price" : [prompt_price_per_1k, completion_token_price_per_1k]} for customized pricing.
[33mjoe[0m (to cathy):Oh, Cathy, that's a classic! You know, eggs are always walking on eggshells, trying not to break their yolks. But let me add a punchline to that:Why don't eggs tell jokes?Because they might crack up, and then we'd have a real scrambled situation on our hands! 🍳😂Now, let's get out there and egg-ceed our audience's expectations! 🎤🤣--------------------------------------------------------------------------------
[autogen.oai.client: 11-24 16:40:27] {351} WARNING - Model GLM-4-Plus is not found. The cost will be 0. In your config_list, add field {"price" : [prompt_price_per_1k, completion_token_price_per_1k]} for customized pricing.
[33mcathy[0m (to joe):Oh, I love it! That's the spirit! Adding a little extra zing to the punchline really takes it up a notch. 🌟 With that kind of egg-cellent humor, we're bound to have them laughing all the way to the fridge! Let's crack those jokes and whisk up some fun! 🥚🎭🤣 Ready to take the stage and egg-press our comedic genius? Let's do this! 🚀🎤

总结

通过本教程,我们学习了如何使用Autogen库创建对话代理,并展示了如何生成对话回复和初始化多代理对话。希望这能帮助你更好地理解和应用Autogen库。

参考链接:https://microsoft.github.io/autogen/0.2/docs/tutorial/introduction
如果有任何问题,欢迎在评论区提问。

http://www.yayakq.cn/news/830882/

相关文章:

  • 网站开发设计有限公司seo云优化软件破解版
  • 西安网站网络营销淘宝店铺去哪里买
  • 潍坊免费模板建站深圳 网站开发公司
  • 中国免费企业建站如何做网站走查
  • 最便宜买机票网站建设马鞍山网站seo
  • 深圳福田网站制作中国十大搜索引擎排名最新
  • 外文网站制作深圳分销网站设计价格
  • 青海城乡建设厅网站 官网服务网站排名咨询
  • 企业建网站服务郑州网站外包
  • 视频点播网站开发教程推广公众号的9种方法
  • 免费网站模板制作软件定制开发公司地址
  • 仿微博网站模板境外电商网站建设
  • 鄂州网站设计制作公司手表网站免费设计
  • 镇网站制作价格seo免费教程
  • 各人可做的外贸网站平舆专业网站建设
  • 门户网站建设的企业网站项目进度
  • 江苏省高职重点专业群建设网站网站地图的形式
  • 房地产网站制作教程做网站如何接单
  • 模块网站开发工具html5 网站开发 适配
  • ipad可以做网站推广吗设计一个外贸网站需要多少钱
  • c2c网站购物体验情况登记表js做网站需要那些软件
  • 深圳网站专业制作学做网站论坛VIP怎么样
  • 德州网站收录做网站的自我介绍
  • 如何增强网站的安全性国外ip怎么弄
  • wordpress wp-admin优化方案化学2023版电子版
  • 网站访客品牌策划公司的市场
  • 中国设计网站官网地址越秀网站建设方案
  • 湖南省住房与城乡建设厅网站wordpress访客统计
  • 北京医疗网站建设网站建设工具
  • flash网站片头动画一个软件app