uipath 2.1.4__py3-none-any.whl → 2.1.6__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.
@@ -17,7 +17,9 @@ Classes:
17
17
  """
18
18
 
19
19
  import json
20
- from typing import Any, Dict, List, Optional
20
+ from typing import Any, Dict, List, Optional, Union
21
+
22
+ from pydantic import BaseModel
21
23
 
22
24
  from .._config import Config
23
25
  from .._execution_context import ExecutionContext
@@ -76,6 +78,67 @@ class EmbeddingModels(object):
76
78
  text_embedding_ada_002 = "text-embedding-ada-002"
77
79
 
78
80
 
81
+ def _cleanup_schema(model_class: type[BaseModel]) -> Dict[str, Any]:
82
+ """Clean up a Pydantic model schema for use with LLM Gateway.
83
+
84
+ This function converts a Pydantic model's JSON schema to a format that's
85
+ compatible with the LLM Gateway's JSON schema requirements by removing
86
+ titles and other metadata that might cause validation issues.
87
+
88
+ Args:
89
+ model_class (type[BaseModel]): A Pydantic BaseModel class to convert to schema.
90
+
91
+ Returns:
92
+ dict: A cleaned JSON schema dictionary suitable for LLM Gateway response_format.
93
+
94
+ Examples:
95
+ ```python
96
+ from pydantic import BaseModel
97
+ from typing import List
98
+
99
+ class Country(BaseModel):
100
+ name: str
101
+ capital: str
102
+ languages: List[str]
103
+
104
+ schema = _cleanup_schema(Country)
105
+ # Returns a clean schema without titles and unnecessary metadata
106
+ ```
107
+ """
108
+ schema = model_class.model_json_schema()
109
+
110
+ def clean_properties(properties):
111
+ """Clean property definitions by removing titles and cleaning nested items."""
112
+ cleaned_props = {}
113
+ for prop_name, prop_def in properties.items():
114
+ if isinstance(prop_def, dict):
115
+ cleaned_prop = {}
116
+ for key, value in prop_def.items():
117
+ if key == "title": # Skip title
118
+ continue
119
+ elif key == "items" and isinstance(value, dict):
120
+ # Clean nested items
121
+ cleaned_items = {}
122
+ for item_key, item_value in value.items():
123
+ if item_key != "title":
124
+ cleaned_items[item_key] = item_value
125
+ cleaned_prop[key] = cleaned_items
126
+ else:
127
+ cleaned_prop[key] = value
128
+ cleaned_props[prop_name] = cleaned_prop
129
+ return cleaned_props
130
+
131
+ # Create clean schema
132
+ clean_schema = {
133
+ "type": "object",
134
+ "properties": clean_properties(schema.get("properties", {})),
135
+ "required": schema.get("required", []),
136
+ "additionalProperties": False,
137
+ }
138
+
139
+ return clean_schema
140
+
141
+
79
142
  class UiPathOpenAIService(BaseService):
80
143
  """Service for calling UiPath's LLM Gateway using OpenAI-compatible API.
81
144
 
@@ -146,7 +209,7 @@ class UiPathOpenAIService(BaseService):
146
209
  model: str = ChatModels.gpt_4o_mini_2024_07_18,
147
210
  max_tokens: int = 50,
148
211
  temperature: float = 0,
149
- response_format: Optional[Dict[str, Any]] = None,
212
+ response_format: Optional[Union[Dict[str, Any], type[BaseModel]]] = None,
150
213
  api_version: str = API_VERSION,
151
214
  ):
152
215
  """Generate chat completions using UiPath's LLM Gateway service.
@@ -168,9 +231,11 @@ class UiPathOpenAIService(BaseService):
168
231
  temperature (float, optional): Temperature for sampling, between 0 and 1.
169
232
  Lower values (closer to 0) make output more deterministic and focused,
170
233
  higher values make it more creative and random. Defaults to 0.
171
- response_format (Optional[Dict[str, Any]], optional): An object specifying the format
172
- that the model must output. Used to enable JSON mode or other structured outputs.
173
- Defaults to None.
234
+ response_format (Optional[Union[Dict[str, Any], type[BaseModel]]], optional):
235
+ An object specifying the format that the model must output. Can be either:
236
+ - A dictionary with response format configuration (traditional format)
237
+ - A Pydantic BaseModel class (automatically converted to JSON schema)
238
+ Used to enable JSON mode or other structured outputs. Defaults to None.
174
239
  api_version (str, optional): The API version to use. Defaults to API_VERSION.
175
240
 
176
241
  Returns:
@@ -198,11 +263,31 @@ class UiPathOpenAIService(BaseService):
198
263
  max_tokens=200,
199
264
  temperature=0.3
200
265
  )
266
+
267
+ # Using Pydantic model for structured response
268
+ from pydantic import BaseModel
269
+ from typing import List
270
+
271
+ class Country(BaseModel):
272
+ name: str
273
+ capital: str
274
+ languages: List[str]
275
+
276
+ response = await service.chat_completions(
277
+ messages=[
278
+ {"role": "system", "content": "You are a helpful assistant. Respond with structured JSON."},
279
+ {"role": "user", "content": "Tell me about Canada."}
280
+ ],
281
+ response_format=Country, # Pass BaseModel directly
282
+ max_tokens=1000
283
+ )
201
284
  ```
202
285
 
203
286
  Note:
204
287
  The conversation history can be included to provide context to the model.
205
288
  Each message should have both 'role' and 'content' keys.
289
+ When using a Pydantic BaseModel as response_format, it will be automatically
290
+ converted to the appropriate JSON schema format for the LLM Gateway.
206
291
  """
207
292
  endpoint = EndpointManager.get_passthrough_endpoint().format(
208
293
  model=model, api_version=api_version
@@ -215,9 +300,24 @@ class UiPathOpenAIService(BaseService):
215
300
  "temperature": temperature,
216
301
  }
217
302
 
218
- # Add response_format if provided
303
+ # Handle response_format - convert BaseModel to schema if needed
219
304
  if response_format:
220
- request_body["response_format"] = response_format
305
+ if isinstance(response_format, type) and issubclass(
306
+ response_format, BaseModel
307
+ ):
308
+ # Convert Pydantic model to JSON schema format
309
+ cleaned_schema = _cleanup_schema(response_format)
310
+ request_body["response_format"] = {
311
+ "type": "json_schema",
312
+ "json_schema": {
313
+ "name": response_format.__name__.lower(),
314
+ "strict": True,
315
+ "schema": cleaned_schema,
316
+ },
317
+ }
318
+ else:
319
+ # Use provided dictionary format directly
320
+ request_body["response_format"] = response_format
221
321
 
222
322
  response = await self.request_async(
223
323
  "POST",
@@ -258,7 +358,7 @@ class UiPathLlmChatService(BaseService):
258
358
  top_p: float = 1,
259
359
  tools: Optional[List[ToolDefinition]] = None,
260
360
  tool_choice: Optional[ToolChoice] = None,
261
- response_format: Optional[Dict[str, Any]] = None,
361
+ response_format: Optional[Union[Dict[str, Any], type[BaseModel]]] = None,
262
362
  api_version: str = NORMALIZED_API_VERSION,
263
363
  ):
264
364
  """Generate chat completions using UiPath's normalized LLM Gateway API.
@@ -295,9 +395,11 @@ class UiPathLlmChatService(BaseService):
295
395
  tool_choice (Optional[ToolChoice], optional): Controls which tools the model can call.
296
396
  Can be "auto" (model decides), "none" (no tools), or a specific tool choice.
297
397
  Defaults to None.
298
- response_format (Optional[Dict[str, Any]], optional): An object specifying the format
299
- that the model must output. Used to enable JSON mode or other structured outputs.
300
- Defaults to None.
398
+ response_format (Optional[Union[Dict[str, Any], type[BaseModel]]], optional):
399
+ An object specifying the format that the model must output. Can be either:
400
+ - A dictionary with response format configuration (traditional format)
401
+ - A Pydantic BaseModel class (automatically converted to JSON schema)
402
+ Used to enable JSON mode or other structured outputs. Defaults to None.
301
403
  api_version (str, optional): The normalized API version to use.
302
404
  Defaults to NORMALIZED_API_VERSION.
303
405
 
@@ -349,6 +451,25 @@ class UiPathLlmChatService(BaseService):
349
451
  presence_penalty=0.2,
350
452
  n=3 # Generate 3 alternative responses
351
453
  )
454
+
455
+ # Using Pydantic model for structured response
456
+ from pydantic import BaseModel
457
+ from typing import List
458
+
459
+ class Country(BaseModel):
460
+ name: str
461
+ capital: str
462
+ languages: List[str]
463
+
464
+ response = await service.chat_completions(
465
+ messages=[
466
+ {"role": "system", "content": "You are a helpful assistant. Respond with structured JSON."},
467
+ {"role": "user", "content": "Tell me about Canada."}
468
+ ],
469
+ response_format=Country, # Pass BaseModel directly
470
+ max_tokens=1000
471
+ )
472
+ )
352
473
  ```
353
474
 
354
475
  Note:
@@ -370,9 +491,24 @@ class UiPathLlmChatService(BaseService):
370
491
  "top_p": top_p,
371
492
  }
372
493
 
373
- # Add response_format if provided
494
+ # Handle response_format - convert BaseModel to schema if needed
374
495
  if response_format:
375
- request_body["response_format"] = response_format
496
+ if isinstance(response_format, type) and issubclass(
497
+ response_format, BaseModel
498
+ ):
499
+ # Convert Pydantic model to JSON schema format
500
+ cleaned_schema = _cleanup_schema(response_format)
501
+ request_body["response_format"] = {
502
+ "type": "json_schema",
503
+ "json_schema": {
504
+ "name": response_format.__name__.lower(),
505
+ "strict": True,
506
+ "schema": cleaned_schema,
507
+ },
508
+ }
509
+ else:
510
+ # Use provided dictionary format directly
511
+ request_body["response_format"] = response_format
376
512
 
377
513
  # Add tools if provided - convert to UiPath format
378
514
  if tools:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uipath
3
- Version: 2.1.4
3
+ Version: 2.1.6
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
@@ -5,14 +5,15 @@ uipath/_folder_context.py,sha256=UMMoU1VWEfYHAZW3Td2SIFYhw5dYsmaaKFhW_JEm6oc,192
5
5
  uipath/_uipath.py,sha256=ZfEcqpY7NRSm6rB2OPgyVXBl9DCnn750ikq8VzzTO_s,4146
6
6
  uipath/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  uipath/_cli/README.md,sha256=GLtCfbeIKZKNnGTCsfSVqRQ27V1btT1i2bSAyW_xZl4,474
8
- uipath/_cli/__init__.py,sha256=vGz3vJHkUvgK9_lKdzqiwwHkge1TCALRiOzGGwyr-8E,1885
8
+ uipath/_cli/__init__.py,sha256=VKcdFaQtoGiyPhxBCx74EMz-sGC3957D21g1DMGXJ7w,1958
9
9
  uipath/_cli/cli_auth.py,sha256=RUSBHfmqhBtITrx52FeXMlVCuNyo8vrjTdjEhmM1Khw,6734
10
10
  uipath/_cli/cli_deploy.py,sha256=KPCmQ0c_NYD5JofSDao5r6QYxHshVCRxlWDVnQvlp5w,645
11
11
  uipath/_cli/cli_init.py,sha256=SmB7VplpXRSa5sgqgzojNsZDw0zfsEi2TfkMx3eQpTo,5132
12
12
  uipath/_cli/cli_invoke.py,sha256=FurosrZNGlmANIrplKWhw3EQ1b46ph5Z2rPwVaYJgmc,4001
13
13
  uipath/_cli/cli_new.py,sha256=9378NYUBc9j-qKVXV7oja-jahfJhXBg8zKVyaon7ctY,2102
14
- uipath/_cli/cli_pack.py,sha256=P7tX3CJg2fzoLhPMHbr6m1fKXWRv2QkyIGgNM1MajT0,20978
14
+ uipath/_cli/cli_pack.py,sha256=D1sIk91Ka1_dMWAOFuHemeqwUvlgPZKDuvfasoTyAE0,10557
15
15
  uipath/_cli/cli_publish.py,sha256=QT17JTClAyLve6ZjB-WvQaJ-j4DdmNneV_eDRyXjeeQ,6578
16
+ uipath/_cli/cli_push.py,sha256=YfATg8auLii0IUQJLWPSA_M_iHNylNE2aIQUtDBMdzQ,18836
16
17
  uipath/_cli/cli_run.py,sha256=cTZYWJkGk2ruk6RRJBXII9J6VjpgGmysv_KlKI1JMHo,6446
17
18
  uipath/_cli/middlewares.py,sha256=CN-QqV69zZPI-hvizvEIb-zTcNh9WjsZIYCF3_nHSio,4915
18
19
  uipath/_cli/spinner.py,sha256=bS-U_HA5yne11ejUERu7CQoXmWdabUD2bm62EfEdV8M,1107
@@ -22,7 +23,7 @@ uipath/_cli/_auth/_models.py,sha256=sYMCfvmprIqnZxStlD_Dxx2bcxgn0Ri4D7uwemwkcNg,
22
23
  uipath/_cli/_auth/_oidc_utils.py,sha256=WaX9jDlXrlX6yD8i8gsocV8ngjaT72Xd1tvsZMmSbco,2127
23
24
  uipath/_cli/_auth/_portal_service.py,sha256=iAxEDEY7OcEbIUSKNZnURAuNsimNmU90NLHkkTLqREY,8079
24
25
  uipath/_cli/_auth/_utils.py,sha256=9nb76xe5XmDZ0TAncp-_1SKqL6FdwRi9eS3C2noN1lY,1591
25
- uipath/_cli/_auth/auth_config.json,sha256=xwh6paXwW3TDIsz2UHP_q3TxmBW-njFXh1q4Nd0knUA,411
26
+ uipath/_cli/_auth/auth_config.json,sha256=YWGtKyDgLl57T4g0M0AYyhrLs_G-294yNB24lzBGtbA,429
26
27
  uipath/_cli/_auth/index.html,sha256=_Q2OtqPfapG_6vumbQYqtb2PfFe0smk7TlGERKEBvB4,22518
27
28
  uipath/_cli/_auth/localhost.crt,sha256=oGl9oLLOiouHubAt39B4zEfylFvKEtbtr_43SIliXJc,1226
28
29
  uipath/_cli/_auth/localhost.key,sha256=X31VYXD8scZtmGA837dGX5l6G-LXHLo5ItWJhZXaz3c,1679
@@ -38,13 +39,16 @@ uipath/_cli/_templates/main.py.template,sha256=QB62qX5HKDbW4lFskxj7h9uuxBITnTWqu
38
39
  uipath/_cli/_templates/package.nuspec.template,sha256=YZyLc-u_EsmIoKf42JsLQ55OGeFmb8VkIU2VF7DFbtw,359
39
40
  uipath/_cli/_utils/_common.py,sha256=wQ0a_lGj0bsuNvwxUfnLwg6T3IdatdfkrPcZMoufJNU,2058
40
41
  uipath/_cli/_utils/_console.py,sha256=rj4V3yeR1wnJzFTHnaE6wcY9OoJV-PiIQnLg_p62ClQ,6664
41
- uipath/_cli/_utils/_constants.py,sha256=9mRv_ZQoEPfvtTMipraQmYMJeCxcaLL7w8cYy4gJoQE,1225
42
+ uipath/_cli/_utils/_constants.py,sha256=AXeVidtHUFiODrkB2BCX_bqDL-bUzRg-Ieh1-2cCrGA,1374
42
43
  uipath/_cli/_utils/_debug.py,sha256=zamzIR4VgbdKADAE4gbmjxDsbgF7wvdr7C5Dqp744Oc,1739
43
44
  uipath/_cli/_utils/_folders.py,sha256=UVJcKPfPAVR5HF4AP6EXdlNVcfEF1v5pwGCpoAgBY34,1155
44
45
  uipath/_cli/_utils/_input_args.py,sha256=pyQhEcQXHdFHYTVNzvfWp439aii5StojoptnmCv5lfs,4094
45
46
  uipath/_cli/_utils/_parse_ast.py,sha256=A-QToBIf-oP7yP2DQTHO6blkk6ik5z_IeaIwtEWO4e0,19516
46
47
  uipath/_cli/_utils/_processes.py,sha256=q7DfEKHISDWf3pngci5za_z0Pbnf_shWiYEcTOTCiyk,1855
48
+ uipath/_cli/_utils/_project_files.py,sha256=noGulQh95d4aqwoa-moK2kXGpIG_1Wqy7rcNmNpjaWs,12192
49
+ uipath/_cli/_utils/_studio_project.py,sha256=_gED64JeVc0u2i0L0Exr-pfnArdlDVPJzAD738YLr24,4443
47
50
  uipath/_cli/_utils/_tracing.py,sha256=2igb03j3EHjF_A406UhtCKkPfudVfFPjUq5tXUEG4oo,1541
51
+ uipath/_cli/_utils/_uv_helpers.py,sha256=6SvoLnZPoKIxW0sjMvD1-ENV_HOXDYzH34GjBqwT138,3450
48
52
  uipath/_services/__init__.py,sha256=10xtw3ENC30yR9CCq_b94RMZ3YrUeyfHV33yWYUd8tU,896
49
53
  uipath/_services/_base_service.py,sha256=twcUCLS_V4D1kxcJt6lckd7rqsVRcy4mfHOflJpu1k0,5830
50
54
  uipath/_services/actions_service.py,sha256=LYKvG4VxNGQgZ46AzGK9kI1Txb-YmVvZj5ScPOue8Ls,15989
@@ -56,7 +60,7 @@ uipath/_services/connections_service.py,sha256=qh-HNL_GJsyPUD0wSJZRF8ZdrTE9l4HrI
56
60
  uipath/_services/context_grounding_service.py,sha256=EBf7lIIYz_s1ubf_07OAZXQHjS8kpZ2vqxo4mI3VL-A,25009
57
61
  uipath/_services/folder_service.py,sha256=9JqgjKhWD-G_KUnfUTP2BADxL6OK9QNZsBsWZHAULdE,2749
58
62
  uipath/_services/jobs_service.py,sha256=CnDd7BM4AMqcMIR1qqu5ohhxf9m0AF4dnGoF4EX38kw,30872
59
- uipath/_services/llm_gateway_service.py,sha256=mX_7md6Sxid-Vu9XFQ8vetb106HnwsYJtxzw4W8fzTg,18670
63
+ uipath/_services/llm_gateway_service.py,sha256=TZDxpd99K9IT1QeyNle5994lGeGfQRWj1icTXB6zBOY,24300
60
64
  uipath/_services/processes_service.py,sha256=Pk6paw7e_a-WvVcfKDLuyj1p--pvNRTXwZNYIwDdYzo,5726
61
65
  uipath/_services/queues_service.py,sha256=VaG3dWL2QK6AJBOLoW2NQTpkPfZjsqsYPl9-kfXPFzA,13534
62
66
  uipath/_utils/__init__.py,sha256=VdcpnENJIa0R6Y26NoxY64-wUVyvb4pKfTh1wXDQeMk,526
@@ -95,8 +99,8 @@ uipath/tracing/_traced.py,sha256=qeVDrds2OUnpdUIA0RhtF0kg2dlAZhyC1RRkI-qivTM,185
95
99
  uipath/tracing/_utils.py,sha256=ZeensQexnw69jVcsVrGyED7mPlAU-L1agDGm6_1A3oc,10388
96
100
  uipath/utils/__init__.py,sha256=VD-KXFpF_oWexFg6zyiWMkxl2HM4hYJMIUDZ1UEtGx0,105
97
101
  uipath/utils/_endpoints_manager.py,sha256=hiGEu6vyfQJoeiiql6w21TNiG6tADUfXlVBimxPU1-Q,4160
98
- uipath-2.1.4.dist-info/METADATA,sha256=YW4-sr1WlE6N4mXyvHYGqKEeYrpqwONhFvbpje0uwXg,6366
99
- uipath-2.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
100
- uipath-2.1.4.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
101
- uipath-2.1.4.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
102
- uipath-2.1.4.dist-info/RECORD,,
102
+ uipath-2.1.6.dist-info/METADATA,sha256=kc-2b_9OI9fOEfr3hnwPnnM8B4QAQjeiHM3-HZQgT-0,6366
103
+ uipath-2.1.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
104
+ uipath-2.1.6.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
105
+ uipath-2.1.6.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
106
+ uipath-2.1.6.dist-info/RECORD,,
File without changes