from praisonaiagents import Agent, Task, PraisonAIAgents, Session
from pydantic import BaseModel
class ExtractedDocument(BaseModel):
filename: str
text: str
sections: list[str]
word_count: int
session = Session(session_id="ocr-001", user_id="user-1")
agent = Agent(
name="OCRAgent",
instructions="Extract text and return structured results.",
llm="gpt-4o-mini",
memory=True
)
task = Task(
description="Extract all text from this document",
expected_output="Structured extraction",
agent=agent,
images=["document.jpg"],
output_pydantic=ExtractedDocument
)
agents = PraisonAIAgents(
agents=[agent],
tasks=[task],
memory=True,
memory_config={"provider": "sqlite", "db_path": "ocr.db"},
verbose=1
)
result = agents.start()
print(result)