ibm-watsonx-orchestrate 1.11.0b0__py3-none-any.whl → 1.12.0b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. ibm_watsonx_orchestrate/__init__.py +1 -1
  2. ibm_watsonx_orchestrate/agent_builder/agents/types.py +30 -0
  3. ibm_watsonx_orchestrate/agent_builder/connections/connections.py +8 -5
  4. ibm_watsonx_orchestrate/agent_builder/connections/types.py +14 -0
  5. ibm_watsonx_orchestrate/agent_builder/knowledge_bases/types.py +25 -10
  6. ibm_watsonx_orchestrate/agent_builder/tools/__init__.py +1 -0
  7. ibm_watsonx_orchestrate/agent_builder/tools/langflow_tool.py +124 -0
  8. ibm_watsonx_orchestrate/agent_builder/tools/openapi_tool.py +3 -3
  9. ibm_watsonx_orchestrate/agent_builder/tools/types.py +20 -2
  10. ibm_watsonx_orchestrate/cli/commands/agents/agents_command.py +10 -2
  11. ibm_watsonx_orchestrate/cli/commands/agents/agents_controller.py +421 -177
  12. ibm_watsonx_orchestrate/cli/commands/connections/connections_command.py +18 -0
  13. ibm_watsonx_orchestrate/cli/commands/connections/connections_controller.py +114 -0
  14. ibm_watsonx_orchestrate/cli/commands/copilot/copilot_server_controller.py +24 -91
  15. ibm_watsonx_orchestrate/cli/commands/environment/environment_command.py +1 -1
  16. ibm_watsonx_orchestrate/cli/commands/evaluations/evaluations_command.py +223 -2
  17. ibm_watsonx_orchestrate/cli/commands/evaluations/evaluations_controller.py +93 -9
  18. ibm_watsonx_orchestrate/cli/commands/models/models_controller.py +3 -3
  19. ibm_watsonx_orchestrate/cli/commands/partners/offering/partners_offering_command.py +56 -0
  20. ibm_watsonx_orchestrate/cli/commands/partners/offering/partners_offering_controller.py +458 -0
  21. ibm_watsonx_orchestrate/cli/commands/partners/offering/types.py +107 -0
  22. ibm_watsonx_orchestrate/cli/commands/partners/partners_command.py +12 -0
  23. ibm_watsonx_orchestrate/cli/commands/partners/partners_controller.py +0 -0
  24. ibm_watsonx_orchestrate/cli/commands/server/server_command.py +114 -635
  25. ibm_watsonx_orchestrate/cli/commands/server/types.py +1 -1
  26. ibm_watsonx_orchestrate/cli/commands/toolkit/toolkit_controller.py +2 -2
  27. ibm_watsonx_orchestrate/cli/commands/tools/tools_command.py +2 -3
  28. ibm_watsonx_orchestrate/cli/commands/tools/tools_controller.py +206 -43
  29. ibm_watsonx_orchestrate/cli/main.py +2 -0
  30. ibm_watsonx_orchestrate/client/base_api_client.py +31 -10
  31. ibm_watsonx_orchestrate/client/connections/connections_client.py +18 -1
  32. ibm_watsonx_orchestrate/client/service_instance.py +19 -34
  33. ibm_watsonx_orchestrate/client/tools/tempus_client.py +3 -0
  34. ibm_watsonx_orchestrate/client/tools/tool_client.py +5 -2
  35. ibm_watsonx_orchestrate/client/utils.py +34 -2
  36. ibm_watsonx_orchestrate/docker/compose-lite.yml +14 -12
  37. ibm_watsonx_orchestrate/docker/default.env +17 -17
  38. ibm_watsonx_orchestrate/flow_builder/flows/flow.py +3 -1
  39. ibm_watsonx_orchestrate/flow_builder/types.py +252 -1
  40. ibm_watsonx_orchestrate/utils/docker_utils.py +280 -0
  41. ibm_watsonx_orchestrate/utils/environment.py +369 -0
  42. ibm_watsonx_orchestrate/utils/utils.py +1 -1
  43. {ibm_watsonx_orchestrate-1.11.0b0.dist-info → ibm_watsonx_orchestrate-1.12.0b0.dist-info}/METADATA +2 -2
  44. {ibm_watsonx_orchestrate-1.11.0b0.dist-info → ibm_watsonx_orchestrate-1.12.0b0.dist-info}/RECORD +47 -39
  45. {ibm_watsonx_orchestrate-1.11.0b0.dist-info → ibm_watsonx_orchestrate-1.12.0b0.dist-info}/WHEEL +0 -0
  46. {ibm_watsonx_orchestrate-1.11.0b0.dist-info → ibm_watsonx_orchestrate-1.12.0b0.dist-info}/entry_points.txt +0 -0
  47. {ibm_watsonx_orchestrate-1.11.0b0.dist-info → ibm_watsonx_orchestrate-1.12.0b0.dist-info}/licenses/LICENSE +0 -0
@@ -10,7 +10,7 @@ from ibm_cloud_sdk_core.authenticators import MCSPV2Authenticator
10
10
  from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
11
11
  from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
12
12
 
13
- from ibm_watsonx_orchestrate.client.utils import check_token_validity, is_cpd_env
13
+ from ibm_watsonx_orchestrate.client.utils import check_token_validity, is_cpd_env, is_ibm_cloud_platform
14
14
  from ibm_watsonx_orchestrate.client.base_service_instance import BaseServiceInstance
15
15
  from ibm_watsonx_orchestrate.cli.commands.environment.types import EnvironmentAuthType
16
16
 
@@ -21,14 +21,6 @@ from ibm_watsonx_orchestrate.client.client_errors import (
21
21
  import logging
22
22
  logger = logging.getLogger(__name__)
23
23
 
24
- from ibm_watsonx_orchestrate.cli.config import (
25
- Config,
26
- CONTEXT_SECTION_HEADER,
27
- CONTEXT_ACTIVE_ENV_OPT,
28
- ENVIRONMENTS_SECTION_HEADER,
29
- ENV_WXO_URL_OPT
30
- )
31
-
32
24
  class ServiceInstance(BaseServiceInstance):
33
25
  """Connect, get details, and check usage of a Watson Machine Learning service instance."""
34
26
 
@@ -50,29 +42,28 @@ class ServiceInstance(BaseServiceInstance):
50
42
  return self._client.token
51
43
 
52
44
  def _create_token(self) -> str:
53
- if not self._credentials.auth_type:
54
- if ".cloud.ibm.com" in self._credentials.url:
55
- logger.warning("Using IBM IAM Auth Type. If this is incorrect please use the '--type' flag to explicitly choose one of 'mcsp', 'mcsp_v1', 'mcsp_v2' or 'cpd' ")
56
- return self._authenticate(EnvironmentAuthType.IBM_CLOUD_IAM)
57
- elif is_cpd_env(self._credentials.url):
58
- logger.warning("Using CPD Auth Type. If this is incorrect please use the '--type' flag to explicitly choose one of 'ibm_iam', 'mcsp', 'mcsp_v1' or 'mcsp_v2' ")
59
- return self._authenticate(EnvironmentAuthType.CPD)
60
- else:
61
- logger.warning("Using MCSP Auth Type. If this is incorrect please use the '--type' flag to explicitly choose one of 'ibm_iam', 'mcsp_v1', 'mcsp_v2' or 'cpd' ")
62
- try:
63
- return self._authenticate(EnvironmentAuthType.MCSP_V1)
64
- except:
65
- return self._authenticate(EnvironmentAuthType.MCSP_V2)
66
- auth_type = self._credentials.auth_type.lower()
45
+ inferred_auth_type = None
46
+ if is_ibm_cloud_platform(self._credentials.url):
47
+ inferred_auth_type = EnvironmentAuthType.IBM_CLOUD_IAM
48
+ elif is_cpd_env(self._credentials.url):
49
+ inferred_auth_type = EnvironmentAuthType.CPD
50
+ else:
51
+ inferred_auth_type = EnvironmentAuthType.MCSP
52
+
53
+ if self._credentials.auth_type:
54
+ if self._credentials.auth_type != inferred_auth_type:
55
+ logger.warning(f"Overriding the default authentication type '{inferred_auth_type}' for url '{self._credentials.url}' with '{self._credentials.auth_type.lower()}'")
56
+ auth_type = self._credentials.auth_type.lower()
57
+ else:
58
+ inferred_type_options = [t for t in EnvironmentAuthType if t != inferred_auth_type]
59
+ logger.warning(f"Using '{inferred_auth_type}' Auth Type. If this is incorrect please use the '--type' flag to explicitly choose one of {', '.join(inferred_type_options[:-1])} or {inferred_type_options[-1]}")
60
+ auth_type = inferred_auth_type
61
+
67
62
  if auth_type == "mcsp":
68
63
  try:
69
64
  return self._authenticate(EnvironmentAuthType.MCSP_V1)
70
65
  except:
71
66
  return self._authenticate(EnvironmentAuthType.MCSP_V2)
72
- elif auth_type == "mcsp_v1":
73
- return self._authenticate(EnvironmentAuthType.MCSP_V1)
74
- elif auth_type == "mcsp_v2":
75
- return self._authenticate(EnvironmentAuthType.MCSP_V2)
76
67
  else:
77
68
  return self._authenticate(auth_type)
78
69
 
@@ -100,13 +91,7 @@ class ServiceInstance(BaseServiceInstance):
100
91
  if self._credentials.iam_url is not None:
101
92
  url = self._credentials.iam_url
102
93
  else:
103
- cfg = Config()
104
- env_cfg = cfg.get(ENVIRONMENTS_SECTION_HEADER)
105
- matching_wxo_url = next(
106
- (env_config['wxo_url'] for env_config in env_cfg.values() if 'bypass_ssl' in env_config and 'verify' in env_config),
107
- None
108
- )
109
- base_url = matching_wxo_url.split("/orchestrate")[0]
94
+ base_url = self._credentials.url.split("/orchestrate")[0]
110
95
  url = f"{base_url}/icp4d-api"
111
96
 
112
97
  password = self._credentials.password if self._credentials.password is not None else None
@@ -42,4 +42,7 @@ class TempusClient(BaseAPIClient):
42
42
 
43
43
  def arun_flow(self, flow_id: str, input: dict) -> dict:
44
44
  return self._post(f"/flows/{flow_id}/versions/TIP/run/async", data=input)
45
+
46
+ def get_flow_model(self, flow_id: str, version: str = "TIP") -> dict:
47
+ return self._get(f"/flow-models/{flow_id}/versions/{version}")
45
48
 
@@ -10,7 +10,7 @@ class ToolClient(BaseAPIClient):
10
10
  def create(self, payload: dict) -> dict:
11
11
  return self._post("/tools", data=payload)
12
12
 
13
- def get(self) -> dict:
13
+ def get(self) -> dict:
14
14
  return self._get("/tools")
15
15
 
16
16
  def update(self, agent_id: str, data: dict) -> dict:
@@ -21,10 +21,13 @@ class ToolClient(BaseAPIClient):
21
21
 
22
22
  def upload_tools_artifact(self, tool_id: str, file_path: str) -> dict:
23
23
  return self._post(f"/tools/{tool_id}/upload", files={"file": (f"{tool_id}.zip", open(file_path, "rb"), "application/zip", {"Expires": "0"})})
24
-
24
+
25
25
  def download_tools_artifact(self, tool_id: str) -> bytes:
26
26
  response = self._get(f"/tools/{tool_id}/download", return_raw=True)
27
27
  return response.content
28
+
29
+ def download_tools_json(self, tool_id: str) -> dict:
30
+ return self.download_tools_artifact(tool_id)
28
31
 
29
32
  def get_draft_by_name(self, tool_name: str) -> List[dict]:
30
33
  return self.get_drafts_by_names([tool_name])
@@ -1,3 +1,5 @@
1
+ import platform
2
+
1
3
  from ibm_watsonx_orchestrate.cli.config import (
2
4
  Config,
3
5
  DEFAULT_CONFIG_FILE_FOLDER,
@@ -66,7 +68,7 @@ def is_ibm_cloud_platform(url:str | None = None) -> bool:
66
68
  if url is None:
67
69
  url = get_current_env_url()
68
70
 
69
- if url.__contains__("cloud.ibm.com"):
71
+ if ".cloud.ibm.com" in url:
70
72
  return True
71
73
  return False
72
74
 
@@ -161,6 +163,8 @@ def instantiate_client(client: type[T] , url: str | None=None) -> T:
161
163
  client_instance = client(base_url=url, api_key=token, is_local=is_local_dev(url), verify=False)
162
164
  elif verify is not None:
163
165
  client_instance = client(base_url=url, api_key=token, is_local=is_local_dev(url), verify=verify)
166
+ else:
167
+ client_instance = client(base_url=url, api_key=token, is_local=is_local_dev(url))
164
168
  else:
165
169
  client_instance = client(base_url=url, api_key=token, is_local=is_local_dev(url))
166
170
 
@@ -168,4 +172,32 @@ def instantiate_client(client: type[T] , url: str | None=None) -> T:
168
172
  except FileNotFoundError as e:
169
173
  message = "No active environment found. Please run `orchestrate env activate` to activate an environment"
170
174
  logger.error(message)
171
- raise FileNotFoundError(message)
175
+ raise FileNotFoundError(message)
176
+
177
+
178
+ def get_architecture () -> str:
179
+ arch = platform.machine().lower()
180
+ if arch in ("amd64", "x86_64"):
181
+ return "amd64"
182
+
183
+ elif arch == "i386":
184
+ return "386"
185
+
186
+ elif arch in ("aarch64", "arm64", "arm"):
187
+ return "arm"
188
+
189
+ else:
190
+ raise Exception("Unsupported architecture %s" % arch)
191
+
192
+
193
+ def is_arm_architecture () -> bool:
194
+ return platform.machine().lower() in ("aarch64", "arm64", "arm")
195
+
196
+
197
+ def get_os_type () -> str:
198
+ system = platform.system().lower()
199
+ if system in ("linux", "darwin", "windows"):
200
+ return system
201
+
202
+ else:
203
+ raise Exception("Unsupported operating system %s" % system)
@@ -133,8 +133,9 @@ services:
133
133
  DOCPROC_ENABLED: ${DOCPROC_ENABLED:-false}
134
134
  IS_OBSERVABILITY_FEATURE_ENABLED: "true"
135
135
  ALLOW_INSECURE_TLS: "true"
136
- ENABLE_EDIT_PROMPTS: "true"
136
+ ENABLE_EDIT_PROMPTS: "false"
137
137
  LANGFLOW_ENABLED: ${LANGFLOW_ENABLED:-false}
138
+ ENABLE_EMBED_SCRIPT: "true"
138
139
  command: 'npm start'
139
140
  ports:
140
141
  - "4025:4025"
@@ -378,6 +379,7 @@ services:
378
379
  IS_WXO_LITE: "TRUE"
379
380
  TRM_BASE_URL: http://tools-runtime-manager:8080
380
381
  AGENT_STEP_DETAILS: redis://wxo-server-redis:6379/0
382
+ RECURSION_LIMIT: ${RECURSION_LIMIT}
381
383
  AGENT_GATEWAY_URI: http://wxo-agent-gateway:8989
382
384
  JWT_SECRET: ${JWT_SECRET}
383
385
  POSTGRES_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@wxo-server-db:5432/postgres
@@ -886,18 +888,18 @@ services:
886
888
  PREFLIGHT_MAX_SIZE: 10Mb
887
889
  PREFLIGHT_MAX_PAGES: 600
888
890
  RUNTIME_LIBRARY: "watson_doc_understanding"
889
- WXAI_API_KEY: ${WXAI_API_KEY:-}
890
- WXAI_IMAGE_DESCRIPTION_MODEL_ID: ${WXAI_IMAGE_DESCRIPTION_MODEL_ID:-mistralai/pixtral-12b}
891
- WXAI_IMAGE_DESCRIPTION_PROJECT_ID: ${WXAI_IMAGE_DESCRIPTION_PROJECT_ID:-}
892
- WXAI_KVP_MODEL_ID: ${WXAI_KVP_MODEL_ID:-}
893
- WXAI_KVP_PROJECT_ID: ${WXAI_KVP_PROJECT_ID:-}
894
- WXAI_SEMANTIC_KVP_PROJECT_ID: ${WXAI_SEMANTIC_KVP_PROJECT_ID:-}
895
- WXAI_SEMANTIC_KVP_MODEL_ID: ${WXAI_SEMANTIC_KVP_MODEL_ID:-mistralai/pixtral-12b}
896
- WXAI_SEMANTIC_KVP_SPACE_ID: ${WXAI_SEMANTIC_KVP_SPACE_ID:-}
897
- WXAI_URL: ${WXAI_URL:-}
891
+ WXAI_API_KEY: ${WXAI_API_KEY:-"gateway"}
892
+ WXAI_IMAGE_DESCRIPTION_MODEL_ID: ${WXAI_IMAGE_DESCRIPTION_MODEL_ID:-mistralai/mistral-small-3-1-24b-instruct-2503}
893
+ WXAI_IMAGE_DESCRIPTION_SPACE_ID: ${WATSONX_SPACE_ID:-}
894
+ WXAI_KVP_MODEL_ID: ${WXAI_KVP_MODEL_ID:-mistralai/mistral-small-3-1-24b-instruct-2503}
895
+ WXAI_KVP_SPACE_ID: ${WATSONX_SPACE_ID:-}
896
+ WXAI_SEMANTIC_KVP_MODEL_ID: ${WXAI_SEMANTIC_KVP_MODEL_ID:-mistralai/mistral-small-3-1-24b-instruct-2503}
897
+ WXAI_SEMANTIC_KVP_SPACE_ID: ${WATSONX_SPACE_ID:-}
898
+ WXAI_URL: ${AI_GATEWAY_BASE_URL:-}
898
899
  WXAI_USERNAME: ${WXAI_USERNAME:-}
899
900
  WXAI_INSTANCE_ID: ${WXAI_INSTANCE_ID:-}
900
- WXAI_VERSION: ${WXAI_VERSION:-5.1}
901
+ WXAI_VERSION: ${WXAI_VERSION:-2023-05-29}
902
+ WXAI_PROVIDER: ${WXAI_PROVIDER:-gateway}
901
903
 
902
904
  profiles:
903
905
  - docproc
@@ -1139,7 +1141,7 @@ services:
1139
1141
  environment:
1140
1142
  LANGFLOW_PORT: 7861
1141
1143
  LANGFLOW_DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@wxo-server-db:5432/langflow
1142
- LANGFLOW_CONFIG_DIR: app/langflow
1144
+ LANGFLOW_CONFIG_DIR: /app/app/langflow
1143
1145
  volumes:
1144
1146
  - langflow-data:/app/langflow
1145
1147
 
@@ -36,7 +36,7 @@ DB_ENCRYPTION_KEY=dummy_db_encryption_key
36
36
  BASE_URL=dummy_base_url
37
37
  SERVER_TYPE=CELERY
38
38
  SQLALCHEMY_DEBUG=false
39
-
39
+ RECURSION_LIMIT=50
40
40
  LANGFUSE_HOST=http://host.docker.internal:3010
41
41
  LANGFUSE_EMAIL=orchestrate@ibm.com
42
42
  LANGFUSE_USERNAME=orchestrate
@@ -58,10 +58,10 @@ REGISTRY_URL=
58
58
 
59
59
 
60
60
 
61
- SERVER_TAG=29-08-2025-59ef405
61
+ SERVER_TAG=09-09-2025-2164abd
62
62
  SERVER_REGISTRY=
63
63
 
64
- WORKER_TAG=29-08-2025-cf32b2d
64
+ WORKER_TAG=09-09-2025-2164abd
65
65
  WORKER_REGISTRY=
66
66
 
67
67
  AI_GATEWAY_TAG=20-08-2025-9ed6d40
@@ -73,9 +73,9 @@ AGENT_GATEWAY_REGISTRY=
73
73
  DB_REGISTRY=
74
74
  # If you build multiarch set all three of these to the same, we have a pr against main
75
75
  # to not have this separation, but we can merge it later
76
- DBTAG=29-07-2025-9f3661b
77
- AMDDBTAG=29-07-2025-9f3661b
78
- ARM64DBTAG=29-07-2025-9f3661b
76
+ DBTAG=09-09-2025-fb76647
77
+ AMDDBTAG=09-09-2025-fb76647
78
+ ARM64DBTAG=09-09-2025-fb76647
79
79
 
80
80
  UI_REGISTRY=
81
81
  UITAG=29-08-2025
@@ -83,16 +83,16 @@ UITAG=29-08-2025
83
83
  CM_REGISTRY=
84
84
  CM_TAG=24-07-2025
85
85
 
86
- TRM_TAG=19-08-2025-fe105eb0b950ff304f712a1a5b9fa3cba92d09da
86
+ TRM_TAG=09-09-2025-6e9d73d
87
87
  TRM_REGISTRY=
88
88
 
89
- TR_TAG=25-08-2025-58ae475
89
+ TR_TAG=09-09-2025-6e9d73d
90
90
  TR_REGISTRY=
91
91
 
92
- BUILDER_TAG=27-08-2025-7432aca
92
+ BUILDER_TAG=12-09-2025-e441686
93
93
  BUILDER_REGISTRY=
94
94
 
95
- FLOW_RUNTIME_TAG=26-08-2025-3b7f19e
95
+ FLOW_RUNTIME_TAG=15-09-2025-2e8478c
96
96
  FLOW_RUMTIME_REGISTRY=
97
97
 
98
98
 
@@ -105,23 +105,23 @@ JAEGER_PROXY_REGISTRY=
105
105
  SOCKET_HANDLER_TAG=29-05-2025
106
106
  SOCKET_HANDLER_REGISTRY=
107
107
 
108
- CPE_TAG=18-08-2025-ae1308e
108
+ CPE_TAG=29-08-2025-e612bea
109
109
  CPE_REGISTRY=
110
110
 
111
- VOICE_CONTROLLER_TAG=12-08-2025
111
+ VOICE_CONTROLLER_TAG=12-09-2025-0e04772
112
112
  VOICE_CONTROLLER_REGISTRY=
113
113
 
114
114
  LANGFLOW_TAG=
115
115
  LANGFLOW_IMAGE=
116
116
 
117
117
  # IBM Document Processing
118
- WDU_TAG=2.6.1
118
+ WDU_TAG=2.7.0
119
119
  WDU_REGISTRY=
120
120
 
121
- DOCPROC_DPS_TAG=20250815-010747-277-173db2a
122
- DOCPROC_LLMSERVICE_TAG=20250820-153924-128-55cf4d5
123
- DOCPROC_CACHE_TAG=20250814-master-82-cf33f87
124
- DOCPROC_DPI_TAG=20250815-004755-273-e65f26b4
121
+ DOCPROC_DPS_TAG=20250904-181617-287-1ca2bf1
122
+ DOCPROC_LLMSERVICE_TAG=20250904-main-136-b94360e
123
+ DOCPROC_CACHE_TAG=20250902-master-83-748d456
124
+ DOCPROC_DPI_TAG=20250905-092707-286-8c6b8f92
125
125
  DOCPROC_REGISTRY=
126
126
 
127
127
  # END -- IMAGE REGISTRIES AND TAGS
@@ -440,7 +440,7 @@ class Flow(Node):
440
440
  node = self._add_node(node)
441
441
  return cast(PromptNode, node)
442
442
 
443
- def docclassfier(self,
443
+ def docclassifier(self,
444
444
  name: str,
445
445
  llm : str = "watsonx/meta-llama/llama-3-2-90b-vision-instruct",
446
446
  version: str = "TIP",
@@ -607,6 +607,7 @@ class Flow(Node):
607
607
  display_name: str|None=None,
608
608
  description: str | None = None,
609
609
  input_map: DataMap = None,
610
+ document_structure: bool = False,
610
611
  kvp_schemas: list[DocProcKVPSchema] = None,
611
612
  enable_hw: bool = False) -> DocProcNode:
612
613
 
@@ -631,6 +632,7 @@ class Flow(Node):
631
632
  output_schema=_get_tool_response_body(output_schema_obj),
632
633
  output_schema_object = output_schema_obj,
633
634
  task=task,
635
+ document_structure=document_structure,
634
636
  plain_text_reading_order=plain_text_reading_order,
635
637
  enable_hw=enable_hw,
636
638
  kvp_schemas=kvp_schemas
@@ -338,13 +338,15 @@ class DocProcSpec(DocProcCommonNodeSpec):
338
338
  description="Optional list of key-value pair schemas to use for extraction.",
339
339
  default=None)
340
340
  plain_text_reading_order : PlainTextReadingOrder = Field(default=PlainTextReadingOrder.block_structure)
341
-
341
+ document_structure: bool = Field(default=False,description="Requests the entire document structure computed by WDU to be returned")
342
+
342
343
  def __init__(self, **data):
343
344
  super().__init__(**data)
344
345
  self.kind = "docproc"
345
346
 
346
347
  def to_json(self) -> dict[str, Any]:
347
348
  model_spec = super().to_json()
349
+ model_spec["document_structure"] = self.document_structure
348
350
  model_spec["task"] = self.task
349
351
  if self.plain_text_reading_order != PlainTextReadingOrder.block_structure:
350
352
  model_spec["plain_text_reading_order"] = self.plain_text_reading_order
@@ -1000,6 +1002,255 @@ class Assignment(BaseModel):
1000
1002
  default_value: Any | None = None
1001
1003
  metadata: dict = Field(default_factory=dict[str, Any])
1002
1004
 
1005
+ class Style(BaseModel):
1006
+ style_id: str = Field(default="", description="Style Identifier which will be used for reference in other objects")
1007
+ font_size: str = Field(default="", description="Font size")
1008
+ font_name: str = Field(default="", description="Font name")
1009
+ is_bold: str = Field(default="", description="Whether or not the the font is bold")
1010
+ is_italic: str = Field(default="", description="Whether or not the the font is italic")
1011
+
1012
+ class PageMetadata(BaseModel):
1013
+ page_number: Optional[int] = Field(default=None, description="Page number, starting from 1")
1014
+ page_image_width: Optional[int] = Field(default=None, description="Width of the page in pixels, assuming the page is an image with default 72 DPI")
1015
+ page_image_height: Optional[int] = Field(default=None, description="Height of the page in pixels, assuming the page is an image with default 72 DPI")
1016
+ dpi: Optional[int] = Field(default=None, description="The DPI to use for the page image, as specified in the input to the API")
1017
+ document_type: Optional[str] = Field(default="", description="Document type")
1018
+
1019
+ class Metadata(BaseModel):
1020
+ num_pages: int = Field(description="Total number of pages in the document")
1021
+ title: Optional[str] = Field(default=None, description="Document title as obtained from source document")
1022
+ language: Optional[str] = Field(default=None, description="Determined by the lang specifier in the <html> tag, or <meta> tag")
1023
+ url: Optional[str] = Field(default=None, description="URL of the document")
1024
+ keywords: Optional[str] = Field(default=None, description="Keywords associated with document")
1025
+ author: Optional[str] = Field(default=None, description="Author of the document")
1026
+ publication_date: Optional[str] = Field(default=None, description="Best effort bases for a publication date (may be the creation date)")
1027
+ subject: Optional[str] = Field(default=None, description="Subject as obtained from the source document")
1028
+ charset: str = Field(default="", description="Character set used for the output")
1029
+ output_tokens_flag: Optional[bool] = Field(default=None, description="Whether individual tokens are output, as specified in the input to the API")
1030
+ output_bounding_boxes_flag: Optional[bool] = Field(default=None, description="Whether bounding boxes are output, as requested in the input to the API")
1031
+ pages_metadata: Optional[List[PageMetadata]] = Field(default=[], description="List of page-level metadata objects")
1032
+
1033
+ class Section(BaseModel):
1034
+ id: str = Field(default="", description="Unique identifier for the section")
1035
+ parent_id: str = Field(default="", description="Unique identifier which denotes parent of this structure")
1036
+ children_ids: List[str] = Field(default="", description="Unique Ids of first level children structures under this structure in correct sequence")
1037
+ section_number: str = Field(default="", description="Section identifier identified in the document")
1038
+ section_level: str = Field(default="", description="Nesting level of section identified in the document")
1039
+ bbox_list: Optional[List[DocProcBoundingBox]] = Field(default=None, description="Cross-pages bounding boxes of that section")
1040
+
1041
+
1042
+ class SectionTitle(BaseModel):
1043
+ id: str = Field(default="", description="Unique identifier for the section")
1044
+ parent_id: str = Field(default="", description="Unique identifier which denotes parent of this structure")
1045
+ children_ids: Optional[List[str]] = Field(default=None, description="Unique Ids of first level children structures under this structure in correct sequence")
1046
+ text_alignment: Optional[str] = Field(default="", description="Text alignment of the section title")
1047
+ text: str = Field(default="", description="Text property added to all objects")
1048
+ bbox: Optional[DocProcBoundingBox] = Field(default=None, description="The bounding box of the section title")
1049
+
1050
+ class List_(BaseModel):
1051
+ id: str = Field(..., description="Unique identifier for the list")
1052
+ title: Optional[str] = Field(None, description="List title")
1053
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1054
+ children_ids: List[str] = Field(..., description="Unique Ids of first level children structures under this structure in correct sequence")
1055
+ bbox_list: Optional[List[DocProcBoundingBox]] = Field(None, description="Cross-pages bounding boxes of that table")
1056
+
1057
+
1058
+ class ListItem(BaseModel):
1059
+ id: str = Field(..., description="Unique identifier for the list item")
1060
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1061
+ children_ids: Optional[List[str]] = Field(None, description="Unique Ids of first level children structures under this structure in correct sequence")
1062
+ text: str = Field(..., description="Text property added to all objects")
1063
+ bbox: Optional[DocProcBoundingBox] = Field(None, description="The bounding box of the list item")
1064
+
1065
+
1066
+ class ListIdentifier(BaseModel):
1067
+ id: str = Field(..., description="Unique identifier for the list item")
1068
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1069
+ children_ids: List[str] = Field(..., description="Unique Ids of first level children structures under this structure in correct sequence")
1070
+
1071
+ class Table(BaseModel):
1072
+ id: str = Field(..., description="Unique identifier for the table")
1073
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1074
+ children_ids: List[str] = Field(..., description="Unique Ids of first level children structures under this structure in correct sequence, in this case, table rows")
1075
+ bbox_list: Optional[List[DocProcBoundingBox]] = Field(None, description="Cross-pages bounding boxes of that table")
1076
+
1077
+
1078
+ class TableRow(BaseModel):
1079
+ id: str = Field(..., description="Unique identifier for the table row")
1080
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1081
+ children_ids: List[str] = Field(..., description="Unique Ids of first level children structures under this structure in correct sequence, in this case, table cells")
1082
+ bbox: Optional[DocProcBoundingBox] = Field(None, description="The bounding box of the table row")
1083
+
1084
+
1085
+ class TableCell(BaseModel):
1086
+ id: str = Field(..., description="Unique identifier for the table cell")
1087
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1088
+ is_row_header: bool = Field(..., description="Whether the cell is part of row header or not")
1089
+ is_col_header: bool = Field(..., description="Whether the cell is part of column header or not")
1090
+ col_span: int = Field(..., description="Column span of the cell")
1091
+ row_span: int = Field(..., description="Row span of the cell")
1092
+ col_start: int = Field(..., description="Column start of the cell within the table")
1093
+ row_start: int = Field(..., description="Row start of the cell within the table")
1094
+ children_ids: Optional[List[str]] = Field(None, description="Children structures, e.g., paragraphs")
1095
+ text: str = Field(..., description="Text property added to all objects")
1096
+ bbox: Optional[DocProcBoundingBox] = Field(None, description="The bounding box of the table cell")
1097
+
1098
+ class Subscript(BaseModel):
1099
+ id: str = Field(..., description="Unique identifier for the subscript")
1100
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1101
+ children_ids: List[str] = Field(default_factory=list, description="Unique Ids of first level children structures under this structure in correct sequence")
1102
+ token_id_ref: Optional[str] = Field(None, description="Id of the token to which the subscript belongs")
1103
+ text: str = Field(..., description="Text property added to all objects")
1104
+
1105
+
1106
+ class Superscript(BaseModel):
1107
+ id: str = Field(..., description="Unique identifier for the superscript")
1108
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1109
+ footnote_ref: str = Field(..., description="Matching footnote id found on the page")
1110
+ token_id_ref: Optional[str] = Field(None, description="Id of the token to which the superscript belongs")
1111
+ children_ids: List[str] = Field(default_factory=list, description="Unique Ids of first level children structures under this structure in correct sequence")
1112
+ text: str = Field(..., description="Text property added to all objects")
1113
+
1114
+
1115
+ class Footnote(BaseModel):
1116
+ id: str = Field(..., description="Unique identifier for the footnote")
1117
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1118
+ children_ids: List[str] = Field(default_factory=list, description="Unique Ids of first level children structures under this structure in correct sequence")
1119
+ text: str = Field(..., description="Text property added to all objects")
1120
+
1121
+
1122
+ class Paragraph(BaseModel):
1123
+ id: str = Field(..., description="Unique identifier for the paragraph")
1124
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1125
+ children_ids: List[str] = Field(default_factory=list, description="Unique Ids of first level children structures under this structure in correct sequence, in this case, tokens")
1126
+ text_alignment: Optional[str] = Field(None, description="Text alignment of the paragraph")
1127
+ indentation: Optional[int] = Field(None, description="Paragraph indentation")
1128
+ text: str = Field(..., description="Text property added to all objects")
1129
+ bbox_list: Optional[DocProcBoundingBox] = Field(default=None, description="Cross-pages bounding boxes of that Paragraph")
1130
+
1131
+
1132
+ class CodeSnippet(BaseModel):
1133
+ id: str = Field(..., description="Unique identifier for the code snippet")
1134
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1135
+ children_ids: List[str] = Field(default_factory=list, description="Unique Ids of first level children structures under this structure in correct sequence, in this case, tokens")
1136
+ text: str = Field(..., description="Text of the code snippet. It can contain multiple lines, including empty lines or lines with leading spaces.")
1137
+
1138
+
1139
+ class Picture(BaseModel):
1140
+ id: str = Field(..., description="Unique identifier for the picture")
1141
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1142
+ children_ids: List[str] = Field(default_factory=list, description="Unique identifiers of the tokens extracted from this picture, if any")
1143
+ text: Optional[str] = Field(None, description="Text extracted from this picture")
1144
+ verbalization: Optional[str] = Field(None, description="Verbalization of this picture")
1145
+ path: Optional[str] = Field(None, description="Path in the output location where the picture itself was saved")
1146
+ picture_class: Optional[str] = Field(None, description="The classification result of the picture")
1147
+ bbox: Optional[DocProcBoundingBox] = Field(None, description="The bounding box of the picture in the context of the page, expressed as pixel coordinates with respect to pages_metadata.page_image_height and pages_metadata.page_image_width")
1148
+
1149
+
1150
+ class PageHeader(BaseModel):
1151
+ id: str = Field(..., description="Unique identifier for the page header")
1152
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1153
+ text: Optional[str] = Field(None, description="The page header text")
1154
+ bbox: Optional[DocProcBoundingBox] = Field(None, description="The bounding box of the page header")
1155
+ children_ids: List[str] = Field(default_factory=list, description="Unique Ids of first level children structures under this structure in correct sequence, in this case, tokens")
1156
+
1157
+
1158
+ class PageFooter(BaseModel):
1159
+ id: str = Field(..., description="Unique identifier for the page footer")
1160
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1161
+ text: Optional[str] = Field(None, description="The page footer text")
1162
+ bbox: Optional[DocProcBoundingBox] = Field(None, description="The bounding box of the page footer")
1163
+ children_ids: List[str] = Field(default_factory=list, description="Unique Ids of first level children structures under this structure in correct sequence, in this case, tokens")
1164
+
1165
+
1166
+ class BarCode(BaseModel):
1167
+ id: str = Field(..., description="Unique identifier for the bar code")
1168
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1169
+ text: Optional[str] = Field(None, description="The value of the bar code")
1170
+ format: Optional[str] = Field(None, description="The format of the bar code")
1171
+ path: Optional[str] = Field(None, description="Path in the output location where the var code picture is saved")
1172
+ bbox: Optional[DocProcBoundingBox] = Field(None, description="The bounding box of the bar code in the context of the page, expressed as pixel coordinates with respect to pages_metadata.page_image_height and pages_metadata.page_image_width")
1173
+
1174
+
1175
+ class QRCode(BaseModel):
1176
+ id: str = Field(..., description="Unique identifier for the QR code")
1177
+ parent_id: str = Field(..., description="Unique identifier which denotes parent of this structure")
1178
+ text: Optional[str] = Field(None, description="The value of the QR code")
1179
+ path: Optional[str] = Field(None, description="Path in the output location where the var code picture is saved")
1180
+ bbox: Optional[DocProcBoundingBox] = Field(None, description="The bounding box of the bar code in the context of the page, expressed as pixel coordinates with respect to pages_metadata.page_image_height and pages_metadata.page_image_width")
1181
+
1182
+
1183
+ class Token(BaseModel):
1184
+ id: str = Field(..., description="Unique identifier for the list identifier")
1185
+ parent_id: Optional[str] = Field(None, description="Unique identifier which denotes parent of this structure")
1186
+ style_id: Optional[str] = Field(None, description="Identifier of the style object associated with this token")
1187
+ text: str = Field(..., description="Actual text of the token")
1188
+ bbox: Optional[DocProcBoundingBox] = Field(None, description="The bounding box of the token in the context of the page, expressed as pixel coordinates with respect to pages_metadata.page_image_height and pages_metadata.page_image_width")
1189
+ confidence: Optional[float] = Field(None, description="Confidence score for the token")
1190
+
1191
+ class Structures(BaseModel):
1192
+ sections: Optional[List[Section]] = Field(
1193
+ default=None, description="All Section objects found in the document"
1194
+ )
1195
+ section_titles: Optional[List[SectionTitle]] = Field(
1196
+ default=None, description="All SectionTitle objects found in the document"
1197
+ )
1198
+ lists: Optional[List[List_]] = Field(
1199
+ default=None, description="All List objects found in the document"
1200
+ )
1201
+ list_items: Optional[List[ListItem]] = Field(
1202
+ default=None, description="All ListItem objects found in the document"
1203
+ )
1204
+ list_identifiers: Optional[List[ListIdentifier]] = Field(
1205
+ default=None, description="All ListIdentifier objects found in the document"
1206
+ )
1207
+ tables: Optional[List[Table]] = Field(
1208
+ default=None, description="All Table objects found in the document"
1209
+ )
1210
+ table_rows: Optional[List[TableRow]] = Field(
1211
+ default=None, description="All TableRow objects found in the document"
1212
+ )
1213
+ table_cells: Optional[List[TableCell]] = Field(
1214
+ default=None, description="All TableCell objects found in the document"
1215
+ )
1216
+ subscripts: Optional[List[Subscript]] = Field(
1217
+ default=None, description="All Subscript objects found in the document"
1218
+ )
1219
+ superscripts: Optional[List[Superscript]] = Field(
1220
+ default=None, description="All Superscript objects found in the document"
1221
+ )
1222
+ footnotes: Optional[List[Footnote]] = Field(
1223
+ default=None, description="All Footnote objects found in the document"
1224
+ )
1225
+ paragraphs: Optional[List[Paragraph]] = Field(
1226
+ default=None, description="All Paragraph objects found in the document"
1227
+ )
1228
+ code_snippets: Optional[List[CodeSnippet]] = Field(
1229
+ default=None, description="All CodeSnippet objects found in the document"
1230
+ )
1231
+ pictures: Optional[List[Picture]] = Field(
1232
+ default=None, description="All Picture objects found in the document"
1233
+ )
1234
+ page_headers: Optional[List[PageHeader]] = Field(
1235
+ default=None, description="All PageHeader objects found in the document"
1236
+ )
1237
+ page_footers: Optional[List[PageFooter]] = Field(
1238
+ default=None, description="All PageFooter objects found in the document"
1239
+ )
1240
+ bar_codes: Optional[List[BarCode]] = Field(
1241
+ default=None, description="All BarCode objects found in the document"
1242
+ )
1243
+ tokens: Optional[List[Token]] = Field(
1244
+ default=None, description="All Token objects found in the document"
1245
+ )
1246
+
1247
+ class AssemblyJsonOutput(BaseModel):
1248
+ metadata: Metadata = Field(description="Metadata about this document")
1249
+ styles: Optional[List[Style]] = Field(description="Font styles used in this document")
1250
+ kvps: Optional[DocProcKVP] = Field(description="Key value pairs found in the document")
1251
+ top_level_structures: List[str] = Field(default=[], description="Array of ids of the top level structures which belong directly under the document")
1252
+ all_structures: Structures = Field(default=None, description="An object containing of all flattened structures identified in the document")
1253
+
1003
1254
  class LanguageCode(StrEnum):
1004
1255
  '''
1005
1256
  The ISO-639 language codes understood by Document Processing functions.