Pre-requisites
Run the following command to enable watsonx Orchestrate Developer Edition to process documents:BASH
Note:
You need to configure a minimum allocation of 20GB RAM to your Docker engine during installation of watsonx Orchestrate Developer edition to support document processing features.
Limitations
Text extractors have the following limits and restrictions:Note:
To run the document field extractor, you must define the
WATSONX_SPACE_ID, WATSONX_APIKEY, and WATSONX_PROJECT_ID credentials in your .env file. For more information on configuring the .env file, see Installing the watsonx Orchestrate Developer Edition.Configuring document extractor node in agentic workflows
-
Define the fields to extract.
Create a class that defines the fields you want to extract. Each field must follow this structure:
Class example:PythonPython
- Configure the document extract node
docext() method to extract an field from a document. This method accepts the following input arguments:
string
required
Unique identifier for the node.
string
The LLM used for field extraction. The default value is
watsonx/meta-llama/llama-3-2-90b-vision-instruct.string
Display name for the node.
object
required
The fields you want to extract.
string
Description of the node.
DataMap
Define input mappings using a structured collection of Assignment objects.
bool
Enable the handwritten feature by setting this to
true.float
The minimum acceptable confidence for an extracted field value.
List[string]
The fields that require user review.
bool
Enables or disables the human-in-the-loop feature. Set to
True to activate it and False to deactivate. The default value is False.string
Selects the Document Extractor runtime. The default value is
classic, which uses the Unstructured Document Extractor. To use the Structured Document Extractor, set the value to layout. For more information, see Choosing a tool option for extracting fields from documents.PageRange
Limits extraction to a specific range of pages. Use this parameter only when
field_extraction_method is set to layout. Using page_range with the classic method raises an error.Use PageRange(start=1, end=5) to extract fields from pages 1 through 5.LanguageCode
The ISO-639 language code that specifies the document’s language for OCR processing. Use the
LanguageCode enum to specify supported languages (e.g., LanguageCode.fr for French, LanguageCode.ja for Japanese). This parameter is essential for scanned PDFs and images containing non-Latin scripts, as it ensures the correct OCR engine is used to recognize characters accurately. Programmatic documents (PDF, .docx, .pptx) do not require this setting.Note:The
min_confidence and review_fields settings control the human-in-the-loop feature. This feature only works when you run the Flow from a chat session.
If a field is extracted with confidence lower than min_confidence, and its name appears in review_fields, the agent opens a review window in the chat. You can then review and confirm the extracted values.docext node accepts input of type DocumentProcessingCommonInput, from the module ibm_watsonx_orchestrate.flow_builder.types.
You can also supply page_range on DocumentProcessingCommonInput instead of setting it at design time on docext(). The same layout-only constraint applies: page_range has no effect unless you set field_extraction_method='layout' on the node.
Example use of the docext node in an agentic workflow:
Python
Using the language parameter
For scanned PDFs and images containing non-Latin scripts, specify the document’s language to ensure accurate OCR processing:Python
Using the language parameter with structured document extractor
When using thelayout field extraction method, you can also specify the language parameter:
Python
Extracting table fields
UseDocExtConfigTableField to extract tabular data — such as invoice line items — from structured documents. Table extraction requires field_extraction_method="layout".
Import DocExtConfigTableField alongside DocExtConfigField:
Python
DocExtConfigTableField defines a table with a list of column definitions, where each column is a standard DocExtConfigField.
Python
Table extraction requires
field_extraction_method="layout". Using DocExtConfigTableField with the default classic method raises an error.Using available_options to constrain extracted values
Use theavailable_options parameter on a DocExtConfigField to restrict the extracted value to a predefined list. This is useful when the field value must be inferred from visual cues — for example, a currency symbol (€) that should map to "EUR" — and you want to prevent the LLM from hallucinating invalid values.
available_options requires field_extraction_method="layout".
Python
available_options requires field_extraction_method="layout". It has no effect when using the default classic extraction method.
