ai_document_annotator
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| AIDocumentAnnotator docler.annotators.ai_document_annotator AI-based document and chunk annotator. |
||
| DefaultMetadata docler.annotators.ai_document_annotator Default metadata for a document or chunk. |
🛈 DocStrings¶
AI-powered document and chunk metadata annotation.
AIDocumentAnnotator
¶
Bases: Annotator[AIDocumentAnnotatorConfig]
AI-based document and chunk annotator.
Enhances documents and chunks with metadata.
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
TMetadata
|
Schema
|
Type of metadata model to use. Must be a schemez Schema. |
DefaultMetadata
|
Source code in src/docler/annotators/ai_document_annotator.py
__init__
¶
__init__(
model: str | None = None,
system_prompt: str | None = None,
user_prompt: str | None = None,
metadata_model: type[TMetadata] = DefaultMetadata,
max_context_length: int = 1500,
batch_size: int = 5,
) -> None
Initialize the AI document annotator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str | None
|
LLM model to use for annotation |
None
|
system_prompt
|
str | None
|
Optional custom prompt for annotation |
None
|
user_prompt
|
str | None
|
Optional custom prompt for annotation |
None
|
metadata_model
|
type[TMetadata]
|
Pydantic model class for metadata structure |
DefaultMetadata
|
max_context_length
|
int
|
Maximum length of context for annotation |
1500
|
batch_size
|
int
|
Number of chunks to process in parallel |
5
|
Source code in src/docler/annotators/ai_document_annotator.py
annotate
async
¶
annotate(document: ChunkedDocument) -> ChunkedDocument
Annotate document and chunks with AI-generated metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
document
|
ChunkedDocument
|
Chunked document to annotate |
required |
Returns:
| Type | Description |
|---|---|
ChunkedDocument
|
Document with enhanced metadata |
Source code in src/docler/annotators/ai_document_annotator.py
DefaultMetadata
¶
Bases: Schema
Default metadata for a document or chunk.