类class
agentscope.ragImageParser
class ImageParser(ParserBase)
源码Source
agentscope/rag/_parser/_image.py:17–92用于图像文件的解析器。位于 agentscope.rag 包,继承自 ParserBase。核心成员包括 supported_extensions、parse。
Wraps the entire file as a single :class:Section holding a
:class:DataBlock with the image's base64-encoded bytes. This is
the input shape a multimodal embedding model expects; the
surrounding pipeline (chunker, vector store) treats the section
opaquely.
The IANA media type is sniffed from the bytes' magic number so callers do not need to pass it explicitly.
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
supported_media_types | list[str] | `supported_media_types` 字段。 | ['image/png', 'image/jpeg', 'image/gif', 'image/bmp', 'image/webp'] |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
def supported_extensions() -> list[str] | 返回规范图像扩展。 Return the canonical image extensions. |
async def parse(file: bytes | str, filename: str) -> list[Section]async | 执行解析相关操作。 Wrap the image bytes in a single :class:`Section`. |
属性详情Attribute Detail
supported_media_types
list[str] = ['image/png', 'image/jpeg', 'image/gif', 'image/bmp', 'image/webp']supported_media_types 字段。声明为 list[str]。
The supported media types field.
源码Source
agentscope/rag/_parser/_image.py:30方法详情Method Detail
supported_extensions
def supported_extensions() -> list[str]
返回规范图像扩展。
Return the canonical image extensions.
list[str]
返回str列表。Returns a list of str.
源码Source
agentscope/rag/_parser/_image.py:39–48parse
async def parse(file: bytes | str, filename: str) -> list[Section]
async
执行解析相关操作。
Wrap the image bytes in a single :class:Section.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
file | bytes | str | 文件(类型 `bytes | str`)。Either the raw image bytes, or a filesystem path to the image file. |
filename | str | filename(类型 `str`)。The source filename, copied into :attr:`Section.source`. |
list[Section]
返回Section列表。`list[Section]`:
- 可能抛出 `Exception`。`FileNotFoundError`: If `file` is a `str` pointing to
- 可能抛出 `Exception`。a path that does not exist.
源码Source
agentscope/rag/_parser/_image.py:50–92