uipath-core 0.1.5__py3-none-any.whl → 0.1.7__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.
- uipath/core/guardrails/__init__.py +2 -0
- uipath/core/guardrails/_deterministic_guardrails_service.py +8 -5
- uipath/core/guardrails/_evaluators.py +6 -6
- uipath/core/guardrails/guardrails.py +12 -3
- uipath/core/tracing/decorators.py +14 -0
- {uipath_core-0.1.5.dist-info → uipath_core-0.1.7.dist-info}/METADATA +1 -1
- {uipath_core-0.1.5.dist-info → uipath_core-0.1.7.dist-info}/RECORD +9 -9
- {uipath_core-0.1.5.dist-info → uipath_core-0.1.7.dist-info}/WHEEL +0 -0
- {uipath_core-0.1.5.dist-info → uipath_core-0.1.7.dist-info}/licenses/LICENSE +0 -0
|
@@ -16,6 +16,7 @@ from .guardrails import (
|
|
|
16
16
|
GuardrailScope,
|
|
17
17
|
GuardrailSelector,
|
|
18
18
|
GuardrailValidationResult,
|
|
19
|
+
GuardrailValidationResultType,
|
|
19
20
|
NumberRule,
|
|
20
21
|
Rule,
|
|
21
22
|
SelectorType,
|
|
@@ -43,4 +44,5 @@ __all__ = [
|
|
|
43
44
|
"GuardrailScope",
|
|
44
45
|
"GuardrailSelector",
|
|
45
46
|
"GuardrailValidationResult",
|
|
47
|
+
"GuardrailValidationResultType",
|
|
46
48
|
]
|
|
@@ -16,6 +16,7 @@ from .guardrails import (
|
|
|
16
16
|
DeterministicGuardrail,
|
|
17
17
|
FieldSource,
|
|
18
18
|
GuardrailValidationResult,
|
|
19
|
+
GuardrailValidationResultType,
|
|
19
20
|
NumberRule,
|
|
20
21
|
SpecificFieldsSelector,
|
|
21
22
|
UniversalRule,
|
|
@@ -38,7 +39,7 @@ class DeterministicGuardrailsService(BaseModel):
|
|
|
38
39
|
# Output rules will be evaluated during post-execution
|
|
39
40
|
if has_output_rule:
|
|
40
41
|
return GuardrailValidationResult(
|
|
41
|
-
|
|
42
|
+
result=GuardrailValidationResultType.PASSED,
|
|
42
43
|
reason="Guardrail contains output-dependent rules that will be evaluated during post-execution",
|
|
43
44
|
)
|
|
44
45
|
return self._evaluate_deterministic_guardrail(
|
|
@@ -64,7 +65,7 @@ class DeterministicGuardrailsService(BaseModel):
|
|
|
64
65
|
# Only input rules exist and they should have been evaluated during pre-execution
|
|
65
66
|
if not has_output_rule:
|
|
66
67
|
return GuardrailValidationResult(
|
|
67
|
-
|
|
68
|
+
result=GuardrailValidationResultType.PASSED,
|
|
68
69
|
reason="Guardrail contains only input-dependent rules that were evaluated during pre-execution",
|
|
69
70
|
)
|
|
70
71
|
|
|
@@ -128,15 +129,17 @@ class DeterministicGuardrailsService(BaseModel):
|
|
|
128
129
|
passed, reason = evaluate_universal_rule(rule, output_data)
|
|
129
130
|
else:
|
|
130
131
|
return GuardrailValidationResult(
|
|
131
|
-
|
|
132
|
+
result=GuardrailValidationResultType.VALIDATION_FAILED,
|
|
132
133
|
reason=f"Unknown rule type: {type(rule)}",
|
|
133
134
|
)
|
|
134
135
|
|
|
135
136
|
if not passed:
|
|
136
137
|
return GuardrailValidationResult(
|
|
137
|
-
|
|
138
|
+
result=GuardrailValidationResultType.VALIDATION_FAILED,
|
|
139
|
+
reason=reason or "Rule validation failed",
|
|
138
140
|
)
|
|
139
141
|
|
|
140
142
|
return GuardrailValidationResult(
|
|
141
|
-
|
|
143
|
+
result=GuardrailValidationResultType.PASSED,
|
|
144
|
+
reason="All deterministic guardrail rules passed",
|
|
142
145
|
)
|
|
@@ -288,13 +288,13 @@ def evaluate_universal_rule(
|
|
|
288
288
|
|
|
289
289
|
Universal rules trigger based on the apply_to scope and execution phase:
|
|
290
290
|
- Pre-execution (empty output_data):
|
|
291
|
-
- INPUT: triggers (
|
|
292
|
-
- OUTPUT: does not trigger (
|
|
293
|
-
- INPUT_AND_OUTPUT: triggers (
|
|
291
|
+
- INPUT: triggers (result = VALIDATION_FAILED)
|
|
292
|
+
- OUTPUT: does not trigger (result = PASSED)
|
|
293
|
+
- INPUT_AND_OUTPUT: triggers (result = VALIDATION_FAILED)
|
|
294
294
|
- Post-execution (output_data has data):
|
|
295
|
-
- INPUT: does not trigger (
|
|
296
|
-
- OUTPUT: triggers (
|
|
297
|
-
- INPUT_AND_OUTPUT: triggers (
|
|
295
|
+
- INPUT: does not trigger (result = PASSED)
|
|
296
|
+
- OUTPUT: triggers (result = VALIDATION_FAILED)
|
|
297
|
+
- INPUT_AND_OUTPUT: triggers (result = VALIDATION_FAILED)
|
|
298
298
|
"""
|
|
299
299
|
# Determine if this is pre-execution (no output data) or post-execution
|
|
300
300
|
is_pre_execution = not output_data or len(output_data) == 0
|
|
@@ -6,18 +6,27 @@ from typing import Annotated, Callable, Literal
|
|
|
6
6
|
from pydantic import BaseModel, ConfigDict, Field
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
class GuardrailValidationResultType(str, Enum):
|
|
10
|
+
"""Guardrail validation result type enumeration."""
|
|
11
|
+
|
|
12
|
+
PASSED = "passed"
|
|
13
|
+
VALIDATION_FAILED = "validation_failed"
|
|
14
|
+
ENTITLEMENTS_MISSING = "entitlements_missing"
|
|
15
|
+
FEATURE_DISABLED = "feature_disabled"
|
|
16
|
+
|
|
17
|
+
|
|
9
18
|
class GuardrailValidationResult(BaseModel):
|
|
10
19
|
"""Result returned from validating input with a given guardrail.
|
|
11
20
|
|
|
12
21
|
Attributes:
|
|
13
|
-
|
|
22
|
+
result: The validation result type.
|
|
14
23
|
reason: Textual explanation describing why the validation passed or failed.
|
|
15
24
|
"""
|
|
16
25
|
|
|
17
26
|
model_config = ConfigDict(populate_by_name=True)
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
alias="
|
|
28
|
+
result: GuardrailValidationResultType = Field(
|
|
29
|
+
alias="result", description="Validation result."
|
|
21
30
|
)
|
|
22
31
|
reason: str = Field(
|
|
23
32
|
alias="reason", description="Explanation for the validation result."
|
|
@@ -6,7 +6,9 @@ import random
|
|
|
6
6
|
from functools import wraps
|
|
7
7
|
from typing import Any, Callable, Optional
|
|
8
8
|
|
|
9
|
+
from opentelemetry import context as context_api
|
|
9
10
|
from opentelemetry import trace
|
|
11
|
+
from opentelemetry.context import _SUPPRESS_INSTRUMENTATION_KEY
|
|
10
12
|
from opentelemetry.trace import NonRecordingSpan, SpanContext, TraceFlags
|
|
11
13
|
from opentelemetry.trace.status import StatusCode
|
|
12
14
|
|
|
@@ -78,6 +80,8 @@ def _opentelemetry_traced(
|
|
|
78
80
|
# --------- Sync wrapper ---------
|
|
79
81
|
@wraps(func)
|
|
80
82
|
def sync_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
83
|
+
if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
|
|
84
|
+
return func(*args, **kwargs)
|
|
81
85
|
span_cm, span = get_span()
|
|
82
86
|
try:
|
|
83
87
|
# Set input attributes BEFORE execution
|
|
@@ -113,6 +117,8 @@ def _opentelemetry_traced(
|
|
|
113
117
|
# --------- Async wrapper ---------
|
|
114
118
|
@wraps(func)
|
|
115
119
|
async def async_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
120
|
+
if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
|
|
121
|
+
return await func(*args, **kwargs)
|
|
116
122
|
span_cm, span = get_span()
|
|
117
123
|
try:
|
|
118
124
|
# Set input attributes BEFORE execution
|
|
@@ -148,6 +154,10 @@ def _opentelemetry_traced(
|
|
|
148
154
|
# --------- Generator wrapper ---------
|
|
149
155
|
@wraps(func)
|
|
150
156
|
def generator_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
157
|
+
if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
|
|
158
|
+
for item in func(*args, **kwargs):
|
|
159
|
+
yield item
|
|
160
|
+
return
|
|
151
161
|
span_cm, span = get_span()
|
|
152
162
|
try:
|
|
153
163
|
# Set input attributes BEFORE execution
|
|
@@ -186,6 +196,10 @@ def _opentelemetry_traced(
|
|
|
186
196
|
# --------- Async generator wrapper ---------
|
|
187
197
|
@wraps(func)
|
|
188
198
|
async def async_generator_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
199
|
+
if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
|
|
200
|
+
async for item in func(*args, **kwargs):
|
|
201
|
+
yield item
|
|
202
|
+
return
|
|
189
203
|
span_cm, span = get_span()
|
|
190
204
|
try:
|
|
191
205
|
# Set input attributes BEFORE execution
|
|
@@ -14,18 +14,18 @@ uipath/core/chat/meta.py,sha256=3t0eS9UHoAPHre97QTUeVbjDhnMX4zj4-qG6ju0B8wY,315
|
|
|
14
14
|
uipath/core/chat/tool.py,sha256=6e5pyX3hOWM5fIzr_fdG49Mbzz6XzJD3nsmha-yGa2k,2308
|
|
15
15
|
uipath/core/errors/__init__.py,sha256=gjxdLibZ0fjwgzPuLJY04P8dIX9rbSM2wQ97jP34ucE,278
|
|
16
16
|
uipath/core/errors/errors.py,sha256=5LajjuTfNW82ju07wT5mD3tXk0S-Ju7OqJqQpPN0F6g,486
|
|
17
|
-
uipath/core/guardrails/__init__.py,sha256=
|
|
18
|
-
uipath/core/guardrails/_deterministic_guardrails_service.py,sha256=
|
|
19
|
-
uipath/core/guardrails/_evaluators.py,sha256=
|
|
20
|
-
uipath/core/guardrails/guardrails.py,sha256=
|
|
17
|
+
uipath/core/guardrails/__init__.py,sha256=hUCmD4y5te2iy01YnJlBuf2RWvqxmsNzoyOamXLXf2E,1028
|
|
18
|
+
uipath/core/guardrails/_deterministic_guardrails_service.py,sha256=uX8f2HSGZ1bf5QFM9fnz0CvglxI3UIqY4OhHrKzemaU,5967
|
|
19
|
+
uipath/core/guardrails/_evaluators.py,sha256=ovmVm-8iB8Pm9arjG7mHM9-GIRkrG3V6oHRPHKxZVO0,14601
|
|
20
|
+
uipath/core/guardrails/guardrails.py,sha256=DraeFkoDKVDnc0EKdFYYP29lQu7U2hneTsj1dxveHU4,4935
|
|
21
21
|
uipath/core/tracing/__init__.py,sha256=1XNLYZ4J76XkRrizGO486mS6yxzVXUbrldpvxTyJe3E,483
|
|
22
22
|
uipath/core/tracing/_utils.py,sha256=FiCFGOFa4czruhlSF87Q5Q4jX9KKPHZiw8k14K7W5v4,6636
|
|
23
|
-
uipath/core/tracing/decorators.py,sha256=
|
|
23
|
+
uipath/core/tracing/decorators.py,sha256=nE57gAb5Ul6c3ep2Nkkqr40SO_eiCoJL8_4VQ0AiHjY,11643
|
|
24
24
|
uipath/core/tracing/exporters.py,sha256=FClouEEQfk3F8J7G_NFoarDJM3R0-gA5jUxA5xRHx5s,1562
|
|
25
25
|
uipath/core/tracing/processors.py,sha256=R_652rtjPmfpUtaXoIcmfZrRZylVXFRNwjOmJUUxOQw,1408
|
|
26
26
|
uipath/core/tracing/span_utils.py,sha256=WYBrd6ZbawAs7r1Js-Zvo9_8GzkD9LhHNOls00bK_xI,12235
|
|
27
27
|
uipath/core/tracing/trace_manager.py,sha256=51rscJcepkTK4bWoCZdE-DFc9wt2F-aSuFBaSXmkHl0,3130
|
|
28
|
-
uipath_core-0.1.
|
|
29
|
-
uipath_core-0.1.
|
|
30
|
-
uipath_core-0.1.
|
|
31
|
-
uipath_core-0.1.
|
|
28
|
+
uipath_core-0.1.7.dist-info/METADATA,sha256=vpXcfigfRmjzvhsyAm8fFs8dEu7BAJ6yAmv_ltKxhzY,938
|
|
29
|
+
uipath_core-0.1.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
30
|
+
uipath_core-0.1.7.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
|
|
31
|
+
uipath_core-0.1.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|