Google Drive API。
前提条件
- 创建或使用已有的 Google Cloud 项目
- 启用 Google Drive API
- 授权桌面应用的凭据
pip install -U google-api-python-client google-auth-httplib2 google-auth-oauthlib
获取 Google 文档数据的说明
默认情况下,GoogleDriveTools 和 GoogleDriveWrapper 期望 credentials.json 文件位于 ~/.credentials/credentials.json,但可以通过设置环境变量 GOOGLE_ACCOUNT_FILE 为 custom/path/to/credentials.json 来自定义路径。
token.json 的位置使用相同的目录(或使用参数 token_path)。注意 token.json 将在首次使用工具时自动创建。
GoogleDriveSearchTool 可以通过一些请求检索选定的文件。
默认情况下,如果使用 folder_id,该文件夹内所有名称与查询匹配的文件都可以被检索为 Document。
- 文件夹:drive.google.com/drive/u/0/folders/1yucgL9WGgWZdM1TOuKkeghlPizuzMYb5 -> 文件夹 ID 为
"1yucgL9WGgWZdM1TOuKkeghlPizuzMYb5" - 文档:docs.google.com/document/d/1bfaMQ18_i56204VaQDVeAFpqEijJTgvurupdEDiaUQw/edit -> 文档 ID 为
"1bfaMQ18_i56204VaQDVeAFpqEijJTgvurupdEDiaUQw"
root 代表您的个人主目录。
Document:
- text/text
- text/plain
- text/html
- text/csv
- text/markdown
- image/png
- image/jpeg
- application/epub+zip
- application/pdf
- application/rtf
- application/vnd.google-apps.document(GDoc)
- application/vnd.google-apps.presentation(GSlide)
- application/vnd.google-apps.spreadsheet(GSheet)
- application/vnd.google.colaboratory(Notebook colab)
- application/vnd.openxmlformats-officedocument.presentationml.presentation(PPTX)
- application/vnd.openxmlformats-officedocument.wordprocessingml.document(DOCX)
GoogleDriveAPIWrapper 的文档。
但是,需要安装相应的软件包。
在 ReAct Agent 中使用工具
要创建使用 Google Drive 工具的 Agent,请安装 LangGraph:create_agent 功能初始化 ReAct Agent。您还需要在 platform.openai.com 设置 OPEN_API_KEY 以访问 OpenAI 的聊天模型。
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

