uipath 2.1.106__py3-none-any.whl → 2.1.107__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/_resources/SDK_REFERENCE.md +1 -1
- uipath/_services/guardrails_service.py +76 -0
- uipath/_services/llm_gateway_service.py +15 -2
- uipath/agent/models/agent.py +147 -2
- uipath/models/guardrails.py +2 -225
- uipath/tracing/_utils.py +18 -4
- {uipath-2.1.106.dist-info → uipath-2.1.107.dist-info}/METADATA +1 -1
- {uipath-2.1.106.dist-info → uipath-2.1.107.dist-info}/RECORD +11 -10
- {uipath-2.1.106.dist-info → uipath-2.1.107.dist-info}/WHEEL +0 -0
- {uipath-2.1.106.dist-info → uipath-2.1.107.dist-info}/entry_points.txt +0 -0
- {uipath-2.1.106.dist-info → uipath-2.1.107.dist-info}/licenses/LICENSE +0 -0
|
@@ -339,7 +339,7 @@ Llm service
|
|
|
339
339
|
|
|
340
340
|
```python
|
|
341
341
|
# Generate chat completions using UiPath's normalized LLM Gateway API.
|
|
342
|
-
sdk.llm.chat_completions(messages: List[Dict[str, str]], model: str="gpt-4o-mini-2024-07-18", max_tokens: int=4096, temperature: float=0, n: int=1, frequency_penalty: float=0, presence_penalty: float=0, top_p: Optional[float]=1, top_k: Optional[int]=None, tools: Optional[List[uipath.models.llm_gateway.ToolDefinition]]=None, tool_choice: Union[uipath.models.llm_gateway.AutoToolChoice, uipath.models.llm_gateway.RequiredToolChoice, uipath.models.llm_gateway.SpecificToolChoice, Literal['auto', 'none'], NoneType]=None, response_format: Union[Dict[str, Any], type[pydantic.main.BaseModel], NoneType]=None, api_version: str="2024-08-01-preview")
|
|
342
|
+
sdk.llm.chat_completions(messages: Union[List[Dict[str, str]], List[tuple[str, str]]], model: str="gpt-4o-mini-2024-07-18", max_tokens: int=4096, temperature: float=0, n: int=1, frequency_penalty: float=0, presence_penalty: float=0, top_p: Optional[float]=1, top_k: Optional[int]=None, tools: Optional[List[uipath.models.llm_gateway.ToolDefinition]]=None, tool_choice: Union[uipath.models.llm_gateway.AutoToolChoice, uipath.models.llm_gateway.RequiredToolChoice, uipath.models.llm_gateway.SpecificToolChoice, Literal['auto', 'none'], NoneType]=None, response_format: Union[Dict[str, Any], type[pydantic.main.BaseModel], NoneType]=None, api_version: str="2024-08-01-preview")
|
|
343
343
|
|
|
344
344
|
```
|
|
345
345
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from typing import Any, Dict, Optional, Union
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
4
|
+
|
|
5
|
+
from .._config import Config
|
|
6
|
+
from .._execution_context import ExecutionContext
|
|
7
|
+
from .._folder_context import FolderContext
|
|
8
|
+
from .._utils import Endpoint, RequestSpec, header_folder
|
|
9
|
+
from ..models.guardrails import BuiltInValidatorGuardrail, Guardrail
|
|
10
|
+
from ..tracing import traced
|
|
11
|
+
from ._base_service import BaseService
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BuiltInGuardrailValidationResult(BaseModel):
|
|
15
|
+
"""Result from built-in guardrail validation."""
|
|
16
|
+
|
|
17
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
18
|
+
|
|
19
|
+
validation_passed: bool = Field(alias="validation_passed")
|
|
20
|
+
reason: str = Field(alias="reason")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class GuardrailViolationError(Exception):
|
|
24
|
+
"""Exception raised when guardrail validation fails."""
|
|
25
|
+
|
|
26
|
+
def __init__(self, detected_issue: Any):
|
|
27
|
+
self.detected_issue = detected_issue
|
|
28
|
+
super().__init__(f"Guardrail violation detected: {detected_issue}")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class GuardrailsService(FolderContext, BaseService):
|
|
32
|
+
"""Service for validating text against UiPath Guardrails."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, config: Config, execution_context: ExecutionContext) -> None:
|
|
35
|
+
super().__init__(config=config, execution_context=execution_context)
|
|
36
|
+
|
|
37
|
+
@traced("evaluate_guardrail", run_type="uipath")
|
|
38
|
+
def evaluate_guardrail(
|
|
39
|
+
self,
|
|
40
|
+
input_data: Union[str, Dict[str, Any]],
|
|
41
|
+
guardrail: Guardrail,
|
|
42
|
+
*,
|
|
43
|
+
folder_key: Optional[str] = None,
|
|
44
|
+
folder_path: Optional[str] = None,
|
|
45
|
+
) -> BuiltInGuardrailValidationResult:
|
|
46
|
+
"""Call the API to validate input_data with the given guardrail.
|
|
47
|
+
|
|
48
|
+
Only supports built-in guardrails for now.
|
|
49
|
+
"""
|
|
50
|
+
if isinstance(guardrail, BuiltInValidatorGuardrail):
|
|
51
|
+
parameters = [
|
|
52
|
+
param.model_dump(by_alias=True)
|
|
53
|
+
for param in guardrail.validator_parameters
|
|
54
|
+
]
|
|
55
|
+
payload = {
|
|
56
|
+
"validator": guardrail.validator_type,
|
|
57
|
+
"input": input_data if isinstance(input_data, str) else str(input_data),
|
|
58
|
+
"parameters": parameters,
|
|
59
|
+
}
|
|
60
|
+
spec = RequestSpec(
|
|
61
|
+
method="POST",
|
|
62
|
+
endpoint=Endpoint("/agentsruntime_/api/execution/guardrails/validate"),
|
|
63
|
+
json=payload,
|
|
64
|
+
headers={**header_folder(folder_key, folder_path)},
|
|
65
|
+
)
|
|
66
|
+
response = self.request(
|
|
67
|
+
spec.method,
|
|
68
|
+
url=spec.endpoint,
|
|
69
|
+
json=spec.json,
|
|
70
|
+
headers=spec.headers,
|
|
71
|
+
)
|
|
72
|
+
return BuiltInGuardrailValidationResult.model_validate(response.json())
|
|
73
|
+
else:
|
|
74
|
+
raise NotImplementedError(
|
|
75
|
+
"Custom guardrail validation is not yet supported by the API."
|
|
76
|
+
)
|
|
@@ -344,7 +344,7 @@ class UiPathLlmChatService(BaseService):
|
|
|
344
344
|
@traced(name="llm_chat_completions", run_type="uipath")
|
|
345
345
|
async def chat_completions(
|
|
346
346
|
self,
|
|
347
|
-
messages: List[Dict[str, str]],
|
|
347
|
+
messages: Union[List[Dict[str, str]], List[tuple[str, str]]],
|
|
348
348
|
model: str = ChatModels.gpt_4o_mini_2024_07_18,
|
|
349
349
|
max_tokens: int = 4096,
|
|
350
350
|
temperature: float = 0,
|
|
@@ -475,13 +475,26 @@ class UiPathLlmChatService(BaseService):
|
|
|
475
475
|
This service uses UiPath's normalized API format which provides consistent
|
|
476
476
|
behavior across different underlying model providers and enhanced enterprise features.
|
|
477
477
|
"""
|
|
478
|
+
converted_messages = []
|
|
479
|
+
|
|
480
|
+
for message in messages:
|
|
481
|
+
if isinstance(message, tuple) and len(message) == 2:
|
|
482
|
+
role, content = message
|
|
483
|
+
converted_messages.append({"role": role, "content": content})
|
|
484
|
+
elif isinstance(message, dict):
|
|
485
|
+
converted_messages.append(message)
|
|
486
|
+
else:
|
|
487
|
+
raise ValueError(
|
|
488
|
+
f"Invalid message format: {message}. Expected tuple (role, content) or dict with 'role' and 'content' keys."
|
|
489
|
+
)
|
|
490
|
+
|
|
478
491
|
endpoint = EndpointManager.get_normalized_endpoint().format(
|
|
479
492
|
model=model, api_version=api_version
|
|
480
493
|
)
|
|
481
494
|
endpoint = Endpoint("/" + endpoint)
|
|
482
495
|
|
|
483
496
|
request_body = {
|
|
484
|
-
"messages":
|
|
497
|
+
"messages": converted_messages,
|
|
485
498
|
"max_tokens": max_tokens,
|
|
486
499
|
"temperature": temperature,
|
|
487
500
|
"n": n,
|
uipath/agent/models/agent.py
CHANGED
|
@@ -6,7 +6,11 @@ from typing import Annotated, Any, Dict, List, Literal, Optional, Union
|
|
|
6
6
|
from pydantic import BaseModel, ConfigDict, Discriminator, Field, Tag, field_validator
|
|
7
7
|
|
|
8
8
|
from uipath.models import Connection
|
|
9
|
-
from uipath.models.guardrails import
|
|
9
|
+
from uipath.models.guardrails import (
|
|
10
|
+
BuiltInValidatorGuardrail,
|
|
11
|
+
CustomGuardrail,
|
|
12
|
+
FieldReference,
|
|
13
|
+
)
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
class AgentResourceType(str, Enum):
|
|
@@ -132,6 +136,37 @@ class AgentProcessToolResourceConfig(BaseAgentToolResourceConfig):
|
|
|
132
136
|
)
|
|
133
137
|
|
|
134
138
|
|
|
139
|
+
class AgentEscalationRecipientType(str, Enum):
|
|
140
|
+
"""Enum for escalation recipient types."""
|
|
141
|
+
|
|
142
|
+
USER_ID = "UserId"
|
|
143
|
+
GROUP_ID = "GroupId"
|
|
144
|
+
USER_EMAIL = "UserEmail"
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class AgentEscalationRecipient(BaseModel):
|
|
148
|
+
"""Recipient for escalation."""
|
|
149
|
+
|
|
150
|
+
type: Union[AgentEscalationRecipientType, str] = Field(..., alias="type")
|
|
151
|
+
value: str = Field(..., alias="value")
|
|
152
|
+
display_name: Optional[str] = Field(default=None, alias="displayName")
|
|
153
|
+
|
|
154
|
+
@field_validator("type", mode="before")
|
|
155
|
+
@classmethod
|
|
156
|
+
def normalize_type(cls, v: Any) -> str:
|
|
157
|
+
"""Normalize recipient type from int (1=UserId, 2=GroupId, 3=UserEmail) or string. Unknown integers are converted to string."""
|
|
158
|
+
if isinstance(v, int):
|
|
159
|
+
mapping = {
|
|
160
|
+
1: AgentEscalationRecipientType.USER_ID,
|
|
161
|
+
2: AgentEscalationRecipientType.GROUP_ID,
|
|
162
|
+
3: AgentEscalationRecipientType.USER_EMAIL,
|
|
163
|
+
}
|
|
164
|
+
return mapping.get(v, str(v))
|
|
165
|
+
return v
|
|
166
|
+
|
|
167
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
168
|
+
|
|
169
|
+
|
|
135
170
|
class AgentIntegrationToolParameter(BaseModel):
|
|
136
171
|
"""Agent integration tool parameter."""
|
|
137
172
|
|
|
@@ -479,6 +514,116 @@ class AgentSettings(BaseModel):
|
|
|
479
514
|
)
|
|
480
515
|
|
|
481
516
|
|
|
517
|
+
class AgentGuardrailActionType(str, Enum):
|
|
518
|
+
"""Action type enumeration."""
|
|
519
|
+
|
|
520
|
+
BLOCK = "block"
|
|
521
|
+
ESCALATE = "escalate"
|
|
522
|
+
FILTER = "filter"
|
|
523
|
+
LOG = "log"
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
class AgentGuardrailBlockAction(BaseModel):
|
|
527
|
+
"""Block action model."""
|
|
528
|
+
|
|
529
|
+
action_type: Literal["block"] = Field(alias="$actionType")
|
|
530
|
+
reason: str
|
|
531
|
+
|
|
532
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
class AgentGuardrailFilterAction(BaseModel):
|
|
536
|
+
"""Filter action model."""
|
|
537
|
+
|
|
538
|
+
action_type: Literal["filter"] = Field(alias="$actionType")
|
|
539
|
+
fields: List[FieldReference]
|
|
540
|
+
|
|
541
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
class AgentGuardrailSeverityLevel(str, Enum):
|
|
545
|
+
"""Severity level enumeration."""
|
|
546
|
+
|
|
547
|
+
ERROR = "Error"
|
|
548
|
+
INFO = "Info"
|
|
549
|
+
WARNING = "Warning"
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
class AgentGuardrailLogAction(BaseModel):
|
|
553
|
+
"""Log action model."""
|
|
554
|
+
|
|
555
|
+
action_type: Literal["log"] = Field(alias="$actionType")
|
|
556
|
+
message: str = Field(..., alias="message")
|
|
557
|
+
severity_level: AgentGuardrailSeverityLevel = Field(alias="severityLevel")
|
|
558
|
+
|
|
559
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
class AgentGuardrailEscalateActionApp(BaseModel):
|
|
563
|
+
"""Escalate action app model."""
|
|
564
|
+
|
|
565
|
+
id: Optional[str] = None
|
|
566
|
+
version: int
|
|
567
|
+
name: str
|
|
568
|
+
folder_id: Optional[str] = Field(None, alias="folderId")
|
|
569
|
+
folder_name: str = Field(alias="folderName")
|
|
570
|
+
app_process_key: Optional[str] = Field(None, alias="appProcessKey")
|
|
571
|
+
runtime: Optional[str] = None
|
|
572
|
+
|
|
573
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
class AgentGuardrailEscalateAction(BaseModel):
|
|
577
|
+
"""Escalate action model."""
|
|
578
|
+
|
|
579
|
+
action_type: Literal["escalate"] = Field(alias="$actionType")
|
|
580
|
+
app: AgentGuardrailEscalateActionApp
|
|
581
|
+
recipient: AgentEscalationRecipient
|
|
582
|
+
|
|
583
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
GuardrailAction = Annotated[
|
|
587
|
+
Union[
|
|
588
|
+
AgentGuardrailBlockAction,
|
|
589
|
+
AgentGuardrailFilterAction,
|
|
590
|
+
AgentGuardrailLogAction,
|
|
591
|
+
AgentGuardrailEscalateAction,
|
|
592
|
+
],
|
|
593
|
+
Field(discriminator="action_type"),
|
|
594
|
+
]
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
class AgentCustomGuardrail(CustomGuardrail):
|
|
598
|
+
"""Agent custom guardrail with action capabilities."""
|
|
599
|
+
|
|
600
|
+
action: GuardrailAction = Field(
|
|
601
|
+
..., description="Action to take when guardrail is triggered"
|
|
602
|
+
)
|
|
603
|
+
|
|
604
|
+
model_config = ConfigDict(
|
|
605
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
606
|
+
)
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
class AgentBuiltInValidatorGuardrail(BuiltInValidatorGuardrail):
|
|
610
|
+
"""Agent built-in validator guardrail with action capabilities."""
|
|
611
|
+
|
|
612
|
+
action: GuardrailAction = Field(
|
|
613
|
+
..., description="Action to take when guardrail is triggered"
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
model_config = ConfigDict(
|
|
617
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
618
|
+
)
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
AgentGuardrail = Annotated[
|
|
622
|
+
Union[AgentCustomGuardrail, AgentBuiltInValidatorGuardrail],
|
|
623
|
+
Field(discriminator="guardrail_type"),
|
|
624
|
+
]
|
|
625
|
+
|
|
626
|
+
|
|
482
627
|
class BaseAgentDefinition(BaseModel):
|
|
483
628
|
"""Agent definition model."""
|
|
484
629
|
|
|
@@ -488,7 +633,7 @@ class BaseAgentDefinition(BaseModel):
|
|
|
488
633
|
output_schema: Dict[str, Any] = Field(
|
|
489
634
|
..., alias="outputSchema", description="JSON schema for output arguments"
|
|
490
635
|
)
|
|
491
|
-
guardrails: Optional[List[
|
|
636
|
+
guardrails: Optional[List[AgentGuardrail]] = Field(
|
|
492
637
|
None, description="List of agent guardrails"
|
|
493
638
|
)
|
|
494
639
|
|
uipath/models/guardrails.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from enum import Enum
|
|
2
|
-
from typing import Annotated,
|
|
2
|
+
from typing import Annotated, Dict, List, Literal, Optional, Union
|
|
3
3
|
|
|
4
|
-
from pydantic import BaseModel, ConfigDict, Field
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class FieldSource(str, Enum):
|
|
@@ -183,112 +183,6 @@ Rule = Annotated[
|
|
|
183
183
|
]
|
|
184
184
|
|
|
185
185
|
|
|
186
|
-
class ActionType(str, Enum):
|
|
187
|
-
"""Action type enumeration."""
|
|
188
|
-
|
|
189
|
-
BLOCK = "block"
|
|
190
|
-
ESCALATE = "escalate"
|
|
191
|
-
FILTER = "filter"
|
|
192
|
-
LOG = "log"
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
class BlockAction(BaseModel):
|
|
196
|
-
"""Block action model."""
|
|
197
|
-
|
|
198
|
-
action_type: Literal["block"] = Field(alias="$actionType")
|
|
199
|
-
reason: str
|
|
200
|
-
|
|
201
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
class FilterAction(BaseModel):
|
|
205
|
-
"""Filter action model."""
|
|
206
|
-
|
|
207
|
-
action_type: Literal["filter"] = Field(alias="$actionType")
|
|
208
|
-
fields: List[FieldReference]
|
|
209
|
-
|
|
210
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
class SeverityLevel(str, Enum):
|
|
214
|
-
"""Severity level enumeration."""
|
|
215
|
-
|
|
216
|
-
ERROR = "Error"
|
|
217
|
-
INFO = "Info"
|
|
218
|
-
WARNING = "Warning"
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
class LogAction(BaseModel):
|
|
222
|
-
"""Log action model."""
|
|
223
|
-
|
|
224
|
-
action_type: Literal["log"] = Field(alias="$actionType")
|
|
225
|
-
message: str = Field(..., alias="message")
|
|
226
|
-
severity_level: SeverityLevel = Field(alias="severityLevel")
|
|
227
|
-
|
|
228
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
class EscalateActionApp(BaseModel):
|
|
232
|
-
"""Escalate action app model."""
|
|
233
|
-
|
|
234
|
-
id: Optional[str] = None
|
|
235
|
-
version: int
|
|
236
|
-
name: str
|
|
237
|
-
folder_id: Optional[str] = Field(None, alias="folderId")
|
|
238
|
-
folder_name: str = Field(alias="folderName")
|
|
239
|
-
app_process_key: Optional[str] = Field(None, alias="appProcessKey")
|
|
240
|
-
runtime: Optional[str] = None
|
|
241
|
-
|
|
242
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
class AgentEscalationRecipientType(str, Enum):
|
|
246
|
-
"""Enum for escalation recipient types."""
|
|
247
|
-
|
|
248
|
-
USER_ID = "UserId"
|
|
249
|
-
GROUP_ID = "GroupId"
|
|
250
|
-
USER_EMAIL = "UserEmail"
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
class AgentEscalationRecipient(BaseModel):
|
|
254
|
-
"""Recipient for escalation."""
|
|
255
|
-
|
|
256
|
-
type: Union[AgentEscalationRecipientType, str] = Field(..., alias="type")
|
|
257
|
-
value: str = Field(..., alias="value")
|
|
258
|
-
display_name: Optional[str] = Field(default=None, alias="displayName")
|
|
259
|
-
|
|
260
|
-
@field_validator("type", mode="before")
|
|
261
|
-
@classmethod
|
|
262
|
-
def normalize_type(cls, v: Any) -> str:
|
|
263
|
-
"""Normalize recipient type from int (1=UserId, 2=GroupId, 3=UserEmail) or string. Unknown integers are converted to string."""
|
|
264
|
-
if isinstance(v, int):
|
|
265
|
-
mapping = {
|
|
266
|
-
1: AgentEscalationRecipientType.USER_ID,
|
|
267
|
-
2: AgentEscalationRecipientType.GROUP_ID,
|
|
268
|
-
3: AgentEscalationRecipientType.USER_EMAIL,
|
|
269
|
-
}
|
|
270
|
-
return mapping.get(v, str(v))
|
|
271
|
-
return v
|
|
272
|
-
|
|
273
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
class EscalateAction(BaseModel):
|
|
277
|
-
"""Escalate action model."""
|
|
278
|
-
|
|
279
|
-
action_type: Literal["escalate"] = Field(alias="$actionType")
|
|
280
|
-
app: EscalateActionApp
|
|
281
|
-
recipient: AgentEscalationRecipient
|
|
282
|
-
|
|
283
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
GuardrailAction = Annotated[
|
|
287
|
-
Union[BlockAction, FilterAction, LogAction, EscalateAction],
|
|
288
|
-
Field(discriminator="action_type"),
|
|
289
|
-
]
|
|
290
|
-
|
|
291
|
-
|
|
292
186
|
class GuardrailScope(str, Enum):
|
|
293
187
|
"""Guardrail scope enumeration."""
|
|
294
188
|
|
|
@@ -312,7 +206,6 @@ class BaseGuardrail(BaseModel):
|
|
|
312
206
|
id: str
|
|
313
207
|
name: str
|
|
314
208
|
description: Optional[str] = None
|
|
315
|
-
action: GuardrailAction
|
|
316
209
|
enabled_for_evals: bool = Field(True, alias="enabledForEvals")
|
|
317
210
|
selector: GuardrailSelector
|
|
318
211
|
|
|
@@ -351,119 +244,3 @@ class GuardrailType(str, Enum):
|
|
|
351
244
|
|
|
352
245
|
BUILT_IN_VALIDATOR = "builtInValidator"
|
|
353
246
|
CUSTOM = "custom"
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
# Helper functions for type checking
|
|
357
|
-
def is_boolean_rule(rule: Rule) -> bool:
|
|
358
|
-
"""Check if rule is a BooleanRule."""
|
|
359
|
-
return hasattr(rule, "rule_type") and rule.rule_type == RuleType.BOOLEAN
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
def is_number_rule(rule: Rule) -> bool:
|
|
363
|
-
"""Check if rule is a NumberRule."""
|
|
364
|
-
return hasattr(rule, "rule_type") and rule.rule_type == RuleType.NUMBER
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
def is_universal_rule(rule: Rule) -> bool:
|
|
368
|
-
"""Check if rule is a UniversalRule."""
|
|
369
|
-
return hasattr(rule, "rule_type") and rule.rule_type == RuleType.UNIVERSAL
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
def is_word_rule(rule: Rule) -> bool:
|
|
373
|
-
"""Check if rule is a WordRule."""
|
|
374
|
-
return hasattr(rule, "rule_type") and rule.rule_type == RuleType.WORD
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
def is_custom_guardrail(guardrail: Guardrail) -> bool:
|
|
378
|
-
"""Check if guardrail is a CustomGuardrail."""
|
|
379
|
-
return (
|
|
380
|
-
hasattr(guardrail, "guardrail_type")
|
|
381
|
-
and guardrail.guardrail_type == GuardrailType.CUSTOM
|
|
382
|
-
)
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
def is_built_in_validator_guardrail(guardrail: Guardrail) -> bool:
|
|
386
|
-
"""Check if guardrail is a BuiltInValidatorGuardrail."""
|
|
387
|
-
return (
|
|
388
|
-
hasattr(guardrail, "guardrail_type")
|
|
389
|
-
and guardrail.guardrail_type == GuardrailType.BUILT_IN_VALIDATOR
|
|
390
|
-
)
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
def is_valid_action_type(value: Any) -> bool:
|
|
394
|
-
"""Check if value is a valid ActionType."""
|
|
395
|
-
return isinstance(value, str) and value.lower() in [
|
|
396
|
-
at.value.lower() for at in ActionType
|
|
397
|
-
]
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
def is_valid_severity_level(value: Any) -> bool:
|
|
401
|
-
"""Check if value is a valid SeverityLevel."""
|
|
402
|
-
return isinstance(value, str) and value in [sl.value for sl in SeverityLevel]
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
# Guardrail Models
|
|
406
|
-
class AgentGuardrailRuleParameter(BaseModel):
|
|
407
|
-
"""Parameter for guardrail rules."""
|
|
408
|
-
|
|
409
|
-
parameter_type: str = Field(..., alias="$parameterType")
|
|
410
|
-
parameter_type_alt: Optional[str] = Field(None, alias="parameterType")
|
|
411
|
-
value: Any = Field(..., description="Parameter value")
|
|
412
|
-
id: str = Field(..., description="Parameter identifier")
|
|
413
|
-
|
|
414
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
class AgentGuardrailRule(BaseModel):
|
|
418
|
-
"""Guardrail validation rule."""
|
|
419
|
-
|
|
420
|
-
rule_type: str = Field(..., alias="$ruleType")
|
|
421
|
-
rule_type_alt: Optional[str] = Field(None, alias="ruleType")
|
|
422
|
-
validator: str = Field(..., description="Validator type")
|
|
423
|
-
parameters: List[AgentGuardrailRuleParameter] = Field(
|
|
424
|
-
default_factory=list, description="Rule parameters"
|
|
425
|
-
)
|
|
426
|
-
|
|
427
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
class AgentGuardrailActionApp(BaseModel):
|
|
431
|
-
"""App configuration for guardrail actions."""
|
|
432
|
-
|
|
433
|
-
name: str = Field(..., description="App name")
|
|
434
|
-
version: str = Field(..., description="App version")
|
|
435
|
-
folder_name: str = Field(..., alias="folderName", description="Folder name")
|
|
436
|
-
|
|
437
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
class AgentGuardrailActionRecipient(BaseModel):
|
|
441
|
-
"""Recipient for guardrail actions."""
|
|
442
|
-
|
|
443
|
-
type: int = Field(..., description="Recipient type")
|
|
444
|
-
value: str = Field(..., description="Recipient identifier")
|
|
445
|
-
display_name: str = Field(..., alias="displayName", description="Display name")
|
|
446
|
-
|
|
447
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
class AgentGuardrailAction(BaseModel):
|
|
451
|
-
"""Action configuration for guardrails."""
|
|
452
|
-
|
|
453
|
-
action_type: str = Field(..., alias="$actionType")
|
|
454
|
-
action_type_alt: Optional[str] = Field(None, alias="actionType")
|
|
455
|
-
app: AgentGuardrailActionApp = Field(..., description="App configuration")
|
|
456
|
-
recipient: AgentGuardrailActionRecipient = Field(..., description="Recipient")
|
|
457
|
-
|
|
458
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
class AgentGuardrailSelector(BaseModel):
|
|
462
|
-
"""Selector for guardrail application scope."""
|
|
463
|
-
|
|
464
|
-
scopes: List[str] = Field(..., description="Scopes where guardrail applies")
|
|
465
|
-
match_names: List[str] = Field(
|
|
466
|
-
..., alias="matchNames", description="Names to match"
|
|
467
|
-
)
|
|
468
|
-
|
|
469
|
-
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
uipath/tracing/_utils.py
CHANGED
|
@@ -13,16 +13,26 @@ from zoneinfo import ZoneInfo
|
|
|
13
13
|
|
|
14
14
|
from opentelemetry.sdk.trace import ReadableSpan
|
|
15
15
|
from opentelemetry.trace import StatusCode
|
|
16
|
+
from pydantic import BaseModel
|
|
16
17
|
|
|
17
18
|
logger = logging.getLogger(__name__)
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
def _simple_serialize_defaults(obj):
|
|
21
|
-
|
|
22
|
+
# Handle Pydantic BaseModel instances
|
|
23
|
+
if hasattr(obj, "model_dump") and not isinstance(obj, type):
|
|
22
24
|
return obj.model_dump(exclude_none=True, mode="json")
|
|
23
|
-
|
|
25
|
+
|
|
26
|
+
# Handle classes - convert to schema representation
|
|
27
|
+
if isinstance(obj, type) and issubclass(obj, BaseModel):
|
|
28
|
+
return {
|
|
29
|
+
"__class__": obj.__name__,
|
|
30
|
+
"__module__": obj.__module__,
|
|
31
|
+
"schema": obj.model_json_schema(),
|
|
32
|
+
}
|
|
33
|
+
if hasattr(obj, "dict") and not isinstance(obj, type):
|
|
24
34
|
return obj.dict()
|
|
25
|
-
if hasattr(obj, "to_dict"):
|
|
35
|
+
if hasattr(obj, "to_dict") and not isinstance(obj, type):
|
|
26
36
|
return obj.to_dict()
|
|
27
37
|
|
|
28
38
|
# Handle dataclasses
|
|
@@ -31,7 +41,7 @@ def _simple_serialize_defaults(obj):
|
|
|
31
41
|
|
|
32
42
|
# Handle enums
|
|
33
43
|
if isinstance(obj, Enum):
|
|
34
|
-
return obj.value
|
|
44
|
+
return _simple_serialize_defaults(obj.value)
|
|
35
45
|
|
|
36
46
|
if isinstance(obj, (set, tuple)):
|
|
37
47
|
if hasattr(obj, "_asdict") and callable(obj._asdict):
|
|
@@ -44,6 +54,10 @@ def _simple_serialize_defaults(obj):
|
|
|
44
54
|
if isinstance(obj, (timezone, ZoneInfo)):
|
|
45
55
|
return obj.tzname(None)
|
|
46
56
|
|
|
57
|
+
# Allow JSON-serializable primitives to pass through unchanged
|
|
58
|
+
if obj is None or isinstance(obj, (bool, int, float, str)):
|
|
59
|
+
return obj
|
|
60
|
+
|
|
47
61
|
return str(obj)
|
|
48
62
|
|
|
49
63
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: uipath
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.107
|
|
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
|
|
@@ -102,7 +102,7 @@ uipath/_resources/AGENTS.md,sha256=nRQNAVeEBaBvuMzXw8uXtMnGebLClUgwIMlgb8_qU9o,1
|
|
|
102
102
|
uipath/_resources/CLAUDE.md,sha256=kYsckFWTVe948z_fNWLysCHvi9_YpchBXl3s1Ek03lU,10
|
|
103
103
|
uipath/_resources/CLI_REFERENCE.md,sha256=M_SCtSjRhj1XwfgSFLfHJJahYXEd_CSQ_EnjLQAn-2Y,6470
|
|
104
104
|
uipath/_resources/REQUIRED_STRUCTURE.md,sha256=3laqGiNa3kauJ7jRI1d7w_fWKUDkqYBjcTT_6_8FAGk,1417
|
|
105
|
-
uipath/_resources/SDK_REFERENCE.md,sha256=
|
|
105
|
+
uipath/_resources/SDK_REFERENCE.md,sha256=1i2S2219HSTVrMHoMPcUxTC4nGqeLKfzeD_JSuIB3ec,23275
|
|
106
106
|
uipath/_services/__init__.py,sha256=_LNy4u--VlhVtTO66bULbCoBjyJBTuyh9jnzjWrv-h4,1140
|
|
107
107
|
uipath/_services/_base_service.py,sha256=x9-9jhPzn9Z16KRdFHhJNvV-FZHvTniMsDfxlS4Cutk,5782
|
|
108
108
|
uipath/_services/actions_service.py,sha256=2RPMR-hFMsOlqEyjIf3aF7-lrf57jdrSD0pBjj0Kyko,16040
|
|
@@ -116,8 +116,9 @@ uipath/_services/documents_service.py,sha256=dVv7kYT2wm4gbtqulSAQhtn418xgzV2yt7g
|
|
|
116
116
|
uipath/_services/entities_service.py,sha256=QKCLE6wRgq3HZraF-M2mljy-8il4vsNHrQhUgkewVVk,14028
|
|
117
117
|
uipath/_services/external_application_service.py,sha256=gZhnGgLn7ZYUZzZF7AumB14QEPanVY-D_02FqEcAFtw,5478
|
|
118
118
|
uipath/_services/folder_service.py,sha256=9JqgjKhWD-G_KUnfUTP2BADxL6OK9QNZsBsWZHAULdE,2749
|
|
119
|
+
uipath/_services/guardrails_service.py,sha256=Uch_3Ph3Obg7vG--iemqJUB7I7vSHmQMYtESAyIzqFI,2796
|
|
119
120
|
uipath/_services/jobs_service.py,sha256=tTZNsdZKN3uP7bWPQyBCpJeQxTfuOWbKYOR4L-_yJo4,32736
|
|
120
|
-
uipath/_services/llm_gateway_service.py,sha256=
|
|
121
|
+
uipath/_services/llm_gateway_service.py,sha256=vRnx5MSSkxxR0Xw4_km0_aDBrWgkZmyJ1QRBp_anfog,24995
|
|
121
122
|
uipath/_services/processes_service.py,sha256=O_uHgQ1rnwiV5quG0OQqabAnE6Rf6cWrMENYY2jKWt8,8585
|
|
122
123
|
uipath/_services/queues_service.py,sha256=VaG3dWL2QK6AJBOLoW2NQTpkPfZjsqsYPl9-kfXPFzA,13534
|
|
123
124
|
uipath/_utils/__init__.py,sha256=VdcpnENJIa0R6Y26NoxY64-wUVyvb4pKfTh1wXDQeMk,526
|
|
@@ -143,7 +144,7 @@ uipath/agent/conversation/exchange.py,sha256=nuk1tEMBHc_skrraT17d8U6AtyJ3h07ExGQ
|
|
|
143
144
|
uipath/agent/conversation/message.py,sha256=1ZkEs146s79TrOAWCQwzBAEJvjAu4lQBpJ64tKXDgGE,2142
|
|
144
145
|
uipath/agent/conversation/meta.py,sha256=3t0eS9UHoAPHre97QTUeVbjDhnMX4zj4-qG6ju0B8wY,315
|
|
145
146
|
uipath/agent/conversation/tool.py,sha256=ol8XI8AVd-QNn5auXNBPcCzOkh9PPFtL7hTK3kqInkU,2191
|
|
146
|
-
uipath/agent/models/agent.py,sha256=
|
|
147
|
+
uipath/agent/models/agent.py,sha256=kAdNWpyzggIYB4ye7vs-hPrHGxYPgTp48DcmQXw-Bcw,22630
|
|
147
148
|
uipath/agent/models/evals.py,sha256=QMIqwCuwabD_vYF0KgJpip5BV0pFLf9ZKUd9AL5eU2w,1843
|
|
148
149
|
uipath/agent/react/__init__.py,sha256=0Ci-uf0gSOReoHQyx3QImY-om3q_SgLT-bJUSlzS3B8,527
|
|
149
150
|
uipath/agent/react/prompts.py,sha256=0a06TJz2XqZuLK-yC_bvZV9ULXpY6UGtybjjbyVzXII,3375
|
|
@@ -175,7 +176,7 @@ uipath/models/documents.py,sha256=g3xAhZlGcLuD6a_DHcUQWoLdzh5dENulouYAwrjGHEw,39
|
|
|
175
176
|
uipath/models/entities.py,sha256=x6jbq4o_QhgL_pCgvHFsp9O8l333kQhn8e9ZCBs72UM,9823
|
|
176
177
|
uipath/models/errors.py,sha256=WCxxHBlLzLF17YxjqsFkkyBLwEQM_dc6fFU5qmBjD4A,597
|
|
177
178
|
uipath/models/exceptions.py,sha256=f71VsUyonK2uuH1Cs0tpP6f9dec6v6cffL1Z9EjTxm0,1870
|
|
178
|
-
uipath/models/guardrails.py,sha256=
|
|
179
|
+
uipath/models/guardrails.py,sha256=tyrJ0WTYX0Ds7VtFyX87k7T9mQaGv-u1maQpnO0IPXM,6034
|
|
179
180
|
uipath/models/interrupt_models.py,sha256=UzuVTMVesI204YQ4qFQFaN-gN3kksddkrujofcaC7zQ,881
|
|
180
181
|
uipath/models/job.py,sha256=h1S-ErUk4-oIdrxo4nEBEJdSv1NTTF4AF8LfXx5Exak,3063
|
|
181
182
|
uipath/models/llm_gateway.py,sha256=rUIus7BrUuuRriXqSJUE9FnjOyQ7pYpaX6hWEYvA6AA,1923
|
|
@@ -187,12 +188,12 @@ uipath/telemetry/_track.py,sha256=3RZgJtY8y28Y5rfVmC432OyRu7N3pSxPouwa82KWFso,47
|
|
|
187
188
|
uipath/tracing/__init__.py,sha256=0oUuxJKOHE14iOL4SP93FOiEYRIFLTq-o0NwRcTB8Q4,317
|
|
188
189
|
uipath/tracing/_otel_exporters.py,sha256=LAtaQV5QN4PSLgEbIVvlmUETNbMYqTX87R-3mRKy_S8,12438
|
|
189
190
|
uipath/tracing/_traced.py,sha256=yBIY05PCCrYyx50EIHZnwJaKNdHPNx-YTR1sHQl0a98,19901
|
|
190
|
-
uipath/tracing/_utils.py,sha256=
|
|
191
|
+
uipath/tracing/_utils.py,sha256=zMjiKjNpSN3YQNEU4-u5AAvPtUsi8QuEqNLya89jfAU,14466
|
|
191
192
|
uipath/utils/__init__.py,sha256=VD-KXFpF_oWexFg6zyiWMkxl2HM4hYJMIUDZ1UEtGx0,105
|
|
192
193
|
uipath/utils/_endpoints_manager.py,sha256=tnF_FiCx8qI2XaJDQgYkMN_gl9V0VqNR1uX7iawuLp8,8230
|
|
193
194
|
uipath/utils/dynamic_schema.py,sha256=w0u_54MoeIAB-mf3GmwX1A_X8_HDrRy6p998PvX9evY,3839
|
|
194
|
-
uipath-2.1.
|
|
195
|
-
uipath-2.1.
|
|
196
|
-
uipath-2.1.
|
|
197
|
-
uipath-2.1.
|
|
198
|
-
uipath-2.1.
|
|
195
|
+
uipath-2.1.107.dist-info/METADATA,sha256=fHXbkUqpyNJ9NMJB1vkME8fMivyaqb4HAZhIB0hPrJc,6626
|
|
196
|
+
uipath-2.1.107.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
197
|
+
uipath-2.1.107.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
|
|
198
|
+
uipath-2.1.107.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
|
|
199
|
+
uipath-2.1.107.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|