ibm-watsonx-orchestrate 1.9.0.dev0__py3-none-any.whl → 1.10.0__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.
- ibm_watsonx_orchestrate/__init__.py +1 -2
- ibm_watsonx_orchestrate/agent_builder/agents/types.py +2 -0
- ibm_watsonx_orchestrate/agent_builder/connections/__init__.py +1 -1
- ibm_watsonx_orchestrate/agent_builder/connections/connections.py +1 -1
- ibm_watsonx_orchestrate/agent_builder/connections/types.py +16 -12
- ibm_watsonx_orchestrate/agent_builder/knowledge_bases/types.py +45 -2
- ibm_watsonx_orchestrate/agent_builder/toolkits/types.py +18 -15
- ibm_watsonx_orchestrate/agent_builder/tools/python_tool.py +1 -1
- ibm_watsonx_orchestrate/agent_builder/tools/types.py +1 -1
- ibm_watsonx_orchestrate/agent_builder/voice_configurations/__init__.py +1 -0
- ibm_watsonx_orchestrate/agent_builder/voice_configurations/types.py +98 -0
- ibm_watsonx_orchestrate/cli/commands/agents/agents_command.py +20 -0
- ibm_watsonx_orchestrate/cli/commands/agents/agents_controller.py +170 -1
- ibm_watsonx_orchestrate/cli/commands/connections/connections_command.py +7 -7
- ibm_watsonx_orchestrate/cli/commands/connections/connections_controller.py +36 -26
- ibm_watsonx_orchestrate/cli/commands/knowledge_bases/knowledge_bases_controller.py +51 -22
- ibm_watsonx_orchestrate/cli/commands/server/server_command.py +110 -16
- ibm_watsonx_orchestrate/cli/commands/toolkit/toolkit_command.py +43 -10
- ibm_watsonx_orchestrate/cli/commands/toolkit/toolkit_controller.py +52 -25
- ibm_watsonx_orchestrate/cli/commands/tools/tools_controller.py +5 -0
- ibm_watsonx_orchestrate/cli/commands/voice_configurations/voice_configurations_command.py +58 -0
- ibm_watsonx_orchestrate/cli/commands/voice_configurations/voice_configurations_controller.py +173 -0
- ibm_watsonx_orchestrate/cli/main.py +2 -0
- ibm_watsonx_orchestrate/client/agents/agent_client.py +64 -1
- ibm_watsonx_orchestrate/client/connections/connections_client.py +4 -3
- ibm_watsonx_orchestrate/client/knowledge_bases/knowledge_base_client.py +4 -4
- ibm_watsonx_orchestrate/client/voice_configurations/voice_configurations_client.py +75 -0
- ibm_watsonx_orchestrate/docker/compose-lite.yml +53 -5
- ibm_watsonx_orchestrate/docker/default.env +22 -14
- ibm_watsonx_orchestrate/flow_builder/flows/__init__.py +2 -0
- ibm_watsonx_orchestrate/flow_builder/flows/flow.py +115 -31
- ibm_watsonx_orchestrate/flow_builder/node.py +39 -15
- ibm_watsonx_orchestrate/flow_builder/types.py +114 -25
- ibm_watsonx_orchestrate/run/connections.py +2 -2
- {ibm_watsonx_orchestrate-1.9.0.dev0.dist-info → ibm_watsonx_orchestrate-1.10.0.dist-info}/METADATA +1 -1
- {ibm_watsonx_orchestrate-1.9.0.dev0.dist-info → ibm_watsonx_orchestrate-1.10.0.dist-info}/RECORD +39 -34
- {ibm_watsonx_orchestrate-1.9.0.dev0.dist-info → ibm_watsonx_orchestrate-1.10.0.dist-info}/WHEEL +0 -0
- {ibm_watsonx_orchestrate-1.9.0.dev0.dist-info → ibm_watsonx_orchestrate-1.10.0.dist-info}/entry_points.txt +0 -0
- {ibm_watsonx_orchestrate-1.9.0.dev0.dist-info → ibm_watsonx_orchestrate-1.10.0.dist-info}/licenses/LICENSE +0 -0
@@ -32,6 +32,7 @@ services:
|
|
32
32
|
- wxo-applied-migrations:/var/lib/postgresql/applied_migrations
|
33
33
|
command: -c shared_preload_libraries=pgsodium
|
34
34
|
|
35
|
+
|
35
36
|
wxo-server-connection-manager:
|
36
37
|
image: ${CM_REGISTRY:-us.icr.io/watson-orchestrate-private}/wxo-connections:${CM_TAG:-latest}
|
37
38
|
platform: linux/amd64
|
@@ -102,6 +103,7 @@ services:
|
|
102
103
|
DISMISS_NOTIFICATION_TIMEOUT: 10000
|
103
104
|
STANDALONE: "true"
|
104
105
|
STREAM_TIMEOUT: ${STREAM_TIMEOUT:-120000}
|
106
|
+
WXO_VOICE_URL: http://localhost:9876/v1
|
105
107
|
command: "./StartServer.sh"
|
106
108
|
ports:
|
107
109
|
- "3000:4002"
|
@@ -127,8 +129,11 @@ services:
|
|
127
129
|
IBM_DPS_CACHE_SERVICE: https://wxo-doc-processing-cache:8080
|
128
130
|
DOCPROC_BASE_URL: http://wxo-doc-processing-infra-standalone:9080
|
129
131
|
BUILDER_ASYNC_CALLBACK_ENDPOINT: http://wxo-builder:4025
|
132
|
+
DOCPROC_ENABLED: ${DOCPROC_ENABLED:-false}
|
130
133
|
IS_OBSERVABILITY_FEATURE_ENABLED: "true"
|
131
134
|
ALLOW_INSECURE_TLS: "true"
|
135
|
+
ENABLE_EDIT_PROMPTS: "true"
|
136
|
+
LANGFLOW_ENABLED: ${LANGFLOW_ENABLED:-false}
|
132
137
|
command: 'npm start'
|
133
138
|
ports:
|
134
139
|
- "4025:4025"
|
@@ -260,6 +265,7 @@ services:
|
|
260
265
|
- default
|
261
266
|
- jaeger-network
|
262
267
|
environment:
|
268
|
+
DEFAULT_AGENT_ENABLED: "true"
|
263
269
|
RUNTIME_MANAGER_API_KEY: ${RUNTIME_MANAGER_API_KEY:-testapikey}
|
264
270
|
PIP_NO_CACHE_DIR:
|
265
271
|
JWT_SECRET: ${JWT_SECRET}
|
@@ -342,6 +348,8 @@ services:
|
|
342
348
|
AGENTOPS_API_KEY_AUTH_ENABLED: ${AGENTOPS_API_KEY_AUTH_ENABLED:-false}
|
343
349
|
AGENTOPS_API_KEY: ${AGENTOPS_API_KEY}
|
344
350
|
ES_HOST: http://elasticsearch:9200
|
351
|
+
ORIGIN_HEADER: "internal"
|
352
|
+
LANGFLOW_ENABLED: ${LANGFLOW_ENABLED:-false}
|
345
353
|
|
346
354
|
wxo-server-worker:
|
347
355
|
image: ${WORKER_REGISTRY:-us.icr.io/watson-orchestrate-private}/wxo-server-conversation_controller:${WORKER_TAG:-latest}
|
@@ -439,6 +447,7 @@ services:
|
|
439
447
|
USE_IBM_TELEMETRY: ${USE_IBM_TELEMETRY:-false}
|
440
448
|
WXO_DEPLOYMENT_PLATFORM: saas
|
441
449
|
CALLBACK_HOST_URL: ${CALLBACK_HOST_URL:-http://wxo-server:4321}
|
450
|
+
LANGFLOW_ENABLED: ${LANGFLOW_ENABLED:-false}
|
442
451
|
|
443
452
|
tools-runtime-manager:
|
444
453
|
image: ${TRM_REGISTRY:-us.icr.io/watson-orchestrate-private}/tools-runtime-manager:${TRM_TAG:-latest}
|
@@ -480,7 +489,8 @@ services:
|
|
480
489
|
STORAGE_S3_REGION: us-east-1
|
481
490
|
AWS_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-minioadmin}
|
482
491
|
AWS_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-watsonxorchestrate}
|
483
|
-
TEMPUS_HOST_NAME: http://wxo-tempus-runtime:9044
|
492
|
+
TEMPUS_HOST_NAME: http://wxo-tempus-runtime:9044
|
493
|
+
LANGFLOW_ENABLED: ${LANGFLOW_ENABLED:-false}
|
484
494
|
extra_hosts:
|
485
495
|
- "host.docker.internal:host-gateway"
|
486
496
|
|
@@ -512,12 +522,13 @@ services:
|
|
512
522
|
STORAGE_S3_REGION: us-east-1
|
513
523
|
AWS_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-minioadmin}
|
514
524
|
AWS_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-watsonxorchestrate}
|
525
|
+
LANGFLOW_ENABLED: ${LANGFLOW_ENABLED:-false}
|
515
526
|
|
516
527
|
########################
|
517
528
|
# IBM AGENT-OPS
|
518
529
|
########################
|
519
530
|
elasticsearch:
|
520
|
-
image: docker.elastic.co/elasticsearch/elasticsearch:8.
|
531
|
+
image: docker.elastic.co/elasticsearch/elasticsearch:8.19.0
|
521
532
|
profiles: [ibm-telemetry]
|
522
533
|
environment:
|
523
534
|
- discovery.type=single-node
|
@@ -790,6 +801,7 @@ services:
|
|
790
801
|
LOG_LEVEL: info
|
791
802
|
DOCPROC_ENABLED: ${DOCPROC_ENABLED:-false}
|
792
803
|
DOCPROC_BASE_URL: http://wxo-doc-processing-infra-standalone:9080
|
804
|
+
DOCPROC_OUTPUT_FILE_SERVER_URL: ${DOCPROC_OUTPUT_FILE_SERVER_URL:-http://wxo-server:4321}
|
793
805
|
WO_API_KEY: ${WO_API_KEY}
|
794
806
|
WO_INSTANCE: ${WO_INSTANCE}
|
795
807
|
AUTHORIZATION_URL: ${AUTHORIZATION_URL}
|
@@ -870,6 +882,19 @@ services:
|
|
870
882
|
PREFLIGHT_MAX_SIZE: 10Mb
|
871
883
|
PREFLIGHT_MAX_PAGES: 600
|
872
884
|
RUNTIME_LIBRARY: "watson_doc_understanding"
|
885
|
+
WXAI_API_KEY: ${WXAI_API_KEY:-}
|
886
|
+
WXAI_IMAGE_DESCRIPTION_MODEL_ID: ${WXAI_IMAGE_DESCRIPTION_MODEL_ID:-mistralai/pixtral-12b}
|
887
|
+
WXAI_IMAGE_DESCRIPTION_PROJECT_ID: ${WXAI_IMAGE_DESCRIPTION_PROJECT_ID:-}
|
888
|
+
WXAI_KVP_MODEL_ID: ${WXAI_KVP_MODEL_ID:-}
|
889
|
+
WXAI_KVP_PROJECT_ID: ${WXAI_KVP_PROJECT_ID:-}
|
890
|
+
WXAI_SEMANTIC_KVP_PROJECT_ID: ${WXAI_SEMANTIC_KVP_PROJECT_ID:-}
|
891
|
+
WXAI_SEMANTIC_KVP_MODEL_ID: ${WXAI_SEMANTIC_KVP_MODEL_ID:-mistralai/pixtral-12b}
|
892
|
+
WXAI_SEMANTIC_KVP_SPACE_ID: ${WXAI_SEMANTIC_KVP_SPACE_ID:-}
|
893
|
+
WXAI_URL: ${WXAI_URL:-}
|
894
|
+
WXAI_USERNAME: ${WXAI_USERNAME:-}
|
895
|
+
WXAI_INSTANCE_ID: ${WXAI_INSTANCE_ID:-}
|
896
|
+
WXAI_VERSION: ${WXAI_VERSION:-5.1}
|
897
|
+
|
873
898
|
profiles:
|
874
899
|
- docproc
|
875
900
|
ports:
|
@@ -998,9 +1023,7 @@ services:
|
|
998
1023
|
SERVICE_NAME: wxo-doc-processing-llm-service
|
999
1024
|
LOG_LEVEL: info
|
1000
1025
|
WATSONX_API_ENDPOINT: ${WATSONX_URL:-https://us-south.ml.cloud.ibm.com}
|
1001
|
-
|
1002
|
-
WATSONX_PROJECT_ID: ${WATSONX_PROJECT_ID}
|
1003
|
-
WATSONX_SPACE_ID: ${WATSONX_SPACE_ID}
|
1026
|
+
WXO_SERVER_BASE_URL : http://wxo-server:4321
|
1004
1027
|
IBM_DPS_CACHE_SERVICE: 'wxo-doc-processing-cache:8080'
|
1005
1028
|
profiles:
|
1006
1029
|
- docproc
|
@@ -1093,6 +1116,30 @@ services:
|
|
1093
1116
|
exit 0;
|
1094
1117
|
"
|
1095
1118
|
|
1119
|
+
wxo-server-voice:
|
1120
|
+
image: ${VOICE_CONTROLLER_REGISTRY:-us.icr.io/watson-orchestrate-private}/wxo-server-voice:${VOICE_CONTROLLER_TAG:-latest}
|
1121
|
+
profiles: [voice]
|
1122
|
+
restart: unless-stopped
|
1123
|
+
ports:
|
1124
|
+
- 9876:8765
|
1125
|
+
environment:
|
1126
|
+
WXO_BASE_DOMAIN_URL: "http://wxo-server:4321"
|
1127
|
+
AI_GATEWAY_URL: "http://ai-gateway:8787"
|
1128
|
+
WXO_ORIGIN_HEADER: "internal"
|
1129
|
+
|
1130
|
+
langflow:
|
1131
|
+
image: ${OPENSOURCE_REGISTRY_PROXY:-docker.io}/langflowai/${LANGFLOW_IMAGE:-langflow}:${LANGFLOW_TAG:-latest}
|
1132
|
+
profiles: [langflow]
|
1133
|
+
ports:
|
1134
|
+
- 7861:7861
|
1135
|
+
environment:
|
1136
|
+
LANGFLOW_PORT: 7861
|
1137
|
+
LANGFLOW_DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@wxo-server-db:5432/langflow
|
1138
|
+
LANGFLOW_CONFIG_DIR: app/langflow
|
1139
|
+
volumes:
|
1140
|
+
- langflow-data:/app/langflow
|
1141
|
+
|
1142
|
+
|
1096
1143
|
volumes:
|
1097
1144
|
tools:
|
1098
1145
|
driver: local
|
@@ -1125,6 +1172,7 @@ volumes:
|
|
1125
1172
|
wdu-models:
|
1126
1173
|
driver: local
|
1127
1174
|
es_data:
|
1175
|
+
langflow-data:
|
1128
1176
|
|
1129
1177
|
networks:
|
1130
1178
|
default:
|
@@ -57,13 +57,14 @@ EVENT_BROKER_TTL="3600"
|
|
57
57
|
REGISTRY_URL=
|
58
58
|
|
59
59
|
|
60
|
-
|
60
|
+
|
61
|
+
SERVER_TAG=29-08-2025-59ef405
|
61
62
|
SERVER_REGISTRY=
|
62
63
|
|
63
|
-
WORKER_TAG=
|
64
|
+
WORKER_TAG=29-08-2025-cf32b2d
|
64
65
|
WORKER_REGISTRY=
|
65
66
|
|
66
|
-
AI_GATEWAY_TAG=
|
67
|
+
AI_GATEWAY_TAG=20-08-2025-9ed6d40
|
67
68
|
AI_GATEWAY_REGISTRY=
|
68
69
|
|
69
70
|
AGENT_GATEWAY_TAG=29-07-2025
|
@@ -77,21 +78,21 @@ AMDDBTAG=29-07-2025-9f3661b
|
|
77
78
|
ARM64DBTAG=29-07-2025-9f3661b
|
78
79
|
|
79
80
|
UI_REGISTRY=
|
80
|
-
UITAG=
|
81
|
+
UITAG=29-08-2025
|
81
82
|
|
82
83
|
CM_REGISTRY=
|
83
84
|
CM_TAG=24-07-2025
|
84
85
|
|
85
|
-
TRM_TAG=
|
86
|
+
TRM_TAG=19-08-2025-fe105eb0b950ff304f712a1a5b9fa3cba92d09da
|
86
87
|
TRM_REGISTRY=
|
87
88
|
|
88
|
-
TR_TAG=
|
89
|
+
TR_TAG=25-08-2025-58ae475
|
89
90
|
TR_REGISTRY=
|
90
91
|
|
91
|
-
BUILDER_TAG=
|
92
|
+
BUILDER_TAG=27-08-2025-7432aca
|
92
93
|
BUILDER_REGISTRY=
|
93
94
|
|
94
|
-
FLOW_RUNTIME_TAG=
|
95
|
+
FLOW_RUNTIME_TAG=18-08-2025-v3
|
95
96
|
FLOW_RUMTIME_REGISTRY=
|
96
97
|
|
97
98
|
|
@@ -104,17 +105,23 @@ JAEGER_PROXY_REGISTRY=
|
|
104
105
|
SOCKET_HANDLER_TAG=29-05-2025
|
105
106
|
SOCKET_HANDLER_REGISTRY=
|
106
107
|
|
107
|
-
CPE_TAG=
|
108
|
+
CPE_TAG=18-08-2025-ae1308e
|
108
109
|
CPE_REGISTRY=
|
109
110
|
|
111
|
+
VOICE_CONTROLLER_TAG=12-08-2025
|
112
|
+
VOICE_CONTROLLER_REGISTRY=
|
113
|
+
|
114
|
+
LANGFLOW_TAG=
|
115
|
+
LANGFLOW_IMAGE=
|
116
|
+
|
110
117
|
# IBM Document Processing
|
111
|
-
WDU_TAG=2.
|
118
|
+
WDU_TAG=2.6.1
|
112
119
|
WDU_REGISTRY=
|
113
120
|
|
114
|
-
DOCPROC_DPS_TAG=
|
115
|
-
DOCPROC_LLMSERVICE_TAG=
|
116
|
-
DOCPROC_CACHE_TAG=
|
117
|
-
DOCPROC_DPI_TAG=
|
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
|
118
125
|
DOCPROC_REGISTRY=
|
119
126
|
|
120
127
|
# END -- IMAGE REGISTRIES AND TAGS
|
@@ -149,6 +156,7 @@ TOOLS_RUNTIME_MANAGER_BASE_URL="http://tools-runtime-manager:8080"
|
|
149
156
|
CONNECTION_SERVICE_BASE_URL="http://wxo-server-connection-manager:3001"
|
150
157
|
AI_GATEWAY_BASE_URL="http://ai-gateway:8787/v1"
|
151
158
|
AI_GATEWAY_ENABLED=True
|
159
|
+
DEFAULT_AGENT_ENABLED=True
|
152
160
|
AGENT_GATEWAY_URI="http://wxo-agent-gateway:8989"
|
153
161
|
DEFAULT_TENANT_ID=10000000-0000-0000-0000-000000000000
|
154
162
|
ES_USERNAME=elastic
|
@@ -25,13 +25,13 @@ from ibm_watsonx_orchestrate.client.tools.tool_client import ToolClient
|
|
25
25
|
from ibm_watsonx_orchestrate.client.tools.tempus_client import TempusClient
|
26
26
|
from ibm_watsonx_orchestrate.client.utils import instantiate_client
|
27
27
|
from ..types import (
|
28
|
-
EndNodeSpec, Expression, ForeachPolicy, ForeachSpec, LoopSpec, BranchNodeSpec, MatchPolicy, PromptLLMParameters, PromptNodeSpec,
|
28
|
+
DocProcKVPSchema, EndNodeSpec, Expression, ForeachPolicy, ForeachSpec, LoopSpec, BranchNodeSpec, MatchPolicy, PlainTextReadingOrder, PromptLLMParameters, PromptNodeSpec, TimerNodeSpec,
|
29
29
|
StartNodeSpec, ToolSpec, JsonSchemaObject, ToolRequestBody, ToolResponseBody, UserFieldKind, UserFieldOption, UserFlowSpec, UserNodeSpec, WaitPolicy,
|
30
|
-
DocProcSpec, TextExtractionResponse, DocProcInput, DecisionsNodeSpec, DecisionsRule, DocExtSpec, File
|
30
|
+
DocProcSpec, TextExtractionResponse, DocProcInput, DecisionsNodeSpec, DecisionsRule, DocExtSpec, File, DocumentClassificationResponse, DocClassifierSpec, DocumentProcessingCommonInput
|
31
31
|
)
|
32
32
|
from .constants import CURRENT_USER, START, END, ANY_USER
|
33
33
|
from ..node import (
|
34
|
-
EndNode, Node, PromptNode, StartNode, UserNode, AgentNode, DataMap, ToolNode, DocProcNode, DecisionsNode, DocExtNode
|
34
|
+
EndNode, Node, PromptNode, StartNode, UserNode, AgentNode, DataMap, ToolNode, DocProcNode, DecisionsNode, DocExtNode, DocClassifierNode
|
35
35
|
)
|
36
36
|
from ..types import (
|
37
37
|
AgentNodeSpec, extract_node_spec, FlowContext, FlowEventType, FlowEvent, FlowSpec,
|
@@ -115,6 +115,10 @@ class Flow(Node):
|
|
115
115
|
# we need a deep compare if the incoming schema and existing_schema is the same
|
116
116
|
# pydantic suppport nested comparison by default
|
117
117
|
|
118
|
+
if isinstance(schema, dict):
|
119
|
+
# recast schema to support direct access
|
120
|
+
schema = JsonSchemaObject.model_validate(schema)
|
121
|
+
|
118
122
|
schema.title = title
|
119
123
|
|
120
124
|
if schema == existing_schema:
|
@@ -199,30 +203,31 @@ class Flow(Node):
|
|
199
203
|
self._refactor_spec_to_schemaref(node.spec)
|
200
204
|
|
201
205
|
def _refactor_spec_to_schemaref(self, spec: NodeSpec):
|
202
|
-
if spec.input_schema and (spec.input_schema.type == "object" or spec.input_schema.type == "array") :
|
206
|
+
if spec.input_schema and not isinstance(spec.input_schema, SchemaRef) and (spec.input_schema.type == "object" or spec.input_schema.type == "array") :
|
203
207
|
if isinstance(spec.input_schema, ToolRequestBody):
|
204
208
|
spec.input_schema = self._add_schema_ref(JsonSchemaObject(type = spec.input_schema.type,
|
205
209
|
properties= spec.input_schema.properties,
|
206
210
|
required= spec.input_schema.required),
|
207
211
|
f"{spec.name}_input")
|
208
|
-
if
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
if spec.output_schema
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
212
|
+
if not isinstance(spec.output_schema, SchemaRef):
|
213
|
+
if spec.output_schema_object is not None and spec.output_schema_object.type == "object":
|
214
|
+
spec.output_schema = self._add_schema_ref(spec.output_schema_object, spec.output_schema_object.title)
|
215
|
+
spec.output_schema_object = None
|
216
|
+
elif spec.output_schema is not None:
|
217
|
+
if isinstance(spec.output_schema, ToolResponseBody):
|
218
|
+
if spec.output_schema.type == "object":
|
219
|
+
json_obj = JsonSchemaObject(type = spec.output_schema.type,
|
220
|
+
description=spec.output_schema.description,
|
221
|
+
properties= spec.output_schema.properties,
|
222
|
+
items = spec.output_schema.items,
|
223
|
+
uniqueItems=spec.output_schema.uniqueItems,
|
224
|
+
anyOf=spec.output_schema.anyOf,
|
225
|
+
required= spec.output_schema.required)
|
226
|
+
spec.output_schema = self._add_schema_ref(json_obj, f"{spec.name}_output")
|
227
|
+
elif spec.output_schema.type == "array":
|
228
|
+
if hasattr(spec.output_schema, "items") and hasattr(spec.output_schema.items, "type") and spec.output_schema.items.type == "object":
|
229
|
+
schema_ref = self._add_schema_ref(spec.output_schema.items)
|
230
|
+
spec.output_schema.items = JsonSchemaObjectRef(ref=f"{schema_ref.ref}")
|
226
231
|
|
227
232
|
# def refactor_datamap_spec_to_schemaref(self, spec: FnDataMapSpec):
|
228
233
|
# '''TODO'''
|
@@ -433,23 +438,95 @@ class Flow(Node):
|
|
433
438
|
node = self._add_node(node)
|
434
439
|
return cast(PromptNode, node)
|
435
440
|
|
441
|
+
def docclassfier(self,
|
442
|
+
name: str,
|
443
|
+
llm : str = "watsonx/meta-llama/llama-3-2-90b-vision-instruct",
|
444
|
+
version: str = "TIP",
|
445
|
+
display_name: str| None = None,
|
446
|
+
classes: type[BaseModel]| None = None,
|
447
|
+
description: str | None = None,
|
448
|
+
min_confidence: float = 0.0,
|
449
|
+
input_map: DataMap = None) -> DocClassifierNode:
|
450
|
+
|
451
|
+
if name is None :
|
452
|
+
raise ValueError("name must be provided.")
|
453
|
+
|
454
|
+
doc_classifier_config = DocClassifierNode.generate_config(llm=llm, min_confidence=min_confidence,input_classes=classes)
|
455
|
+
|
456
|
+
input_schema_obj = _get_json_schema_obj(parameter_name = "input", type_def = DocumentProcessingCommonInput)
|
457
|
+
output_schema_obj = _get_json_schema_obj(parameter_name = "output", type_def = DocumentClassificationResponse)
|
458
|
+
|
459
|
+
if "$defs" in output_schema_obj.model_extra:
|
460
|
+
output_schema_obj.model_extra.pop("$defs")
|
461
|
+
# Create the docclassifier spec
|
462
|
+
task_spec = DocClassifierSpec(
|
463
|
+
name=name,
|
464
|
+
display_name=display_name if display_name is not None else name,
|
465
|
+
description=description,
|
466
|
+
input_schema=_get_tool_request_body(input_schema_obj),
|
467
|
+
output_schema=_get_tool_response_body(output_schema_obj),
|
468
|
+
output_schema_object = output_schema_obj,
|
469
|
+
config=doc_classifier_config,
|
470
|
+
version=version
|
471
|
+
)
|
472
|
+
node = DocClassifierNode(spec=task_spec)
|
473
|
+
|
474
|
+
# setup input map
|
475
|
+
if input_map:
|
476
|
+
node.input_map = self._get_data_map(input_map)
|
477
|
+
|
478
|
+
# add the node to the list of node
|
479
|
+
|
480
|
+
node = self._add_node(node)
|
481
|
+
return cast(DocClassifierNode, node)
|
482
|
+
|
483
|
+
|
484
|
+
def timer(self,
|
485
|
+
name: str,
|
486
|
+
delay: int,
|
487
|
+
display_name: str | None = None,
|
488
|
+
description: str | None = None,
|
489
|
+
input_map: DataMap = None) -> Node:
|
490
|
+
|
491
|
+
if name is None:
|
492
|
+
raise ValueError("name must be provided.")
|
493
|
+
if delay < 0:
|
494
|
+
raise ValueError("delay must be non-negative.")
|
495
|
+
|
496
|
+
timer_spec = TimerNodeSpec(
|
497
|
+
name=name,
|
498
|
+
display_name=display_name if display_name is not None else name,
|
499
|
+
description=description,
|
500
|
+
delay=delay
|
501
|
+
)
|
502
|
+
|
503
|
+
node = Node(spec=timer_spec)
|
504
|
+
|
505
|
+
if input_map:
|
506
|
+
node.input_map = self._get_data_map(input_map)
|
507
|
+
|
508
|
+
node = self._add_node(node)
|
509
|
+
return node
|
510
|
+
|
511
|
+
|
436
512
|
def docext(self,
|
437
513
|
name: str,
|
438
|
-
llm : str = "meta-llama/llama-3-2-
|
514
|
+
llm : str = "watsonx/meta-llama/llama-3-2-90b-vision-instruct",
|
439
515
|
version: str = "TIP",
|
440
516
|
display_name: str| None = None,
|
441
|
-
|
517
|
+
fields: type[BaseModel]| None = None,
|
442
518
|
description: str | None = None,
|
443
|
-
input_map: DataMap = None
|
519
|
+
input_map: DataMap = None,
|
520
|
+
enable_hw: bool = False) -> tuple[DocExtNode, type[BaseModel]]:
|
444
521
|
|
445
522
|
if name is None :
|
446
523
|
raise ValueError("name must be provided.")
|
447
524
|
|
448
|
-
doc_ext_config = DocExtNode.generate_config(llm=llm,
|
525
|
+
doc_ext_config = DocExtNode.generate_config(llm=llm, fields=fields)
|
449
526
|
|
450
|
-
DocExtFieldValue = DocExtNode.generate_docext_field_value_model(
|
527
|
+
DocExtFieldValue = DocExtNode.generate_docext_field_value_model(fields=fields)
|
451
528
|
|
452
|
-
input_schema_obj = _get_json_schema_obj(parameter_name = "input", type_def =
|
529
|
+
input_schema_obj = _get_json_schema_obj(parameter_name = "input", type_def = DocumentProcessingCommonInput)
|
453
530
|
output_schema_obj = _get_json_schema_obj("output", DocExtFieldValue)
|
454
531
|
|
455
532
|
if "$defs" in output_schema_obj.model_extra:
|
@@ -464,7 +541,8 @@ class Flow(Node):
|
|
464
541
|
output_schema=_get_tool_response_body(output_schema_obj),
|
465
542
|
output_schema_object = output_schema_obj,
|
466
543
|
config=doc_ext_config,
|
467
|
-
version=version
|
544
|
+
version=version,
|
545
|
+
enable_hw=enable_hw
|
468
546
|
)
|
469
547
|
node = DocExtNode(spec=task_spec)
|
470
548
|
|
@@ -523,9 +601,12 @@ class Flow(Node):
|
|
523
601
|
def docproc(self,
|
524
602
|
name: str,
|
525
603
|
task: str,
|
604
|
+
plain_text_reading_order : PlainTextReadingOrder = PlainTextReadingOrder.block_structure,
|
526
605
|
display_name: str|None=None,
|
527
606
|
description: str | None = None,
|
528
|
-
input_map: DataMap = None
|
607
|
+
input_map: DataMap = None,
|
608
|
+
kvp_schemas: list[DocProcKVPSchema] = None,
|
609
|
+
enable_hw: bool = False) -> DocProcNode:
|
529
610
|
|
530
611
|
if name is None :
|
531
612
|
raise ValueError("name must be provided.")
|
@@ -547,7 +628,10 @@ class Flow(Node):
|
|
547
628
|
input_schema=_get_tool_request_body(input_schema_obj),
|
548
629
|
output_schema=_get_tool_response_body(output_schema_obj),
|
549
630
|
output_schema_object = output_schema_obj,
|
550
|
-
task=task
|
631
|
+
task=task,
|
632
|
+
plain_text_reading_order=plain_text_reading_order,
|
633
|
+
enable_hw=enable_hw,
|
634
|
+
kvp_schemas=kvp_schemas
|
551
635
|
)
|
552
636
|
|
553
637
|
node = DocProcNode(spec=task_spec)
|
@@ -6,8 +6,8 @@ import yaml
|
|
6
6
|
from pydantic import BaseModel, Field, SerializeAsAny, create_model
|
7
7
|
from enum import Enum
|
8
8
|
|
9
|
-
from .types import EndNodeSpec, NodeSpec, AgentNodeSpec, PromptNodeSpec, StartNodeSpec, ToolNodeSpec, UserFieldKind, UserFieldOption, UserNodeSpec, DocProcSpec, \
|
10
|
-
DocExtSpec, DocExtConfig,
|
9
|
+
from .types import DocExtConfigField, EndNodeSpec, NodeSpec, AgentNodeSpec, PromptNodeSpec, TimerNodeSpec, StartNodeSpec, ToolNodeSpec, UserFieldKind, UserFieldOption, UserNodeSpec, DocProcSpec, \
|
10
|
+
DocExtSpec, DocExtConfig, DocClassifierSpec, DecisionsNodeSpec, DocClassifierConfig
|
11
11
|
|
12
12
|
from .data_map import DataMap
|
13
13
|
|
@@ -120,6 +120,24 @@ class DocProcNode(Node):
|
|
120
120
|
def get_spec(self) -> DocProcSpec:
|
121
121
|
return cast(DocProcSpec, self.spec)
|
122
122
|
|
123
|
+
class DocClassifierNode(Node):
|
124
|
+
def __repr__(self):
|
125
|
+
return f"DocClassifierNode(name='{self.spec.name}', description='{self.spec.description}')"
|
126
|
+
|
127
|
+
def get_spec(self) -> DocClassifierSpec:
|
128
|
+
return cast(DocClassifierSpec, self.spec)
|
129
|
+
|
130
|
+
@staticmethod
|
131
|
+
def generate_config(llm: str, input_classes: type[BaseModel], min_confidence: float) -> DocClassifierConfig:
|
132
|
+
return DocClassifierConfig(llm=llm, classes=input_classes.__dict__.values(), min_confidence=min_confidence)
|
133
|
+
|
134
|
+
class TimerNode(Node):
|
135
|
+
def __repr__(self):
|
136
|
+
return f"TimerNode(name='{self.spec.name}', description='{self.spec.description}')"
|
137
|
+
|
138
|
+
def get_spec(self) -> TimerNodeSpec:
|
139
|
+
return cast(TimerNodeSpec, self.spec)
|
140
|
+
|
123
141
|
class DocExtNode(Node):
|
124
142
|
def __repr__(self):
|
125
143
|
return f"DocExtNode(name='{self.spec.name}', description='{self.spec.description}')"
|
@@ -128,23 +146,29 @@ class DocExtNode(Node):
|
|
128
146
|
return cast(DocExtSpec, self.spec)
|
129
147
|
|
130
148
|
@staticmethod
|
131
|
-
def generate_config(llm: str,
|
132
|
-
|
133
|
-
return DocExtConfig(llm=llm, entities=entities)
|
149
|
+
def generate_config(llm: str, fields: type[BaseModel]) -> DocExtConfig:
|
150
|
+
return DocExtConfig(llm=llm, fields=fields.__dict__.values())
|
134
151
|
|
135
152
|
@staticmethod
|
136
|
-
def generate_docext_field_value_model(
|
153
|
+
def generate_docext_field_value_model(fields: type[BaseModel]) -> type[BaseModel]:
|
137
154
|
create_field_value_description = lambda field_name: "Extracted value for " + field_name
|
155
|
+
field_definitions = {}
|
156
|
+
|
157
|
+
for name, value in fields.model_dump().items():
|
158
|
+
field_type = str
|
159
|
+
field_kwargs = {
|
160
|
+
"title": value['name'],
|
161
|
+
"description": create_field_value_description(value['name']),
|
162
|
+
"type": value["type"] if value["type"] != "date" else "string"
|
163
|
+
}
|
164
|
+
|
165
|
+
# Add json_schema_extra if type is 'date'
|
166
|
+
if value["type"] == "date":
|
167
|
+
field_kwargs["json_schema_extra"] = {"format": "date"}
|
168
|
+
|
169
|
+
field_definitions[name] = (field_type, Field(**field_kwargs))
|
138
170
|
|
139
|
-
DocExtFieldValue = create_model(
|
140
|
-
"DocExtFieldValue",
|
141
|
-
**{
|
142
|
-
name: (str, Field(
|
143
|
-
title=value['name'],
|
144
|
-
description=create_field_value_description(value['name']),
|
145
|
-
)
|
146
|
-
)
|
147
|
-
for name, value in input_entities.model_dump().items()})
|
171
|
+
DocExtFieldValue = create_model("DocExtFieldValue", **field_definitions)
|
148
172
|
return DocExtFieldValue
|
149
173
|
|
150
174
|
class DecisionsNode(Node):
|