You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(tool): configure accepted image media types on Read and build its schema from a params model
- Replace `image_format`/Pillow conversion with `image_types`, a list of
image media types (or globs) the downstream model accepts; defaults to
png/jpeg/gif/webp and a model card's `input_types` can be passed as-is.
Images of other types return an error instead of a DataBlock.
- Define `_ReadParams(ParamsBase)` and expose `input_schema`/`description`
as properties so the supported image types render into the description.
- Drop Pillow from the core dependencies.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
description="The absolute path to the file to read.",
54
+
)
55
+
offset: int=Field(
56
+
default=1,
57
+
ge=1,
58
+
description="Optional 1-based line number to start reading from. "
59
+
"Only applies to plain text files (default: 1)",
60
+
)
61
+
limit: int=Field(
62
+
default=2000,
63
+
ge=1,
64
+
le=2000,
65
+
description="Optional maximum number of lines to read. Only applies "
66
+
"to plain text files (default: 2000, max: 2000)",
67
+
)
68
+
pages: str|None=Field(
69
+
default=None,
70
+
description='Page range for PDF files (e.g. "1-5", "3", "10-20"), '
71
+
f"max {_PDF_MAX_PAGES_PER_READ} pages per request; required for "
72
+
f"PDFs over {_PDF_MAX_PAGES_WITHOUT_RANGE} pages. Only applies to "
73
+
"PDF files.",
74
+
)
75
+
44
76
45
77
classRead(ToolBase):
46
78
"""The read tool."""
@@ -49,103 +81,77 @@ class Read(ToolBase):
49
81
"""The tool name presented to the agent."""
50
82
51
83
# pylint: disable=line-too-long
52
-
description: str="""Reads a file from the local filesystem. You can access any file directly by using this tool.
84
+
_DESCRIPTION_TEMPLATE: str="""Reads a file from the local filesystem. You can access any file directly by using this tool.
53
85
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
54
86
55
87
Usage:
56
88
- The file_path parameter must be an absolute path, not a relative path
57
89
- By default, it reads up to 2000 lines starting from the beginning of the file
58
90
- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters
59
91
- Results are returned using cat -n format, with line numbers starting at 1
60
-
- This tool allows you to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as you're a multimodal LLM.
61
-
- This tool can read PDF files (.pdf). Text is extracted per page. For large PDFs (more than 10 pages), you MUST provide the pages parameter to read specific pages (max 20 pages per request)."""# noqa: E501
62
-
"""The description presented to the agent."""
63
-
64
-
input_schema: dict[str, Any] = {
65
-
"type": "object",
66
-
"properties": {
67
-
"file_path": {
68
-
"type": "string",
69
-
"description": "The absolute path to the file to read.",
70
-
},
71
-
"offset": {
72
-
"type": "integer",
73
-
"description": "Optional 1-based line number to start reading "
74
-
"from. Only applies to plain text files (default: 1)",
75
-
"default": 1,
76
-
"minimum": 1,
77
-
},
78
-
"limit": {
79
-
"type": "integer",
80
-
"description": "Optional maximum number of lines to read. "
81
-
"Only applies to plain text files (default: 2000, max: 2000)",
82
-
"default": 2000,
83
-
"maximum": 2000,
84
-
"minimum": 1,
85
-
},
86
-
"pages": {
87
-
"type": "string",
88
-
"description": 'Page range for PDF files (e.g. "1-5", '
89
-
'"3", "10-20"), max 20 pages per request; required '
90
-
"for PDFs over 10 pages. Only applies to PDF files.",
91
-
},
92
-
},
93
-
"required": ["file_path"],
94
-
}
92
+
- This tool allows you to read images ({image_types}). When reading an image file the contents are presented visually as you're a multimodal LLM.
93
+
- This tool can read PDF files (.pdf). Text is extracted per page. For large PDFs (more than {max_pages_without_range} pages), you MUST provide the pages parameter to read specific pages (max {max_pages_per_read} pages per request)."""# noqa: E501
0 commit comments