"""
展示如何使用 Todoist 工具的 Agno 示例
需求:
- 注册/登录 Todoist 并获取 Todoist API 令牌(从 https://app.todoist.com/app/settings/integrations/developer 获取)
- pip install todoist-api-python
用法:
- 设置以下环境变量:
export TODOIST_API_TOKEN="your_api_token"
- 或在创建 TodoistTools 实例时提供它们
"""
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.todoist import TodoistTools
todoist_agent = Agent(
name="Todoist Agent",
role="Manage your todoist tasks",
instructions=[
"When given a task, create a todoist task for it.",
"When given a list of tasks, create a todoist task for each one.",
"When given a task to update, update the todoist task.",
"When given a task to delete, delete the todoist task.",
"When given a task to get, get the todoist task.",
],
agent_id="todoist-agent",
model=OpenAIChat(id="gpt-4o"),
tools=[TodoistTools()],
markdown=True,
debug_mode=True,
show_tool_calls=True,
)
# 示例 1:创建一个任务
print("\n=== Create a task ===")
todoist_agent.print_response("Create a todoist task to buy groceries tomorrow at 10am")
# 示例 2:删除一个任务
print("\n=== Delete a task ===")
todoist_agent.print_response(
"Delete the todoist task to buy groceries tomorrow at 10am"
)
# 示例 3:获取所有任务
print("\n=== Get all tasks ===")
todoist_agent.print_response("Get all the todoist tasks")
创建虚拟环境
打开 Terminal
并创建一个 python 虚拟环境。
python3 -m venv .venv
source .venv/bin/activate
设置您的 API 令牌
export TODOIST_API_TOKEN=xxx
export OPENAI_API_KEY=xxx
安装库
pip install -U todoist-api-python openai agno
运行 Agent
python cookbook/tools/todoist_tools.py