Skip to content
Report an issue

Documents

DocumentsService

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(tag, project_name, file=None, file_path=None)

Classify a document using a DU Modern project.

Parameters:

Name Type Description Default
project_name str

Name of the DU Modern project.

required
tag str

Tag of the published project version.

required
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:

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

classify_async async

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

Asynchronously version of the classify method.

create_validation_action

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

Create a validation 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
ValidationAction ValidationAction

The created validation action.

Examples:

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

create_validation_action_async async

create_validation_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,
    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.

required
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
Note

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

Returns:

Name Type Description
ExtractionResponse Union[ExtractionResponse, ExtractionResponseIXP]

The extraction result containing predicted 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(
    tag="Production",
    classification_result=max(classification_results, key=lambda result: result.confidence),
)

extract_async async

extract_async(
    tag,
    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_validation_result

get_validation_result(validation_action)

Get the result of a validation 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 ValidationAction

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

required

Returns:

Name Type Description
ValidatedResult ValidatedResult

The result of the validation action.

Examples:

validated_result = service.get_validation_result(validation_action)

get_validation_result_async async

get_validation_result_async(validation_action)

Asynchronous version of the get_validation_result method.