Skip to content

Cogniswitch agent

CogniswitchAgentPack #

Bases: BaseLlamaPack

Source code in llama_index/packs/cogniswitch_agent/base.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class CogniswitchAgentPack(BaseLlamaPack):
    def __init__(self, cogniswitch_tool_kwargs: Dict[str, Any]) -> None:
        """初始化参数。"""
        try:
            from llama_index.tools.cogniswitch import CogniswitchToolSpec
        except ImportError:
            raise ImportError("llama_hub not installed.")

        self.tool_spec = CogniswitchToolSpec(**cogniswitch_tool_kwargs)
        self.agent = ReActAgent.from_tools(self.tool_spec.to_tool_list())

    def get_modules(self) -> Dict[str, Any]:
        """获取模块。"""
        return {"cogniswitch_tool": self.tool_spec, "agent": self.agent}

    def run(self, *args: Any, **kwargs: Any) -> Any:
        """运行流水线。"""
        return self.agent.chat(*args, **kwargs)

get_modules #

get_modules() -> Dict[str, Any]

获取模块。

Source code in llama_index/packs/cogniswitch_agent/base.py
18
19
20
def get_modules(self) -> Dict[str, Any]:
    """获取模块。"""
    return {"cogniswitch_tool": self.tool_spec, "agent": self.agent}

run #

run(*args: Any, **kwargs: Any) -> Any

运行流水线。

Source code in llama_index/packs/cogniswitch_agent/base.py
22
23
24
def run(self, *args: Any, **kwargs: Any) -> Any:
    """运行流水线。"""
    return self.agent.chat(*args, **kwargs)