Index
base
AbstractDocumentTaskProvider
Bases: AbstractTaskProvider
A task provider performs a specific, repeatable task on a document.
Source code in docprompt/tasks/base.py
AbstractPageTaskProvider
Bases: AbstractTaskProvider
A page task provider performs a specific, repeatable task on a page.
Source code in docprompt/tasks/base.py
AbstractTaskProvider
Bases: BaseModel
, Generic[TTaskInput, TTaskConfig, TTaskResult]
A task provider performs a specific, repeatable task on a document or its pages.
NOTE: Either the process_document_pages
or aprocess_document_pages
method must be implemented in
a valid subclass. The process_document_pages
method is explicitly defined, while the aprocess_document_pages
method is an async version of the same method.
If you wish to provide seperate implementations for sync and async, you can define both methods individually, and they will each use their own custom implementation when called. Otherwise, if you only implement one or the other of a flexible method pair, the other will automatically be generated and provided for you at runtime.
Source code in docprompt/tasks/base.py
38 39 40 41 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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
Meta
The meta class is utilized by the flexible methods decorator.
For all classes that are not concrete implementations, we should set the abstract attribute to True, which will prevent the check from failing when the flexible methods decorator is looking for the implementation of the methods.
Source code in docprompt/tasks/base.py
set_invoke_kwargs(info)
Set the default invoke kwargs for the task provider.
validate_class_vars(data)
classmethod
Ensure that the class has a name and capabilities defined.
Source code in docprompt/tasks/base.py
capabilities
PageLevelCapabilities
Bases: str
, Enum
Represents a capability that a provider can fulfill
Source code in docprompt/tasks/capabilities.py
classification
anthropic
The antrhopic implementation of page level calssification.
AnthropicClassificationProvider
Bases: BaseClassificationProvider
The Anthropic implementation of unscored page classification.
Source code in docprompt/tasks/classification/anthropic.py
AnthropicPageClassificationOutputParser
Bases: BasePageClassificationOutputParser
The output parser for the page classification system.
Source code in docprompt/tasks/classification/anthropic.py
parse(text)
Parse the results of the classification task.
Source code in docprompt/tasks/classification/anthropic.py
base
BaseClassificationProvider
Bases: AbstractPageTaskProvider[bytes, ClassificationConfig, ClassificationOutput]
The base classification provider.
Source code in docprompt/tasks/classification/base.py
BasePageClassificationOutputParser
Bases: ABC
, BaseOutputParser[ClassificationConfig, ClassificationOutput]
The output parser for the page classification system.
Source code in docprompt/tasks/classification/base.py
resolve_confidence(_match)
Get the confidence level from the text.
resolve_match(_match)
Get the regex pattern for the output parser.
Source code in docprompt/tasks/classification/base.py
ClassificationConfig
Bases: BaseModel
Source code in docprompt/tasks/classification/base.py
formatted_labels
property
Produce the formatted labels for the prompt template.
validate_label_bindings(data)
Validate the the label/description bindings based on the type.
Source code in docprompt/tasks/classification/base.py
credentials
The credentials module defines a simple model schema for storing credentials.
APIKeyCredential
Bases: BaseCredentials
The API key credential model.
Source code in docprompt/tasks/credentials.py
AWSCredentials
Bases: BaseCredentials
The AWS credentials model.
Source code in docprompt/tasks/credentials.py
BaseCredentials
Bases: BaseModel
The base credentials model.
Source code in docprompt/tasks/credentials.py
kwargs: Dict[str, str]
property
Return the credentials as a dictionary with secrets exposed.
GCPServiceFileCredentials
Bases: BaseCredentials
The GCP service account credentials model.
Source code in docprompt/tasks/credentials.py
factory
Define the base factory for creating task providers.
AbstractTaskMixin
AbstractTaskProviderFactory
Bases: ABC
, BaseModel
The abstract interface for a provider task factory.
We need to define the basic interface for how we can create task providers. The task provider factory is responsible for allowing the creation of task providers for specific backends, (i.e. Anthropic, OpenAI, etc.)
Source code in docprompt/tasks/factory.py
AmazonTaskProviderFactory
Bases: AbstractTaskProviderFactory
, PageOCRMixin
The task provider factory for Amazon.
Source code in docprompt/tasks/factory.py
get_page_ocr_provider(**kwargs)
Get the page OCR provider.
Source code in docprompt/tasks/factory.py
AnthropicTaskProviderFactory
Bases: AbstractTaskProviderFactory
, PageClassificationMixin
, PageMarkerizationMixin
, PageTableExtractionMixin
The task provider factory for Anthropic.
NOTE: We can either utilize the standard Anthropic API or we can utilize AWS Bedrock. In the event that a user wants to utilize the standard Anthropic API.
Source code in docprompt/tasks/factory.py
get_page_classification_provider(**kwargs)
Get the page classification provider.
Source code in docprompt/tasks/factory.py
get_page_markerization_provider(**kwargs)
Get the page markerization provider.
Source code in docprompt/tasks/factory.py
get_page_table_extraction_provider(**kwargs)
Get the page table extraction provider.
Source code in docprompt/tasks/factory.py
DocumentVQAMixin
Bases: AbstractTaskMixin
, Generic[TTaskProvider]
Mixin for multi-page document VQA task.
Source code in docprompt/tasks/factory.py
GCPTaskProviderFactory
Bases: AbstractTaskProviderFactory
, PageOCRMixin
The task provider factory for GCP.
Source code in docprompt/tasks/factory.py
get_page_ocr_provider(project_id, processor_id, **kwargs)
Get the page OCR provider.
Source code in docprompt/tasks/factory.py
PageClassificationMixin
Bases: AbstractTaskMixin
, Generic[TTaskProvider]
Mixin for page classification task.
Source code in docprompt/tasks/factory.py
PageMarkerizationMixin
Bases: AbstractTaskMixin
, Generic[TTaskProvider]
Mixin for page markerization task.
Source code in docprompt/tasks/factory.py
PageOCRMixin
Bases: AbstractTaskMixin
, Generic[TTaskProvider]
Mixin for page OCR task.
Source code in docprompt/tasks/factory.py
PageRasterizationMixin
Bases: AbstractTaskMixin
, Generic[TTaskProvider]
Mixin for page rasterization task.
Source code in docprompt/tasks/factory.py
PageSegmentationMixin
Bases: AbstractTaskMixin
, Generic[TTaskProvider]
Mixin for page segmentation task.
Source code in docprompt/tasks/factory.py
PageTableExtractionMixin
Bases: AbstractTaskMixin
, Generic[TTaskProvider]
Mixin for page table extraction task.
Source code in docprompt/tasks/factory.py
PageTableIdentificationMixin
Bases: AbstractTaskMixin
, Generic[TTaskProvider]
Mixin for page table identification task.
Source code in docprompt/tasks/factory.py
PageVQAMixin
Bases: AbstractTaskMixin
, Generic[TTaskProvider]
Mixin for page VQA task.
Source code in docprompt/tasks/factory.py
markerize
anthropic
base
message
The core primatives for any language model interfacing. Docprompt uses these for the prompt garden, but supports free conversion to and from these types from other libaries.
OpenAIMessage
Bases: BaseModel
Source code in docprompt/tasks/message.py
from_image_uri(image_uri)
classmethod
Create an image message from a URI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role |
The role of the message. |
required | |
image_uri |
str
|
The URI of the image. |
required |
Source code in docprompt/tasks/message.py
ocr
amazon
base
gcp
GoogleOcrProvider
Bases: BaseOCRProvider
Source code in docprompt/tasks/ocr/gcp.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
|
text_from_layout(layout, document_text, offset=0)
Offset is used to account for the fact that text references are relative to the entire document.
Source code in docprompt/tasks/ocr/gcp.py
result
tesseract
parser
The base output parser that seeks to mimic the langhain implementation.
BaseOutputParser
Bases: BaseModel
, Generic[TTaskInput, TTaskOutput]
The output parser for the page classification system.
Source code in docprompt/tasks/parser.py
from_task_input(task_input)
abstractmethod
result
BaseResult
Bases: BaseModel
Source code in docprompt/tasks/result.py
contribute_to_document_node(document_node, **kwargs)
abstractmethod
Contribute this task result to the document node or a specific page node.
:param document_node: The DocumentNode to contribute to :param page_number: If provided, contribute to a specific page. If None, contribute to the document.
Source code in docprompt/tasks/result.py
ResultContainer
Bases: BaseModel
, Generic[PageOrDocumentTaskResult]
Represents a container for results of a task