代码

cookbook/tools/google_calendar_tools.py
from agno.agent import Agent
from agno.tools.googlecalendar import GoogleCalendarTools

agent = Agent(
    tools=[GoogleCalendarTools()],
    show_tool_calls=True,
    markdown=True,
)

agent.print_response("我今天有什么日程?")
agent.print_response("明天下午2点安排一个与约翰的会议")

用法

1

创建虚拟环境

打开 Terminal 并创建一个 python 虚拟环境。

python3 -m venv .venv
source .venv/bin/activate
2

设置你的 API 密钥

export OPENAI_API_KEY=xxx
3

设置 Google 日历凭证

export GOOGLE_CALENDAR_CREDENTIALS=path/to/credentials.json
4

安装库

pip install -U google-auth-oauthlib google-auth-httplib2 google-api-python-client openai agno
5

运行 Agent

python cookbook/tools/google_calendar_tools.py