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

OCRConversation, OCRPromptTemplate, OCRPromptTemplateCallable, OCRPromptTemplateLike, build_ocr_conversation(...)

churro_ocr.templates.base

HFChatTemplate

churro_ocr.templates.hf

DEFAULT_OCR_TEMPLATE, model ids, and built-in prompt presets

churro_ocr.templates.presets

churro_ocr.templates.base#

Provider-neutral template protocols for OCR backends.

class churro_ocr.templates.base.OCRPromptTemplate[source]#

Bases: Protocol

Protocol 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:
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: object

Template 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

__init__(system_message=None, user_prompt=None, include_image=True, user_prompt_first=False)#
Parameters:
  • system_message (str | None)

  • user_prompt (str | None)

  • include_image (bool)

  • user_prompt_first (bool)

Return type:

None

churro_ocr.templates.presets#

Built-in OCR template presets.