uipath-langchain-client 1.0.1__py3-none-any.whl → 1.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uipath_langchain_client/__version__.py +1 -1
- uipath_langchain_client/clients/google/chat_models.py +12 -155
- uipath_langchain_client/clients/vertexai/chat_models.py +4 -0
- {uipath_langchain_client-1.0.1.dist-info → uipath_langchain_client-1.0.2.dist-info}/METADATA +2 -2
- {uipath_langchain_client-1.0.1.dist-info → uipath_langchain_client-1.0.2.dist-info}/RECORD +6 -6
- {uipath_langchain_client-1.0.1.dist-info → uipath_langchain_client-1.0.2.dist-info}/WHEEL +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
from collections.abc import AsyncIterator, Iterator
|
|
2
1
|
from typing import Self
|
|
3
2
|
|
|
4
|
-
from httpx import
|
|
5
|
-
from pydantic import Field,
|
|
3
|
+
from httpx import URL, Request
|
|
4
|
+
from pydantic import Field, model_validator
|
|
6
5
|
from uipath_langchain_client.base_client import UiPathBaseLLMClient
|
|
7
6
|
from uipath_langchain_client.settings import UiPathAPIConfig
|
|
8
7
|
|
|
@@ -18,135 +17,6 @@ except ImportError as e:
|
|
|
18
17
|
) from e
|
|
19
18
|
|
|
20
19
|
|
|
21
|
-
def _wrap_iter_lines(original: Iterator[str]) -> Iterator[str]:
|
|
22
|
-
"""Wrap iter_lines to extract individual JSON objects from streaming responses.
|
|
23
|
-
|
|
24
|
-
The LLM Gateway wraps streaming JSON responses in an array like [{...}, {...}].
|
|
25
|
-
This extracts each complete JSON object and yields them individually.
|
|
26
|
-
Handles multiple JSON objects on a single line (e.g., {...},{...}).
|
|
27
|
-
|
|
28
|
-
We prefix output with 'data: ' so the SDK's _iter_response_stream bypasses its
|
|
29
|
-
broken brace counting (which doesn't handle braces inside strings) and yields
|
|
30
|
-
our JSON objects directly.
|
|
31
|
-
|
|
32
|
-
Temporal Fix until it's fixed in the main package.
|
|
33
|
-
"""
|
|
34
|
-
buffer = ""
|
|
35
|
-
balance = 0
|
|
36
|
-
in_string = False
|
|
37
|
-
escape_next = False
|
|
38
|
-
|
|
39
|
-
for line in original:
|
|
40
|
-
# Handle data: prefix (SSE format)
|
|
41
|
-
if line.startswith("data:"):
|
|
42
|
-
line = line[5:].lstrip()
|
|
43
|
-
|
|
44
|
-
for char in line:
|
|
45
|
-
# Handle escape sequences in strings
|
|
46
|
-
if escape_next:
|
|
47
|
-
buffer += char
|
|
48
|
-
escape_next = False
|
|
49
|
-
continue
|
|
50
|
-
|
|
51
|
-
if char == "\\" and in_string:
|
|
52
|
-
buffer += char
|
|
53
|
-
escape_next = True
|
|
54
|
-
continue
|
|
55
|
-
|
|
56
|
-
if char == '"':
|
|
57
|
-
in_string = not in_string
|
|
58
|
-
buffer += char
|
|
59
|
-
continue
|
|
60
|
-
|
|
61
|
-
# Only track braces outside of strings
|
|
62
|
-
if not in_string:
|
|
63
|
-
if char == "{":
|
|
64
|
-
balance += 1
|
|
65
|
-
buffer += char
|
|
66
|
-
elif char == "}":
|
|
67
|
-
buffer += char
|
|
68
|
-
balance -= 1
|
|
69
|
-
if balance == 0 and buffer:
|
|
70
|
-
# Complete JSON object found - yield with 'data: ' prefix
|
|
71
|
-
# so SDK bypasses its broken brace counting
|
|
72
|
-
yield "data: " + buffer
|
|
73
|
-
buffer = ""
|
|
74
|
-
elif balance == 0:
|
|
75
|
-
# Skip characters outside JSON objects (array brackets, commas, whitespace)
|
|
76
|
-
continue
|
|
77
|
-
else:
|
|
78
|
-
buffer += char
|
|
79
|
-
else:
|
|
80
|
-
buffer += char
|
|
81
|
-
|
|
82
|
-
# Yield any remaining buffer (handles incomplete streams)
|
|
83
|
-
if buffer:
|
|
84
|
-
yield "data: " + buffer
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
async def _wrap_aiter_lines(original: AsyncIterator[str]) -> AsyncIterator[str]:
|
|
88
|
-
"""Async version of _wrap_iter_lines.
|
|
89
|
-
|
|
90
|
-
Extracts individual JSON objects from streaming responses.
|
|
91
|
-
Handles multiple JSON objects on a single line (e.g., {...},{...}).
|
|
92
|
-
|
|
93
|
-
We prefix output with 'data: ' so the SDK's _iter_response_stream bypasses its
|
|
94
|
-
broken brace counting (which doesn't handle braces inside strings) and yields
|
|
95
|
-
our JSON objects directly.
|
|
96
|
-
"""
|
|
97
|
-
buffer = ""
|
|
98
|
-
balance = 0
|
|
99
|
-
in_string = False
|
|
100
|
-
escape_next = False
|
|
101
|
-
|
|
102
|
-
async for line in original:
|
|
103
|
-
# Handle data: prefix (SSE format)
|
|
104
|
-
if line.startswith("data:"):
|
|
105
|
-
line = line[5:].lstrip()
|
|
106
|
-
|
|
107
|
-
for char in line:
|
|
108
|
-
# Handle escape sequences in strings
|
|
109
|
-
if escape_next:
|
|
110
|
-
buffer += char
|
|
111
|
-
escape_next = False
|
|
112
|
-
continue
|
|
113
|
-
|
|
114
|
-
if char == "\\" and in_string:
|
|
115
|
-
buffer += char
|
|
116
|
-
escape_next = True
|
|
117
|
-
continue
|
|
118
|
-
|
|
119
|
-
if char == '"':
|
|
120
|
-
in_string = not in_string
|
|
121
|
-
buffer += char
|
|
122
|
-
continue
|
|
123
|
-
|
|
124
|
-
# Only track braces outside of strings
|
|
125
|
-
if not in_string:
|
|
126
|
-
if char == "{":
|
|
127
|
-
balance += 1
|
|
128
|
-
buffer += char
|
|
129
|
-
elif char == "}":
|
|
130
|
-
buffer += char
|
|
131
|
-
balance -= 1
|
|
132
|
-
if balance == 0 and buffer:
|
|
133
|
-
# Complete JSON object found - yield with 'data: ' prefix
|
|
134
|
-
# so SDK bypasses its broken brace counting
|
|
135
|
-
yield "data: " + buffer
|
|
136
|
-
buffer = ""
|
|
137
|
-
elif balance == 0:
|
|
138
|
-
# Skip characters outside JSON objects (array brackets, commas, whitespace)
|
|
139
|
-
continue
|
|
140
|
-
else:
|
|
141
|
-
buffer += char
|
|
142
|
-
else:
|
|
143
|
-
buffer += char
|
|
144
|
-
|
|
145
|
-
# Yield any remaining buffer (handles incomplete streams)
|
|
146
|
-
if buffer:
|
|
147
|
-
yield "data: " + buffer
|
|
148
|
-
|
|
149
|
-
|
|
150
20
|
class UiPathChatGoogleGenerativeAI(UiPathBaseLLMClient, ChatGoogleGenerativeAI):
|
|
151
21
|
api_config: UiPathAPIConfig = UiPathAPIConfig(
|
|
152
22
|
api_type="completions",
|
|
@@ -159,34 +29,21 @@ class UiPathChatGoogleGenerativeAI(UiPathBaseLLMClient, ChatGoogleGenerativeAI):
|
|
|
159
29
|
|
|
160
30
|
# Override fields to avoid errors when instantiating the class
|
|
161
31
|
model: str = Field(default="", alias="model_name")
|
|
162
|
-
|
|
32
|
+
project: str | None = "PLACEHOLDER"
|
|
33
|
+
location: str | None = "PLACEHOLDER"
|
|
163
34
|
|
|
164
35
|
@model_validator(mode="after")
|
|
165
36
|
def setup_uipath_client(self) -> Self:
|
|
166
|
-
def
|
|
167
|
-
""
|
|
168
|
-
|
|
169
|
-
response.iter_lines = lambda: _wrap_iter_lines(original_iter_lines())
|
|
170
|
-
|
|
171
|
-
async def fix_streaming_response_async(response: Response):
|
|
172
|
-
"""Monkey-patch aiter_lines to strip JSON array brackets."""
|
|
173
|
-
original_aiter_lines = response.aiter_lines
|
|
174
|
-
response.aiter_lines = lambda: _wrap_aiter_lines(original_aiter_lines())
|
|
175
|
-
|
|
176
|
-
self.uipath_sync_client.event_hooks["response"].append(fix_streaming_response)
|
|
177
|
-
self.uipath_async_client.event_hooks["response"].append(fix_streaming_response_async)
|
|
178
|
-
|
|
179
|
-
# TODO: in exactly 2 weeks, we need to uncomment this part of the code because it will work, 5 february 2026 is the date.
|
|
180
|
-
# def fix_url_for_streaming(request: Request):
|
|
181
|
-
# if request.headers.get("X-UiPath-Streaming-Enabled") == "true":
|
|
182
|
-
# request.url = URL(request.url).copy_add_param("alt", "sse")
|
|
37
|
+
def fix_url_for_streaming(request: Request):
|
|
38
|
+
if request.headers.get("X-UiPath-Streaming-Enabled") == "true":
|
|
39
|
+
request.url = URL(request.url).copy_add_param("alt", "sse")
|
|
183
40
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
41
|
+
async def fix_url_for_streaming_async(request: Request):
|
|
42
|
+
if request.headers.get("X-UiPath-Streaming-Enabled") == "true":
|
|
43
|
+
request.url = URL(request.url).copy_add_param("alt", "sse")
|
|
187
44
|
|
|
188
|
-
|
|
189
|
-
|
|
45
|
+
self.uipath_sync_client.event_hooks["request"].append(fix_url_for_streaming)
|
|
46
|
+
self.uipath_async_client.event_hooks["request"].append(fix_url_for_streaming_async)
|
|
190
47
|
|
|
191
48
|
self.client = Client(
|
|
192
49
|
vertexai=True,
|
|
@@ -23,6 +23,10 @@ class UiPathChatAnthropicVertex(UiPathBaseLLMClient, ChatAnthropicVertex): # ty
|
|
|
23
23
|
freeze_base_url=True,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
+
# Override fields to avoid errors when instantiating the class
|
|
27
|
+
project: str | None = "PLACEHOLDER"
|
|
28
|
+
location: str = "PLACEHOLDER"
|
|
29
|
+
|
|
26
30
|
@model_validator(mode="after")
|
|
27
31
|
def setup_uipath_client(self) -> Self:
|
|
28
32
|
self.client = AnthropicVertex(
|
{uipath_langchain_client-1.0.1.dist-info → uipath_langchain_client-1.0.2.dist-info}/METADATA
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: uipath-langchain-client
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: LangChain-compatible chat models and embeddings for UiPath's LLM services
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Requires-Dist: langchain>=1.2.7
|
|
7
|
-
Requires-Dist: uipath-llm-client>=1.0.
|
|
7
|
+
Requires-Dist: uipath-llm-client>=1.0.2
|
|
8
8
|
Provides-Extra: all
|
|
9
9
|
Requires-Dist: langchain-anthropic>=1.3.1; extra == 'all'
|
|
10
10
|
Requires-Dist: langchain-aws>=1.2.1; extra == 'all'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
uipath_langchain_client/__init__.py,sha256=3rOLh-mBT_DWUNShlnOzzcU9OxT98V7i_fQPcFRAGuQ,1605
|
|
2
|
-
uipath_langchain_client/__version__.py,sha256=
|
|
2
|
+
uipath_langchain_client/__version__.py,sha256=4nhzfK4r7krVivStesBcwAOfNmRJXk2QNvz_mT5-iMY,154
|
|
3
3
|
uipath_langchain_client/base_client.py,sha256=ZOv51sfGpJLS0fQq0kUIy0v0BA_WF6jEFky9EgO7fpQ,10911
|
|
4
4
|
uipath_langchain_client/factory.py,sha256=6KKAQqtdtDS8cwsZ5MUoChiqnDye41svbZ5CeUaggYg,8312
|
|
5
5
|
uipath_langchain_client/settings.py,sha256=mcSXWzZ_jkG_y-1XJOJpDZH9YVHZd6MMbNMMHXujGjw,920
|
|
@@ -13,7 +13,7 @@ uipath_langchain_client/clients/bedrock/chat_models.py,sha256=F1LuKnwWjiZSeV1Zbs
|
|
|
13
13
|
uipath_langchain_client/clients/bedrock/embeddings.py,sha256=rLv2bWG46i3CJDfd7X9dB3acASQwTNfcxksZ7TRQjtg,1141
|
|
14
14
|
uipath_langchain_client/clients/bedrock/utils.py,sha256=YYWyerreQj4X2iR-Lsg1i7ELLUi9HLk63AXuzuHp4KM,3129
|
|
15
15
|
uipath_langchain_client/clients/google/__init__.py,sha256=oWzq3pprWR-si-mZt40VrQ5f53f-O7AKSWzqP60VDHE,271
|
|
16
|
-
uipath_langchain_client/clients/google/chat_models.py,sha256=
|
|
16
|
+
uipath_langchain_client/clients/google/chat_models.py,sha256=6KQufo3mt1lDW3o4iR1OMYhG1uZKoAOmCkyvTWsmxWg,2377
|
|
17
17
|
uipath_langchain_client/clients/google/embeddings.py,sha256=jx2TmzvcxIcKA0iitm5-iqSIj0hqy5RmLnNXMXbkXns,1705
|
|
18
18
|
uipath_langchain_client/clients/normalized/__init__.py,sha256=r0tJ3QvhZPcbNjZJz8ADVCVTcyV1nb0zluwhb-tAAMg,257
|
|
19
19
|
uipath_langchain_client/clients/normalized/chat_models.py,sha256=kIs8kyW5OKWiNWnxn7o8hz6W-yizaFVvd3V7KZAC8Sw,16639
|
|
@@ -22,7 +22,7 @@ uipath_langchain_client/clients/openai/__init__.py,sha256=f6O7otwFkSc5CxVOHpZ1GH
|
|
|
22
22
|
uipath_langchain_client/clients/openai/chat_models.py,sha256=fAaDeR5bQ6FFgufP0Qq8Hs3f-1QKHvLNvghGw18pGzQ,4029
|
|
23
23
|
uipath_langchain_client/clients/openai/embeddings.py,sha256=3saz1Do0rylJBVUWLcF8h651VaIED-ivUiiUnLPLJmE,3310
|
|
24
24
|
uipath_langchain_client/clients/vertexai/__init__.py,sha256=g_rPq14ij0DPxUC4tX7vNDB5KVvfULxOUXyReM97PZw,132
|
|
25
|
-
uipath_langchain_client/clients/vertexai/chat_models.py,sha256=
|
|
26
|
-
uipath_langchain_client-1.0.
|
|
27
|
-
uipath_langchain_client-1.0.
|
|
28
|
-
uipath_langchain_client-1.0.
|
|
25
|
+
uipath_langchain_client/clients/vertexai/chat_models.py,sha256=BpLGbDZ6YP6mOgxXZp8lXf9tId-JAuYhEFUcrqFejHE,2022
|
|
26
|
+
uipath_langchain_client-1.0.2.dist-info/METADATA,sha256=CiEtjIYvU7UI_4aYFn4c2MUlgg4lpX4Wi-e5xefgVEs,8762
|
|
27
|
+
uipath_langchain_client-1.0.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
28
|
+
uipath_langchain_client-1.0.2.dist-info/RECORD,,
|
|
File without changes
|