Skip to content

Gmail openai agent

GmailOpenAIAgentPack #

Bases: BaseLlamaPack

Source code in llama_index/packs/gmail_openai_agent/base.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class GmailOpenAIAgentPack(BaseLlamaPack):
    def __init__(self, gmail_tool_kwargs: Dict[str, Any]) -> None:
        """初始化参数。"""
        try:
            from llama_index.tools.google import GmailToolSpec
        except ImportError:
            raise ImportError("llama_hub not installed.")

        self.tool_spec = GmailToolSpec(**gmail_tool_kwargs)
        self.agent = OpenAIAgent.from_tools(self.tool_spec.to_tool_list())

    def get_modules(self) -> Dict[str, Any]:
        """获取模块。"""
        return {"gmail_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/gmail_openai_agent/base.py
26
27
28
def get_modules(self) -> Dict[str, Any]:
    """获取模块。"""
    return {"gmail_tool": self.tool_spec, "agent": self.agent}

run #

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

运行流水线。

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