Template APIs#
churro_ocr.templates is a convenience namespace that re-exports template protocols, chat-template helpers, and built-in model presets from the owning modules below.
Use the canonical module that defines each symbol:
Convenience import |
Canonical reference |
|---|---|
|
|
|
|
|
|
churro_ocr.templates.base#
Provider-neutral template protocols for OCR backends.
- class churro_ocr.templates.base.OCRPromptTemplate[source]#
Bases:
ProtocolProtocol for OCR templates that build model conversations.
- build_conversation(page)[source]#
Build a model conversation for one page.
- Parameters:
page (DocumentPage) – Page to convert into a model-specific prompt payload.
- Returns:
Structured conversation ready for backend-specific rendering.
- Return type:
OCRConversation
- __init__(*args, **kwargs)#
- churro_ocr.templates.base.build_ocr_conversation(template, page)[source]#
Build an OCR conversation from a template or template callable.
- Parameters:
template (OCRPromptTemplate | Callable[[DocumentPage], OCRConversation]) – Prompt template object or callable.
page (DocumentPage) – Page to convert into a conversation.
- Returns:
Structured OCR conversation for
page.- Return type:
OCRConversation
churro_ocr.templates.hf#
Built-in OCR templates.
- class churro_ocr.templates.hf.HFChatTemplate[source]#
Bases:
objectTemplate for processor/tokenizer chat-template OCR models.
- Parameters:
system_message – Optional system message prepended to the conversation.
user_prompt – Optional user-side text prompt appended with the image.
include_image – Whether to include the page image in the user message.
user_prompt_first – Whether to place the user prompt before the image.
- build_conversation(page)[source]#
Build a structured multimodal conversation for one OCR page.
- Parameters:
page (DocumentPage) – Page to represent in the conversation.
- Returns:
Conversation payload suitable for chat-template OCR models.
- Return type:
OCRConversation
churro_ocr.templates.presets#
Built-in OCR template presets.