* feat: accept pdf, images and office files * refactor: rename FileConverter to FileParser, simplify file retain API - Rename engine/converters/ → engine/parsers/, FileConverter → FileParser, ConverterRegistry → FileParserRegistry, MarkitdownConverter → MarkitdownParser - Rename env var HINDSIGHT_API_FILE_CONVERTER → HINDSIGHT_API_FILE_PARSER - Remove async/document_tags params from FileRetainRequest (always async now) - Add retain_files() to Python Hindsight client and retainFiles() to TypeScript client - Add sample.pdf to doc examples for working file upload demonstrations - Update test_file_retain.py to use new parser names and always-async behavior - Fix Go client missing os import in api_files.go - Simplify postgresql.py storage to minimal schema * fix: update rust CLI tests to use is_supported_file instead of is_text_file * fix: patch Go api_files.go to add missing 'os' import after generation * fix: insert 'os' import after 'net/url' in api_files.go patch for correct position * chore: regenerate OpenAPI spec and clients (converter→parser description update)
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
"""Abstract base class for file parsers."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
class FileParser(ABC):
|
|
"""Abstract base for file to markdown parsers."""
|
|
|
|
@abstractmethod
|
|
async def convert(self, file_data: bytes, filename: str) -> str:
|
|
"""
|
|
Parse file to markdown.
|
|
|
|
Args:
|
|
file_data: Raw file bytes
|
|
filename: Original filename (used for format detection)
|
|
|
|
Returns:
|
|
Markdown content as string
|
|
|
|
Raises:
|
|
ValueError: If file format is not supported
|
|
RuntimeError: If parsing fails
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def supports(self, filename: str, content_type: str | None = None) -> bool:
|
|
"""
|
|
Check if parser supports this file type.
|
|
|
|
Args:
|
|
filename: File name (used for extension check)
|
|
content_type: MIME type (optional)
|
|
|
|
Returns:
|
|
True if this parser can handle the file
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def name(self) -> str:
|
|
"""
|
|
Get parser name.
|
|
|
|
Returns:
|
|
Parser name (e.g., "markitdown")
|
|
"""
|
|
pass
|