AIImageAnnotator
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| Annotator docler.annotators.base Base class for chunk annotation processors. |
||
| Generic typing Abstract base class for generic types. |
⋔ Inheritance diagram¶
graph TD
2532931700["ai_image_annotator.AIImageAnnotator"]
808376040["base.Annotator"]
925645236["abc.ABC"]
2751680898["builtins.object"]
1753584424["provider.BaseProvider"]
3481597255["typing.Generic"]
808376040 --> 2532931700
925645236 --> 808376040
2751680898 --> 925645236
1753584424 --> 808376040
3481597255 --> 1753584424
2751680898 --> 3481597255
3481597255 --> 808376040
3481597255 --> 2532931700
🛈 DocStrings¶
Bases: Annotator[AIImageAnnotatorConfig]
AI-based image annotator.
Analyzes images in chunks and adds descriptions and metadata.
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
TMetadata
|
Schema
|
Type of metadata model to use. Must be a Pydantic Schema. |
DefaultImageMetadata
|
Source code in src/docler/annotators/ai_image_annotator.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
__init__
¶
__init__(
model: str | None = None,
system_prompt: str | None = None,
user_prompt: str | None = None,
metadata_model: type[TMetadata] = DefaultImageMetadata,
batch_size: int = 3,
) -> None
Initialize the AI image annotator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str | None
|
Vision model to use (must support images) |
None
|
system_prompt
|
str | None
|
Custom prompt for image analysis |
None
|
user_prompt
|
str | None
|
Custom user prompt template for image analysis |
None
|
metadata_model
|
type[TMetadata]
|
Pydantic model for image metadata |
DefaultImageMetadata
|
batch_size
|
int
|
Number of images to process concurrently |
3
|
Source code in src/docler/annotators/ai_image_annotator.py
annotate
async
¶
annotate(document: ChunkedDocument) -> ChunkedDocument
Annotate all images in the chunks with AI-generated descriptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
document
|
ChunkedDocument
|
Chunked document containing chunks with images to annotate |
required |
Returns:
| Type | Description |
|---|---|
ChunkedDocument
|
Document with annotated images in chunks |