Get Result

Retrieve the result data previously obtained with Predict.

Arguments

Argument Type Default value Description
extendedboolFalseGet all the details inside the result data. (main fields only by default)

The stored raw result is usually pre-processed with a library specific keyword prior the return.

param extended:Get all the details inside the result data. (main fields only by default)
returns:Usually a list of fields detected in the document.

Example: Robot Framework

*** Tasks ***
Scan With Base64
    Document AI Base64
    ${data} =    Get Result
    Log List    ${data}

Example: Python

result = lib_docai.get_result()
for field in result:
    print(field)

Init Engine

Initialize the engine you want to scan documents with.

Arguments

Argument Type Default value Description
nameEngineName, strnullName of the engine.
secretstr, Path, Tuple, List, Dict, NoneNoneAuthenticate with a string/file/object secret directly.
vaultDict, str, NoneNoneSpecify the Vault storage name and secret key in order to authenticate. ('name:key' or {name: key} formats are supported)
kwargsnull

This is required before being able to run Predict. Once initialized, you don't need to run this again, simply use Switch Engine to jump between the engines. The final secret value (passed directly with secret or picked up automatically from the Vault with vault) will be split into authorization args and kwargs or just passed as it is to the wrapped library. Keep in mind that some engines are expecting API keys where others tokens or private keys. Any optional keyword argument will be passed further in the wrapped library.

param name:Name of the engine.
param secret:Authenticate with a string/file/object secret directly.
param vault:Specify the Vault storage name and secret key in order to authenticate. ('name:key' or {name: key} formats are supported)

Example: Robot Framework

*** Keywords ***
Init Base64
    Init Engine    base64ai    vault=document_ai:base64ai

Example: Python

from RPA.DocumentAI import DocumentAI
from RPA.Robocorp.Vault import Vault

lib_docai = DocumentAI()
mail_apikey = Vault().get_secret("document_ai")["base64ai"]
lib_docai.init_engine("base64ai", secret=mail_apikey)

Predict

Scan a document with the currently active engine and store the result internally for a later retrieval.

Arguments

Argument Type Default value Description
locationPath, strnullPath to a local file or URL address of a remote one. (not all engines work with URLs)
modelstr, List[str], NoneNoneModel name(s) to scan with. (some engines guess the model if not specified)
kwargsnull

Based on the selected engine, this wraps a chain of libraries until calling a service API in the end, where the passed file is analyzed. Any optional keyword argument will be passed further in the wrapped library. (some engines require mandatory parameters like project ID or region)

param location:Path to a local file or URL address of a remote one. (not all engines work with URLs)
param model:Model name(s) to scan with. (some engines guess the model if not specified)

Example: Robot Framework

*** Tasks ***
Document AI Base64
    [Setup]    Init Base64
    Predict    https://site.com/path/to/invoice.png

Example: Python

lib_docai.predict("local/path/to/invoice.png", model="finance/invoice")

Switch Engine

Switch between already initialized engines.

Arguments

Argument Type Default value Description
nameEngineName, strnullName of the engine to be set as active. (choose between: google, base64ai, nanonets)

Use this to jump between engines when scanning with multiple of them.

param name:Name of the engine to be set as active. (choose between: google, base64ai, nanonets)

Example: Robot Framework

*** Tasks ***
Document AI All
    @{engines} =    Create List     base64ai    nanonets
    FOR    ${engine}    IN    @{engines}
        Switch Engine    ${engine}
        Log    Scanning with engine: ${engine}...
        Predict    invoice.png
        ${data} =    Get Result
        Log List    ${data}
    END

Example: Python

lib_docai.switch_engine("base64ai")
lib_docai.predict("invoice.png")