跳到正文
所有工具

file_read

文件与 Finder · macOS · Windows

效果: 读取. 状态: 受限可用.

“受限可用”表示工具可能取决于版本、平台、权限、账户或配置,并不表示它在所有安装中都已启用。

macOS

用途

根据绝对路径读取本地文件系统中的纯文本文件;这是读取本地文本文件时首选的默认工具(除非文件是 PDF、Word、Excel 或 PowerPoint 文档,这些格式有各自的读取工具)。可读取这台 Mac 上的任何位置,包括主目录、外部磁盘、云盘和 /tmp,但有一个例外:绝不会读取凭据和身份位置(钥匙串、~/.ssh、~/.aws、浏览器登录信息、其他用户的主目录、Time Machine 备份)。支持 .txt、.md、.csv、.json、.xml、.log、.yaml、.toml 以及常见代码文件类型;自动检测 UTF-8,并回退到 Latin-1/Windows-1252。OneDrive 中的文件请使用 onedrive_read_file,Google Drive 中的文件请使用 gdrive_read_file;PDF 使用 pdf_read,Word 使用 word_read,Excel 使用 excel_read。

必填输入

输入名称会严格保持工具要求的形式。下方可展开的架构中保留英文规范技术定义。

权限与确认

架构未声明明确的确认参数。这并不代表可以未经许可操作;请检查效果并取得授权。

英文规范技术架构 — macOS
{
  "properties": {
    "force_download": {
      "description": "If the file is stored in the cloud and evicted from this Mac (dataless), request the download and wait for it instead of failing. Off by default: a download can take minutes and use metered data, so it is the caller's decision.",
      "type": "boolean"
    },
    "max_bytes": {
      "description": "Maximum bytes to read (default 256 KB, max 2 MB). A longer file comes back with truncated=true and next_offset: pass next_offset as offset to continue.",
      "type": "integer"
    },
    "offset": {
      "description": "Start reading at this byte offset (default 0)",
      "type": "integer"
    },
    "path": {
      "description": "Absolute path to the file",
      "type": "string"
    }
  },
  "required": [
    "path"
  ],
  "type": "object"
}

文档示例

file_read 的文档示例。请勿执行此示例。所示参数属于虚构数据集;在实际调用前,请解析真实标识符并获得授权。

{
  "path": "/Users/demo/Documents/meeting-notes.txt"
}

Windows

用途

根据绝对路径读取本地文件系统中的纯文本文件;这是读取本地文本文件的默认工具(这些文档类型请使用 pdf_read/word_read/excel_read/ppt_read,云存储请使用 onedrive_read_file / gdrive_read_file)。可读取这台 PC 上的任何位置,但凭据和身份位置(浏览器登录信息、SSH 和云密钥、Windows 凭据存储、其他用户的配置文件)除外,这些位置绝不会被读取。支持使用 offset/max_bytes 分块读取大型文件:被截断的读取会给出 truncated=true 和 next_offset,即继续读取时使用的 offset。

必填输入

输入名称会严格保持工具要求的形式。下方可展开的架构中保留英文规范技术定义。

权限与确认

架构未声明明确的确认参数。这并不代表可以未经许可操作;请检查效果并取得授权。

英文规范技术架构 — Windows
{
  "properties": {
    "force_download": {
      "description": "For a cloud placeholder (OneDrive online-only) bigger than 25 MB: download it and wait up to 60 s. Smaller ones are downloaded on their own.",
      "type": "boolean"
    },
    "max_bytes": {
      "description": "Maximum bytes to read (default 256 KB, max 2 MB). A cut read says next_offset.",
      "type": "integer"
    },
    "offset": {
      "description": "Start reading at this byte offset (default 0).",
      "type": "integer"
    },
    "path": {
      "description": "Absolute path to the file (a leading ~ is expanded).",
      "type": "string"
    }
  },
  "required": [
    "path"
  ],
  "type": "object"
}

文档示例

file_read 的文档示例。请勿执行此示例。所示参数属于虚构数据集;在实际调用前,请解析真实标识符并获得授权。

{
  "path": "C:\\Users\\demo\\Documents\\meeting-notes.txt"
}