O C R Agent • AI Agent SDK
OCRAgent: A specialized agent for OCR (Optical Character Recognition).
OCRAgent
Defined in the Ocr Agent module.
AI Agent
A specialized agent for OCR (Optical Character Recognition).
Extracts text from documents (PDFs) and images using AI models.
Supported Providers: – Mistral: mistral/mistral-ocr-latest
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%
graph LR
input["Input Data"] --> agent["Agent: OCRAgent"]
agent --> output["Output Result"]
style agent fill:#8B0000,color:#fff
style input fill:#8B0000,color:#fff
style output fill:#8B0000,color:#fffConstructor
ParamField
Optional[str]No description available.
ParamField
Optional[str]No description available.
ParamField
Optional[str]No description available.
ParamField
Optional[str]No description available.
ParamField
Optional[str]No description available.
ParamField
Optional[str]No description available.
ParamField
OptionalNo description available.
ParamField
Union[bool, int]No description available.
Methods
console()
Lazily initialize Rich Console.
litellm()Lazy load litellm module when needed.
extract()Extract text from a document or image.
aextract()Async version of extract().
read()Quick OCR – extract and return markdown text.
aread()Async version of read().
Usage
from praisonaiagents import OCRAgent
agent = OCRAgent(llm="mistral/mistral-ocr-latest")
# Extract from PDF URL
result = agent.extract("https://example.com/document.pdf")
print(result.text)
# Extract from image URL
result = agent.extract("https://example.com/image.png")
for page in result.pages:
print(page.markdown)Source
View on GitHubpraisonaiagents/agent/ocr_agent.py at line 41