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

PPTParser

class PPTParser(ParserBase)
源码Source agentscope/rag/_parser/_ppt.py:130–393

用于PowerPoint.pptx文件的解析器。位于 agentscope.rag 包,继承自 ParserBase。核心成员包括 supported_extensions、parse。

Slide order is preserved. Within a slide, shapes are visited in document order and grouped into a minimum number of sections:

  • Text shapes and table shapes contribute to one running text section. When separate_table=True a table closes the running section and starts a new one of its own.
  • Picture shapes emit a standalone :class:Section whose content is a :class:DataBlock holding the base64-encoded image bytes.

slide_prefix / slide_suffix are wrapped around each slide's text content (the prefix is prepended to the slide's first text section, the suffix is appended to its last text section). Use None on either to disable wrapping.

构造器摘要Constructor Summary

构造器Constructor说明Description
def __init__(include_image: bool = True, separate_table: bool = False, table_format: Literal['markdown', 'json'] = 'mar…
初始化 `PPTParser` 实例。
Initialize the PowerPoint parser.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
supported_media_typeslist[str]
`supported_media_types` 字段。
['application/vnd.openxmlformats-officedocument.presentationml.presentation']

方法摘要Method Summary

方法Method说明Description
def supported_extensions() -> list[str]
返回 `supported_extensions` 结果。
Return ``[".pptx"]`` — the only format ``python-pptx`` reads.
async def parse(file: bytes | str, filename: str) -> list[Section]async
执行解析相关操作。
Parse a PPTX file into a list of :class:`Section` objects.

构造器详情Constructor Detail

PPTParser

def __init__(include_image: bool = True, separate_table: bool = False, table_format: Literal['markdown', 'json'] = 'markdown', slide_prefix: str | None = '<slide index={index}>', slide_suffix: str | None = '</slide>') -> None

初始化 PPTParser 实例。

Initialize the PowerPoint parser.

参数Parameters
名称Name类型Type说明Description
include_image默认default Trueboolinclude 图像(类型 `bool`)。When `True`, picture shapes are emitted as :class:`DataBlock` sections. Set to `False` to keep a text-only index.
separate_table默认default Falseboolseparate table(类型 `bool`)。When `True`, each table becomes its own text section, never merged with surrounding text. table_format (`Literal["markdown", "json"]`, defaults to `"markdown"`): How to render tables. `"markdown"` uses pipe-table syntax, escaping pipes and rendering cell line breaks as ` `; `"json"` emits a JSON array prefixed with a ` ` marker and preserves extracted cell strings without Markdown rendering. slide_prefix (`str | None`, defaults to `" "`): Prepended to the first text section of each slide. Supports the `{index}` placeholder (starting at 1). Use `None` to disable.
table_format默认default 'markdown'Literal['markdown', 'json']table 格式(类型 `Literal['markdown', 'json']`)。The table format.
slide_prefix默认default '<slide index={index}>'str | Noneslide prefix(类型 `str | None`)。The slide prefix.
slide_suffix默认default '</slide>'str | Noneslide suffix(类型 `str | None`)。Appended to the last text section of each slide. Use `None` to disable.
异常Raises
  • 可能抛出 `Exception`。`ValueError`: If `table_format` is not one of
  • 可能抛出 `Exception`。`"markdown"` / `"json"`.
源码Source agentscope/rag/_parser/_ppt.py:160–207

属性详情Attribute Detail

supported_media_types

list[str] = ['application/vnd.openxmlformats-officedocument.presentationml.presentation']

supported_media_types 字段。声明为 list[str]。

The supported media types field.

源码Source agentscope/rag/_parser/_ppt.py:149

方法详情Method Detail

supported_extensions

def supported_extensions() -> list[str]

返回 supported_extensions 结果。

Return [".pptx"] — the only format python-pptx reads.

返回Returns list[str]
返回str列表。Returns a list of str.
源码Source agentscope/rag/_parser/_ppt.py:155–158

parse

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

执行解析相关操作。

Parse a PPTX file into a list of :class:Section objects.

参数Parameters
名称Name类型Type说明Description
filebytes | str文件(类型 `bytes | str`)。Either the raw PPTX bytes, or a filesystem path to the PPTX file.
filenamestrfilename(类型 `str`)。The source filename, copied into each Section's :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.
  • 可能抛出 `Exception`。`ImportError`: If :mod:`python-pptx` is not installed.
  • 可能抛出 `Exception`。`ValueError`: If the bytes cannot be parsed.
源码Source agentscope/rag/_parser/_ppt.py:209–268
基于官方固定版本源码静态生成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.