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

做期货在哪个网站查资料站长平台百度

做期货在哪个网站查资料,站长平台百度,网站域名续费怎么做,javaweb视频网站开发简介 文章主要介绍了如何扩展一个自定义Agent,这里是用官方提供的总结摘要的Agent做了个示例,先给大家看下显示效果 代码目录 博主将代码放在core目录了,后续经过对源码的解读感觉放在dbgpt_serve.agent.agents.expand目录下可能更合适&…

简介

文章主要介绍了如何扩展一个自定义Agent,这里是用官方提供的总结摘要的Agent做了个示例,先给大家看下显示效果

代码目录

博主将代码放在core目录了,后续经过对源码的解读感觉放在dbgpt_serve.agent.agents.expand目录下可能更合适,大家自行把控即可

代码详情

summarizer_action.py

from typing import Optional

from pydantic import BaseModel, Field

from dbgpt.vis import Vis

from dbgpt.agent import Action, ActionOutput, AgentResource, ResourceType

from dbgpt.agent.util import cmp_string_equal

NOT_RELATED_MESSAGE = "Did not find the information you want."

# The parameter object that the Action that the current Agent needs to execute needs to output.

class SummaryActionInput(BaseModel):

    summary: str = Field(

        ...,

        description="The summary content",

    )

class SummaryAction(Action[SummaryActionInput]):

    def __init__(self, **kwargs):

        super().__init__(**kwargs)

    @property

    def resource_need(self) -> Optional[ResourceType]:

        # The resource type that the current Agent needs to use

        # here we do not need to use resources, just return None

        return None

    @property

    def render_protocol(self) -> Optional[Vis]:

        # The visualization rendering protocol that the current Agent needs to use

        # here we do not need to use visualization rendering, just return None

        return None

    @property

    def out_model_type(self):

        return SummaryActionInput

    async def run(

            self,

            ai_message: str,

            resource: Optional[AgentResource] = None,

            rely_action_out: Optional[ActionOutput] = None,

            need_vis_render: bool = True,

            **kwargs,

    ) -> ActionOutput:

        """Perform the action.

        The entry point for actual execution of Action. Action execution will be

        automatically initiated after model inference.

        """

        try:

            # Parse the input message

            param: SummaryActionInput = self._input_convert(ai_message, SummaryActionInput)

        except Exception:

            return ActionOutput(

                is_exe_success=False,

                content="The requested correctly structured answer could not be found, "

                        f"ai message: {ai_message}",

            )

        # Check if the summary content is not related to user questions

        if param.summary and cmp_string_equal(

                param.summary,

                NOT_RELATED_MESSAGE,

                ignore_case=True,

                ignore_punctuation=True,

                ignore_whitespace=True,

        ):

            return ActionOutput(

                is_exe_success=False,

                content="the provided text content is not related to user questions at all."

                        f"ai message: {ai_message}",

            )

        else:

            return ActionOutput(

                is_exe_success=True,

                content=param.summary,

            )

summarizer_agent.py

from typing import Optional

from pydantic import BaseModel, Field

from dbgpt.vis import Vis

from dbgpt.agent import Action, ActionOutput, AgentResource, ResourceType

from dbgpt.agent.util import cmp_string_equal

NOT_RELATED_MESSAGE = "Did not find the information you want."

# The parameter object that the Action that the current Agent needs to execute needs to output.

class SummaryActionInput(BaseModel):

    summary: str = Field(

        ...,

        description="The summary content",

    )

class SummaryAction(Action[SummaryActionInput]):

    def __init__(self, **kwargs):

        super().__init__(**kwargs)

    @property

    def resource_need(self) -> Optional[ResourceType]:

        # The resource type that the current Agent needs to use

        # here we do not need to use resources, just return None

        return None

    @property

    def render_protocol(self) -> Optional[Vis]:

        # The visualization rendering protocol that the current Agent needs to use

        # here we do not need to use visualization rendering, just return None

        return None

    @property

    def out_model_type(self):

        return SummaryActionInput

    async def run(

            self,

            ai_message: str,

            resource: Optional[AgentResource] = None,

            rely_action_out: Optional[ActionOutput] = None,

            need_vis_render: bool = True,

            **kwargs,

    ) -> ActionOutput:

        """Perform the action.

        The entry point for actual execution of Action. Action execution will be

        automatically initiated after model inference.

        """

        try:

            # Parse the input message

            param: SummaryActionInput = self._input_convert(ai_message, SummaryActionInput)

        except Exception:

            return ActionOutput(

                is_exe_success=False,

                content="The requested correctly structured answer could not be found, "

                        f"ai message: {ai_message}",

            )

        # Check if the summary content is not related to user questions

        if param.summary and cmp_string_equal(

                param.summary,

                NOT_RELATED_MESSAGE,

                ignore_case=True,

                ignore_punctuation=True,

                ignore_whitespace=True,

        ):

            return ActionOutput(

                is_exe_success=False,

                content="the provided text content is not related to user questions at all."

                        f"ai message: {ai_message}",

            )

        else:

            return ActionOutput(

                is_exe_success=True,

                content=param.summary,

            )

这样重启项目就能看到自定义的agent了

http://www.cadmedia.cn/news/9978.html

相关文章:

  • 龙岩网站建设公司seo排名推广
  • wordpress做定制T恤的网站深圳今日重大新闻
  • 网站建设基础培训营销方案范文100例
  • 网站建设推广顾问是什么意思爱站关键词查询
  • 网站建设哪家最好seo关键词排名注册价格
  • 企业网站维护建设项目实践报告下载百度安装到桌面
  • 网站推广www网络黄页推广软件
  • 网站建设做到哪些内容seo查询是什么意思
  • 深圳网站制作880日本比分预测最新分析
  • 建站管理域名管理绑定外部域名中资源网站优化排名软件公司
  • 电子工厂网站建设关键词竞价广告
  • 软件开发工程师做什么宁波抖音seo搜索优化软件
  • 苍南最好的网站建设公司知名网站
  • 柳州建设厅官方网站网络营销的基本职能
  • 58同城保定网站建设seo是什么姓氏
  • 南京溧水城市建设集团网站软文通
  • 唐山免费网站制作黑科技引流推广神器怎么下载
  • 企业在网站建设上的不足seo有哪些优化工具
  • 网站备案流程教程服装网络营销策划书
  • 巩义公司做网站百度一下你就知道手机版官网
  • 企业微信电脑版广东seo价格是多少钱
  • ps线下培训班一般学费多少徐州百度快照优化
  • 昭阳区建设局网站北京网站优化校学费
  • 禹城网站定制sem是什么品牌
  • 网站建设维护是什么岗位成人零基础学电脑培训班
  • 遮罩层怎么做网页合肥seo优化
  • ip138查询网站网址域名ip厦门百度整站优化服务
  • 怎么制作网站半透明背景百度小程序排名优化
  • 专业建设网站多少钱登封网站设计
  • 青海省公路建设市场信用信息服务网站快速排名优化系统