uipath 2.0.74__py3-none-any.whl → 2.0.76__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/cli_pack.py +166 -53
- uipath/_services/llm_gateway_service.py +18 -85
- uipath/models/llm_gateway.py +0 -5
- uipath/utils/__init__.py +5 -0
- uipath/utils/_endpoints_manager.py +88 -0
- {uipath-2.0.74.dist-info → uipath-2.0.76.dist-info}/METADATA +1 -1
- {uipath-2.0.74.dist-info → uipath-2.0.76.dist-info}/RECORD +10 -8
- {uipath-2.0.74.dist-info → uipath-2.0.76.dist-info}/WHEEL +0 -0
- {uipath-2.0.74.dist-info → uipath-2.0.76.dist-info}/entry_points.txt +0 -0
- {uipath-2.0.74.dist-info → uipath-2.0.76.dist-info}/licenses/LICENSE +0 -0
uipath/_cli/cli_pack.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# type: ignore
|
|
2
2
|
import json
|
|
3
3
|
import os
|
|
4
|
+
import re
|
|
4
5
|
import subprocess
|
|
5
6
|
import uuid
|
|
6
7
|
import zipfile
|
|
7
8
|
from string import Template
|
|
9
|
+
from typing import Dict, Tuple
|
|
8
10
|
|
|
9
11
|
import click
|
|
10
12
|
|
|
@@ -50,6 +52,7 @@ def check_config(directory):
|
|
|
50
52
|
"entryPoints": config_data["entryPoints"],
|
|
51
53
|
"version": toml_data["version"],
|
|
52
54
|
"authors": toml_data["authors"],
|
|
55
|
+
"dependencies": toml_data.get("dependencies", {}),
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
|
|
@@ -113,7 +116,7 @@ def handle_uv_operations(directory):
|
|
|
113
116
|
run_uv_lock(directory)
|
|
114
117
|
|
|
115
118
|
|
|
116
|
-
def generate_operate_file(entryPoints):
|
|
119
|
+
def generate_operate_file(entryPoints, dependencies=None):
|
|
117
120
|
project_id = str(uuid.uuid4())
|
|
118
121
|
|
|
119
122
|
first_entry = entryPoints[0]
|
|
@@ -130,6 +133,10 @@ def generate_operate_file(entryPoints):
|
|
|
130
133
|
"runtimeOptions": {"requiresUserInteraction": False, "isAttended": False},
|
|
131
134
|
}
|
|
132
135
|
|
|
136
|
+
# Add dependencies if provided
|
|
137
|
+
if dependencies:
|
|
138
|
+
operate_json_data["dependencies"] = dependencies
|
|
139
|
+
|
|
133
140
|
return operate_json_data
|
|
134
141
|
|
|
135
142
|
|
|
@@ -149,40 +156,6 @@ def generate_bindings_content():
|
|
|
149
156
|
return bindings_content
|
|
150
157
|
|
|
151
158
|
|
|
152
|
-
def get_proposed_version(directory):
|
|
153
|
-
output_dir = os.path.join(directory, ".uipath")
|
|
154
|
-
if not os.path.exists(output_dir):
|
|
155
|
-
return None
|
|
156
|
-
|
|
157
|
-
# Get all .nupkg files
|
|
158
|
-
nupkg_files = [f for f in os.listdir(output_dir) if f.endswith(".nupkg")]
|
|
159
|
-
if not nupkg_files:
|
|
160
|
-
return None
|
|
161
|
-
|
|
162
|
-
# Sort by modification time to get most recent
|
|
163
|
-
latest_file = max(
|
|
164
|
-
nupkg_files, key=lambda f: os.path.getmtime(os.path.join(output_dir, f))
|
|
165
|
-
)
|
|
166
|
-
|
|
167
|
-
# Extract version from filename
|
|
168
|
-
# Remove .nupkg extension first
|
|
169
|
-
name_version = latest_file[:-6]
|
|
170
|
-
# Find 3rd last occurrence of . by splitting and joining parts
|
|
171
|
-
parts = name_version.split(".")
|
|
172
|
-
if len(parts) >= 3:
|
|
173
|
-
version = ".".join(parts[-3:])
|
|
174
|
-
else:
|
|
175
|
-
version = name_version
|
|
176
|
-
|
|
177
|
-
# Increment patch version by 1
|
|
178
|
-
try:
|
|
179
|
-
major, minor, patch = version.split(".")
|
|
180
|
-
new_version = f"{major}.{minor}.{int(patch) + 1}"
|
|
181
|
-
return new_version
|
|
182
|
-
except Exception:
|
|
183
|
-
return "0.0.1"
|
|
184
|
-
|
|
185
|
-
|
|
186
159
|
def generate_content_types_content():
|
|
187
160
|
templates_path = os.path.join(
|
|
188
161
|
os.path.dirname(__file__), "_templates", "[Content_Types].xml.template"
|
|
@@ -278,9 +251,10 @@ def pack_fn(
|
|
|
278
251
|
version,
|
|
279
252
|
authors,
|
|
280
253
|
directory,
|
|
254
|
+
dependencies=None,
|
|
281
255
|
include_uv_lock=True,
|
|
282
256
|
):
|
|
283
|
-
operate_file = generate_operate_file(entryPoints)
|
|
257
|
+
operate_file = generate_operate_file(entryPoints, dependencies)
|
|
284
258
|
entrypoints_file = generate_entrypoints_file(entryPoints)
|
|
285
259
|
|
|
286
260
|
# Get bindings from uipath.json if available
|
|
@@ -389,28 +363,166 @@ def pack_fn(
|
|
|
389
363
|
z.writestr(f"content/{file}", f.read())
|
|
390
364
|
|
|
391
365
|
|
|
392
|
-
def
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
366
|
+
def parse_dependency_string(dependency: str) -> Tuple[str, str]:
|
|
367
|
+
"""Parse a dependency string into package name and version specifier.
|
|
368
|
+
|
|
369
|
+
Handles PEP 508 dependency specifications including:
|
|
370
|
+
- Simple names: "requests"
|
|
371
|
+
- Version specifiers: "requests>=2.28.0"
|
|
372
|
+
- Complex specifiers: "requests>=2.28.0,<3.0.0"
|
|
373
|
+
- Extras: "requests[security]>=2.28.0"
|
|
374
|
+
- Environment markers: "requests>=2.28.0; python_version>='3.8'"
|
|
375
|
+
|
|
376
|
+
Args:
|
|
377
|
+
dependency: Raw dependency string from pyproject.toml
|
|
378
|
+
|
|
379
|
+
Returns:
|
|
380
|
+
Tuple of (package_name, version_specifier)
|
|
381
|
+
|
|
382
|
+
Examples:
|
|
383
|
+
"requests" -> ("requests", "*")
|
|
384
|
+
"requests>=2.28.0" -> ("requests", ">=2.28.0")
|
|
385
|
+
"requests>=2.28.0,<3.0.0" -> ("requests", ">=2.28.0,<3.0.0")
|
|
386
|
+
"requests[security]>=2.28.0" -> ("requests", ">=2.28.0")
|
|
387
|
+
"""
|
|
388
|
+
# Remove whitespace
|
|
389
|
+
dependency = dependency.strip()
|
|
390
|
+
|
|
391
|
+
# Handle environment markers (everything after semicolon)
|
|
392
|
+
if ";" in dependency:
|
|
393
|
+
dependency = dependency.split(";")[0].strip()
|
|
394
|
+
|
|
395
|
+
# Pattern to match package name with optional extras and version specifiers
|
|
396
|
+
# Matches: package_name[extras] version_specs
|
|
397
|
+
pattern = r"^([a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?)(\[[^\]]+\])?(.*)"
|
|
398
|
+
match = re.match(pattern, dependency)
|
|
399
|
+
|
|
400
|
+
if not match:
|
|
401
|
+
# Fallback for edge cases
|
|
402
|
+
return dependency, "*"
|
|
403
|
+
|
|
404
|
+
package_name = match.group(1)
|
|
405
|
+
version_part = match.group(4).strip() if match.group(4) else ""
|
|
406
|
+
|
|
407
|
+
# If no version specifier, return wildcard
|
|
408
|
+
if not version_part:
|
|
409
|
+
return package_name, "*"
|
|
410
|
+
|
|
411
|
+
# Clean up version specifier
|
|
412
|
+
version_spec = version_part.strip()
|
|
413
|
+
|
|
414
|
+
# Validate that version specifier starts with a valid operator
|
|
415
|
+
valid_operators = [">=", "<=", "==", "!=", "~=", ">", "<"]
|
|
416
|
+
if not any(version_spec.startswith(op) for op in valid_operators):
|
|
417
|
+
# If it doesn't start with an operator, treat as exact version
|
|
418
|
+
if version_spec:
|
|
419
|
+
version_spec = f"=={version_spec}"
|
|
420
|
+
else:
|
|
421
|
+
version_spec = "*"
|
|
422
|
+
|
|
423
|
+
return package_name, version_spec
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def extract_dependencies_from_toml(project_data: Dict) -> Dict[str, str]:
|
|
427
|
+
"""Extract and parse dependencies from pyproject.toml project data.
|
|
428
|
+
|
|
429
|
+
Args:
|
|
430
|
+
project_data: The "project" section from pyproject.toml
|
|
431
|
+
|
|
432
|
+
Returns:
|
|
433
|
+
Dictionary mapping package names to version specifiers
|
|
434
|
+
"""
|
|
435
|
+
dependencies = {}
|
|
436
|
+
|
|
437
|
+
if "dependencies" not in project_data:
|
|
438
|
+
return dependencies
|
|
439
|
+
|
|
440
|
+
deps_list = project_data["dependencies"]
|
|
441
|
+
if not isinstance(deps_list, list):
|
|
442
|
+
console.warning("dependencies should be a list in pyproject.toml")
|
|
443
|
+
return dependencies
|
|
444
|
+
|
|
445
|
+
for dep in deps_list:
|
|
446
|
+
if not isinstance(dep, str):
|
|
447
|
+
console.warning(f"Skipping non-string dependency: {dep}")
|
|
448
|
+
continue
|
|
449
|
+
|
|
450
|
+
try:
|
|
451
|
+
name, version_spec = parse_dependency_string(dep)
|
|
452
|
+
if name: # Only add if we got a valid name
|
|
453
|
+
dependencies[name] = version_spec
|
|
454
|
+
except Exception as e:
|
|
455
|
+
console.warning(f"Failed to parse dependency '{dep}': {e}")
|
|
456
|
+
continue
|
|
457
|
+
|
|
458
|
+
return dependencies
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
def read_toml_project(file_path: str) -> dict:
|
|
462
|
+
"""Read and parse pyproject.toml file with improved error handling and validation.
|
|
463
|
+
|
|
464
|
+
Args:
|
|
465
|
+
file_path: Path to pyproject.toml file
|
|
466
|
+
|
|
467
|
+
Returns:
|
|
468
|
+
Dictionary containing project metadata and dependencies
|
|
469
|
+
"""
|
|
470
|
+
try:
|
|
471
|
+
with open(file_path, "rb") as f:
|
|
472
|
+
content = tomllib.load(f)
|
|
473
|
+
except Exception as e:
|
|
474
|
+
console.error(f"Failed to read or parse pyproject.toml: {e}")
|
|
475
|
+
|
|
476
|
+
# Validate required sections
|
|
477
|
+
if "project" not in content:
|
|
478
|
+
console.error("pyproject.toml is missing the required field: project.")
|
|
479
|
+
|
|
480
|
+
project = content["project"]
|
|
481
|
+
|
|
482
|
+
# Validate required fields with better error messages
|
|
483
|
+
required_fields = {
|
|
484
|
+
"name": "Project name is required in pyproject.toml",
|
|
485
|
+
"description": "Project description is required in pyproject.toml",
|
|
486
|
+
"version": "Project version is required in pyproject.toml",
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
for field, error_msg in required_fields.items():
|
|
490
|
+
if field not in project:
|
|
400
491
|
console.error(
|
|
401
|
-
"pyproject.toml is missing the required field: project.
|
|
492
|
+
f"pyproject.toml is missing the required field: project.{field}. {error_msg}"
|
|
402
493
|
)
|
|
403
|
-
|
|
494
|
+
|
|
495
|
+
# Check for empty values only if field exists
|
|
496
|
+
if field in project and (
|
|
497
|
+
not project[field]
|
|
498
|
+
or (isinstance(project[field], str) and not project[field].strip())
|
|
499
|
+
):
|
|
404
500
|
console.error(
|
|
405
|
-
"
|
|
501
|
+
f"Project {field} cannot be empty. Please specify a {field} in pyproject.toml."
|
|
406
502
|
)
|
|
407
503
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
504
|
+
# Extract author information safely
|
|
505
|
+
authors = project.get("authors", [])
|
|
506
|
+
author_name = ""
|
|
507
|
+
|
|
508
|
+
if authors and isinstance(authors, list) and len(authors) > 0:
|
|
509
|
+
first_author = authors[0]
|
|
510
|
+
if isinstance(first_author, dict):
|
|
511
|
+
author_name = first_author.get("name", "")
|
|
512
|
+
elif isinstance(first_author, str):
|
|
513
|
+
# Handle case where authors is a list of strings
|
|
514
|
+
author_name = first_author
|
|
515
|
+
|
|
516
|
+
# Extract dependencies with improved parsing
|
|
517
|
+
dependencies = extract_dependencies_from_toml(project)
|
|
518
|
+
|
|
519
|
+
return {
|
|
520
|
+
"name": project["name"].strip(),
|
|
521
|
+
"description": project["description"].strip(),
|
|
522
|
+
"version": project["version"].strip(),
|
|
523
|
+
"authors": author_name.strip(),
|
|
524
|
+
"dependencies": dependencies,
|
|
525
|
+
}
|
|
414
526
|
|
|
415
527
|
|
|
416
528
|
def get_project_version(directory):
|
|
@@ -492,6 +604,7 @@ def pack(root, nolock):
|
|
|
492
604
|
version or config["version"],
|
|
493
605
|
config["authors"],
|
|
494
606
|
root,
|
|
607
|
+
config.get("dependencies"),
|
|
495
608
|
include_uv_lock=not nolock,
|
|
496
609
|
)
|
|
497
610
|
display_project_info(config)
|
|
@@ -10,9 +10,9 @@ from ..models.llm_gateway import (
|
|
|
10
10
|
TextEmbedding,
|
|
11
11
|
ToolChoice,
|
|
12
12
|
ToolDefinition,
|
|
13
|
-
UsageInfo,
|
|
14
13
|
)
|
|
15
14
|
from ..tracing._traced import traced
|
|
15
|
+
from ..utils import EndpointManager
|
|
16
16
|
from ._base_service import BaseService
|
|
17
17
|
|
|
18
18
|
# Common constants
|
|
@@ -54,36 +54,12 @@ class UiPathOpenAIService(BaseService):
|
|
|
54
54
|
def __init__(self, config: Config, execution_context: ExecutionContext) -> None:
|
|
55
55
|
super().__init__(config=config, execution_context=execution_context)
|
|
56
56
|
|
|
57
|
-
@traced(name="llm_embeddings_usage", run_type="uipath")
|
|
58
|
-
async def embeddings_usage(
|
|
59
|
-
self, input: str, embedding_model: str = EmbeddingModels.text_embedding_ada_002
|
|
60
|
-
):
|
|
61
|
-
"""Embedd the input text using llm gateway service.
|
|
62
|
-
|
|
63
|
-
Args:
|
|
64
|
-
input (str): The input text to embedd.
|
|
65
|
-
embedding_model (str, optional): The embedding model to use. Defaults to text-embedding-ada-002.
|
|
66
|
-
|
|
67
|
-
Returns:
|
|
68
|
-
EmbeddingUsageInfo: The embedding usage information.
|
|
69
|
-
"""
|
|
70
|
-
endpoint = Endpoint(
|
|
71
|
-
f"/llmgateway_/openai/deployments/{embedding_model}/embeddings/usage"
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
response = await self.request_async(
|
|
75
|
-
"POST",
|
|
76
|
-
endpoint,
|
|
77
|
-
content=json.dumps({"input": input}),
|
|
78
|
-
params={"api-version": API_VERSION},
|
|
79
|
-
headers=DEFAULT_LLM_HEADERS,
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
return UsageInfo.model_validate(response.json())
|
|
83
|
-
|
|
84
57
|
@traced(name="llm_embeddings", run_type="uipath")
|
|
85
58
|
async def embeddings(
|
|
86
|
-
self,
|
|
59
|
+
self,
|
|
60
|
+
input: str,
|
|
61
|
+
embedding_model: str = EmbeddingModels.text_embedding_ada_002,
|
|
62
|
+
openai_api_version: str = API_VERSION,
|
|
87
63
|
):
|
|
88
64
|
"""Embed the input text using llm gateway service.
|
|
89
65
|
|
|
@@ -93,9 +69,10 @@ class UiPathOpenAIService(BaseService):
|
|
|
93
69
|
Returns:
|
|
94
70
|
TextEmbedding: The embedding response.
|
|
95
71
|
"""
|
|
96
|
-
endpoint =
|
|
97
|
-
|
|
72
|
+
endpoint = EndpointManager.get_embeddings_endpoint().format(
|
|
73
|
+
model=embedding_model, api_version=openai_api_version
|
|
98
74
|
)
|
|
75
|
+
endpoint = Endpoint("/" + endpoint)
|
|
99
76
|
|
|
100
77
|
response = await self.request_async(
|
|
101
78
|
"POST",
|
|
@@ -114,6 +91,7 @@ class UiPathOpenAIService(BaseService):
|
|
|
114
91
|
model: str = ChatModels.gpt_4o_mini_2024_07_18,
|
|
115
92
|
max_tokens: int = 50,
|
|
116
93
|
temperature: float = 0,
|
|
94
|
+
api_version: str = API_VERSION,
|
|
117
95
|
):
|
|
118
96
|
"""Get chat completions using llm gateway service.
|
|
119
97
|
|
|
@@ -139,59 +117,10 @@ class UiPathOpenAIService(BaseService):
|
|
|
139
117
|
Returns:
|
|
140
118
|
ChatCompletion: The chat completion response.
|
|
141
119
|
"""
|
|
142
|
-
endpoint =
|
|
143
|
-
|
|
144
|
-
request_body = {
|
|
145
|
-
"messages": messages,
|
|
146
|
-
"max_tokens": max_tokens,
|
|
147
|
-
"temperature": temperature,
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
response = await self.request_async(
|
|
151
|
-
"POST",
|
|
152
|
-
endpoint,
|
|
153
|
-
content=json.dumps(request_body),
|
|
154
|
-
params={"api-version": API_VERSION},
|
|
155
|
-
headers=DEFAULT_LLM_HEADERS,
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
return ChatCompletion.model_validate(response.json())
|
|
159
|
-
|
|
160
|
-
@traced(name="llm_chat_completions_usage", run_type="uipath")
|
|
161
|
-
async def chat_completions_usage(
|
|
162
|
-
self,
|
|
163
|
-
messages: List[Dict[str, str]],
|
|
164
|
-
model: str = ChatModels.gpt_4o_mini_2024_07_18,
|
|
165
|
-
max_tokens: int = 50,
|
|
166
|
-
temperature: float = 0,
|
|
167
|
-
):
|
|
168
|
-
"""Get chat completions usage using llm gateway service.
|
|
169
|
-
|
|
170
|
-
Args:
|
|
171
|
-
messages (List[Dict[str, str]]): List of message dictionaries with 'role' and 'content' keys.
|
|
172
|
-
The supported roles are 'system', 'user', and 'assistant'.
|
|
173
|
-
|
|
174
|
-
Example:
|
|
175
|
-
```
|
|
176
|
-
[
|
|
177
|
-
{"role": "system", "content": "You are a helpful Python programming assistant."},
|
|
178
|
-
{"role": "user", "content": "How do I read a file in Python?"},
|
|
179
|
-
{"role": "assistant", "content": "You can use the built-in open() function."},
|
|
180
|
-
{"role": "user", "content": "Can you show an example?"}
|
|
181
|
-
]
|
|
182
|
-
```
|
|
183
|
-
The conversation history can be included to provide context to the model.
|
|
184
|
-
model (str, optional): The model to use for chat completion. Defaults to ChatModels.gpt_4o_mini_2024_07_18.
|
|
185
|
-
max_tokens (int, optional): Maximum number of tokens to generate. Defaults to 50.
|
|
186
|
-
temperature (float, optional): Temperature for sampling, between 0 and 1.
|
|
187
|
-
Lower values make output more deterministic. Defaults to 0.
|
|
188
|
-
|
|
189
|
-
Returns:
|
|
190
|
-
ChatCompletion: The chat completion usage response.
|
|
191
|
-
"""
|
|
192
|
-
endpoint = Endpoint(
|
|
193
|
-
f"/llmgateway_/openai/deployments/{model}/chat/completions/usage"
|
|
120
|
+
endpoint = EndpointManager.get_passthrough_endpoint().format(
|
|
121
|
+
model=model, api_version=api_version
|
|
194
122
|
)
|
|
123
|
+
endpoint = Endpoint("/" + endpoint)
|
|
195
124
|
|
|
196
125
|
request_body = {
|
|
197
126
|
"messages": messages,
|
|
@@ -207,7 +136,7 @@ class UiPathOpenAIService(BaseService):
|
|
|
207
136
|
headers=DEFAULT_LLM_HEADERS,
|
|
208
137
|
)
|
|
209
138
|
|
|
210
|
-
return
|
|
139
|
+
return ChatCompletion.model_validate(response.json())
|
|
211
140
|
|
|
212
141
|
|
|
213
142
|
class UiPathLlmChatService(BaseService):
|
|
@@ -229,6 +158,7 @@ class UiPathLlmChatService(BaseService):
|
|
|
229
158
|
top_p: float = 1,
|
|
230
159
|
tools: Optional[List[ToolDefinition]] = None,
|
|
231
160
|
tool_choice: Optional[ToolChoice] = None,
|
|
161
|
+
api_version: str = NORMALIZED_API_VERSION,
|
|
232
162
|
):
|
|
233
163
|
"""Get chat completions using UiPath's normalized LLM Gateway API.
|
|
234
164
|
|
|
@@ -250,7 +180,10 @@ class UiPathLlmChatService(BaseService):
|
|
|
250
180
|
Returns:
|
|
251
181
|
ChatCompletion: The chat completion response.
|
|
252
182
|
"""
|
|
253
|
-
endpoint =
|
|
183
|
+
endpoint = EndpointManager.get_normalized_endpoint().format(
|
|
184
|
+
model=model, api_version=api_version
|
|
185
|
+
)
|
|
186
|
+
endpoint = Endpoint("/" + endpoint)
|
|
254
187
|
|
|
255
188
|
request_body = {
|
|
256
189
|
"messages": messages,
|
uipath/models/llm_gateway.py
CHANGED
uipath/utils/__init__.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
loggger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class UiPathEndpoints(Enum):
|
|
12
|
+
AH_NORMALIZED_COMPLETION_ENDPOINT = "agenthub_/llm/api/chat/completions"
|
|
13
|
+
AH_PASSTHROUGH_COMPLETION_ENDPOINT = "agenthub_/llm/openai/deployments/{model}/chat/completions?api-version={api_version}"
|
|
14
|
+
AH_EMBEDDING_ENDPOINT = (
|
|
15
|
+
"agenthub_/llm/openai/deployments/{model}/embeddings?api-version={api_version}"
|
|
16
|
+
)
|
|
17
|
+
AH_CAPABILITIES_ENDPOINT = "agenthub_/llm/api/capabilities"
|
|
18
|
+
|
|
19
|
+
NORMALIZED_COMPLETION_ENDPOINT = "llmgateway_/api/chat/completions"
|
|
20
|
+
PASSTHROUGH_COMPLETION_ENDPOINT = "llmgateway_/openai/deployments/{model}/chat/completions?api-version={api_version}"
|
|
21
|
+
EMBEDDING_ENDPOINT = (
|
|
22
|
+
"llmgateway_/openai/deployments/{model}/embeddings?api-version={api_version}"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class EndpointManager:
|
|
27
|
+
"""Manages and caches the UiPath endpoints.
|
|
28
|
+
This class provides functionality to determine which UiPath endpoints to use based on
|
|
29
|
+
the availability of AgentHub. It checks for AgentHub capabilities and caches the result
|
|
30
|
+
to avoid repeated network calls.
|
|
31
|
+
Class Attributes:
|
|
32
|
+
_base_url (str): The base URL for UiPath services, retrieved from the UIPATH_URL
|
|
33
|
+
environment variable.
|
|
34
|
+
_agenthub_available (Optional[bool]): Cached result of AgentHub availability check.
|
|
35
|
+
|
|
36
|
+
Methods:
|
|
37
|
+
is_agenthub_available(): Checks if AgentHub is available, caching the result.
|
|
38
|
+
get_passthrough_endpoint(): Returns the appropriate passthrough completion endpoint.
|
|
39
|
+
get_normalized_endpoint(): Returns the appropriate normalized completion endpoint.
|
|
40
|
+
get_embeddings_endpoint(): Returns the appropriate embeddings endpoint.
|
|
41
|
+
All endpoint methods automatically select between AgentHub and standard endpoints
|
|
42
|
+
based on availability.
|
|
43
|
+
""" # noqa: D205
|
|
44
|
+
|
|
45
|
+
_base_url = os.getenv("UIPATH_URL", "")
|
|
46
|
+
_agenthub_available: Optional[bool] = None
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def is_agenthub_available(cls) -> bool:
|
|
50
|
+
"""Check if AgentHub is available and cache the result."""
|
|
51
|
+
if cls._agenthub_available is None:
|
|
52
|
+
cls._agenthub_available = cls._check_agenthub()
|
|
53
|
+
return cls._agenthub_available
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def _check_agenthub(cls) -> bool:
|
|
57
|
+
"""Perform the actual check for AgentHub capabilities."""
|
|
58
|
+
try:
|
|
59
|
+
with httpx.Client() as http_client:
|
|
60
|
+
base_url = os.getenv("UIPATH_URL", "")
|
|
61
|
+
capabilities_url = f"{base_url.rstrip('/')}/{UiPathEndpoints.AH_CAPABILITIES_ENDPOINT.value}"
|
|
62
|
+
loggger.debug(f"Checking AgentHub capabilities at {capabilities_url}")
|
|
63
|
+
response = http_client.get(capabilities_url)
|
|
64
|
+
return response.status_code == 200
|
|
65
|
+
except Exception as e:
|
|
66
|
+
loggger.error(f"Error checking AgentHub capabilities: {e}", exc_info=True)
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def get_passthrough_endpoint(cls) -> str:
|
|
71
|
+
if cls.is_agenthub_available():
|
|
72
|
+
return UiPathEndpoints.AH_PASSTHROUGH_COMPLETION_ENDPOINT.value
|
|
73
|
+
|
|
74
|
+
return UiPathEndpoints.PASSTHROUGH_COMPLETION_ENDPOINT.value
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def get_normalized_endpoint(cls) -> str:
|
|
78
|
+
if cls.is_agenthub_available():
|
|
79
|
+
return UiPathEndpoints.AH_NORMALIZED_COMPLETION_ENDPOINT.value
|
|
80
|
+
|
|
81
|
+
return UiPathEndpoints.NORMALIZED_COMPLETION_ENDPOINT.value
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def get_embeddings_endpoint(cls) -> str:
|
|
85
|
+
if cls.is_agenthub_available():
|
|
86
|
+
return UiPathEndpoints.AH_EMBEDDING_ENDPOINT.value
|
|
87
|
+
|
|
88
|
+
return UiPathEndpoints.EMBEDDING_ENDPOINT.value
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: uipath
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.76
|
|
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
|
|
@@ -11,7 +11,7 @@ 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=
|
|
14
|
+
uipath/_cli/cli_pack.py,sha256=IKEnSf_bJrYMhxCCJCEdfP5xSivsRpQTTN_SS2zt1_k,21051
|
|
15
15
|
uipath/_cli/cli_publish.py,sha256=QT17JTClAyLve6ZjB-WvQaJ-j4DdmNneV_eDRyXjeeQ,6578
|
|
16
16
|
uipath/_cli/cli_run.py,sha256=zYg-9U6mkofdGsE0IGjYi1dOMlG8CdBxiVGxfFiLq5Y,5882
|
|
17
17
|
uipath/_cli/middlewares.py,sha256=f7bVODO9tgdtWNepG5L58-B-VgBSU6Ek2tIU6wLz0xA,4905
|
|
@@ -56,7 +56,7 @@ uipath/_services/connections_service.py,sha256=qh-HNL_GJsyPUD0wSJZRF8ZdrTE9l4HrI
|
|
|
56
56
|
uipath/_services/context_grounding_service.py,sha256=EBf7lIIYz_s1ubf_07OAZXQHjS8kpZ2vqxo4mI3VL-A,25009
|
|
57
57
|
uipath/_services/folder_service.py,sha256=9JqgjKhWD-G_KUnfUTP2BADxL6OK9QNZsBsWZHAULdE,2749
|
|
58
58
|
uipath/_services/jobs_service.py,sha256=CnDd7BM4AMqcMIR1qqu5ohhxf9m0AF4dnGoF4EX38kw,30872
|
|
59
|
-
uipath/_services/llm_gateway_service.py,sha256=
|
|
59
|
+
uipath/_services/llm_gateway_service.py,sha256=ZdKRLdEVL8Zkcl9NDT5AKADxnjqeMIuOe5H2Oy7hYKw,9421
|
|
60
60
|
uipath/_services/processes_service.py,sha256=b-c4ynjcgS0ymp130r0lI93z7DF989u8HWOmWCux754,5727
|
|
61
61
|
uipath/_services/queues_service.py,sha256=VaG3dWL2QK6AJBOLoW2NQTpkPfZjsqsYPl9-kfXPFzA,13534
|
|
62
62
|
uipath/_utils/__init__.py,sha256=VdcpnENJIa0R6Y26NoxY64-wUVyvb4pKfTh1wXDQeMk,526
|
|
@@ -83,7 +83,7 @@ uipath/models/errors.py,sha256=gPyU4sKYn57v03aOVqm97mnU9Do2e7bwMQwiSQVp9qc,461
|
|
|
83
83
|
uipath/models/exceptions.py,sha256=jav4egsVRfC1jN_FLnV7FVgWZapSepSKZQCxMe94Pac,590
|
|
84
84
|
uipath/models/interrupt_models.py,sha256=UzuVTMVesI204YQ4qFQFaN-gN3kksddkrujofcaC7zQ,881
|
|
85
85
|
uipath/models/job.py,sha256=f9L6_kg_VP0dAYvdcz1DWEWzy4NZPdlpHREod0uNK1E,3099
|
|
86
|
-
uipath/models/llm_gateway.py,sha256=
|
|
86
|
+
uipath/models/llm_gateway.py,sha256=rUIus7BrUuuRriXqSJUE9FnjOyQ7pYpaX6hWEYvA6AA,1923
|
|
87
87
|
uipath/models/processes.py,sha256=Atvfrt6X4TYST3iA62jpS_Uxc3hg6uah11p-RaKZ6dk,2029
|
|
88
88
|
uipath/models/queues.py,sha256=N_s0GKucbyjh0RnO8SxPk6wlRgvq8KIIYsfaoIY46tM,6446
|
|
89
89
|
uipath/telemetry/__init__.py,sha256=Wna32UFzZR66D-RzTKlPWlvji9i2HJb82NhHjCCXRjY,61
|
|
@@ -93,8 +93,10 @@ uipath/tracing/__init__.py,sha256=GKRINyWdHVrDsI-8mrZDLdf0oey6GHGlNZTOADK-kgc,22
|
|
|
93
93
|
uipath/tracing/_otel_exporters.py,sha256=x0PDPmDKJcxashsuehVsSsqBCzRr6WsNFaq_3_HS5F0,3014
|
|
94
94
|
uipath/tracing/_traced.py,sha256=qeVDrds2OUnpdUIA0RhtF0kg2dlAZhyC1RRkI-qivTM,18528
|
|
95
95
|
uipath/tracing/_utils.py,sha256=ZeensQexnw69jVcsVrGyED7mPlAU-L1agDGm6_1A3oc,10388
|
|
96
|
-
uipath
|
|
97
|
-
uipath
|
|
98
|
-
uipath-2.0.
|
|
99
|
-
uipath-2.0.
|
|
100
|
-
uipath-2.0.
|
|
96
|
+
uipath/utils/__init__.py,sha256=VD-KXFpF_oWexFg6zyiWMkxl2HM4hYJMIUDZ1UEtGx0,105
|
|
97
|
+
uipath/utils/_endpoints_manager.py,sha256=zcOsYwyoRzDuvdhdHwNabrqXRqC6e5J_GdEOriT7Dek,3768
|
|
98
|
+
uipath-2.0.76.dist-info/METADATA,sha256=S6VEHJtJKp2Za2augr2F9JVaItp8bzEEPj6wOe7uD2k,6462
|
|
99
|
+
uipath-2.0.76.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
100
|
+
uipath-2.0.76.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
|
|
101
|
+
uipath-2.0.76.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
|
|
102
|
+
uipath-2.0.76.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|