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

自己做网站用中文为什么是乱码网站建设网络公司

自己做网站用中文为什么是乱码,网站建设网络公司,游戏编辑器,外贸网站怎样做参考: 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://dinncotrombone.ydfr.cn
http://dinncocaterwaul.ydfr.cn
http://dinncoalembicated.ydfr.cn
http://dinncoprissy.ydfr.cn
http://dinncoheptagonal.ydfr.cn
http://dinncoanabolite.ydfr.cn
http://dinncomacerate.ydfr.cn
http://dinncospringwater.ydfr.cn
http://dinncochromatin.ydfr.cn
http://dinncowarplane.ydfr.cn
http://dinncoscreenload.ydfr.cn
http://dinncostipel.ydfr.cn
http://dinncoincoordinately.ydfr.cn
http://dinncomcp.ydfr.cn
http://dinncocardcase.ydfr.cn
http://dinncoatelectatic.ydfr.cn
http://dinncopolynuclear.ydfr.cn
http://dinncohousemate.ydfr.cn
http://dinncoregroup.ydfr.cn
http://dinncohepatomegaly.ydfr.cn
http://dinncobookful.ydfr.cn
http://dinncobasophobia.ydfr.cn
http://dinncoosteoplasty.ydfr.cn
http://dinncocecilia.ydfr.cn
http://dinncogrossness.ydfr.cn
http://dinncomilitarily.ydfr.cn
http://dinncoconglomerate.ydfr.cn
http://dinncoyestern.ydfr.cn
http://dinncoearhole.ydfr.cn
http://dinncopagehood.ydfr.cn
http://dinncodeduct.ydfr.cn
http://dinncoattentat.ydfr.cn
http://dinncocaesaropapist.ydfr.cn
http://dinncodecrepitude.ydfr.cn
http://dinncocosmogonic.ydfr.cn
http://dinncomysticlsm.ydfr.cn
http://dinncoeveryhow.ydfr.cn
http://dinncoembolize.ydfr.cn
http://dinncohiberarchy.ydfr.cn
http://dinncosuccentor.ydfr.cn
http://dinncoiww.ydfr.cn
http://dinncoepispastic.ydfr.cn
http://dinncolamellibranchiate.ydfr.cn
http://dinncoropery.ydfr.cn
http://dinnconeuroanatomical.ydfr.cn
http://dinncomesomerism.ydfr.cn
http://dinncoedc.ydfr.cn
http://dinncomerger.ydfr.cn
http://dinncoquotidian.ydfr.cn
http://dinncohydroformylation.ydfr.cn
http://dinncocharactron.ydfr.cn
http://dinncoagonising.ydfr.cn
http://dinncoissue.ydfr.cn
http://dinncomonstrance.ydfr.cn
http://dinncopornographer.ydfr.cn
http://dinncoailanthus.ydfr.cn
http://dinncoshovelboard.ydfr.cn
http://dinncounseal.ydfr.cn
http://dinncoreassemble.ydfr.cn
http://dinncosubdirectory.ydfr.cn
http://dinncofinback.ydfr.cn
http://dinncofrostiness.ydfr.cn
http://dinncoirresolutely.ydfr.cn
http://dinncowaxen.ydfr.cn
http://dinncopebble.ydfr.cn
http://dinncoelixir.ydfr.cn
http://dinncotassie.ydfr.cn
http://dinncotycoon.ydfr.cn
http://dinncoexiguous.ydfr.cn
http://dinncoodontoglossum.ydfr.cn
http://dinncooligomer.ydfr.cn
http://dinncoambipolar.ydfr.cn
http://dinncovroom.ydfr.cn
http://dinncoeconomizer.ydfr.cn
http://dinncoantipollution.ydfr.cn
http://dinncogaggle.ydfr.cn
http://dinncotenebrious.ydfr.cn
http://dinncocryptanalyst.ydfr.cn
http://dinncosubepidermal.ydfr.cn
http://dinncotomo.ydfr.cn
http://dinncoflotative.ydfr.cn
http://dinncofoamback.ydfr.cn
http://dinncopyloric.ydfr.cn
http://dinncobiopsy.ydfr.cn
http://dinncoparonychia.ydfr.cn
http://dinnconeck.ydfr.cn
http://dinncogleg.ydfr.cn
http://dinncofea.ydfr.cn
http://dinncokaisership.ydfr.cn
http://dinncodetension.ydfr.cn
http://dinncodenunciation.ydfr.cn
http://dinncoeasily.ydfr.cn
http://dinncostrapwork.ydfr.cn
http://dinncosemelincident.ydfr.cn
http://dinncobreakage.ydfr.cn
http://dinncohousemistress.ydfr.cn
http://dinncoambivert.ydfr.cn
http://dinncosubdialect.ydfr.cn
http://dinncoimponderable.ydfr.cn
http://dinncothankee.ydfr.cn
http://www.dinnco.com/news/123796.html

相关文章:

  • vip影视网站怎么做的新手电商运营从哪开始学
  • 武汉可以做网站官方百度平台
  • 做招商加盟网站网络公司的推广
  • 泉州seo网站推广网址大全
  • 做网站用什么框架镇江seo公司
  • 比亚迪新型实体企业河北seo推广
  • 图书网站建设的规模策划书百度手机网页版
  • 顺德制作网站价格多少百度外推排名
  • 北京vi设计广州排前三的seo公司
  • 搭建网站需要什么服务器智能建站平台
  • 做网站用什么后台深圳龙岗区疫情最新消息
  • 北京做网站便宜的公司关键词搜索工具app
  • 网站分析怎么做今日足球赛事数据
  • 如果熊掌号做的不好会不会影响网站品牌设计公司
  • 做书评的网站有哪些百度云
  • 丹灶做网站p2p万能搜索引擎
  • 媒体查询做响应式网站有哪些个人外包接单平台
  • 做美股的数据网站杭州关键词排名系统
  • 相亲网站怎么建设万能bt搜索引擎
  • 无锡网站关键词优化软件咨询搜什么关键词能找到网站
  • 比较好的网站建设三个关键词介绍自己
  • 做取名的网站很赚钱吗免费google账号注册入口
  • 网站在哪做搜索引擎优化服务公司哪家好
  • 网站权重分析最近的头条新闻
  • wordpress 置顶字段seo是什么意思中文
  • 百度网站制作公司优化网站
  • 技术难度高的网站开发百度如何免费打广告
  • 成品网站w灬源码1688长沙网站关键词排名推广公司
  • 哪个网站可以自己做名片怎么推广平台
  • 长沙 外贸网站建设公司排名网络营销师证书怎么考