uipath 2.1.89__py3-none-any.whl → 2.1.91__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/_evals/_runtime.py +4 -4
- uipath/_cli/_evals/mocks/llm_mocker.py +8 -3
- uipath/_cli/_evals/mocks/mocks.py +8 -1
- uipath/_cli/_push/sw_file_handler.py +3 -3
- uipath/_cli/_utils/_parse_ast.py +58 -32
- uipath/_cli/_utils/_project_files.py +8 -10
- uipath/_cli/cli_init.py +58 -40
- uipath/_cli/cli_pack.py +13 -11
- uipath/_cli/cli_push.py +4 -4
- uipath/_cli/models/__init__.py +0 -0
- uipath/_cli/models/runtime_schema.py +71 -0
- uipath/_resources/AGENTS.md +2 -20
- uipath/_resources/REQUIRED_STRUCTURE.md +23 -52
- uipath/_resources/SDK_REFERENCE.md +1 -1
- uipath/agent/models/agent.py +227 -55
- uipath/agent/models/evals.py +56 -0
- uipath/telemetry/_track.py +1 -0
- {uipath-2.1.89.dist-info → uipath-2.1.91.dist-info}/METADATA +1 -1
- {uipath-2.1.89.dist-info → uipath-2.1.91.dist-info}/RECORD +22 -19
- {uipath-2.1.89.dist-info → uipath-2.1.91.dist-info}/WHEEL +0 -0
- {uipath-2.1.89.dist-info → uipath-2.1.91.dist-info}/entry_points.txt +0 -0
- {uipath-2.1.89.dist-info → uipath-2.1.91.dist-info}/licenses/LICENSE +0 -0
uipath/_resources/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent Code Patterns Reference
|
|
2
2
|
|
|
3
|
-
This document provides practical code patterns for building UiPath coded agents using
|
|
3
|
+
This document provides practical code patterns for building UiPath coded agents using the UiPath Python SDK.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -8,32 +8,14 @@ This document provides practical code patterns for building UiPath coded agents
|
|
|
8
8
|
|
|
9
9
|
This documentation is split into multiple files for efficient context loading. Load only the files you need:
|
|
10
10
|
|
|
11
|
-
### Core Documentation Files
|
|
12
|
-
|
|
13
11
|
1. **@.agent/REQUIRED_STRUCTURE.md** - Agent structure patterns and templates
|
|
14
12
|
- **When to load:** Creating a new agent or understanding required patterns
|
|
15
|
-
- **Contains:** Required Pydantic models (Input,
|
|
16
|
-
- **Size:** ~90 lines
|
|
13
|
+
- **Contains:** Required Pydantic models (Input, Output), SDK initialization patterns, standard agent template
|
|
17
14
|
|
|
18
15
|
2. **@.agent/SDK_REFERENCE.md** - Complete SDK API reference
|
|
19
16
|
- **When to load:** Calling UiPath SDK methods, working with services (actions, assets, jobs, etc.)
|
|
20
17
|
- **Contains:** All SDK services and methods with full signatures and type annotations
|
|
21
|
-
- **Size:** ~400 lines
|
|
22
18
|
|
|
23
19
|
3. **@.agent/CLI_REFERENCE.md** - CLI commands documentation
|
|
24
20
|
- **When to load:** Working with `uipath init`, `uipath run`, or `uipath eval` commands
|
|
25
21
|
- **Contains:** Command syntax, options, usage examples, and workflows
|
|
26
|
-
- **Size:** ~200 lines
|
|
27
|
-
|
|
28
|
-
### Usage Guidelines
|
|
29
|
-
|
|
30
|
-
**For LLMs:**
|
|
31
|
-
- Read this file (AGENTS.md) first to understand the documentation structure
|
|
32
|
-
- Load .agent/REQUIRED_STRUCTURE.md when building new agents or need structure reference
|
|
33
|
-
- Load .agent/SDK_REFERENCE.md only when you need to call specific SDK methods
|
|
34
|
-
- Load .agent/CLI_REFERENCE.md only when working with CLI commands
|
|
35
|
-
|
|
36
|
-
**Benefits:**
|
|
37
|
-
- Reduced token usage by loading only relevant context
|
|
38
|
-
- Faster response times
|
|
39
|
-
- More focused context for specific tasks
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
### Required Components
|
|
6
6
|
|
|
7
|
-
Every agent implementation MUST include these
|
|
7
|
+
Every agent implementation MUST include these two Pydantic models:
|
|
8
8
|
|
|
9
9
|
```python
|
|
10
10
|
from pydantic import BaseModel
|
|
@@ -14,80 +14,51 @@ class Input(BaseModel):
|
|
|
14
14
|
# Add your input fields here
|
|
15
15
|
pass
|
|
16
16
|
|
|
17
|
-
class State(BaseModel):
|
|
18
|
-
"""Define the agent's internal state that flows between nodes"""
|
|
19
|
-
# Add your state fields here
|
|
20
|
-
pass
|
|
21
|
-
|
|
22
17
|
class Output(BaseModel):
|
|
23
18
|
"""Define output fields that the agent returns"""
|
|
24
19
|
# Add your output fields here
|
|
25
20
|
pass
|
|
26
21
|
```
|
|
27
22
|
|
|
28
|
-
###
|
|
29
|
-
|
|
30
|
-
Unless the user explicitly requests a different LLM provider, always use `UiPathChat`:
|
|
23
|
+
### SDK Initialization
|
|
31
24
|
|
|
32
25
|
```python
|
|
33
|
-
from
|
|
26
|
+
from uipath import UiPath
|
|
34
27
|
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
# Initialize with environment variables
|
|
29
|
+
uipath = UiPath()
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
# With explicit credentials
|
|
32
|
+
uipath = UiPath(base_url="https://cloud.uipath.com/...", secret="your_token")
|
|
33
|
+
|
|
34
|
+
# Or with client_id and client_secret
|
|
35
|
+
uipath = UiPath(
|
|
36
|
+
client_id=UIPATH_CLIENT_ID,
|
|
37
|
+
client_secret=UIPATH_CLIENT_SECRET,
|
|
38
|
+
scope=UIPATH_SCOPE,
|
|
39
|
+
base_url=UIPATH_URL
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
42
|
|
|
43
43
|
### Standard Agent Template
|
|
44
44
|
|
|
45
45
|
Every agent should follow this basic structure:
|
|
46
46
|
|
|
47
47
|
```python
|
|
48
|
-
from
|
|
49
|
-
from langgraph.graph import START, StateGraph, END
|
|
50
|
-
from uipath_langchain.chat import UiPathChat
|
|
48
|
+
from uipath import UiPath
|
|
51
49
|
from pydantic import BaseModel
|
|
52
50
|
|
|
53
|
-
# 1. Define Input,
|
|
51
|
+
# 1. Define Input, and Output models
|
|
54
52
|
class Input(BaseModel):
|
|
55
53
|
field: str
|
|
56
54
|
|
|
57
|
-
class State(BaseModel):
|
|
58
|
-
field: str
|
|
59
|
-
result: str = ""
|
|
60
|
-
|
|
61
55
|
class Output(BaseModel):
|
|
62
56
|
result: str
|
|
63
57
|
|
|
64
|
-
# 2. Initialize
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
# 3. Define agent nodes (async functions)
|
|
68
|
-
async def process_node(state: State) -> State:
|
|
69
|
-
response = await llm.ainvoke([HumanMessage(state.field)])
|
|
70
|
-
return State(field=state.field, result=response.content)
|
|
71
|
-
|
|
72
|
-
async def output_node(state: State) -> Output:
|
|
73
|
-
return Output(result=state.result)
|
|
58
|
+
# 2. Initialize with environment variables
|
|
59
|
+
uipath = UiPath()
|
|
74
60
|
|
|
75
|
-
#
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
builder.add_node("output", output_node)
|
|
79
|
-
builder.add_edge(START, "process")
|
|
80
|
-
builder.add_edge("process", "output")
|
|
81
|
-
builder.add_edge("output", END)
|
|
82
|
-
|
|
83
|
-
# 5. Compile the graph
|
|
84
|
-
graph = builder.compile()
|
|
61
|
+
# 3. Define the main function (the main function can be named "main", "run" or "execute")
|
|
62
|
+
def main(input_data: Input) -> Output:
|
|
63
|
+
pass
|
|
85
64
|
```
|
|
86
|
-
|
|
87
|
-
**Key Rules**:
|
|
88
|
-
1. Always use async/await for all node functions
|
|
89
|
-
2. All nodes (except output) must accept and return `State`
|
|
90
|
-
3. The final output node must return `Output`
|
|
91
|
-
4. Use `StateGraph(State, input=Input, output=Output)` for initialization
|
|
92
|
-
5. Always compile with `graph = builder.compile()`
|
|
93
|
-
|
uipath/agent/models/agent.py
CHANGED
|
@@ -3,11 +3,8 @@
|
|
|
3
3
|
from enum import Enum
|
|
4
4
|
from typing import Annotated, Any, Dict, List, Literal, Optional, Union
|
|
5
5
|
|
|
6
|
-
from pydantic import BaseModel, ConfigDict, Discriminator, Field, Tag
|
|
6
|
+
from pydantic import BaseModel, ConfigDict, Discriminator, Field, Tag, field_validator
|
|
7
7
|
|
|
8
|
-
from uipath._cli._evals._models._evaluation_set import EvaluationSet
|
|
9
|
-
from uipath._cli._evals._models._evaluator import Evaluator
|
|
10
|
-
from uipath._cli._evals._models._mocks import ExampleCall
|
|
11
8
|
from uipath.models import Connection
|
|
12
9
|
|
|
13
10
|
|
|
@@ -17,6 +14,7 @@ class AgentResourceType(str, Enum):
|
|
|
17
14
|
TOOL = "tool"
|
|
18
15
|
CONTEXT = "context"
|
|
19
16
|
ESCALATION = "escalation"
|
|
17
|
+
MCP = "mcp"
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
class BaseAgentResourceConfig(BaseModel):
|
|
@@ -55,12 +53,14 @@ class AgentToolType(str, Enum):
|
|
|
55
53
|
"""Agent tool type."""
|
|
56
54
|
|
|
57
55
|
AGENT = "agent"
|
|
58
|
-
INTEGRATION = "integration"
|
|
59
56
|
PROCESS = "process"
|
|
57
|
+
API = "api"
|
|
58
|
+
PROCESS_ORCHESTRATION = "processorchestration"
|
|
59
|
+
INTEGRATION = "integration"
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
class AgentToolSettings(BaseModel):
|
|
63
|
-
"""Settings for tool
|
|
63
|
+
"""Settings for tool."""
|
|
64
64
|
|
|
65
65
|
max_attempts: Optional[int] = Field(None, alias="maxAttempts")
|
|
66
66
|
retry_delay: Optional[int] = Field(None, alias="retryDelay")
|
|
@@ -74,7 +74,9 @@ class AgentToolSettings(BaseModel):
|
|
|
74
74
|
class BaseResourceProperties(BaseModel):
|
|
75
75
|
"""Base resource properties."""
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
model_config = ConfigDict(
|
|
78
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
79
|
+
)
|
|
78
80
|
|
|
79
81
|
|
|
80
82
|
class AgentProcessToolProperties(BaseResourceProperties):
|
|
@@ -91,7 +93,12 @@ class AgentProcessToolProperties(BaseResourceProperties):
|
|
|
91
93
|
class AgentProcessToolResourceConfig(BaseAgentToolResourceConfig):
|
|
92
94
|
"""Tool resource with tool-specific properties."""
|
|
93
95
|
|
|
94
|
-
type: Literal[
|
|
96
|
+
type: Literal[
|
|
97
|
+
AgentToolType.AGENT,
|
|
98
|
+
AgentToolType.PROCESS,
|
|
99
|
+
AgentToolType.API,
|
|
100
|
+
AgentToolType.PROCESS_ORCHESTRATION,
|
|
101
|
+
]
|
|
95
102
|
output_schema: Dict[str, Any] = Field(
|
|
96
103
|
..., alias="outputSchema", description="Output schema for the tool"
|
|
97
104
|
)
|
|
@@ -101,6 +108,17 @@ class AgentProcessToolResourceConfig(BaseAgentToolResourceConfig):
|
|
|
101
108
|
settings: AgentToolSettings = Field(
|
|
102
109
|
default_factory=AgentToolSettings, description="Tool settings"
|
|
103
110
|
)
|
|
111
|
+
arguments: Dict[str, Any] = Field(
|
|
112
|
+
default_factory=dict, description="Tool arguments"
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
@field_validator("type", mode="before")
|
|
116
|
+
@classmethod
|
|
117
|
+
def normalize_type(cls, v: Any) -> str:
|
|
118
|
+
"""Normalize tool type to lowercase format."""
|
|
119
|
+
if isinstance(v, str):
|
|
120
|
+
return v.lower()
|
|
121
|
+
return v
|
|
104
122
|
|
|
105
123
|
model_config = ConfigDict(
|
|
106
124
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
@@ -133,7 +151,7 @@ class AgentIntegrationToolParameter(BaseModel):
|
|
|
133
151
|
|
|
134
152
|
|
|
135
153
|
class AgentIntegrationToolProperties(BaseResourceProperties):
|
|
136
|
-
"""Properties specific to tool
|
|
154
|
+
"""Properties specific to tool."""
|
|
137
155
|
|
|
138
156
|
tool_path: str = Field(..., alias="toolPath")
|
|
139
157
|
object_name: str = Field(..., alias="objectName")
|
|
@@ -141,7 +159,7 @@ class AgentIntegrationToolProperties(BaseResourceProperties):
|
|
|
141
159
|
tool_description: str = Field(..., alias="toolDescription")
|
|
142
160
|
method: str = Field(..., alias="method")
|
|
143
161
|
connection: Connection = Field(..., alias="connection")
|
|
144
|
-
body_structure: dict[str, Any] = Field(
|
|
162
|
+
body_structure: Optional[dict[str, Any]] = Field(None, alias="bodyStructure")
|
|
145
163
|
parameters: List[AgentIntegrationToolParameter] = Field([], alias="parameters")
|
|
146
164
|
|
|
147
165
|
model_config = ConfigDict(
|
|
@@ -154,26 +172,93 @@ class AgentIntegrationToolResourceConfig(BaseAgentToolResourceConfig):
|
|
|
154
172
|
|
|
155
173
|
type: Literal[AgentToolType.INTEGRATION] = AgentToolType.INTEGRATION
|
|
156
174
|
properties: AgentIntegrationToolProperties
|
|
175
|
+
arguments: Optional[Dict[str, Any]] = Field(
|
|
176
|
+
default_factory=dict, description="Tool arguments"
|
|
177
|
+
)
|
|
178
|
+
is_enabled: Optional[bool] = Field(None, alias="isEnabled")
|
|
179
|
+
|
|
180
|
+
@field_validator("type", mode="before")
|
|
181
|
+
@classmethod
|
|
182
|
+
def normalize_type(cls, v: Any) -> str:
|
|
183
|
+
"""Normalize tool type to lowercase format."""
|
|
184
|
+
if isinstance(v, str):
|
|
185
|
+
return v.lower()
|
|
186
|
+
return v
|
|
187
|
+
|
|
157
188
|
model_config = ConfigDict(
|
|
158
189
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
159
190
|
)
|
|
160
191
|
|
|
161
192
|
|
|
162
|
-
class AgentUnknownToolResourceConfig(
|
|
193
|
+
class AgentUnknownToolResourceConfig(BaseAgentResourceConfig):
|
|
163
194
|
"""Fallback for unknown or future tool types."""
|
|
164
195
|
|
|
165
196
|
resource_type: Literal[AgentResourceType.TOOL] = AgentResourceType.TOOL
|
|
166
197
|
type: str = Field(alias="$resourceType")
|
|
198
|
+
arguments: Optional[Dict[str, Any]] = Field(
|
|
199
|
+
default_factory=dict, description="Tool arguments"
|
|
200
|
+
)
|
|
201
|
+
is_enabled: Optional[bool] = Field(None, alias="isEnabled")
|
|
167
202
|
|
|
168
203
|
model_config = ConfigDict(extra="allow")
|
|
169
204
|
|
|
170
205
|
|
|
206
|
+
class AgentContextQuerySetting(BaseModel):
|
|
207
|
+
"""Query setting for context configuration."""
|
|
208
|
+
|
|
209
|
+
description: Optional[str] = Field(None)
|
|
210
|
+
variant: Optional[str] = Field(None)
|
|
211
|
+
|
|
212
|
+
model_config = ConfigDict(
|
|
213
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class AgentContextValueSetting(BaseModel):
|
|
218
|
+
"""Generic value setting for context configuration."""
|
|
219
|
+
|
|
220
|
+
value: Any = Field(...)
|
|
221
|
+
|
|
222
|
+
model_config = ConfigDict(
|
|
223
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class AgentContextOutputColumn(BaseModel):
|
|
228
|
+
"""Output column configuration for Batch Transform."""
|
|
229
|
+
|
|
230
|
+
name: str = Field(...)
|
|
231
|
+
description: Optional[str] = Field(None)
|
|
232
|
+
|
|
233
|
+
model_config = ConfigDict(
|
|
234
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
|
|
171
238
|
class AgentContextSettings(BaseModel):
|
|
172
|
-
"""Settings for context
|
|
239
|
+
"""Settings for context."""
|
|
173
240
|
|
|
174
241
|
result_count: int = Field(alias="resultCount")
|
|
175
|
-
retrieval_mode: Literal["Semantic", "Structured"] =
|
|
242
|
+
retrieval_mode: Literal["Semantic", "Structured", "DeepRAG", "BatchTransform"] = (
|
|
243
|
+
Field(alias="retrievalMode")
|
|
244
|
+
)
|
|
176
245
|
threshold: float = Field(default=0)
|
|
246
|
+
query: Optional[AgentContextQuerySetting] = Field(None)
|
|
247
|
+
folder_path_prefix: Optional[Union[Dict[str, Any], AgentContextValueSetting]] = (
|
|
248
|
+
Field(None, alias="folderPathPrefix")
|
|
249
|
+
)
|
|
250
|
+
file_extension: Optional[Union[Dict[str, Any], AgentContextValueSetting]] = Field(
|
|
251
|
+
None, alias="fileExtension"
|
|
252
|
+
)
|
|
253
|
+
citation_mode: Optional[AgentContextValueSetting] = Field(
|
|
254
|
+
None, alias="citationMode"
|
|
255
|
+
)
|
|
256
|
+
web_search_grounding: Optional[AgentContextValueSetting] = Field(
|
|
257
|
+
None, alias="webSearchGrounding"
|
|
258
|
+
)
|
|
259
|
+
output_columns: Optional[List[AgentContextOutputColumn]] = Field(
|
|
260
|
+
None, alias="outputColumns"
|
|
261
|
+
)
|
|
177
262
|
|
|
178
263
|
model_config = ConfigDict(
|
|
179
264
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
@@ -187,19 +272,67 @@ class AgentContextResourceConfig(BaseAgentResourceConfig):
|
|
|
187
272
|
folder_path: str = Field(alias="folderPath")
|
|
188
273
|
index_name: str = Field(alias="indexName")
|
|
189
274
|
settings: AgentContextSettings = Field(..., description="Context settings")
|
|
275
|
+
is_enabled: Optional[bool] = Field(None, alias="isEnabled")
|
|
276
|
+
|
|
277
|
+
model_config = ConfigDict(
|
|
278
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
class AgentMcpTool(BaseModel):
|
|
283
|
+
"""MCP available tool."""
|
|
284
|
+
|
|
285
|
+
name: str = Field(..., alias="name")
|
|
286
|
+
description: str = Field(..., alias="description")
|
|
287
|
+
input_schema: Dict[str, Any] = Field(..., alias="inputSchema")
|
|
190
288
|
|
|
191
289
|
model_config = ConfigDict(
|
|
192
290
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
193
291
|
)
|
|
194
292
|
|
|
195
293
|
|
|
294
|
+
class AgentMcpResourceConfig(BaseAgentResourceConfig):
|
|
295
|
+
"""MCP resource configuration."""
|
|
296
|
+
|
|
297
|
+
resource_type: Literal[AgentResourceType.MCP] = Field(alias="$resourceType")
|
|
298
|
+
folder_path: str = Field(alias="folderPath")
|
|
299
|
+
slug: str = Field(..., alias="slug")
|
|
300
|
+
available_tools: List[AgentMcpTool] = Field(..., alias="availableTools")
|
|
301
|
+
is_enabled: Optional[bool] = Field(None, alias="isEnabled")
|
|
302
|
+
|
|
303
|
+
model_config = ConfigDict(
|
|
304
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
class AgentEscalationRecipientType(str, Enum):
|
|
309
|
+
"""Enum for escalation recipient types."""
|
|
310
|
+
|
|
311
|
+
USER_ID = "UserId"
|
|
312
|
+
GROUP_ID = "GroupId"
|
|
313
|
+
USER_EMAIL = "UserEmail"
|
|
314
|
+
|
|
315
|
+
|
|
196
316
|
class AgentEscalationRecipient(BaseModel):
|
|
197
317
|
"""Recipient for escalation."""
|
|
198
318
|
|
|
199
|
-
type:
|
|
319
|
+
type: Union[AgentEscalationRecipientType, str] = Field(..., alias="type")
|
|
200
320
|
value: str = Field(..., alias="value")
|
|
201
321
|
display_name: Optional[str] = Field(default=None, alias="displayName")
|
|
202
322
|
|
|
323
|
+
@field_validator("type", mode="before")
|
|
324
|
+
@classmethod
|
|
325
|
+
def normalize_type(cls, v: Any) -> str:
|
|
326
|
+
"""Normalize recipient type from int (1=UserId, 2=GroupId, 3=UserEmail) or string. Unknown integers are converted to string."""
|
|
327
|
+
if isinstance(v, int):
|
|
328
|
+
mapping = {
|
|
329
|
+
1: AgentEscalationRecipientType.USER_ID,
|
|
330
|
+
2: AgentEscalationRecipientType.GROUP_ID,
|
|
331
|
+
3: AgentEscalationRecipientType.USER_EMAIL,
|
|
332
|
+
}
|
|
333
|
+
return mapping.get(v, str(v))
|
|
334
|
+
return v
|
|
335
|
+
|
|
203
336
|
model_config = ConfigDict(
|
|
204
337
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
205
338
|
)
|
|
@@ -227,7 +360,7 @@ class AgentEscalationChannelProperties(BaseResourceProperties):
|
|
|
227
360
|
class AgentEscalationChannel(BaseModel):
|
|
228
361
|
"""Agent escalation channel."""
|
|
229
362
|
|
|
230
|
-
id: str = Field(
|
|
363
|
+
id: Optional[str] = Field(None, alias="id")
|
|
231
364
|
name: str = Field(..., alias="name")
|
|
232
365
|
type: str = Field(alias="type")
|
|
233
366
|
description: str = Field(..., alias="description")
|
|
@@ -239,8 +372,12 @@ class AgentEscalationChannel(BaseModel):
|
|
|
239
372
|
alias="outputSchema",
|
|
240
373
|
description="Output schema for the escalation channel",
|
|
241
374
|
)
|
|
375
|
+
outcome_mapping: Optional[Dict[str, str]] = Field(None, alias="outcomeMapping")
|
|
242
376
|
properties: AgentEscalationChannelProperties = Field(..., alias="properties")
|
|
243
377
|
recipients: List[AgentEscalationRecipient] = Field(..., alias="recipients")
|
|
378
|
+
task_title: Optional[str] = Field(default=None, alias="taskTitle")
|
|
379
|
+
priority: Optional[str] = None
|
|
380
|
+
labels: List[str] = Field(default_factory=list)
|
|
244
381
|
|
|
245
382
|
model_config = ConfigDict(
|
|
246
383
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
@@ -250,11 +387,11 @@ class AgentEscalationChannel(BaseModel):
|
|
|
250
387
|
class AgentEscalationResourceConfig(BaseAgentResourceConfig):
|
|
251
388
|
"""Escalation resource with escalation-specific properties."""
|
|
252
389
|
|
|
390
|
+
id: Optional[str] = Field(None, alias="id")
|
|
253
391
|
resource_type: Literal[AgentResourceType.ESCALATION] = Field(alias="$resourceType")
|
|
254
392
|
channels: List[AgentEscalationChannel] = Field(alias="channels")
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
is_agent_memory_enabled: bool = Field(alias="isAgentMemoryEnabled")
|
|
393
|
+
is_agent_memory_enabled: bool = Field(default=False, alias="isAgentMemoryEnabled")
|
|
394
|
+
escalation_type: int = Field(default=0, alias="escalationType")
|
|
258
395
|
|
|
259
396
|
model_config = ConfigDict(
|
|
260
397
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
@@ -269,9 +406,16 @@ def custom_discriminator(data: Any) -> str:
|
|
|
269
406
|
return "AgentContextResourceConfig"
|
|
270
407
|
elif resource_type == AgentResourceType.ESCALATION:
|
|
271
408
|
return "AgentEscalationResourceConfig"
|
|
409
|
+
elif resource_type == AgentResourceType.MCP:
|
|
410
|
+
return "AgentMcpResourceConfig"
|
|
272
411
|
elif resource_type == AgentResourceType.TOOL:
|
|
273
412
|
tool_type = data.get("type")
|
|
274
|
-
if tool_type
|
|
413
|
+
if tool_type in [
|
|
414
|
+
AgentToolType.AGENT,
|
|
415
|
+
AgentToolType.PROCESS,
|
|
416
|
+
AgentToolType.API,
|
|
417
|
+
AgentToolType.PROCESS_ORCHESTRATION,
|
|
418
|
+
]:
|
|
275
419
|
return "AgentProcessToolResourceConfig"
|
|
276
420
|
elif tool_type == AgentToolType.INTEGRATION:
|
|
277
421
|
return "AgentIntegrationToolResourceConfig"
|
|
@@ -296,47 +440,24 @@ AgentResourceConfig = Annotated[
|
|
|
296
440
|
],
|
|
297
441
|
Annotated[AgentContextResourceConfig, Tag("AgentContextResourceConfig")],
|
|
298
442
|
Annotated[AgentEscalationResourceConfig, Tag("AgentEscalationResourceConfig")],
|
|
443
|
+
Annotated[AgentMcpResourceConfig, Tag("AgentMcpResourceConfig")],
|
|
299
444
|
Annotated[AgentUnknownResourceConfig, Tag("AgentUnknownResourceConfig")],
|
|
300
445
|
],
|
|
301
446
|
Field(discriminator=Discriminator(custom_discriminator)),
|
|
302
447
|
]
|
|
303
448
|
|
|
304
449
|
|
|
305
|
-
class
|
|
306
|
-
"""
|
|
450
|
+
class AgentMetadata(BaseModel):
|
|
451
|
+
"""Metadata for agent."""
|
|
307
452
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
input_schema: Dict[str, Any] = Field(
|
|
311
|
-
..., alias="inputSchema", description="JSON schema for input arguments"
|
|
312
|
-
)
|
|
313
|
-
output_schema: Dict[str, Any] = Field(
|
|
314
|
-
..., alias="outputSchema", description="JSON schema for output arguments"
|
|
315
|
-
)
|
|
316
|
-
version: str = Field("1.0.0", description="Agent version")
|
|
317
|
-
resources: List[AgentResourceConfig] = Field(
|
|
318
|
-
..., description="List of tools, context, and escalation resources"
|
|
319
|
-
)
|
|
320
|
-
evaluation_sets: Optional[List[EvaluationSet]] = Field(
|
|
321
|
-
None,
|
|
322
|
-
alias="evaluationSets",
|
|
323
|
-
description="List of agent evaluation sets",
|
|
324
|
-
)
|
|
325
|
-
evaluators: Optional[List[Evaluator]] = Field(
|
|
326
|
-
None, description="List of agent evaluators"
|
|
327
|
-
)
|
|
453
|
+
is_conversational: bool = Field(alias="isConversational")
|
|
454
|
+
storage_version: str = Field(alias="storageVersion")
|
|
328
455
|
|
|
329
456
|
model_config = ConfigDict(
|
|
330
457
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
331
458
|
)
|
|
332
459
|
|
|
333
460
|
|
|
334
|
-
class AgentType(str, Enum):
|
|
335
|
-
"""Agent type."""
|
|
336
|
-
|
|
337
|
-
LOW_CODE = "lowCode"
|
|
338
|
-
|
|
339
|
-
|
|
340
461
|
class AgentMessageRole(str, Enum):
|
|
341
462
|
"""Enum for message roles."""
|
|
342
463
|
|
|
@@ -345,23 +466,31 @@ class AgentMessageRole(str, Enum):
|
|
|
345
466
|
|
|
346
467
|
|
|
347
468
|
class AgentMessage(BaseModel):
|
|
348
|
-
"""Message model for agent
|
|
469
|
+
"""Message model for agent definition."""
|
|
349
470
|
|
|
350
|
-
role: AgentMessageRole
|
|
471
|
+
role: Literal[AgentMessageRole.SYSTEM, AgentMessageRole.USER]
|
|
351
472
|
content: str
|
|
352
473
|
|
|
474
|
+
@field_validator("role", mode="before")
|
|
475
|
+
@classmethod
|
|
476
|
+
def normalize_role(cls, v: Any) -> str:
|
|
477
|
+
"""Normalize role to lowercase format."""
|
|
478
|
+
if isinstance(v, str):
|
|
479
|
+
return v.lower()
|
|
480
|
+
return v
|
|
481
|
+
|
|
353
482
|
model_config = ConfigDict(
|
|
354
483
|
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
355
484
|
)
|
|
356
485
|
|
|
357
486
|
|
|
358
487
|
class AgentSettings(BaseModel):
|
|
359
|
-
"""Settings for agent
|
|
488
|
+
"""Settings for agent."""
|
|
360
489
|
|
|
361
490
|
engine: str = Field(..., description="Engine type, e.g., 'basic-v1'")
|
|
362
|
-
model: str = Field(..., description="LLM model
|
|
491
|
+
model: str = Field(..., description="LLM model")
|
|
363
492
|
max_tokens: int = Field(
|
|
364
|
-
..., alias="maxTokens", description="Maximum number of tokens"
|
|
493
|
+
..., alias="maxTokens", description="Maximum number of tokens per completion"
|
|
365
494
|
)
|
|
366
495
|
temperature: float = Field(..., description="Temperature for response generation")
|
|
367
496
|
|
|
@@ -370,17 +499,60 @@ class AgentSettings(BaseModel):
|
|
|
370
499
|
)
|
|
371
500
|
|
|
372
501
|
|
|
502
|
+
class BaseAgentDefinition(BaseModel):
|
|
503
|
+
"""Agent definition model."""
|
|
504
|
+
|
|
505
|
+
input_schema: Dict[str, Any] = Field(
|
|
506
|
+
..., alias="inputSchema", description="JSON schema for input arguments"
|
|
507
|
+
)
|
|
508
|
+
output_schema: Dict[str, Any] = Field(
|
|
509
|
+
..., alias="outputSchema", description="JSON schema for output arguments"
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
model_config = ConfigDict(
|
|
513
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
514
|
+
)
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
class AgentType(str, Enum):
|
|
518
|
+
"""Agent type."""
|
|
519
|
+
|
|
520
|
+
LOW_CODE = "lowCode"
|
|
521
|
+
CODED = "coded"
|
|
522
|
+
|
|
523
|
+
|
|
373
524
|
class LowCodeAgentDefinition(BaseAgentDefinition):
|
|
374
525
|
"""Low code agent definition."""
|
|
375
526
|
|
|
376
527
|
type: Literal[AgentType.LOW_CODE] = AgentType.LOW_CODE
|
|
528
|
+
|
|
529
|
+
id: str = Field(..., description="Agent id or project name")
|
|
530
|
+
name: str = Field(..., description="Agent name or project name")
|
|
531
|
+
metadata: Optional[AgentMetadata] = Field(None, description="Agent metadata")
|
|
377
532
|
messages: List[AgentMessage] = Field(
|
|
378
533
|
..., description="List of system and user messages"
|
|
379
534
|
)
|
|
380
|
-
|
|
381
|
-
|
|
535
|
+
|
|
536
|
+
version: str = Field("1.0.0", description="Agent version")
|
|
537
|
+
resources: List[AgentResourceConfig] = Field(
|
|
538
|
+
..., description="List of tools, context, mcp and escalation resources"
|
|
539
|
+
)
|
|
540
|
+
features: List[Any] = Field(default_factory=list, description="Agent feature list")
|
|
541
|
+
settings: AgentSettings = Field(..., description="Agent settings")
|
|
542
|
+
|
|
543
|
+
model_config = ConfigDict(
|
|
544
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
class CodedAgentDefinition(BaseAgentDefinition):
|
|
549
|
+
"""Coded agent definition."""
|
|
550
|
+
|
|
551
|
+
type: Literal[AgentType.CODED] = AgentType.CODED
|
|
552
|
+
|
|
553
|
+
model_config = ConfigDict(
|
|
554
|
+
validate_by_name=True, validate_by_alias=True, extra="allow"
|
|
382
555
|
)
|
|
383
|
-
settings: AgentSettings = Field(..., description="Agent settings configuration")
|
|
384
556
|
|
|
385
557
|
|
|
386
558
|
KnownAgentDefinition = Annotated[
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Agent Evaluation Models.
|
|
2
|
+
|
|
3
|
+
These models extend the base agent models with evaluation and simulation-specific fields.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import List, Optional
|
|
7
|
+
|
|
8
|
+
from pydantic import Field
|
|
9
|
+
|
|
10
|
+
from uipath._cli._evals._models._evaluation_set import EvaluationSet
|
|
11
|
+
from uipath._cli._evals._models._evaluator import Evaluator
|
|
12
|
+
from uipath._cli._evals._models._mocks import ExampleCall
|
|
13
|
+
from uipath.agent.models.agent import (
|
|
14
|
+
AgentEscalationChannelProperties,
|
|
15
|
+
AgentIntegrationToolProperties,
|
|
16
|
+
AgentProcessToolProperties,
|
|
17
|
+
BaseResourceProperties,
|
|
18
|
+
LowCodeAgentDefinition,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AgentEvalResourceProperties(BaseResourceProperties):
|
|
23
|
+
"""Resource properties with simulation support."""
|
|
24
|
+
|
|
25
|
+
example_calls: Optional[List[ExampleCall]] = Field(None, alias="exampleCalls")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class AgentEvalProcessToolProperties(AgentProcessToolProperties):
|
|
29
|
+
"""Process tool properties with simulation support."""
|
|
30
|
+
|
|
31
|
+
example_calls: Optional[List[ExampleCall]] = Field(None, alias="exampleCalls")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class AgentEvalIntegrationToolProperties(AgentIntegrationToolProperties):
|
|
35
|
+
"""Integration tool properties with simulation support."""
|
|
36
|
+
|
|
37
|
+
example_calls: Optional[List[ExampleCall]] = Field(None, alias="exampleCalls")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class AgentEvalEscalationChannelProperties(AgentEscalationChannelProperties):
|
|
41
|
+
"""Escalation channel properties with simulation support."""
|
|
42
|
+
|
|
43
|
+
example_calls: Optional[List[ExampleCall]] = Field(None, alias="exampleCalls")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class AgentEvalsDefinition(LowCodeAgentDefinition):
|
|
47
|
+
"""Agent definition with evaluation sets and evaluators support."""
|
|
48
|
+
|
|
49
|
+
evaluation_sets: Optional[List[EvaluationSet]] = Field(
|
|
50
|
+
None,
|
|
51
|
+
alias="evaluationSets",
|
|
52
|
+
description="List of agent evaluation sets",
|
|
53
|
+
)
|
|
54
|
+
evaluators: Optional[List[Evaluator]] = Field(
|
|
55
|
+
None, description="List of agent evaluators"
|
|
56
|
+
)
|