uipath 2.1.105__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/_cli/_debug/_bridge.py +181 -13
- uipath/_cli/_debug/_runtime.py +21 -5
- uipath/_cli/_runtime/_contracts.py +1 -0
- 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.105.dist-info → uipath-2.1.107.dist-info}/METADATA +1 -1
- {uipath-2.1.105.dist-info → uipath-2.1.107.dist-info}/RECORD +14 -13
- {uipath-2.1.105.dist-info → uipath-2.1.107.dist-info}/WHEEL +0 -0
- {uipath-2.1.105.dist-info → uipath-2.1.107.dist-info}/entry_points.txt +0 -0
- {uipath-2.1.105.dist-info → uipath-2.1.107.dist-info}/licenses/LICENSE +0 -0
uipath/_cli/_debug/_bridge.py
CHANGED
|
@@ -3,7 +3,8 @@ import json
|
|
|
3
3
|
import logging
|
|
4
4
|
import os
|
|
5
5
|
from abc import ABC, abstractmethod
|
|
6
|
-
from
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from typing import Any, Dict, List, Optional, Set
|
|
7
8
|
|
|
8
9
|
from pydantic import BaseModel
|
|
9
10
|
from pysignalr.client import SignalRClient
|
|
@@ -22,6 +23,50 @@ from uipath._events._events import UiPathAgentStateEvent
|
|
|
22
23
|
logger = logging.getLogger(__name__)
|
|
23
24
|
|
|
24
25
|
|
|
26
|
+
class DebuggerQuitException(Exception):
|
|
27
|
+
"""Raised when user quits the debugger."""
|
|
28
|
+
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class DebugCommand(str, Enum):
|
|
33
|
+
"""Available debug commands."""
|
|
34
|
+
|
|
35
|
+
CONTINUE = "continue"
|
|
36
|
+
STEP = "step"
|
|
37
|
+
BREAKPOINT = "breakpoint"
|
|
38
|
+
LIST_BREAKPOINTS = "list"
|
|
39
|
+
CLEAR_BREAKPOINT = "clear"
|
|
40
|
+
HELP = "help"
|
|
41
|
+
QUIT = "quit"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class DebuggerState:
|
|
45
|
+
"""Maintains debugger state across execution."""
|
|
46
|
+
|
|
47
|
+
def __init__(self):
|
|
48
|
+
self.breakpoints: Set[str] = set()
|
|
49
|
+
self.step_mode: bool = False
|
|
50
|
+
|
|
51
|
+
def add_breakpoint(self, node_name: str) -> None:
|
|
52
|
+
"""Add a breakpoint at a node."""
|
|
53
|
+
self.breakpoints.add(node_name)
|
|
54
|
+
|
|
55
|
+
def remove_breakpoint(self, node_name: str) -> None:
|
|
56
|
+
"""Remove a breakpoint from a node."""
|
|
57
|
+
self.breakpoints.discard(node_name)
|
|
58
|
+
|
|
59
|
+
def clear_all_breakpoints(self) -> None:
|
|
60
|
+
"""Clear all breakpoints."""
|
|
61
|
+
self.breakpoints.clear()
|
|
62
|
+
|
|
63
|
+
def should_break(self, node_name: str) -> bool:
|
|
64
|
+
"""Check if execution should break at this node."""
|
|
65
|
+
if self.step_mode:
|
|
66
|
+
return True
|
|
67
|
+
return node_name in self.breakpoints
|
|
68
|
+
|
|
69
|
+
|
|
25
70
|
class UiPathDebugBridge(ABC):
|
|
26
71
|
"""Abstract interface for debug communication.
|
|
27
72
|
|
|
@@ -77,6 +122,15 @@ class UiPathDebugBridge(ABC):
|
|
|
77
122
|
"""Wait for resume command from debugger."""
|
|
78
123
|
pass
|
|
79
124
|
|
|
125
|
+
@abstractmethod
|
|
126
|
+
def get_breakpoints(self) -> List[str]:
|
|
127
|
+
"""Get nodes to suspend execution at.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
List of node names to suspend at, or ["*"] for all nodes (step mode)
|
|
131
|
+
"""
|
|
132
|
+
pass
|
|
133
|
+
|
|
80
134
|
|
|
81
135
|
class ConsoleDebugBridge(UiPathDebugBridge):
|
|
82
136
|
"""Console-based debug bridge for local development."""
|
|
@@ -89,15 +143,12 @@ class ConsoleDebugBridge(UiPathDebugBridge):
|
|
|
89
143
|
"""
|
|
90
144
|
self.console = Console()
|
|
91
145
|
self.verbose = verbose
|
|
146
|
+
self.state = DebuggerState()
|
|
92
147
|
|
|
93
148
|
async def connect(self) -> None:
|
|
94
149
|
"""Connect to console debugger."""
|
|
95
150
|
self.console.print()
|
|
96
|
-
self.
|
|
97
|
-
self.console.print("[bold cyan]Debug Mode")
|
|
98
|
-
self.console.print("[dim]Press ENTER to continue | Type 'quit' to exit")
|
|
99
|
-
self.console.print("[bold cyan]─" * 40)
|
|
100
|
-
self.console.print()
|
|
151
|
+
self._print_help()
|
|
101
152
|
|
|
102
153
|
async def disconnect(self) -> None:
|
|
103
154
|
"""Cleanup."""
|
|
@@ -182,18 +233,128 @@ class ConsoleDebugBridge(UiPathDebugBridge):
|
|
|
182
233
|
|
|
183
234
|
async def wait_for_resume(self) -> Any:
|
|
184
235
|
"""Wait for user to press Enter or type commands."""
|
|
185
|
-
|
|
186
|
-
|
|
236
|
+
while True: # Keep looping until we get a resume command
|
|
237
|
+
self.console.print()
|
|
187
238
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
239
|
+
# Run input() in executor to not block async loop
|
|
240
|
+
loop = asyncio.get_running_loop()
|
|
241
|
+
user_input = await loop.run_in_executor(None, lambda: input("> "))
|
|
191
242
|
|
|
192
|
-
|
|
243
|
+
command_result = self._parse_command(user_input.strip())
|
|
244
|
+
|
|
245
|
+
# Handle commands that need another prompt
|
|
246
|
+
if command_result["command"] in [
|
|
247
|
+
DebugCommand.BREAKPOINT,
|
|
248
|
+
DebugCommand.LIST_BREAKPOINTS,
|
|
249
|
+
DebugCommand.CLEAR_BREAKPOINT,
|
|
250
|
+
DebugCommand.HELP,
|
|
251
|
+
]:
|
|
252
|
+
# These commands don't resume execution, loop again
|
|
253
|
+
continue
|
|
254
|
+
|
|
255
|
+
# Reset step modes if continuing
|
|
256
|
+
if command_result["command"] == DebugCommand.CONTINUE:
|
|
257
|
+
self.state.step_mode = False
|
|
258
|
+
|
|
259
|
+
if command_result["command"] == DebugCommand.QUIT:
|
|
260
|
+
raise DebuggerQuitException("User requested exit")
|
|
261
|
+
|
|
262
|
+
# Commands that resume execution: CONTINUE, STEP
|
|
263
|
+
self.console.print()
|
|
264
|
+
return command_result
|
|
265
|
+
|
|
266
|
+
def get_breakpoints(self) -> List[str]:
|
|
267
|
+
"""Get nodes to suspend execution at."""
|
|
268
|
+
if self.state.step_mode:
|
|
269
|
+
return ["*"] # Suspend at all nodes
|
|
270
|
+
return list(self.state.breakpoints) # Only suspend at breakpoints
|
|
271
|
+
|
|
272
|
+
def _parse_command(self, user_input: str) -> Dict[str, Any]:
|
|
273
|
+
"""Parse user command input.
|
|
274
|
+
|
|
275
|
+
Returns:
|
|
276
|
+
Dict with 'command' and optional 'args'
|
|
277
|
+
"""
|
|
278
|
+
if not user_input:
|
|
279
|
+
return {"command": DebugCommand.CONTINUE, "args": None}
|
|
280
|
+
|
|
281
|
+
parts = user_input.lower().split()
|
|
282
|
+
cmd = parts[0]
|
|
283
|
+
args = parts[1:] if len(parts) > 1 else []
|
|
284
|
+
|
|
285
|
+
if cmd in ["c", "continue"]:
|
|
286
|
+
return {"command": DebugCommand.CONTINUE, "args": None}
|
|
287
|
+
|
|
288
|
+
elif cmd in ["s", "step"]:
|
|
289
|
+
self.state.step_mode = True
|
|
290
|
+
return {"command": DebugCommand.STEP, "args": None}
|
|
291
|
+
|
|
292
|
+
elif cmd in ["b", "break", "breakpoint"]:
|
|
293
|
+
if not args:
|
|
294
|
+
self.console.print(
|
|
295
|
+
"[red]Error: breakpoint command requires a node name[/red]"
|
|
296
|
+
)
|
|
297
|
+
return {"command": DebugCommand.HELP, "args": None}
|
|
298
|
+
node_name = " ".join(args)
|
|
299
|
+
self.state.add_breakpoint(node_name)
|
|
300
|
+
self.console.print(f"[green]✓ Breakpoint set at: {node_name}[/green]")
|
|
301
|
+
return {"command": DebugCommand.BREAKPOINT, "args": {"node": node_name}}
|
|
302
|
+
|
|
303
|
+
elif cmd in ["l", "list"]:
|
|
304
|
+
self._list_breakpoints()
|
|
305
|
+
return {"command": DebugCommand.LIST_BREAKPOINTS, "args": None}
|
|
306
|
+
|
|
307
|
+
elif cmd in ["r", "remove", "delete"]:
|
|
308
|
+
if not args:
|
|
309
|
+
self.console.print("[yellow]Removing all breakpoints[/yellow]")
|
|
310
|
+
self.state.clear_all_breakpoints()
|
|
311
|
+
else:
|
|
312
|
+
node_name = " ".join(args)
|
|
313
|
+
self.state.remove_breakpoint(node_name)
|
|
314
|
+
self.console.print(f"[green]✓ Breakpoint removed: {node_name}[/green]")
|
|
315
|
+
return {
|
|
316
|
+
"command": DebugCommand.CLEAR_BREAKPOINT,
|
|
317
|
+
"args": {"node": " ".join(args) if args else None},
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
elif cmd in ["q", "quit", "exit"]:
|
|
193
321
|
raise KeyboardInterrupt("User requested exit")
|
|
194
322
|
|
|
323
|
+
elif cmd in ["h", "help", "?"]:
|
|
324
|
+
self._print_help()
|
|
325
|
+
return {"command": DebugCommand.HELP, "args": None}
|
|
326
|
+
|
|
327
|
+
else:
|
|
328
|
+
self.console.print(f"[red]Unknown command: {cmd}[/red]")
|
|
329
|
+
self.console.print("[dim]Type 'help' for available commands[/dim]")
|
|
330
|
+
return {"command": DebugCommand.HELP, "args": None}
|
|
331
|
+
|
|
332
|
+
def _list_breakpoints(self) -> None:
|
|
333
|
+
"""List all active breakpoints."""
|
|
334
|
+
if not self.state.breakpoints:
|
|
335
|
+
self.console.print("[dim]No breakpoints set[/dim]")
|
|
336
|
+
else:
|
|
337
|
+
self.console.print("[yellow]Active breakpoints:[/yellow]")
|
|
338
|
+
for i, bp in enumerate(sorted(self.state.breakpoints), 1):
|
|
339
|
+
self.console.print(f" {i}. [cyan]{bp}[/cyan]")
|
|
340
|
+
|
|
341
|
+
def _print_help(self) -> None:
|
|
342
|
+
"""Print available commands."""
|
|
343
|
+
self.console.print("[bold cyan]Debug Mode Commands[/bold cyan]")
|
|
344
|
+
self.console.print(
|
|
345
|
+
" [yellow]c, continue[/yellow] Continue until next breakpoint"
|
|
346
|
+
)
|
|
347
|
+
self.console.print(" [yellow]s, step[/yellow] Step to next node")
|
|
348
|
+
self.console.print(
|
|
349
|
+
" [yellow]b <node>[/yellow] Set breakpoint at <node>"
|
|
350
|
+
)
|
|
351
|
+
self.console.print(" [yellow]l, list[/yellow] List all breakpoints")
|
|
352
|
+
self.console.print(
|
|
353
|
+
" [yellow]r <node>[/yellow] Remove breakpoint at <node>"
|
|
354
|
+
)
|
|
355
|
+
self.console.print(" [yellow]h, help[/yellow] Show help")
|
|
356
|
+
self.console.print(" [yellow]q, quit[/yellow] Exit debugger")
|
|
195
357
|
self.console.print()
|
|
196
|
-
return user_input
|
|
197
358
|
|
|
198
359
|
def _print_json(self, data: Dict[str, Any], label: str = "data") -> None:
|
|
199
360
|
"""Print JSON data with enhanced hierarchy."""
|
|
@@ -289,6 +450,7 @@ class SignalRDebugBridge(UiPathDebugBridge):
|
|
|
289
450
|
self.hub_url = hub_url
|
|
290
451
|
self.access_token = access_token
|
|
291
452
|
self.headers = headers or {}
|
|
453
|
+
self.state = DebuggerState()
|
|
292
454
|
self._client: Optional[SignalRClient] = None
|
|
293
455
|
self._connected_event = asyncio.Event()
|
|
294
456
|
self._resume_event: Optional[asyncio.Event] = None
|
|
@@ -396,6 +558,12 @@ class SignalRDebugBridge(UiPathDebugBridge):
|
|
|
396
558
|
logger.info("Resume command received")
|
|
397
559
|
return self._resume_data
|
|
398
560
|
|
|
561
|
+
def get_breakpoints(self) -> List[str]:
|
|
562
|
+
"""Get nodes to suspend execution at."""
|
|
563
|
+
if self.state.step_mode:
|
|
564
|
+
return ["*"] # Suspend at all nodes
|
|
565
|
+
return list(self.state.breakpoints) # Only suspend at breakpoints
|
|
566
|
+
|
|
399
567
|
async def _send(self, method: str, data: Dict[str, Any]) -> None:
|
|
400
568
|
"""Send message to SignalR hub."""
|
|
401
569
|
if not self._client:
|
uipath/_cli/_debug/_runtime.py
CHANGED
|
@@ -11,9 +11,10 @@ from .._runtime._contracts import (
|
|
|
11
11
|
UiPathRuntimeContext,
|
|
12
12
|
UiPathRuntimeFactory,
|
|
13
13
|
UiPathRuntimeResult,
|
|
14
|
+
UiPathRuntimeStatus,
|
|
14
15
|
UiPathRuntimeStreamNotSupportedError,
|
|
15
16
|
)
|
|
16
|
-
from ._bridge import UiPathDebugBridge
|
|
17
|
+
from ._bridge import DebuggerQuitException, UiPathDebugBridge
|
|
17
18
|
|
|
18
19
|
logger = logging.getLogger(__name__)
|
|
19
20
|
|
|
@@ -91,8 +92,15 @@ class UiPathDebugRuntime(UiPathBaseRuntime, Generic[T, C]):
|
|
|
91
92
|
final_result: Optional[UiPathRuntimeResult] = None
|
|
92
93
|
execution_completed = False
|
|
93
94
|
|
|
95
|
+
# Starting in paused state - wait for breakpoints and resume
|
|
96
|
+
await self.debug_bridge.wait_for_resume()
|
|
97
|
+
|
|
94
98
|
# Keep streaming until execution completes (not just paused at breakpoint)
|
|
95
99
|
while not execution_completed:
|
|
100
|
+
# Update breakpoints from debug bridge
|
|
101
|
+
self._inner_runtime.context.breakpoints = (
|
|
102
|
+
self.debug_bridge.get_breakpoints()
|
|
103
|
+
)
|
|
96
104
|
# Stream events from inner runtime
|
|
97
105
|
async for event in self._inner_runtime.stream():
|
|
98
106
|
# Handle final result
|
|
@@ -101,10 +109,18 @@ class UiPathDebugRuntime(UiPathBaseRuntime, Generic[T, C]):
|
|
|
101
109
|
|
|
102
110
|
# Check if it's a breakpoint result
|
|
103
111
|
if isinstance(event, UiPathBreakpointResult):
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
try:
|
|
113
|
+
# Hit a breakpoint - wait for resume and continue
|
|
114
|
+
await self.debug_bridge.emit_breakpoint_hit(event)
|
|
115
|
+
await self.debug_bridge.wait_for_resume()
|
|
116
|
+
|
|
117
|
+
self._inner_runtime.context.resume = True
|
|
118
|
+
|
|
119
|
+
except DebuggerQuitException:
|
|
120
|
+
final_result = UiPathRuntimeResult(
|
|
121
|
+
status=UiPathRuntimeStatus.SUCCESSFUL,
|
|
122
|
+
)
|
|
123
|
+
execution_completed = True
|
|
108
124
|
else:
|
|
109
125
|
# Normal completion or suspension with dynamic interrupt
|
|
110
126
|
execution_completed = True
|
|
@@ -382,6 +382,7 @@ class UiPathRuntimeContext(BaseModel):
|
|
|
382
382
|
log_handler: Optional[logging.Handler] = None
|
|
383
383
|
chat_handler: Optional[UiPathConversationHandler] = None
|
|
384
384
|
is_conversational: Optional[bool] = None
|
|
385
|
+
breakpoints: Optional[List[str]] = None
|
|
385
386
|
|
|
386
387
|
model_config = {"arbitrary_types_allowed": True, "extra": "allow"}
|
|
387
388
|
|
|
@@ -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
|
|
@@ -32,8 +32,8 @@ uipath/_cli/_auth/auth_config.json,sha256=o8J5BBFwiEtjZLHpJ_64lvnTeYeRIHaJ-Bhg0Q
|
|
|
32
32
|
uipath/_cli/_auth/index.html,sha256=uGK0CDTP8Rys_p4O_Pbd2x4tz0frKNVcumjrXnal5Nc,22814
|
|
33
33
|
uipath/_cli/_auth/localhost.crt,sha256=oGl9oLLOiouHubAt39B4zEfylFvKEtbtr_43SIliXJc,1226
|
|
34
34
|
uipath/_cli/_auth/localhost.key,sha256=X31VYXD8scZtmGA837dGX5l6G-LXHLo5ItWJhZXaz3c,1679
|
|
35
|
-
uipath/_cli/_debug/_bridge.py,sha256=
|
|
36
|
-
uipath/_cli/_debug/_runtime.py,sha256=
|
|
35
|
+
uipath/_cli/_debug/_bridge.py,sha256=_CArFkZlwBYUkmpfqehcXyPNVDXv00vPNFfKJiOVJoA,22269
|
|
36
|
+
uipath/_cli/_debug/_runtime.py,sha256=iQ0L7WVvh0eF85D6sckZTTjE5wc_KQjCncT23hEdC6k,5596
|
|
37
37
|
uipath/_cli/_dev/_terminal/__init__.py,sha256=di_RiN9Mcp9wqyKRRqXag28vbSw8_78mCnQZNn9H-Ss,14027
|
|
38
38
|
uipath/_cli/_dev/_terminal/_components/_chat.py,sha256=NLRoy49QScHiI-q0FGykkaU8ajv1d23fx7issSALcFA,4119
|
|
39
39
|
uipath/_cli/_dev/_terminal/_components/_details.py,sha256=FbLYtJ56gqHV6CIrpzO_n9Sk_YNg4nzRKTSsbj-DBPQ,17257
|
|
@@ -68,7 +68,7 @@ uipath/_cli/_evals/mocks/mocker_factory.py,sha256=V5QKSTtQxztTo4-fK1TyAaXw2Z3mHf
|
|
|
68
68
|
uipath/_cli/_evals/mocks/mockito_mocker.py,sha256=AO2BmFwA6hz3Lte-STVr7aJDPvMCqKNKa4j2jeNZ_U4,2677
|
|
69
69
|
uipath/_cli/_evals/mocks/mocks.py,sha256=HY0IaSqqO8hioBB3rp5XwAjSpQE4K5hoH6oJQ-sH72I,2207
|
|
70
70
|
uipath/_cli/_push/sw_file_handler.py,sha256=DrGOpX7-dodrROh7YcjHlCBUuOEdVMh8o0550TL-ZYA,22520
|
|
71
|
-
uipath/_cli/_runtime/_contracts.py,sha256=
|
|
71
|
+
uipath/_cli/_runtime/_contracts.py,sha256=DvpDLkmCESMID2S_ryUu7Y1N26-QIRrDNgk-pPGoOSU,35697
|
|
72
72
|
uipath/_cli/_runtime/_escalation.py,sha256=x3vI98qsfRA-fL_tNkRVTFXioM5Gv2w0GFcXJJ5eQtg,7981
|
|
73
73
|
uipath/_cli/_runtime/_hitl.py,sha256=JAwTUKvxO4HpnZMwE4E0AegAPw_uYOwgt0OYcu6EvTg,11474
|
|
74
74
|
uipath/_cli/_runtime/_logging.py,sha256=srjAi3Cy6g7b8WNHiYNjaZT4t40F3XRqquuoGd2kh4Y,14019
|
|
@@ -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
|