AS AgentScopeAPI 手册 / API Reference
类class agentscope.rag

ImageParser

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_typeslist[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.

返回Returns list[str]
返回str列表。Returns a list of str.
源码Source agentscope/rag/_parser/_image.py:39–48

parse

async def parse(file: bytes | str, filename: str) -> list[Section]
async

执行解析相关操作。

Wrap the image bytes in a single :class:Section.

参数Parameters
名称Name类型Type说明Description
filebytes | str文件(类型 `bytes | str`)。Either the raw image bytes, or a filesystem path to the image file.
filenamestrfilename(类型 `str`)。The source filename, copied into :attr:`Section.source`.
返回Returns list[Section]
返回Section列表。`list[Section]`:
异常Raises
  • 可能抛出 `Exception`。`FileNotFoundError`: If `file` is a `str` pointing to
  • 可能抛出 `Exception`。a path that does not exist.
源码Source agentscope/rag/_parser/_image.py:50–92
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.