uipath 2.1.117__py3-none-any.whl → 2.1.119__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.
Potentially problematic release.
This version of uipath might be problematic. Click here for more details.
- uipath/_cli/_auth/_auth_service.py +1 -1
- uipath/_cli/_auth/_oidc_utils.py +101 -5
- uipath/_cli/_auth/_portal_service.py +1 -1
- uipath/_cli/_auth/_url_utils.py +10 -10
- uipath/_cli/_auth/auth_config_cloud.json +6 -0
- uipath/_resources/CLI_REFERENCE.md +5 -5
- uipath/_resources/SDK_REFERENCE.md +9 -3
- uipath/_services/documents_service.py +466 -59
- uipath/agent/models/agent.py +30 -4
- uipath/models/documents.py +64 -0
- {uipath-2.1.117.dist-info → uipath-2.1.119.dist-info}/METADATA +1 -1
- {uipath-2.1.117.dist-info → uipath-2.1.119.dist-info}/RECORD +16 -15
- /uipath/_cli/_auth/{auth_config.json → auth_config_25_10.json} +0 -0
- {uipath-2.1.117.dist-info → uipath-2.1.119.dist-info}/WHEEL +0 -0
- {uipath-2.1.117.dist-info → uipath-2.1.119.dist-info}/entry_points.txt +0 -0
- {uipath-2.1.117.dist-info → uipath-2.1.119.dist-info}/licenses/LICENSE +0 -0
|
@@ -121,7 +121,7 @@ class AuthService:
|
|
|
121
121
|
return False
|
|
122
122
|
|
|
123
123
|
def _perform_oauth_flow(self) -> TokenData:
|
|
124
|
-
auth_config = OidcUtils.get_auth_config()
|
|
124
|
+
auth_config = OidcUtils.get_auth_config(self._domain)
|
|
125
125
|
auth_url, code_verifier, state = OidcUtils.get_auth_url(
|
|
126
126
|
self._domain, auth_config
|
|
127
127
|
)
|
uipath/_cli/_auth/_oidc_utils.py
CHANGED
|
@@ -2,8 +2,12 @@ import base64
|
|
|
2
2
|
import hashlib
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
|
-
from
|
|
5
|
+
from typing import Optional
|
|
6
|
+
from urllib.parse import urlencode, urlparse
|
|
6
7
|
|
|
8
|
+
import httpx
|
|
9
|
+
|
|
10
|
+
from ..._utils._ssl_context import get_httpx_client_kwargs
|
|
7
11
|
from .._utils._console import ConsoleLogger
|
|
8
12
|
from ._models import AuthConfig
|
|
9
13
|
from ._url_utils import build_service_url
|
|
@@ -25,6 +29,84 @@ def get_state_param() -> str:
|
|
|
25
29
|
return base64.urlsafe_b64encode(os.urandom(32)).decode("utf-8").rstrip("=")
|
|
26
30
|
|
|
27
31
|
|
|
32
|
+
def _get_version_from_api(domain: str) -> Optional[str]:
|
|
33
|
+
"""Fetch the version from the UiPath orchestrator API.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
domain: The UiPath domain (e.g., 'https://alpha.uipath.com')
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
The version string (e.g., '25.10.0-beta.415') or None if unable to fetch
|
|
40
|
+
"""
|
|
41
|
+
try:
|
|
42
|
+
version_url = build_service_url(domain, "/orchestrator_/api/status/version")
|
|
43
|
+
client_kwargs = get_httpx_client_kwargs()
|
|
44
|
+
# Override timeout for version check
|
|
45
|
+
client_kwargs["timeout"] = 5.0
|
|
46
|
+
|
|
47
|
+
with httpx.Client(**client_kwargs) as client:
|
|
48
|
+
response = client.get(version_url)
|
|
49
|
+
response.raise_for_status()
|
|
50
|
+
data = response.json()
|
|
51
|
+
return data.get("version")
|
|
52
|
+
except Exception:
|
|
53
|
+
# Silently fail and return None if we can't fetch the version
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _is_cloud_domain(domain: str) -> bool:
|
|
58
|
+
"""Check if the domain is a cloud domain (alpha, staging, or cloud.uipath.com).
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
domain: The domain string (e.g., 'https://alpha.uipath.com')
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
True if it's a cloud domain, False otherwise
|
|
65
|
+
"""
|
|
66
|
+
parsed = urlparse(domain)
|
|
67
|
+
netloc = parsed.netloc.lower()
|
|
68
|
+
return netloc in [
|
|
69
|
+
"alpha.uipath.com",
|
|
70
|
+
"staging.uipath.com",
|
|
71
|
+
"cloud.uipath.com",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _select_config_file(domain: str) -> str:
|
|
76
|
+
"""Select the appropriate auth config file based on domain and version.
|
|
77
|
+
|
|
78
|
+
Logic:
|
|
79
|
+
1. If domain is alpha/staging/cloud.uipath.com -> use auth_config_cloud.json
|
|
80
|
+
2. Otherwise, try to get version from API
|
|
81
|
+
3. If version starts with '25.10' -> use auth_config_25_10.json
|
|
82
|
+
4. If version can't be determined -> fallback to auth_config_cloud.json
|
|
83
|
+
5. Otherwise -> fallback to auth_config_cloud.json
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
domain: The UiPath domain
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
The filename of the config to use
|
|
90
|
+
"""
|
|
91
|
+
# Check if it's a known cloud domain
|
|
92
|
+
if _is_cloud_domain(domain):
|
|
93
|
+
return "auth_config_cloud.json"
|
|
94
|
+
|
|
95
|
+
# Try to get version from API
|
|
96
|
+
version = _get_version_from_api(domain)
|
|
97
|
+
|
|
98
|
+
# If we can't determine version, fallback to cloud config
|
|
99
|
+
if version is None:
|
|
100
|
+
return "auth_config_cloud.json"
|
|
101
|
+
|
|
102
|
+
# Check if version is 25.10.*
|
|
103
|
+
if version.startswith("25.10"):
|
|
104
|
+
return "auth_config_25_10.json"
|
|
105
|
+
|
|
106
|
+
# Default fallback to cloud config
|
|
107
|
+
return "auth_config_cloud.json"
|
|
108
|
+
|
|
109
|
+
|
|
28
110
|
class OidcUtils:
|
|
29
111
|
_console = ConsoleLogger()
|
|
30
112
|
|
|
@@ -43,10 +125,24 @@ class OidcUtils:
|
|
|
43
125
|
return next((p for p in candidates if is_free(p)), None)
|
|
44
126
|
|
|
45
127
|
@classmethod
|
|
46
|
-
def get_auth_config(cls) -> AuthConfig:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
128
|
+
def get_auth_config(cls, domain: Optional[str] = None) -> AuthConfig:
|
|
129
|
+
"""Get the appropriate auth configuration based on domain.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
domain: The UiPath domain (e.g., 'https://cloud.uipath.com').
|
|
133
|
+
If None, uses default auth_config_cloud.json
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
AuthConfig with the appropriate configuration
|
|
137
|
+
"""
|
|
138
|
+
# Select the appropriate config file based on domain
|
|
139
|
+
if domain:
|
|
140
|
+
config_file = _select_config_file(domain)
|
|
141
|
+
else:
|
|
142
|
+
config_file = "auth_config_cloud.json"
|
|
143
|
+
|
|
144
|
+
config_path = os.path.join(os.path.dirname(__file__), config_file)
|
|
145
|
+
with open(config_path, "r") as f:
|
|
50
146
|
auth_config = json.load(f)
|
|
51
147
|
|
|
52
148
|
custom_port = os.getenv("UIPATH_AUTH_PORT")
|
|
@@ -94,7 +94,7 @@ class PortalService:
|
|
|
94
94
|
|
|
95
95
|
def refresh_access_token(self, refresh_token: str) -> TokenData: # type: ignore
|
|
96
96
|
url = build_service_url(self.domain, "/identity_/connect/token")
|
|
97
|
-
client_id = OidcUtils.get_auth_config().get("client_id")
|
|
97
|
+
client_id = OidcUtils.get_auth_config(self.domain).get("client_id")
|
|
98
98
|
|
|
99
99
|
data = {
|
|
100
100
|
"grant_type": "refresh_token",
|
uipath/_cli/_auth/_url_utils.py
CHANGED
|
@@ -15,13 +15,20 @@ def resolve_domain(
|
|
|
15
15
|
Args:
|
|
16
16
|
base_url: The base URL explicitly provided.
|
|
17
17
|
environment: The environment name (e.g., 'alpha', 'staging', 'cloud').
|
|
18
|
-
force: Whether to ignore UIPATH_URL from environment variables.
|
|
18
|
+
force: Whether to ignore UIPATH_URL from environment variables when base_url is set.
|
|
19
19
|
|
|
20
20
|
Returns:
|
|
21
21
|
A valid base URL for UiPath services.
|
|
22
22
|
"""
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
# If base_url is a real URL, prefer it
|
|
24
|
+
if base_url and base_url.startswith("http"):
|
|
25
|
+
parsed = urlparse(base_url)
|
|
26
|
+
domain = f"{parsed.scheme}://{parsed.netloc}"
|
|
27
|
+
if domain:
|
|
28
|
+
return domain
|
|
29
|
+
|
|
30
|
+
# If base_url is not set (or force is False), check UIPATH_URL
|
|
31
|
+
if not base_url or not force:
|
|
25
32
|
uipath_url = os.getenv("UIPATH_URL")
|
|
26
33
|
if uipath_url and environment == "cloud":
|
|
27
34
|
parsed = urlparse(uipath_url)
|
|
@@ -34,13 +41,6 @@ def resolve_domain(
|
|
|
34
41
|
"Please ensure it includes scheme and netloc (e.g., 'https://cloud.uipath.com')."
|
|
35
42
|
)
|
|
36
43
|
|
|
37
|
-
# If base_url is a real URL, prefer it
|
|
38
|
-
if base_url and base_url.startswith("http"):
|
|
39
|
-
parsed = urlparse(base_url)
|
|
40
|
-
domain = f"{parsed.scheme}://{parsed.netloc}"
|
|
41
|
-
if domain:
|
|
42
|
-
return domain
|
|
43
|
-
|
|
44
44
|
# Otherwise, fall back to environment
|
|
45
45
|
return f"https://{environment or 'cloud'}.uipath.com"
|
|
46
46
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"client_id": "36dea5b8-e8bb-423d-8e7b-c808df8f1c00",
|
|
3
|
+
"redirect_uri": "http://localhost:__PY_REPLACE_PORT__/oidc/login",
|
|
4
|
+
"scope": "offline_access ProcessMining OrchestratorApiUserAccess StudioWebBackend IdentityServerApi ConnectionService DataService DocumentUnderstanding Du.Digitization.Api Du.Classification.Api Du.Extraction.Api Du.Validation.Api EnterpriseContextService Directory JamJamApi LLMGateway LLMOps OMS RCS.FolderAuthorization TM.Projects TM.TestCases TM.Requirements TM.TestSets",
|
|
5
|
+
"port": 8104
|
|
6
|
+
}
|
|
@@ -62,10 +62,10 @@ uv run uipath init --infer-bindings
|
|
|
62
62
|
| Option | Type | Default | Description |
|
|
63
63
|
|--------|------|---------|-------------|
|
|
64
64
|
| `--resume` | flag | false | Resume execution from a previous state |
|
|
65
|
-
| `-f`, `--file` | value |
|
|
66
|
-
| `--input-file` | value |
|
|
67
|
-
| `--output-file` | value |
|
|
68
|
-
| `--trace-file` | value |
|
|
65
|
+
| `-f`, `--file` | value | `Sentinel.UNSET` | File path for the .json input |
|
|
66
|
+
| `--input-file` | value | `Sentinel.UNSET` | Alias for '-f/--file' arguments |
|
|
67
|
+
| `--output-file` | value | `Sentinel.UNSET` | File path where the output will be written |
|
|
68
|
+
| `--trace-file` | value | `Sentinel.UNSET` | File path where the trace spans will be written (JSON Lines format) |
|
|
69
69
|
| `--debug` | flag | false | Enable debugging with debugpy. The process will wait for a debugger to attach. |
|
|
70
70
|
| `--debug-port` | value | `5678` | Port for the debug server (default: 5678) |
|
|
71
71
|
|
|
@@ -117,7 +117,7 @@ uv run uipath run --resume
|
|
|
117
117
|
|--------|------|---------|-------------|
|
|
118
118
|
| `--no-report` | flag | false | Do not report the evaluation results |
|
|
119
119
|
| `--workers` | value | `1` | Number of parallel workers for running evaluations (default: 1) |
|
|
120
|
-
| `--output-file` | value |
|
|
120
|
+
| `--output-file` | value | `Sentinel.UNSET` | File path where the output will be written |
|
|
121
121
|
|
|
122
122
|
**Usage Examples:**
|
|
123
123
|
|
|
@@ -124,17 +124,23 @@ sdk.context_grounding.search_async(name: str, query: str, number_of_results: int
|
|
|
124
124
|
Documents service
|
|
125
125
|
|
|
126
126
|
```python
|
|
127
|
+
# Classify a document using a DU Modern project.
|
|
128
|
+
sdk.documents.classify(tag: str, project_name: str, file: Union[IO[bytes], bytes, str, NoneType]=None, file_path: Optional[str]=None) -> typing.List[uipath.models.documents.ClassificationResult]
|
|
129
|
+
|
|
130
|
+
# Asynchronously version of the [`classify`][uipath._services.documents_service.DocumentsService.classify] method.
|
|
131
|
+
sdk.documents.classify_async(tag: str, project_name: str, file: Union[IO[bytes], bytes, str, NoneType]=None, file_path: Optional[str]=None) -> typing.List[uipath.models.documents.ClassificationResult]
|
|
132
|
+
|
|
127
133
|
# Create a validation action for a document based on the extraction response. More details about validation actions can be found in the [official documentation](https://docs.uipath.com/ixp/automation-cloud/latest/user-guide/validating-extractions).
|
|
128
134
|
sdk.documents.create_validation_action(action_title: str, action_priority: <enum 'ActionPriority, action_catalog: str, action_folder: str, storage_bucket_name: str, storage_bucket_directory_path: str, extraction_response: uipath.models.documents.ExtractionResponse) -> uipath.models.documents.ValidationAction
|
|
129
135
|
|
|
130
136
|
# Asynchronous version of the [`create_validation_action`][uipath._services.documents_service.DocumentsService.create_validation_action] method.
|
|
131
137
|
sdk.documents.create_validation_action_async(action_title: str, action_priority: <enum 'ActionPriority, action_catalog: str, action_folder: str, storage_bucket_name: str, storage_bucket_directory_path: str, extraction_response: uipath.models.documents.ExtractionResponse) -> uipath.models.documents.ValidationAction
|
|
132
138
|
|
|
133
|
-
# Extract predicted data from a document using an IXP project.
|
|
134
|
-
sdk.documents.extract(
|
|
139
|
+
# Extract predicted data from a document using an DU Modern/IXP project.
|
|
140
|
+
sdk.documents.extract(tag: str, project_name: Optional[str]=None, file: Union[IO[bytes], bytes, str, NoneType]=None, file_path: Optional[str]=None, classification_result: Optional[uipath.models.documents.ClassificationResult]=None, project_type: Optional[uipath.models.documents.ProjectType]=None, document_type_name: Optional[str]=None) -> typing.Union[uipath.models.documents.ExtractionResponse, uipath.models.documents.ExtractionResponseIXP]
|
|
135
141
|
|
|
136
142
|
# Asynchronously version of the [`extract`][uipath._services.documents_service.DocumentsService.extract] method.
|
|
137
|
-
sdk.documents.extract_async(
|
|
143
|
+
sdk.documents.extract_async(tag: str, project_name: Optional[str]=None, file: Union[IO[bytes], bytes, str, NoneType]=None, file_path: Optional[str]=None, classification_result: Optional[uipath.models.documents.ClassificationResult]=None, project_type: Optional[uipath.models.documents.ProjectType]=None, document_type_name: Optional[str]=None) -> typing.Union[uipath.models.documents.ExtractionResponse, uipath.models.documents.ExtractionResponseIXP]
|
|
138
144
|
|
|
139
145
|
# Get the result of a validation action.
|
|
140
146
|
sdk.documents.get_validation_result(validation_action: uipath.models.documents.ValidationAction) -> uipath.models.documents.ValidatedResult
|
|
@@ -13,6 +13,8 @@ from .._folder_context import FolderContext
|
|
|
13
13
|
from .._utils import Endpoint
|
|
14
14
|
from ..models.documents import (
|
|
15
15
|
ActionPriority,
|
|
16
|
+
ClassificationResponse,
|
|
17
|
+
ClassificationResult,
|
|
16
18
|
ExtractionResponse,
|
|
17
19
|
ExtractionResponseIXP,
|
|
18
20
|
ProjectType,
|
|
@@ -26,6 +28,58 @@ POLLING_INTERVAL = 2 # seconds
|
|
|
26
28
|
POLLING_TIMEOUT = 300 # seconds
|
|
27
29
|
|
|
28
30
|
|
|
31
|
+
def _is_provided(arg: Any) -> bool:
|
|
32
|
+
return arg is not None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _must_not_be_provided(**kwargs: Any) -> None:
|
|
36
|
+
for name, value in kwargs.items():
|
|
37
|
+
if value is not None:
|
|
38
|
+
raise ValueError(f"`{name}` must not be provided")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _must_be_provided(**kwargs: Any) -> None:
|
|
42
|
+
for name, value in kwargs.items():
|
|
43
|
+
if value is None:
|
|
44
|
+
raise ValueError(f"`{name}` must be provided")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _exactly_one_must_be_provided(**kwargs: Any) -> None:
|
|
48
|
+
provided = [name for name, value in kwargs.items() if value is not None]
|
|
49
|
+
if len(provided) != 1:
|
|
50
|
+
raise ValueError(
|
|
51
|
+
f"Exactly one of `{', '.join(kwargs.keys())}` must be provided"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _validate_extract_params_and_get_project_type(
|
|
56
|
+
project_name: Optional[str],
|
|
57
|
+
file: Optional[FileContent],
|
|
58
|
+
file_path: Optional[str],
|
|
59
|
+
classification_result: Optional[ClassificationResult],
|
|
60
|
+
project_type: Optional[ProjectType],
|
|
61
|
+
document_type_name: Optional[str],
|
|
62
|
+
) -> ProjectType:
|
|
63
|
+
if _is_provided(project_name):
|
|
64
|
+
_must_be_provided(project_type=project_type)
|
|
65
|
+
_exactly_one_must_be_provided(file=file, file_path=file_path)
|
|
66
|
+
_must_not_be_provided(classification_result=classification_result)
|
|
67
|
+
if project_type == ProjectType.MODERN:
|
|
68
|
+
_must_be_provided(document_type_name=document_type_name)
|
|
69
|
+
else:
|
|
70
|
+
_must_not_be_provided(
|
|
71
|
+
project_name=project_name,
|
|
72
|
+
project_type=project_type,
|
|
73
|
+
file=file,
|
|
74
|
+
file_path=file_path,
|
|
75
|
+
document_type_name=document_type_name,
|
|
76
|
+
)
|
|
77
|
+
_must_be_provided(classification_result=classification_result)
|
|
78
|
+
project_type = ProjectType.MODERN
|
|
79
|
+
|
|
80
|
+
return project_type # type: ignore
|
|
81
|
+
|
|
82
|
+
|
|
29
83
|
class DocumentsService(FolderContext, BaseService):
|
|
30
84
|
"""Service for managing UiPath DocumentUnderstanding Document Operations.
|
|
31
85
|
|
|
@@ -100,10 +154,65 @@ class DocumentsService(FolderContext, BaseService):
|
|
|
100
154
|
)
|
|
101
155
|
return {tag["name"] for tag in response.json().get("tags", [])}
|
|
102
156
|
|
|
157
|
+
def _get_document_id(
|
|
158
|
+
self,
|
|
159
|
+
project_id: Optional[str],
|
|
160
|
+
file: Optional[FileContent],
|
|
161
|
+
file_path: Optional[str],
|
|
162
|
+
classification_result: Optional[ClassificationResult],
|
|
163
|
+
) -> str:
|
|
164
|
+
if classification_result is not None:
|
|
165
|
+
return classification_result.document_id
|
|
166
|
+
|
|
167
|
+
document_id = self._start_digitization(
|
|
168
|
+
project_id=project_id, # type: ignore
|
|
169
|
+
file=file,
|
|
170
|
+
file_path=file_path,
|
|
171
|
+
)
|
|
172
|
+
self._wait_for_digitization(
|
|
173
|
+
project_id=project_id, # type: ignore
|
|
174
|
+
document_id=document_id,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
return document_id
|
|
178
|
+
|
|
179
|
+
async def _get_document_id_async(
|
|
180
|
+
self,
|
|
181
|
+
project_id: Optional[str],
|
|
182
|
+
file: Optional[FileContent],
|
|
183
|
+
file_path: Optional[str],
|
|
184
|
+
classification_result: Optional[ClassificationResult],
|
|
185
|
+
) -> str:
|
|
186
|
+
if classification_result is not None:
|
|
187
|
+
return classification_result.document_id
|
|
188
|
+
|
|
189
|
+
document_id = await self._start_digitization_async(
|
|
190
|
+
project_id=project_id, # type: ignore
|
|
191
|
+
file=file,
|
|
192
|
+
file_path=file_path,
|
|
193
|
+
)
|
|
194
|
+
await self._wait_for_digitization_async(
|
|
195
|
+
project_id=project_id, # type: ignore
|
|
196
|
+
document_id=document_id,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
return document_id
|
|
200
|
+
|
|
103
201
|
def _get_project_id_and_validate_tag(
|
|
104
|
-
self,
|
|
202
|
+
self,
|
|
203
|
+
tag: str,
|
|
204
|
+
project_name: Optional[str],
|
|
205
|
+
project_type: Optional[ProjectType],
|
|
206
|
+
classification_result: Optional[ClassificationResult],
|
|
105
207
|
) -> str:
|
|
106
|
-
|
|
208
|
+
if project_name is not None:
|
|
209
|
+
project_id = self._get_project_id_by_name(
|
|
210
|
+
project_name,
|
|
211
|
+
project_type, # type: ignore
|
|
212
|
+
)
|
|
213
|
+
else:
|
|
214
|
+
project_id = classification_result.project_id # type: ignore
|
|
215
|
+
|
|
107
216
|
tags = self._get_project_tags(project_id)
|
|
108
217
|
if tag not in tags:
|
|
109
218
|
raise ValueError(
|
|
@@ -113,11 +222,20 @@ class DocumentsService(FolderContext, BaseService):
|
|
|
113
222
|
return project_id
|
|
114
223
|
|
|
115
224
|
async def _get_project_id_and_validate_tag_async(
|
|
116
|
-
self,
|
|
225
|
+
self,
|
|
226
|
+
tag: str,
|
|
227
|
+
project_name: Optional[str],
|
|
228
|
+
project_type: Optional[ProjectType],
|
|
229
|
+
classification_result: Optional[ClassificationResult],
|
|
117
230
|
) -> str:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
231
|
+
if project_name is not None:
|
|
232
|
+
project_id = await self._get_project_id_by_name_async(
|
|
233
|
+
project_name,
|
|
234
|
+
project_type, # type: ignore
|
|
235
|
+
)
|
|
236
|
+
else:
|
|
237
|
+
project_id = classification_result.project_id # type: ignore
|
|
238
|
+
|
|
121
239
|
tags = await self._get_project_tags_async(project_id)
|
|
122
240
|
if tag not in tags:
|
|
123
241
|
raise ValueError(
|
|
@@ -129,44 +247,100 @@ class DocumentsService(FolderContext, BaseService):
|
|
|
129
247
|
def _start_digitization(
|
|
130
248
|
self,
|
|
131
249
|
project_id: str,
|
|
132
|
-
file: FileContent,
|
|
250
|
+
file: Optional[FileContent] = None,
|
|
251
|
+
file_path: Optional[str] = None,
|
|
133
252
|
) -> str:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
253
|
+
with open(Path(file_path), "rb") if file_path else nullcontext(file) as handle:
|
|
254
|
+
return self.request(
|
|
255
|
+
"POST",
|
|
256
|
+
url=Endpoint(
|
|
257
|
+
f"/du_/api/framework/projects/{project_id}/digitization/start"
|
|
258
|
+
),
|
|
259
|
+
params={"api-version": 1.1},
|
|
260
|
+
headers=self._get_common_headers(),
|
|
261
|
+
files={"File": handle},
|
|
262
|
+
).json()["documentId"]
|
|
143
263
|
|
|
144
264
|
async def _start_digitization_async(
|
|
145
265
|
self,
|
|
146
266
|
project_id: str,
|
|
147
|
-
file: FileContent,
|
|
267
|
+
file: Optional[FileContent] = None,
|
|
268
|
+
file_path: Optional[str] = None,
|
|
148
269
|
) -> str:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
270
|
+
with open(Path(file_path), "rb") if file_path else nullcontext(file) as handle:
|
|
271
|
+
return (
|
|
272
|
+
await self.request_async(
|
|
273
|
+
"POST",
|
|
274
|
+
url=Endpoint(
|
|
275
|
+
f"/du_/api/framework/projects/{project_id}/digitization/start"
|
|
276
|
+
),
|
|
277
|
+
params={"api-version": 1.1},
|
|
278
|
+
headers=self._get_common_headers(),
|
|
279
|
+
files={"File": handle},
|
|
280
|
+
)
|
|
281
|
+
).json()["documentId"]
|
|
282
|
+
|
|
283
|
+
def _wait_for_digitization(self, project_id: str, document_id: str) -> None:
|
|
284
|
+
def result_getter() -> Tuple[str, Optional[str], Optional[str]]:
|
|
285
|
+
result = self.request(
|
|
286
|
+
method="GET",
|
|
152
287
|
url=Endpoint(
|
|
153
|
-
f"/du_/api/framework/projects/{project_id}/digitization/
|
|
288
|
+
f"/du_/api/framework/projects/{project_id}/digitization/result/{document_id}"
|
|
154
289
|
),
|
|
155
290
|
params={"api-version": 1.1},
|
|
156
291
|
headers=self._get_common_headers(),
|
|
157
|
-
|
|
292
|
+
).json()
|
|
293
|
+
return (
|
|
294
|
+
result["status"],
|
|
295
|
+
result.get("error", None),
|
|
296
|
+
result.get("result", None),
|
|
158
297
|
)
|
|
159
|
-
|
|
298
|
+
|
|
299
|
+
self._wait_for_operation(
|
|
300
|
+
result_getter=result_getter,
|
|
301
|
+
wait_statuses=["NotStarted", "Running"],
|
|
302
|
+
success_status="Succeeded",
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
async def _wait_for_digitization_async(
|
|
306
|
+
self, project_id: str, document_id: str
|
|
307
|
+
) -> None:
|
|
308
|
+
async def result_getter() -> Tuple[str, Optional[str], Optional[str]]:
|
|
309
|
+
result = (
|
|
310
|
+
await self.request_async(
|
|
311
|
+
method="GET",
|
|
312
|
+
url=Endpoint(
|
|
313
|
+
f"/du_/api/framework/projects/{project_id}/digitization/result/{document_id}"
|
|
314
|
+
),
|
|
315
|
+
params={"api-version": 1.1},
|
|
316
|
+
headers=self._get_common_headers(),
|
|
317
|
+
)
|
|
318
|
+
).json()
|
|
319
|
+
return (
|
|
320
|
+
result["status"],
|
|
321
|
+
result.get("error", None),
|
|
322
|
+
result.get("result", None),
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
await self._wait_for_operation_async(
|
|
326
|
+
result_getter=result_getter,
|
|
327
|
+
wait_statuses=["NotStarted", "Running"],
|
|
328
|
+
success_status="Succeeded",
|
|
329
|
+
)
|
|
160
330
|
|
|
161
331
|
def _get_document_type_id(
|
|
162
332
|
self,
|
|
163
333
|
project_id: str,
|
|
164
334
|
document_type_name: Optional[str],
|
|
165
335
|
project_type: ProjectType,
|
|
336
|
+
classification_result: Optional[ClassificationResult],
|
|
166
337
|
) -> str:
|
|
167
338
|
if project_type == ProjectType.IXP:
|
|
168
339
|
return str(UUID(int=0))
|
|
169
340
|
|
|
341
|
+
if classification_result is not None:
|
|
342
|
+
return classification_result.document_type_id
|
|
343
|
+
|
|
170
344
|
response = self.request(
|
|
171
345
|
"GET",
|
|
172
346
|
url=Endpoint(f"/du_/api/framework/projects/{project_id}/document-types"),
|
|
@@ -190,10 +364,14 @@ class DocumentsService(FolderContext, BaseService):
|
|
|
190
364
|
project_id: str,
|
|
191
365
|
document_type_name: Optional[str],
|
|
192
366
|
project_type: ProjectType,
|
|
367
|
+
classification_result: Optional[ClassificationResult],
|
|
193
368
|
) -> str:
|
|
194
369
|
if project_type == ProjectType.IXP:
|
|
195
370
|
return str(UUID(int=0))
|
|
196
371
|
|
|
372
|
+
if classification_result is not None:
|
|
373
|
+
return classification_result.document_type_id
|
|
374
|
+
|
|
197
375
|
response = await self.request_async(
|
|
198
376
|
"GET",
|
|
199
377
|
url=Endpoint(f"/du_/api/framework/projects/{project_id}/document-types"),
|
|
@@ -380,25 +558,225 @@ class DocumentsService(FolderContext, BaseService):
|
|
|
380
558
|
|
|
381
559
|
return ExtractionResponse.model_validate(extraction_response)
|
|
382
560
|
|
|
561
|
+
def _start_classification(
|
|
562
|
+
self,
|
|
563
|
+
project_id: str,
|
|
564
|
+
tag: str,
|
|
565
|
+
document_id: str,
|
|
566
|
+
) -> str:
|
|
567
|
+
return self.request(
|
|
568
|
+
"POST",
|
|
569
|
+
url=Endpoint(
|
|
570
|
+
f"/du_/api/framework/projects/{project_id}/{tag}/classification/start"
|
|
571
|
+
),
|
|
572
|
+
params={"api-version": 1.1},
|
|
573
|
+
headers=self._get_common_headers(),
|
|
574
|
+
json={"documentId": document_id},
|
|
575
|
+
).json()["operationId"]
|
|
576
|
+
|
|
577
|
+
async def _start_classification_async(
|
|
578
|
+
self,
|
|
579
|
+
project_id: str,
|
|
580
|
+
tag: str,
|
|
581
|
+
document_id: str,
|
|
582
|
+
) -> str:
|
|
583
|
+
return (
|
|
584
|
+
await self.request_async(
|
|
585
|
+
"POST",
|
|
586
|
+
url=Endpoint(
|
|
587
|
+
f"/du_/api/framework/projects/{project_id}/{tag}/classification/start"
|
|
588
|
+
),
|
|
589
|
+
params={"api-version": 1.1},
|
|
590
|
+
headers=self._get_common_headers(),
|
|
591
|
+
json={"documentId": document_id},
|
|
592
|
+
)
|
|
593
|
+
).json()["operationId"]
|
|
594
|
+
|
|
595
|
+
def _wait_for_classification(
|
|
596
|
+
self,
|
|
597
|
+
project_id: str,
|
|
598
|
+
tag: str,
|
|
599
|
+
operation_id: str,
|
|
600
|
+
) -> List[ClassificationResult]:
|
|
601
|
+
def result_getter() -> Tuple[str, Optional[str], Optional[str]]:
|
|
602
|
+
result = self.request(
|
|
603
|
+
method="GET",
|
|
604
|
+
url=Endpoint(
|
|
605
|
+
f"/du_/api/framework/projects/{project_id}/{tag}/classification/result/{operation_id}"
|
|
606
|
+
),
|
|
607
|
+
params={"api-version": 1.1},
|
|
608
|
+
headers=self._get_common_headers(),
|
|
609
|
+
).json()
|
|
610
|
+
return (
|
|
611
|
+
result["status"],
|
|
612
|
+
result.get("error", None),
|
|
613
|
+
result.get("result", None),
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
classification_response = self._wait_for_operation(
|
|
617
|
+
result_getter=result_getter,
|
|
618
|
+
wait_statuses=["NotStarted", "Running"],
|
|
619
|
+
success_status="Succeeded",
|
|
620
|
+
)
|
|
621
|
+
for classification_result in classification_response["classificationResults"]:
|
|
622
|
+
classification_result["ProjectId"] = project_id
|
|
623
|
+
|
|
624
|
+
return ClassificationResponse.model_validate(
|
|
625
|
+
classification_response
|
|
626
|
+
).classification_results
|
|
627
|
+
|
|
628
|
+
async def _wait_for_classification_async(
|
|
629
|
+
self,
|
|
630
|
+
project_id: str,
|
|
631
|
+
tag: str,
|
|
632
|
+
operation_id: str,
|
|
633
|
+
) -> List[ClassificationResult]:
|
|
634
|
+
async def result_getter() -> Tuple[str, Optional[str], Optional[str]]:
|
|
635
|
+
result = (
|
|
636
|
+
await self.request_async(
|
|
637
|
+
method="GET",
|
|
638
|
+
url=Endpoint(
|
|
639
|
+
f"/du_/api/framework/projects/{project_id}/{tag}/classification/result/{operation_id}"
|
|
640
|
+
),
|
|
641
|
+
params={"api-version": 1.1},
|
|
642
|
+
headers=self._get_common_headers(),
|
|
643
|
+
)
|
|
644
|
+
).json()
|
|
645
|
+
return (
|
|
646
|
+
result["status"],
|
|
647
|
+
result.get("error", None),
|
|
648
|
+
result.get("result", None),
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
classification_response = await self._wait_for_operation_async(
|
|
652
|
+
result_getter=result_getter,
|
|
653
|
+
wait_statuses=["NotStarted", "Running"],
|
|
654
|
+
success_status="Succeeded",
|
|
655
|
+
)
|
|
656
|
+
for classification_result in classification_response["classificationResults"]:
|
|
657
|
+
classification_result["ProjectId"] = project_id
|
|
658
|
+
|
|
659
|
+
return ClassificationResponse.model_validate(
|
|
660
|
+
classification_response
|
|
661
|
+
).classification_results
|
|
662
|
+
|
|
663
|
+
@traced(name="documents_classify", run_type="uipath")
|
|
664
|
+
def classify(
|
|
665
|
+
self,
|
|
666
|
+
tag: str,
|
|
667
|
+
project_name: str,
|
|
668
|
+
file: Optional[FileContent] = None,
|
|
669
|
+
file_path: Optional[str] = None,
|
|
670
|
+
) -> List[ClassificationResult]:
|
|
671
|
+
"""Classify a document using a DU Modern project.
|
|
672
|
+
|
|
673
|
+
Args:
|
|
674
|
+
project_name (str): Name of the [DU Modern](https://docs.uipath.com/document-understanding/automation-cloud/latest/user-guide/about-document-understanding) project.
|
|
675
|
+
tag (str): Tag of the published project version.
|
|
676
|
+
file (FileContent, optional): The document file to be classified.
|
|
677
|
+
file_path (str, optional): Path to the document file to be classified.
|
|
678
|
+
|
|
679
|
+
Note:
|
|
680
|
+
Either `file` or `file_path` must be provided, but not both.
|
|
681
|
+
|
|
682
|
+
Returns:
|
|
683
|
+
List[ClassificationResult]: A list of classification results.
|
|
684
|
+
|
|
685
|
+
Examples:
|
|
686
|
+
```python
|
|
687
|
+
with open("path/to/document.pdf", "rb") as file:
|
|
688
|
+
classification_results = service.classify(
|
|
689
|
+
project_name="MyModernProjectName",
|
|
690
|
+
tag="Production",
|
|
691
|
+
file=file,
|
|
692
|
+
)
|
|
693
|
+
```
|
|
694
|
+
"""
|
|
695
|
+
_exactly_one_must_be_provided(file=file, file_path=file_path)
|
|
696
|
+
|
|
697
|
+
project_id = self._get_project_id_and_validate_tag(
|
|
698
|
+
tag=tag,
|
|
699
|
+
project_name=project_name,
|
|
700
|
+
project_type=ProjectType.MODERN,
|
|
701
|
+
classification_result=None,
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
document_id = self._get_document_id(
|
|
705
|
+
project_id=project_id,
|
|
706
|
+
file=file,
|
|
707
|
+
file_path=file_path,
|
|
708
|
+
classification_result=None,
|
|
709
|
+
)
|
|
710
|
+
|
|
711
|
+
operation_id = self._start_classification(
|
|
712
|
+
project_id=project_id,
|
|
713
|
+
tag=tag,
|
|
714
|
+
document_id=document_id,
|
|
715
|
+
)
|
|
716
|
+
|
|
717
|
+
return self._wait_for_classification(
|
|
718
|
+
project_id=project_id,
|
|
719
|
+
tag=tag,
|
|
720
|
+
operation_id=operation_id,
|
|
721
|
+
)
|
|
722
|
+
|
|
723
|
+
@traced(name="documents_classify_async", run_type="uipath")
|
|
724
|
+
async def classify_async(
|
|
725
|
+
self,
|
|
726
|
+
tag: str,
|
|
727
|
+
project_name: str,
|
|
728
|
+
file: Optional[FileContent] = None,
|
|
729
|
+
file_path: Optional[str] = None,
|
|
730
|
+
) -> List[ClassificationResult]:
|
|
731
|
+
"""Asynchronously version of the [`classify`][uipath._services.documents_service.DocumentsService.classify] method."""
|
|
732
|
+
_exactly_one_must_be_provided(file=file, file_path=file_path)
|
|
733
|
+
|
|
734
|
+
project_id = await self._get_project_id_and_validate_tag_async(
|
|
735
|
+
tag=tag,
|
|
736
|
+
project_name=project_name,
|
|
737
|
+
project_type=ProjectType.MODERN,
|
|
738
|
+
classification_result=None,
|
|
739
|
+
)
|
|
740
|
+
|
|
741
|
+
document_id = await self._get_document_id_async(
|
|
742
|
+
project_id=project_id,
|
|
743
|
+
file=file,
|
|
744
|
+
file_path=file_path,
|
|
745
|
+
classification_result=None,
|
|
746
|
+
)
|
|
747
|
+
|
|
748
|
+
operation_id = await self._start_classification_async(
|
|
749
|
+
project_id=project_id,
|
|
750
|
+
tag=tag,
|
|
751
|
+
document_id=document_id,
|
|
752
|
+
)
|
|
753
|
+
|
|
754
|
+
return await self._wait_for_classification_async(
|
|
755
|
+
project_id=project_id,
|
|
756
|
+
tag=tag,
|
|
757
|
+
operation_id=operation_id,
|
|
758
|
+
)
|
|
759
|
+
|
|
383
760
|
@traced(name="documents_extract", run_type="uipath")
|
|
384
761
|
def extract(
|
|
385
762
|
self,
|
|
386
|
-
project_name: str,
|
|
387
763
|
tag: str,
|
|
764
|
+
project_name: Optional[str] = None,
|
|
388
765
|
file: Optional[FileContent] = None,
|
|
389
766
|
file_path: Optional[str] = None,
|
|
390
|
-
|
|
767
|
+
classification_result: Optional[ClassificationResult] = None,
|
|
768
|
+
project_type: Optional[ProjectType] = None,
|
|
391
769
|
document_type_name: Optional[str] = None,
|
|
392
770
|
) -> Union[ExtractionResponse, ExtractionResponseIXP]:
|
|
393
|
-
"""Extract predicted data from a document using an IXP project.
|
|
771
|
+
"""Extract predicted data from a document using an DU Modern/IXP project.
|
|
394
772
|
|
|
395
773
|
Args:
|
|
396
|
-
project_name (str): Name of the [IXP](https://docs.uipath.com/ixp/automation-cloud/latest/overview/managing-projects#creating-a-new-project)/[DU Modern](https://docs.uipath.com/document-understanding/automation-cloud/latest/user-guide/about-document-understanding) project.
|
|
774
|
+
project_name (str, optional): Name of the [IXP](https://docs.uipath.com/ixp/automation-cloud/latest/overview/managing-projects#creating-a-new-project)/[DU Modern](https://docs.uipath.com/document-understanding/automation-cloud/latest/user-guide/about-document-understanding) project. Must be provided if `classification_result` is not provided.
|
|
397
775
|
tag (str): Tag of the published project version.
|
|
398
|
-
file (FileContent, optional): The document file to be processed.
|
|
399
|
-
file_path (str, optional): Path to the document file to be processed.
|
|
400
|
-
project_type (ProjectType, optional): Type of the project.
|
|
401
|
-
document_type_name (str, optional): Document type name associated with the extractor to be used for extraction. Required if `project_type` is `ProjectType.MODERN
|
|
776
|
+
file (FileContent, optional): The document file to be processed. Must be provided if `classification_result` is not provided.
|
|
777
|
+
file_path (str, optional): Path to the document file to be processed. Must be provided if `classification_result` is not provided.
|
|
778
|
+
project_type (ProjectType, optional): Type of the project. Must be provided if `project_name` is provided.
|
|
779
|
+
document_type_name (str, optional): Document type name associated with the extractor to be used for extraction. Required if `project_type` is `ProjectType.MODERN` and `project_name` is provided.
|
|
402
780
|
|
|
403
781
|
Note:
|
|
404
782
|
Either `file` or `file_path` must be provided, but not both.
|
|
@@ -417,7 +795,7 @@ class DocumentsService(FolderContext, BaseService):
|
|
|
417
795
|
)
|
|
418
796
|
```
|
|
419
797
|
|
|
420
|
-
DU Modern projects:
|
|
798
|
+
DU Modern projects (providing document type name):
|
|
421
799
|
```python
|
|
422
800
|
with open("path/to/document.pdf", "rb") as file:
|
|
423
801
|
extraction_response = service.extract(
|
|
@@ -428,27 +806,50 @@ class DocumentsService(FolderContext, BaseService):
|
|
|
428
806
|
document_type_name="Receipts",
|
|
429
807
|
)
|
|
430
808
|
```
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
809
|
+
|
|
810
|
+
DU Modern projects (using existing classification result):
|
|
811
|
+
```python
|
|
812
|
+
with open("path/to/document.pdf", "rb") as file:
|
|
813
|
+
classification_results = uipath.documents.classify(
|
|
814
|
+
tag="Production",
|
|
815
|
+
project_name="MyModernProjectName",
|
|
816
|
+
file=file,
|
|
817
|
+
)
|
|
818
|
+
|
|
819
|
+
extraction_result = uipath.documents.extract(
|
|
820
|
+
tag="Production",
|
|
821
|
+
classification_result=max(classification_results, key=lambda result: result.confidence),
|
|
439
822
|
)
|
|
823
|
+
```
|
|
824
|
+
"""
|
|
825
|
+
project_type = _validate_extract_params_and_get_project_type(
|
|
826
|
+
project_name=project_name,
|
|
827
|
+
file=file,
|
|
828
|
+
file_path=file_path,
|
|
829
|
+
classification_result=classification_result,
|
|
830
|
+
project_type=project_type,
|
|
831
|
+
document_type_name=document_type_name,
|
|
832
|
+
)
|
|
440
833
|
|
|
441
834
|
project_id = self._get_project_id_and_validate_tag(
|
|
442
|
-
|
|
835
|
+
tag=tag,
|
|
836
|
+
project_name=project_name,
|
|
837
|
+
project_type=project_type,
|
|
838
|
+
classification_result=classification_result,
|
|
443
839
|
)
|
|
444
840
|
|
|
445
|
-
|
|
446
|
-
|
|
841
|
+
document_id = self._get_document_id(
|
|
842
|
+
project_id=project_id,
|
|
843
|
+
file=file,
|
|
844
|
+
file_path=file_path,
|
|
845
|
+
classification_result=classification_result,
|
|
846
|
+
)
|
|
447
847
|
|
|
448
848
|
document_type_id = self._get_document_type_id(
|
|
449
849
|
project_id=project_id,
|
|
450
850
|
document_type_name=document_type_name,
|
|
451
851
|
project_type=project_type,
|
|
852
|
+
classification_result=classification_result,
|
|
452
853
|
)
|
|
453
854
|
|
|
454
855
|
operation_id = self._start_extraction(
|
|
@@ -469,37 +870,43 @@ class DocumentsService(FolderContext, BaseService):
|
|
|
469
870
|
@traced(name="documents_extract_async", run_type="uipath")
|
|
470
871
|
async def extract_async(
|
|
471
872
|
self,
|
|
472
|
-
project_name: str,
|
|
473
873
|
tag: str,
|
|
874
|
+
project_name: Optional[str] = None,
|
|
474
875
|
file: Optional[FileContent] = None,
|
|
475
876
|
file_path: Optional[str] = None,
|
|
476
|
-
|
|
877
|
+
classification_result: Optional[ClassificationResult] = None,
|
|
878
|
+
project_type: Optional[ProjectType] = None,
|
|
477
879
|
document_type_name: Optional[str] = None,
|
|
478
880
|
) -> Union[ExtractionResponse, ExtractionResponseIXP]:
|
|
479
881
|
"""Asynchronously version of the [`extract`][uipath._services.documents_service.DocumentsService.extract] method."""
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
882
|
+
project_type = _validate_extract_params_and_get_project_type(
|
|
883
|
+
project_name=project_name,
|
|
884
|
+
file=file,
|
|
885
|
+
file_path=file_path,
|
|
886
|
+
classification_result=classification_result,
|
|
887
|
+
project_type=project_type,
|
|
888
|
+
document_type_name=document_type_name,
|
|
889
|
+
)
|
|
488
890
|
|
|
489
891
|
project_id = await self._get_project_id_and_validate_tag_async(
|
|
490
|
-
|
|
892
|
+
tag=tag,
|
|
893
|
+
project_name=project_name,
|
|
894
|
+
project_type=project_type,
|
|
895
|
+
classification_result=classification_result,
|
|
491
896
|
)
|
|
492
897
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
898
|
+
document_id = await self._get_document_id_async(
|
|
899
|
+
project_id=project_id,
|
|
900
|
+
file=file,
|
|
901
|
+
file_path=file_path,
|
|
902
|
+
classification_result=classification_result,
|
|
903
|
+
)
|
|
498
904
|
|
|
499
905
|
document_type_id = await self._get_document_type_id_async(
|
|
500
906
|
project_id=project_id,
|
|
501
907
|
document_type_name=document_type_name,
|
|
502
908
|
project_type=project_type,
|
|
909
|
+
classification_result=classification_result,
|
|
503
910
|
)
|
|
504
911
|
|
|
505
912
|
operation_id = await self._start_extraction_async(
|
uipath/agent/models/agent.py
CHANGED
|
@@ -278,13 +278,25 @@ class AgentContextOutputColumn(BaseModel):
|
|
|
278
278
|
)
|
|
279
279
|
|
|
280
280
|
|
|
281
|
+
class AgentContextRetrievalMode(str, Enum):
|
|
282
|
+
"""Enum for retrieval modes."""
|
|
283
|
+
|
|
284
|
+
SEMANTIC = "Semantic"
|
|
285
|
+
STRUCTURED = "Structured"
|
|
286
|
+
DEEP_RAG = "DeepRAG"
|
|
287
|
+
BATCH_TRANSFORM = "BatchTransform"
|
|
288
|
+
|
|
289
|
+
|
|
281
290
|
class AgentContextSettings(BaseModel):
|
|
282
291
|
"""Settings for context."""
|
|
283
292
|
|
|
284
293
|
result_count: int = Field(alias="resultCount")
|
|
285
|
-
retrieval_mode: Literal[
|
|
286
|
-
|
|
287
|
-
|
|
294
|
+
retrieval_mode: Literal[
|
|
295
|
+
AgentContextRetrievalMode.SEMANTIC,
|
|
296
|
+
AgentContextRetrievalMode.STRUCTURED,
|
|
297
|
+
AgentContextRetrievalMode.DEEP_RAG,
|
|
298
|
+
AgentContextRetrievalMode.BATCH_TRANSFORM,
|
|
299
|
+
] = Field(alias="retrievalMode")
|
|
288
300
|
threshold: float = Field(default=0)
|
|
289
301
|
query: Optional[AgentContextQuerySetting] = Field(None)
|
|
290
302
|
folder_path_prefix: Optional[Union[Dict[str, Any], AgentContextValueSetting]] = (
|
|
@@ -303,6 +315,20 @@ class AgentContextSettings(BaseModel):
|
|
|
303
315
|
None, alias="outputColumns"
|
|
304
316
|
)
|
|
305
317
|
|
|
318
|
+
@field_validator("retrieval_mode", mode="before")
|
|
319
|
+
@classmethod
|
|
320
|
+
def normalize_retrieval_mode(cls, v: Any) -> str:
|
|
321
|
+
"""Normalize context retrieval mode."""
|
|
322
|
+
if isinstance(v, str):
|
|
323
|
+
lowercase_mapping = {
|
|
324
|
+
"semantic": AgentContextRetrievalMode.SEMANTIC,
|
|
325
|
+
"structured": AgentContextRetrievalMode.STRUCTURED,
|
|
326
|
+
"deeprag": AgentContextRetrievalMode.DEEP_RAG,
|
|
327
|
+
"batchtransform": AgentContextRetrievalMode.BATCH_TRANSFORM,
|
|
328
|
+
}
|
|
329
|
+
return lowercase_mapping.get(v.lower(), v)
|
|
330
|
+
return v
|
|
331
|
+
|
|
306
332
|
model_config = ConfigDict(
|
|
307
333
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
308
334
|
)
|
|
@@ -553,7 +579,7 @@ class AgentGuardrailLogAction(BaseModel):
|
|
|
553
579
|
"""Log action model."""
|
|
554
580
|
|
|
555
581
|
action_type: Literal["log"] = Field(alias="$actionType")
|
|
556
|
-
message: str = Field(
|
|
582
|
+
message: Optional[str] = Field(None, alias="message")
|
|
557
583
|
severity_level: AgentGuardrailSeverityLevel = Field(alias="severityLevel")
|
|
558
584
|
|
|
559
585
|
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
uipath/models/documents.py
CHANGED
|
@@ -151,3 +151,67 @@ class ValidatedResult(BaseModel):
|
|
|
151
151
|
|
|
152
152
|
document_id: str = Field(alias="DocumentId")
|
|
153
153
|
results_document: dict = Field(alias="ResultsDocument") # type: ignore
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class Reference(BaseModel):
|
|
157
|
+
model_config = ConfigDict(
|
|
158
|
+
serialize_by_alias=True,
|
|
159
|
+
validate_by_alias=True,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
text_start_index: int = Field(alias="TextStartIndex")
|
|
163
|
+
text_length: int = Field(alias="TextLength")
|
|
164
|
+
tokens: List[str] = Field(alias="Tokens")
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class DocumentBounds(BaseModel):
|
|
168
|
+
model_config = ConfigDict(
|
|
169
|
+
serialize_by_alias=True,
|
|
170
|
+
validate_by_alias=True,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
start_page: int = Field(alias="StartPage")
|
|
174
|
+
page_count: int = Field(alias="PageCount")
|
|
175
|
+
text_start_index: int = Field(alias="TextStartIndex")
|
|
176
|
+
text_length: int = Field(alias="TextLength")
|
|
177
|
+
page_range: str = Field(alias="PageRange")
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class ClassificationResult(BaseModel):
|
|
181
|
+
"""A model representing the result of a document classification.
|
|
182
|
+
|
|
183
|
+
Attributes:
|
|
184
|
+
document_id (str): The ID of the classified document.
|
|
185
|
+
document_type_id (str): The ID of the predicted document type.
|
|
186
|
+
confidence (float): The confidence score of the classification.
|
|
187
|
+
ocr_confidence (float): The OCR confidence score of the document.
|
|
188
|
+
reference (Reference): The reference information for the classified document.
|
|
189
|
+
document_bounds (DocumentBounds): The bounds of the document in terms of pages and text.
|
|
190
|
+
classifier_name (str): The name of the classifier used.
|
|
191
|
+
project_id (str): The ID of the project associated with the classification.
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
model_config = ConfigDict(
|
|
195
|
+
serialize_by_alias=True,
|
|
196
|
+
validate_by_alias=True,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
document_id: str = Field(alias="DocumentId")
|
|
200
|
+
document_type_id: str = Field(alias="DocumentTypeId")
|
|
201
|
+
confidence: float = Field(alias="Confidence")
|
|
202
|
+
ocr_confidence: float = Field(alias="OcrConfidence")
|
|
203
|
+
reference: Reference = Field(alias="Reference")
|
|
204
|
+
document_bounds: DocumentBounds = Field(alias="DocumentBounds")
|
|
205
|
+
classifier_name: str = Field(alias="ClassifierName")
|
|
206
|
+
project_id: str = Field(alias="ProjectId")
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
class ClassificationResponse(BaseModel):
|
|
210
|
+
model_config = ConfigDict(
|
|
211
|
+
serialize_by_alias=True,
|
|
212
|
+
validate_by_alias=True,
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
classification_results: List[ClassificationResult] = Field(
|
|
216
|
+
alias="classificationResults"
|
|
217
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: uipath
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.119
|
|
4
4
|
Summary: Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools.
|
|
5
5
|
Project-URL: Homepage, https://uipath.com
|
|
6
6
|
Project-URL: Repository, https://github.com/UiPath/uipath-python
|
|
@@ -24,13 +24,14 @@ uipath/_cli/cli_run.py,sha256=9vbmSG_FzS0x8KNNzSrST37FKjUOzhXPjl8xTm2ZEqQ,4203
|
|
|
24
24
|
uipath/_cli/middlewares.py,sha256=tb0c4sU1SCYi0PNs956Qmk24NDk0C0mBfVQmTcyORE0,5000
|
|
25
25
|
uipath/_cli/spinner.py,sha256=bS-U_HA5yne11ejUERu7CQoXmWdabUD2bm62EfEdV8M,1107
|
|
26
26
|
uipath/_cli/_auth/_auth_server.py,sha256=v_b8KNwn0tAv8jxpeKdllOVzl31q9AcdwpE_koAK_w4,7235
|
|
27
|
-
uipath/_cli/_auth/_auth_service.py,sha256=
|
|
27
|
+
uipath/_cli/_auth/_auth_service.py,sha256=BoyMytg4tah1558bWzhS33hUacu17vh3Qr6nRBHD1RI,5417
|
|
28
28
|
uipath/_cli/_auth/_models.py,sha256=kWhqd5FqBo_oi3DW2x1IaJHsEloXq0I24f-pX5zb_O4,753
|
|
29
|
-
uipath/_cli/_auth/_oidc_utils.py,sha256=
|
|
30
|
-
uipath/_cli/_auth/_portal_service.py,sha256=
|
|
31
|
-
uipath/_cli/_auth/_url_utils.py,sha256
|
|
29
|
+
uipath/_cli/_auth/_oidc_utils.py,sha256=VEXnri7KinOdZMEPGYUf4mUZpCvSwmIL8TUBx6WhxDU,6446
|
|
30
|
+
uipath/_cli/_auth/_portal_service.py,sha256=fWnHGwd60Q_mrNEeENibqe5wv4ixp-yrG7X4XrXsXNk,8022
|
|
31
|
+
uipath/_cli/_auth/_url_utils.py,sha256=-OD7Gz7pYgJU8CahFZdeX0Na1IB2EIX3u964VmZ1K8Q,2898
|
|
32
32
|
uipath/_cli/_auth/_utils.py,sha256=To4Ara_UF4g7nzUfKqFA11lTjhQWIZWNm4xwa5nNKmU,896
|
|
33
|
-
uipath/_cli/_auth/
|
|
33
|
+
uipath/_cli/_auth/auth_config_25_10.json,sha256=o8J5BBFwiEtjZLHpJ_64lvnTeYeRIHaJ-Bhg0QvcUX8,521
|
|
34
|
+
uipath/_cli/_auth/auth_config_cloud.json,sha256=o8J5BBFwiEtjZLHpJ_64lvnTeYeRIHaJ-Bhg0QvcUX8,521
|
|
34
35
|
uipath/_cli/_auth/index.html,sha256=uGK0CDTP8Rys_p4O_Pbd2x4tz0frKNVcumjrXnal5Nc,22814
|
|
35
36
|
uipath/_cli/_auth/localhost.crt,sha256=oGl9oLLOiouHubAt39B4zEfylFvKEtbtr_43SIliXJc,1226
|
|
36
37
|
uipath/_cli/_auth/localhost.key,sha256=X31VYXD8scZtmGA837dGX5l6G-LXHLo5ItWJhZXaz3c,1679
|
|
@@ -106,9 +107,9 @@ uipath/_events/_event_bus.py,sha256=4-VzstyX69cr7wT1EY7ywp-Ndyz2CyemD3Wk_-QmRpo,
|
|
|
106
107
|
uipath/_events/_events.py,sha256=S-3zQiJM6y0pKysXhxQQciNaGcnqJqRw5PrRGgFEKn4,4565
|
|
107
108
|
uipath/_resources/AGENTS.md,sha256=nRQNAVeEBaBvuMzXw8uXtMnGebLClUgwIMlgb8_qU9o,1039
|
|
108
109
|
uipath/_resources/CLAUDE.md,sha256=kYsckFWTVe948z_fNWLysCHvi9_YpchBXl3s1Ek03lU,10
|
|
109
|
-
uipath/_resources/CLI_REFERENCE.md,sha256=
|
|
110
|
+
uipath/_resources/CLI_REFERENCE.md,sha256=v6pVR2jbBP7hTXwAwi3Ia5C96BfDKs4xGCCUOmsbEBM,6530
|
|
110
111
|
uipath/_resources/REQUIRED_STRUCTURE.md,sha256=3laqGiNa3kauJ7jRI1d7w_fWKUDkqYBjcTT_6_8FAGk,1417
|
|
111
|
-
uipath/_resources/SDK_REFERENCE.md,sha256=
|
|
112
|
+
uipath/_resources/SDK_REFERENCE.md,sha256=lvQxxdsHi-kzur2C1L4fJ6cEvjVdJPUNSX8UMofgqUQ,19485
|
|
112
113
|
uipath/_services/__init__.py,sha256=_LNy4u--VlhVtTO66bULbCoBjyJBTuyh9jnzjWrv-h4,1140
|
|
113
114
|
uipath/_services/_base_service.py,sha256=x9-9jhPzn9Z16KRdFHhJNvV-FZHvTniMsDfxlS4Cutk,5782
|
|
114
115
|
uipath/_services/actions_service.py,sha256=2RPMR-hFMsOlqEyjIf3aF7-lrf57jdrSD0pBjj0Kyko,16040
|
|
@@ -118,7 +119,7 @@ uipath/_services/attachments_service.py,sha256=NPQYK7CGjfBaNT_1S5vEAfODmOChTbQZf
|
|
|
118
119
|
uipath/_services/buckets_service.py,sha256=5s8tuivd7GUZYj774DDUYTa0axxlUuesc4EBY1V5sdk,18496
|
|
119
120
|
uipath/_services/connections_service.py,sha256=tKJHHOKQYKR6LkgB-V_2d0vFpLEdFeMzwj_xmBVHUDw,18416
|
|
120
121
|
uipath/_services/context_grounding_service.py,sha256=Pjx-QQQEiSKD-hY6ityj3QUSALN3fIcKLLHr_NZ0d_g,37117
|
|
121
|
-
uipath/_services/documents_service.py,sha256=
|
|
122
|
+
uipath/_services/documents_service.py,sha256=2mPZzmOl2r5i8RYvdeRSJtEFWSSsiXqIauTgNTW75s4,45341
|
|
122
123
|
uipath/_services/entities_service.py,sha256=QKCLE6wRgq3HZraF-M2mljy-8il4vsNHrQhUgkewVVk,14028
|
|
123
124
|
uipath/_services/external_application_service.py,sha256=gZhnGgLn7ZYUZzZF7AumB14QEPanVY-D_02FqEcAFtw,5478
|
|
124
125
|
uipath/_services/folder_service.py,sha256=9JqgjKhWD-G_KUnfUTP2BADxL6OK9QNZsBsWZHAULdE,2749
|
|
@@ -150,7 +151,7 @@ uipath/agent/conversation/exchange.py,sha256=nuk1tEMBHc_skrraT17d8U6AtyJ3h07ExGQ
|
|
|
150
151
|
uipath/agent/conversation/message.py,sha256=1ZkEs146s79TrOAWCQwzBAEJvjAu4lQBpJ64tKXDgGE,2142
|
|
151
152
|
uipath/agent/conversation/meta.py,sha256=3t0eS9UHoAPHre97QTUeVbjDhnMX4zj4-qG6ju0B8wY,315
|
|
152
153
|
uipath/agent/conversation/tool.py,sha256=ol8XI8AVd-QNn5auXNBPcCzOkh9PPFtL7hTK3kqInkU,2191
|
|
153
|
-
uipath/agent/models/agent.py,sha256=
|
|
154
|
+
uipath/agent/models/agent.py,sha256=F2KBPORufrqplb6cfBck8YI8GO3miNLD2ebpDqV0xEE,23562
|
|
154
155
|
uipath/agent/models/evals.py,sha256=QMIqwCuwabD_vYF0KgJpip5BV0pFLf9ZKUd9AL5eU2w,1843
|
|
155
156
|
uipath/agent/react/__init__.py,sha256=0Ci-uf0gSOReoHQyx3QImY-om3q_SgLT-bJUSlzS3B8,527
|
|
156
157
|
uipath/agent/react/prompts.py,sha256=0a06TJz2XqZuLK-yC_bvZV9ULXpY6UGtybjjbyVzXII,3375
|
|
@@ -204,7 +205,7 @@ uipath/models/buckets.py,sha256=N3Lj_dVCv709-ywhOOdyCSvsuLn41eGuAfSiik6Q6F8,1285
|
|
|
204
205
|
uipath/models/connections.py,sha256=jmzlfnddqlxjmiVhqsETRV6TQPH3fFqJGsygG0gUf7g,2745
|
|
205
206
|
uipath/models/context_grounding.py,sha256=3MaF2Fv2QYle8UUWvKGkCN5XGpx2T4a34fdbBqJ2fCs,1137
|
|
206
207
|
uipath/models/context_grounding_index.py,sha256=OhRyxZDHDSrEmBFK0-JLqMMMT64jir4XkHtQ54IKtc0,2683
|
|
207
|
-
uipath/models/documents.py,sha256=
|
|
208
|
+
uipath/models/documents.py,sha256=gh063bG0pl4YGThWQIgprwRCKxnKVoMOZrXDfDEVnQw,7337
|
|
208
209
|
uipath/models/entities.py,sha256=x6jbq4o_QhgL_pCgvHFsp9O8l333kQhn8e9ZCBs72UM,9823
|
|
209
210
|
uipath/models/errors.py,sha256=WCxxHBlLzLF17YxjqsFkkyBLwEQM_dc6fFU5qmBjD4A,597
|
|
210
211
|
uipath/models/exceptions.py,sha256=f71VsUyonK2uuH1Cs0tpP6f9dec6v6cffL1Z9EjTxm0,1870
|
|
@@ -224,8 +225,8 @@ uipath/tracing/_utils.py,sha256=zMjiKjNpSN3YQNEU4-u5AAvPtUsi8QuEqNLya89jfAU,1446
|
|
|
224
225
|
uipath/utils/__init__.py,sha256=VD-KXFpF_oWexFg6zyiWMkxl2HM4hYJMIUDZ1UEtGx0,105
|
|
225
226
|
uipath/utils/_endpoints_manager.py,sha256=tnF_FiCx8qI2XaJDQgYkMN_gl9V0VqNR1uX7iawuLp8,8230
|
|
226
227
|
uipath/utils/dynamic_schema.py,sha256=w0u_54MoeIAB-mf3GmwX1A_X8_HDrRy6p998PvX9evY,3839
|
|
227
|
-
uipath-2.1.
|
|
228
|
-
uipath-2.1.
|
|
229
|
-
uipath-2.1.
|
|
230
|
-
uipath-2.1.
|
|
231
|
-
uipath-2.1.
|
|
228
|
+
uipath-2.1.119.dist-info/METADATA,sha256=3bFAJBRf1iXbqhxg8hQUgj3ggLWI6Sptx_R-iQbunbM,6626
|
|
229
|
+
uipath-2.1.119.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
230
|
+
uipath-2.1.119.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
|
|
231
|
+
uipath-2.1.119.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
|
|
232
|
+
uipath-2.1.119.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|