Get Fields From Prediction Result

Helper keyword to get found fields from a prediction result. For example see Scan Document File or Scan Document URL keyword.

Arguments

Argument Type Default value Description
predictionDict[Hashable, str | int | float | bool | list | dict | None], List[str | int | float | bool | list | dict | None], str, int, float, bool, list, dict, Nonenullprediction result dictionary
param prediction:
 prediction result dictionary
return:list of found fields

Get User Data

Get user data including details on credits used and credits remaining for the Base64 service.

Returned user data contains following keys:

  • givenName
  • familyName
  • email
  • hasWorkEmail
  • companyName
  • numberOfCredits
  • numberOfPages
  • numberOfUploads
  • numberOfCreditsSpentOnDocuments (visible if used)
  • numberOfCreditsSpentOnFaceDetection (visible if used)
  • numberOfCreditsSpentOnFaceRecognition (visible if used)
  • hasActiveAwsContract
  • subscriptionType
  • subscriptionPeriod
  • tags
  • ccEmails
  • status
  • remainingCredits (calculated by the keyword)
return:object containing details on the API user

Robot Framework example:

${userdata}=   Get User Data
Log To Console  I have still ${userdata}[remainingCredits] credits left

Python example:

userdata = baselib.get_user_data()
print(f"I have still {userdata['remainingCredits']} credits left")

Scan Document File

Scan a document file. Can be given a model_types to specifically target certain models.

Arguments

Argument Type Default value Description
file_pathstrnullfilepath to the file
model_typesstr, List[str], NoneNonesingle model type or list of model types
mockboolFalseset to True to use /mock/scan endpoint instead of /scan
param file_path:
 filepath to the file
param model_types:
 single model type or list of model types
param mock:set to True to use /mock/scan endpoint instead of /scan
return:result of the document scan

Robot Framework example:

${results}=    Scan Document File
...    ${CURDIR}${/}files${/}IMG_8277.jpeg
...    model_types=finance/check/usa,finance/invoice
FOR    ${result}    IN    @{results}
    Log To Console    Model: ${result}[model]
    Log To Console    Fields: ${result}[fields]
    Log To Console    Text (OCR): ${result}[ocr]
END

Python example:

result = baselib.scan_document_file(
    "./files/Invoice-1120.pdf",
    model_types="finance/invoice,finance/check/usa",
)
for r in result:
    print(f"Model: {r['model']}")
    for key, val in r["fields"].items():
        print(f"{key}: {val['value']}")
    print(f"Text (OCR): {r['ocr']}")

Scan Document Url

Scan a document URL. Can be given a model_types to specifically target certain models.

Arguments

Argument Type Default value Description
urlstrnullvalid url to a file
model_typesstr, List[str], NoneNonesingle model type or list of model types
mockboolFalseset to True to use /mock/scan endpoint instead of /scan
param url:valid url to a file
param model_types:
 single model type or list of model types
param mock:set to True to use /mock/scan endpoint instead of /scan
return:result of the document scan

Robot Framework example:

${results}=    Scan Document URL
...    https://base64.ai/static/content/features/data-extraction/models//2.png
FOR    ${result}    IN    @{results}
    Log To Console    Model: ${result}[model]
    Log To Console    Fields: ${result}[fields]
    Log To Console    Text (OCR): ${result}[ocr]
END

Python example:

result = baselib.scan_document_url(
    "https://base64.ai/static/content/features/data-extraction/models//2.png"
)
for r in result:
    print(f"Model: {r['model']}")
    for key, props in r["fields"].items():
        print(f"FIELD {key}: {props['value']}")
    print(f"Text (OCR): {r['ocr']}")

Set Authorization

Set Base64 AI request headers with email and key related to API.

Arguments

Argument Type Default value Description
api_emailstrnullemail address related to the API
api_keystrnullkey related to the API
param api_email:
 email address related to the API
param api_key:key related to the API

Robot Framework example:

${secrets}=   Get Secret  base64ai-auth
Set Authorization    ${secrets}[email-address]    ${secrets}[apikey]

Python example:

secrets = Vault().get_secret("base64ai-auth")
baselib = Base64AI()
baselib.set_authorization(secrets["email-address"], secrets["apikey"])