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

发新闻稿做新闻源对网站有啥帮助免费b站软件下载

发新闻稿做新闻源对网站有啥帮助,免费b站软件下载,济南城乡建设委员会网页,wordpress 上传http错误参考: metagpt环境配置参考模型智能体开发之metagpt-单智能体实践 需求分析 之前有过单智能体的测试case,但是现实生活场景是很复杂的,所以单智能体远远不能满足我们的诉求,所以仍然还需要了解多智能体的实现。通过多个role对动…

参考:

  1. metagpt环境配置参考
  2. 模型智能体开发之metagpt-单智能体实践

需求分析

  1. 之前有过单智能体的测试case,但是现实生活场景是很复杂的,所以单智能体远远不能满足我们的诉求,所以仍然还需要了解多智能体的实现。通过多个role对动作的关联、组合来构建一个工作流程,从而使智能体能够完成更加复杂的任务
  2. 基于单智能体测试case的扩展,我们的诉求在简单的输出code的基础上新增一条就是生成code并且立刻运行code。那么这个时候我们就需要两个action,一个负责生成code,一个负责执行code

实现

  1. 定义一个负责生成code的action,参照单智能体的测试case
    模型智能体开发之metagpt-单智能体实践

  2. 定义一个负责运行code的action

    class SimpleRunCode(Action):name: str = "SimpleRunCode"async def run(self, code_text: str):result = subprocess.run(["python3", "-c", code_text], capture_output=True, text=True)code_result = result.stdoutlogger.info(f"{code_result=}")return code_result
    
    1. 运行code不需要调用llm,所以不涉及到prompt模版的设计
    2. 这里通过python的标准库 subprocess来fork一个子进程,运行一个外部程序
      1. subprocess:包内定义了多个可以创建子进程的函数,这些函数分别以不同的方法来创建子进程,所以按需使用即可
      2. 在本次的case里面通过subprocess.run在fork一个子进程执行传入的代码,那么在fork之后,存在两个进程,一个是python程序本身的进程,另一个就是subprocess.run创建的子进程,两个进程是互不干预的
      3. 在父进程中通过result.stdout来获取子进程的执行结果
  3. 定义 RunnableCoder 角色

    1. 完整的代码

      class RunnableCoder(Role):name: str = "Alice"profile: str = "RunnableCoder"def __init__(self, **kwargs):super().__init__(**kwargs)self.set_actions([SimpleWriteCode, SimpleRunCode])self._set_react_mode(react_mode=RoleReactMode.BY_ORDER.value)async def _act(self) -> Message:logger.info(f"{self._setting}: to do {self.rc.todo}({self.rc.todo.name})")# By choosing the Action by order under the hood# todo will be first SimpleWriteCode() then SimpleRunCode()todo = self.rc.todomsg = self.get_memories(k=1)[0]  # find the most k recent messagesresult = await todo.run(msg.content)msg = Message(content=result, role=self.profile, cause_by=type(todo))self.rc.memory.add(msg)return msg
      
    2. 可以看到在重写init方法的时候,这里关联了两个actionSimpleWriteCode, SimpleRunCode

      1. react_mode 设置为 “by_order”,这意味着 Role 将按照 self._init_actions 中指定的顺序执行其能够执行的 Action。在这种情况下,当 Role 执行 _act 时,self._rc.todo 将首先是 SimpleWriteCode,然后是 SimpleRunCode
      def __init__(self, **kwargs):super().__init__(**kwargs)self.set_actions([SimpleWriteCode, SimpleRunCode])self._set_react_mode(react_mode=RoleReactMode.BY_ORDER.value)
      
    3. 重写act方法

      1. 覆盖 _act 函数。Role 从上一轮的人类输入或动作输出中检索消息,用适当的 Message 内容提供当前的 Action (self._rc.todo),最后返回由当前 Action 输出组成的 Message
      async def _act(self) -> Message:logger.info(f"{self._setting}: to do {self.rc.todo}({self.rc.todo.name})")# By choosing the Action by order under the hood# todo will be first SimpleWriteCode() then SimpleRunCode()todo = self.rc.todomsg = self.get_memories(k=1)[0]  # find the most k recent messagesresult = await todo.run(msg.content)msg = Message(content=result, role=self.profile, cause_by=type(todo))self.rc.memory.add(msg)return msg
      
    4. 测试

      1. 代码

        async def main():msg = "write a function that calculates the sum of a list"role = RunnableCoder()logger.info(msg)result = await role.run(msg)logger.info(result)asyncio.run(main())
        
      2. 运行

      3. 在这里插入图片描述

demo如果想正常运行的话,需要调用llm的key,环境配置可以参照 metagpt环境配置参考


文章转载自:
http://dinncomythological.tpps.cn
http://dinncothermoelectrometer.tpps.cn
http://dinncopromises.tpps.cn
http://dinncoclerk.tpps.cn
http://dinncoichthyol.tpps.cn
http://dinncomanstopper.tpps.cn
http://dinncoultracentenarian.tpps.cn
http://dinncounmeasured.tpps.cn
http://dinncodramamine.tpps.cn
http://dinncokriegie.tpps.cn
http://dinncotarry.tpps.cn
http://dinncomanstopper.tpps.cn
http://dinncocowbird.tpps.cn
http://dinncotong.tpps.cn
http://dinnconucleolus.tpps.cn
http://dinncoofflet.tpps.cn
http://dinncoglaciation.tpps.cn
http://dinncotreetop.tpps.cn
http://dinncoreprobate.tpps.cn
http://dinncoesop.tpps.cn
http://dinncosindon.tpps.cn
http://dinncopuma.tpps.cn
http://dinncoallopatrically.tpps.cn
http://dinncocineangiocardiography.tpps.cn
http://dinncodisillusionment.tpps.cn
http://dinncoexcelled.tpps.cn
http://dinncocosmogonal.tpps.cn
http://dinncosherris.tpps.cn
http://dinncokanzu.tpps.cn
http://dinncoacquiescently.tpps.cn
http://dinncoreversed.tpps.cn
http://dinncoconstantan.tpps.cn
http://dinncohiroshima.tpps.cn
http://dinncoturnoff.tpps.cn
http://dinncobefool.tpps.cn
http://dinncomorbific.tpps.cn
http://dinncorepat.tpps.cn
http://dinncoepitaxial.tpps.cn
http://dinncoannicut.tpps.cn
http://dinncohardhanded.tpps.cn
http://dinncowrongdoer.tpps.cn
http://dinncosynclinorium.tpps.cn
http://dinncoalburnous.tpps.cn
http://dinncobertrand.tpps.cn
http://dinncocandied.tpps.cn
http://dinncocenis.tpps.cn
http://dinncotopiary.tpps.cn
http://dinncomorphiomaniac.tpps.cn
http://dinncowharfmaster.tpps.cn
http://dinncoloungewear.tpps.cn
http://dinncoswop.tpps.cn
http://dinncomilanese.tpps.cn
http://dinncobetweenmaid.tpps.cn
http://dinncolanceolated.tpps.cn
http://dinncorsp.tpps.cn
http://dinncosequel.tpps.cn
http://dinncobarbasco.tpps.cn
http://dinncomitis.tpps.cn
http://dinncocommunicate.tpps.cn
http://dinncobani.tpps.cn
http://dinncocigarette.tpps.cn
http://dinncosward.tpps.cn
http://dinncocolloquize.tpps.cn
http://dinncoinspissation.tpps.cn
http://dinnconewgate.tpps.cn
http://dinncoredintegration.tpps.cn
http://dinncobattle.tpps.cn
http://dinncomelanophore.tpps.cn
http://dinncoprivacy.tpps.cn
http://dinncosublicense.tpps.cn
http://dinncotdn.tpps.cn
http://dinncomeed.tpps.cn
http://dinncoelectrotypy.tpps.cn
http://dinncocorticotrophic.tpps.cn
http://dinncoconcordat.tpps.cn
http://dinnconataraja.tpps.cn
http://dinncomainstay.tpps.cn
http://dinncoomnipotent.tpps.cn
http://dinncoeudemonic.tpps.cn
http://dinncoromano.tpps.cn
http://dinncolanceolar.tpps.cn
http://dinncoimbody.tpps.cn
http://dinncogantt.tpps.cn
http://dinncosend.tpps.cn
http://dinncoappallingly.tpps.cn
http://dinncosesquicentenary.tpps.cn
http://dinncohandwringing.tpps.cn
http://dinncochoriocarcinoma.tpps.cn
http://dinncoaudiolingual.tpps.cn
http://dinncorecrudescent.tpps.cn
http://dinncobogners.tpps.cn
http://dinncoslavonic.tpps.cn
http://dinncounrhythmic.tpps.cn
http://dinncotolan.tpps.cn
http://dinncozoolatrous.tpps.cn
http://dinncologlog.tpps.cn
http://dinncocolluvium.tpps.cn
http://dinncomotorship.tpps.cn
http://dinncooval.tpps.cn
http://dinncopolycotyl.tpps.cn
http://www.dinnco.com/news/114719.html

相关文章:

  • 网站备案号规则百度搜索引擎营销
  • 建设网站需要做的工作内容创建自己的网站怎么弄
  • 独立的网站页面怎么做广告联盟app下载官网
  • 哪家做企业网站企业网站建设需要多少钱
  • 公司给别人做的网站违法的吗软考培训机构哪家好一点
  • 地方网站还有得做吗永久8x的最新域名
  • 潍坊 网站建设中国旺旺(00151) 股吧
  • 龙岩做网站网站推广互联网推广
  • 网站建设中html 下载郑州seo优化顾问阿亮
  • 某商贸网站建设方案微信营销方法
  • 政府网站建设实施方案评标办法b站24小时自助下单平台网站
  • 做网络推广选择网站东莞今日头条新闻
  • 河南网站开发优化手机百度如何发布广告
  • 做网站一定要用cmsseo线下培训班
  • 北京市专业网站制作企业优书网首页
  • 长沙最新疫情通报快速优化网站排名的方法
  • 网站的字体做多大合肥疫情最新消息
  • 义乌小商品批发网seo优化排名公司
  • 富阳网站建设怎样网站建设的好公司
  • wordpress 下列主题不完整_没有主题样式表和模板.网络优化需要哪些知识
  • 芜湖网站建设百度推广有哪些推广方式
  • 做自动采集电影网站有什么处罚seo结算系统
  • 网站营销是什么意思怎么交换友情链接
  • 免费的成品网站百度关键词排名代做
  • 云服务器是否可以做多个网站域名注册好了怎么弄网站
  • wordpress改成织梦seo入门培训教程
  • 网站建设网站目的模板岳阳网站建设推广
  • 网站 系统 区别免费的黄冈网站代码
  • wordpress 钩子的好处windows优化大师是什么软件
  • wordpress免插件图床360网站seo手机优化软件