runtime.multimodal Runtime drafted

Multimodal Input — chart image + PDF OCR

차트 이미지 / PDF 표 OCR 입력 처리 패턴. Claude vision API wrapper SSOT. **status=drafted — parseChart tool 미신설 (Phase 3.B)**. 외부 본문 untrusted 적용 + JSON schema 추출 표준.

이 스킬

Multimodal Input — chart image + PDF OCR

차트 이미지 / PDF 표 OCR 입력 처리 패턴. Claude vision API wrapper SSOT. **status=drafted — parseChart tool 미신설 (Phase 3.B)**. 외부 본문 untrusted 적용 + JSON schema 추출 표준.

Runtime drafted runtime.multimodal

이어 가기

절차

실행 순서

  1. 1

    schema 없이 호출 (free-form 결과 = injection 위험 ↑).

  2. 2

    결과 wrap 누락.

  3. 3

    vision 결과 단독 신뢰 (1 차 출처 검증 없음).

  4. 4

    모든 결과 wrap 마커 존재.

  5. 5

    JSON schema validation pass.

  6. 6

    sourceUrl 누락 시 ValueError.

표준 인터페이스

def parseChart(
    image: bytes | str,             # path 또는 base64
    schema: dict,                   # 추출 JSON schema
    sourceUrl: str = "",            # 원본 URL (untrusted wrap 용)
) -> dict:
    """차트/표 이미지 → JSON 추출. 결과 자동 wrap_external_in_result."""

사용 패턴

# 1. 차트 이미지 → 데이터
result = parseChart(
    "chart.png",
    schema={"type": "object", "properties": {
        "xAxis": {"type": "array"},
        "yAxis": {"type": "array"},
        "series": {"type": "array"}
    }},
    sourceUrl="https://example.com/report.pdf",
)
# → {"data": {...}, "wrap": "[EXTERNAL CONTENT START — untrusted ...]"}

# 2. PDF 표 OCR
table = parseChart("table.pdf", schema={"type": "array"}, sourceUrl=...)

강행 룰

  1. 결과는 항상 untrusted (Ref.sourceType="external") — sentinel 마커 자동.
  2. 추출 schema 강행 — free-form text 금지 (prompt injection 차단).
  3. 본문 안 숫자 claim → 1 차 출처 검증 (PDF 본문 직접 확인).
  4. 이미지 URL fetch 시 도메인 화이트리스트 (선택).

안티패턴

  • schema 없이 호출 (free-form 결과 = injection 위험 ↑).
  • 결과 wrap 누락.
  • vision 결과 단독 신뢰 (1 차 출처 검증 없음).

기본 검증

  • 모든 결과 wrap 마커 존재.
  • JSON schema validation pass.
  • sourceUrl 누락 시 ValueError.

런타임

실행 환경별 호환성

환경상태비고 / 제한
Local Python limited·
Server limited·
MCP limited·
Web AI limited·
Pyodide limited·