Skip to content

Document

Document

Document(source=None, text=None, **kwargs)

Natural language interface for documents.

Supports PDF, DOCX, PPTX, XLSX, HTML, JSON, MD, TXT, XML, YAML, RTF formats. Documents are automatically chunked for efficient processing.

PARAMETER DESCRIPTION
source

Path to document file. Mutually exclusive with text.

TYPE: str DEFAULT: None

text

Document content as text. Mutually exclusive with source.

TYPE: str DEFAULT: None

ask

ask(prompt, model=None, context=None, output_type=None, stream=False)

Ask natural language questions and get structured responses.

PARAMETER DESCRIPTION
prompt

Natural language question or instruction.

TYPE: str

model

AI model to use (e.g., 'openai:gpt-4', 'anthropic:claude-3-5-sonnet').

TYPE: str DEFAULT: None

context

Additional business context for better responses.

TYPE: str DEFAULT: None

output_type

Pydantic model for structured responses.

TYPE: BaseModel DEFAULT: None

stream

Show live AI reasoning in terminal.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Any

Response matching the requested output type.

tools

tools()

Available tool methods for document operations.

RETURNS DESCRIPTION
list[callable]

Methods for document reading with intelligent chunking.

instructions

instructions(context=None)

Generate system instructions for AI agents.

PARAMETER DESCRIPTION
context

Additional business context to include in instructions.

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
str

System instructions for AI interaction with this datasource.