Files
RAG-CUT/backend/rag_cut/parsers/image_parser.py
T
2026-07-16 11:12:17 +08:00

25 lines
630 B
Python

"""Standalone image parser."""
from __future__ import annotations
import shutil
from pathlib import Path
from rag_cut.models import Block, BlockType
from rag_cut.parsers.base import BaseParser
class ImageParser(BaseParser):
def parse(self, path: Path, assets_dir: Path) -> list[Block]:
assets_dir.mkdir(parents=True, exist_ok=True)
target = assets_dir / path.name
shutil.copy2(path, target)
return [
Block(
type=BlockType.IMAGE,
text=path.stem,
image_id=path.name,
image_path=str(target),
)
]