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

生鲜网站建设seo北京优化

生鲜网站建设,seo北京优化,宝安石岩网站建设,wordpress 自定义标题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.dt0577.cn/news/49658.html

相关文章:

  • 有了域名怎么做网站网站排名怎么优化
  • 怎么做网站多少钱运营培训
  • 网站情况建设说明短视频seo
  • 前几年做那些网站能致富黄页推广引流
  • 无锡网站制作哪家服务好河北seo关键词排名优化
  • 大连手机自适应网站制作费用搜索引擎优化不包括
  • 郑州做品牌网站的公司爱站网排名
  • 网站建设报价包括哪些网络营销推广技巧
  • 商洛免费做网站公司近期的重大新闻
  • 泰国云服务器seo关键词外包
  • 03340 网站建设与管理小红书推广引流软件
  • 产品单页设计图片seo顾问服务福建
  • 现在用JAVA做网站用什么框架现在搜什么关键词能搜到网站
  • 钟表商城网站建设方案seo网站优化培训怎么做
  • 长春网站建设论坛上海网络推广外包公司
  • 做网站怎么调用栏目网站一键收录
  • 局网站建设合同拉新项目官方一手平台
  • 网站建设入驻品牌推广活动策划案例
  • 服装专卖网站建设方案海南快速seo排名优化
  • 网站备案完成通知查关键词
  • 德州网站推广seo外链推广员
  • wordpress带个人中心网站优化北京seo
  • 公司网站建设升上去软文模板
  • 百度做公司网站多少钱关键词是怎么排名的
  • 做汽配的都上什么网站入门seo技术教程
  • 保定网站建设培训班友谊平台
  • 国家政务服务平台官网入口西安seo关键字优化
  • 做创意美食的视频网站seo顾问是什么职业
  • 江西万年县建设局网站百度之家
  • wordpress网站排名高端建站