Skip to content
Report an issue

Documents

UiPath Documents Models.

This module contains models related to UiPath Document Understanding service.

ActionPriority

Bases: str, Enum

Priority levels for validation actions. More details can be found in the official documentation.

CRITICAL class-attribute instance-attribute

CRITICAL = 'Critical'

Critical priority

HIGH class-attribute instance-attribute

HIGH = 'High'

High priority

LOW class-attribute instance-attribute

LOW = 'Low'

Low priority

MEDIUM class-attribute instance-attribute

MEDIUM = 'Medium'

Medium priority

ClassificationResponse

Bases: BaseModel

A model representing the response from a document classification process.

ClassificationResult

Bases: BaseModel

A model representing the result of a document classification.

Attributes:

Name Type Description
document_id str

The ID of the classified document.

document_type_id str

The ID of the predicted document type.

confidence float

The confidence score of the classification.

ocr_confidence float

The OCR confidence score of the document.

reference Reference

The reference information for the classified document.

document_bounds DocumentBounds

The bounds of the document in terms of pages and text.

classifier_name str

The name of the classifier used.

project_id str

The ID of the project associated with the classification.

DocumentBounds

Bases: BaseModel

A model representing the bounds of a document in terms of pages and text.

DocumentsService

Bases: FolderContext, BaseService

Service for managing UiPath DocumentUnderstanding Document Operations.

This service provides methods to extract data from documents using UiPath's Document Understanding capabilities.

Preview Feature

This function is currently experimental. Behavior and parameters are subject to change in future versions.

classify

classify(
    project_type,
    tag=None,
    project_name=None,
    file=None,
    file_path=None,
)

Classify a document using a DU Modern project.

Parameters:

Name Type Description Default
project_type ProjectType

Type of the project.

required
project_name str

Name of the DU Modern project. Must be provided if project_type is not ProjectType.PRETRAINED.

None
tag str

Tag of the published project version. Must be provided if project_type is not ProjectType.PRETRAINED.

None
file FileContent

The document file to be classified.

None
file_path str

Path to the document file to be classified.

None
Note

Either file or file_path must be provided, but not both.

Returns:

Type Description
list[ClassificationResult]

List[ClassificationResult]: A list of classification results.

Examples:

Modern DU project:
with open("path/to/document.pdf", "rb") as file:
    classification_results = service.classify(
        project_name="MyModernProjectName",
        tag="Production",
        file=file,
    )

Pretrained project:
with open("path/to/document.pdf", "rb") as file:
    classification_results = service.classify(
        project_type=ProjectType.PRETRAINED,
        file=file,
    )

classify_async async

classify_async(
    project_type,
    tag=None,
    project_name=None,
    file=None,
    file_path=None,
)

Asynchronously version of the classify method.

create_validate_classification_action

create_validate_classification_action(
    action_title,
    action_priority,
    action_catalog,
    action_folder,
    storage_bucket_name,
    storage_bucket_directory_path,
    classification_results,
)

Create a validate classification action for a document based on the classification results. More details about validation actions can be found in the official documentation.

Parameters:

Name Type Description Default
action_title str

Title of the action.

required
action_priority ActionPriority

Priority of the action.

required
action_catalog str

Catalog of the action.

required
action_folder str

Folder of the action.

required
storage_bucket_name str

Name of the storage bucket.

required
storage_bucket_directory_path str

Directory path in the storage bucket.

required
classification_results list[ClassificationResult]

The classification results to be validated, typically obtained from the classify method.

required

Returns:

Name Type Description
ValidateClassificationAction ValidateClassificationAction

The created validate classification action.

Examples:

validation_action = service.create_validate_classification_action(
    action_title="Test Validation Action",
    action_priority=ActionPriority.MEDIUM,
    action_catalog="default_du_actions",
    action_folder="Shared",
    storage_bucket_name="du_storage_bucket",
    storage_bucket_directory_path="TestDirectory",
    classification_results=classification_results,
)

create_validate_classification_action_async async

create_validate_classification_action_async(
    action_title,
    action_priority,
    action_catalog,
    action_folder,
    storage_bucket_name,
    storage_bucket_directory_path,
    classification_results,
)

Asynchronous version of the create_validation_action method.

create_validate_extraction_action

create_validate_extraction_action(
    action_title,
    action_priority,
    action_catalog,
    action_folder,
    storage_bucket_name,
    storage_bucket_directory_path,
    extraction_response,
)

Create a validate extraction action for a document based on the extraction response. More details about validation actions can be found in the official documentation.

Parameters:

Name Type Description Default
action_title str

Title of the action.

required
action_priority ActionPriority

Priority of the action.

required
action_catalog str

Catalog of the action.

required
action_folder str

Folder of the action.

required
storage_bucket_name str

Name of the storage bucket.

required
storage_bucket_directory_path str

Directory path in the storage bucket.

required
extraction_response ExtractionResponse

The extraction result to be validated, typically obtained from the extract method.

required

Returns:

Name Type Description
ValidateClassificationAction ValidateExtractionAction

The created validation action.

Examples:

validation_action = service.create_validate_extraction_action(
    action_title="Test Validation Action",
    action_priority=ActionPriority.MEDIUM,
    action_catalog="default_du_actions",
    action_folder="Shared",
    storage_bucket_name="du_storage_bucket",
    storage_bucket_directory_path="TestDirectory",
    extraction_response=extraction_response,
)

create_validate_extraction_action_async async

create_validate_extraction_action_async(
    action_title,
    action_priority,
    action_catalog,
    action_folder,
    storage_bucket_name,
    storage_bucket_directory_path,
    extraction_response,
)

Asynchronous version of the create_validation_action method.

extract

extract(
    tag=None,
    project_name=None,
    file=None,
    file_path=None,
    classification_result=None,
    project_type=None,
    document_type_name=None,
)

Extract predicted data from a document using an DU Modern/IXP project.

Parameters:

Name Type Description Default
project_name str

Name of the IXP/DU Modern project. Must be provided if classification_result is not provided.

None
tag str

Tag of the published project version. Must be provided if classification_result is not provided and project_type is not ProjectType.PRETRAINED.

None
file FileContent

The document file to be processed. Must be provided if classification_result is not provided.

None
file_path str

Path to the document file to be processed. Must be provided if classification_result is not provided.

None
project_type ProjectType

Type of the project. Must be provided if project_name is provided.

None
document_type_name str

Document type name associated with the extractor to be used for extraction. Required if project_type is ProjectType.MODERN and project_name is provided.

None
classification_result ClassificationResult

The classification result obtained from a previous classification step. If provided, project_name, project_type, file, file_path, and document_type_name must not be provided.

None
Note

Either file or file_path must be provided, but not both.

Returns:

Type Description
ExtractionResponse | ExtractionResponseIXP

Union[ExtractionResponse, ExtractionResponseIXP]: The extraction response containing the extracted data.

Examples:

IXP projects:

with open("path/to/document.pdf", "rb") as file:
    extraction_response = service.extract(
        project_name="MyIXPProjectName",
        tag="live",
        file=file,
    )

DU Modern projects (providing document type name):

with open("path/to/document.pdf", "rb") as file:
    extraction_response = service.extract(
        project_name="MyModernProjectName",
        tag="Production",
        file=file,
        project_type=ProjectType.MODERN,
        document_type_name="Receipts",
    )

DU Modern projects (using existing classification result):

with open("path/to/document.pdf", "rb") as file:
    classification_results = uipath.documents.classify(
        tag="Production",
        project_name="MyModernProjectName",
        file=file,
    )

extraction_result = uipath.documents.extract(
    classification_result=max(classification_results, key=lambda result: result.confidence),
)

extract_async async

extract_async(
    tag=None,
    project_name=None,
    file=None,
    file_path=None,
    classification_result=None,
    project_type=None,
    document_type_name=None,
)

Asynchronously version of the extract method.

get_validate_classification_result

get_validate_classification_result(validation_action)

Get the result of a validate classification action.

Note

This method will block until the validation action is completed, meaning the user has completed the validation in UiPath Action Center.

Parameters:

Name Type Description Default
validation_action ValidateClassificationAction

The validation action to get the result for, typically obtained from the create_validate_classification_action method.

required

Returns:

Type Description
list[ClassificationResult]

List[ClassificationResult]: The validated classification results.

Examples:

validated_results = service.get_validate_classification_result(validate_classification_action)

get_validate_classification_result_async async

get_validate_classification_result_async(validation_action)

Asynchronous version of the get_validation_result method.

get_validate_extraction_result

get_validate_extraction_result(validation_action)

Get the result of a validate extraction action.

Note

This method will block until the validation action is completed, meaning the user has completed the validation in UiPath Action Center.

Parameters:

Name Type Description Default
validation_action ValidateClassificationAction

The validation action to get the result for, typically obtained from the create_validate_extraction_action method.

required

Returns:

Type Description
ExtractionResponse | ExtractionResponseIXP

Union[ExtractionResponse, ExtractionResponseIXP]: The validated extraction response.

Examples:

validated_result = service.get_validate_extraction_result(validate_extraction_action)

get_validate_extraction_result_async async

get_validate_extraction_result_async(validation_action)

Asynchronous version of the get_validation_result method.

ExtractionResponse

Bases: BaseModel

A model representing the response from a document extraction process.

Attributes:

Name Type Description
extraction_result ExtractionResult

The result of the extraction process.

project_id str

The ID of the project associated with the extraction.

tag str

The tag associated with the published model version.

document_type_id str

The ID of the document type associated with the extraction.

ExtractionResponseIXP

Bases: ExtractionResponse

A model representing the response from a document extraction process for IXP projects.

Attributes:

Name Type Description
data_projection list[FieldGroupValueProjection]

A simplified projection of the extracted data.

ExtractionResult

Bases: BaseModel

A model representing the result of a document extraction process.

FieldGroupValueProjection

Bases: BaseModel

A model representing a projection of a field group value in a document extraction result.

FieldType

Bases: str, Enum

Field types supported by Document Understanding service.

FieldValueProjection

Bases: BaseModel

A model representing a projection of a field value in a document extraction result.

ProjectType

Bases: str, Enum

Project types available and supported by Documents Service.

IXP class-attribute instance-attribute

IXP = 'IXP'

Represents an IXP project type.

MODERN class-attribute instance-attribute

MODERN = 'Modern'

Represents a DU Modern project type.

PRETRAINED class-attribute instance-attribute

PRETRAINED = 'Pretrained'

Represents a Pretrained project type.

Reference

Bases: BaseModel

A model representing a reference within a document.

ValidateClassificationAction

Bases: ValidationAction

A model representing a validation action for document classification.

ValidateExtractionAction

Bases: ValidationAction

A model representing a validation action for document extraction.

ValidationAction

Bases: BaseModel

A model representing a validation action for a document.

Attributes:

Name Type Description
action_data dict

The data associated with the validation action.

action_status str

The status of the validation action. Possible values can be found in the official documentation.

project_id str

The ID of the project associated with the validation action.

tag str

The tag associated with the published model version.

operation_id str

The operation ID associated with the validation action.