Skip to content

Commit 6679668

Browse files
authored
Fix/fix normalized (#39)
1 parent 275e36f commit 6679668

4 files changed

Lines changed: 30 additions & 7 deletions

File tree

packages/uipath_langchain_client/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to `uipath_langchain_client` will be documented in this file.
44

5+
## [1.3.1] - 2026-03-12
6+
7+
### Fix
8+
- Fix normalized client raise error
9+
510
## [1.3.0] - 2026-03-10
611

712
### Version Bump
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__title__ = "UiPath LangChain Client"
22
__description__ = "A Python client for interacting with UiPath's LLM services via LangChain."
3-
__version__ = "1.3.0"
3+
__version__ = "1.3.1"

packages/uipath_langchain_client/src/uipath_langchain_client/base_client.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def uipath_request(
189189
url: URL | str = "/",
190190
*,
191191
request_body: dict[str, Any] | None = None,
192+
raise_status_error: bool = False,
192193
**kwargs: Any,
193194
) -> Response:
194195
"""Make a synchronous HTTP request to the UiPath API.
@@ -205,18 +206,25 @@ def uipath_request(
205206
Raises:
206207
UiPathAPIError: On HTTP 4xx/5xx responses (raised by transport layer).
207208
"""
208-
return self.uipath_sync_client.request(method, url, json=request_body, **kwargs)
209+
response = self.uipath_sync_client.request(method, url, json=request_body, **kwargs)
210+
if raise_status_error:
211+
response.raise_for_status()
212+
return response
209213

210214
async def uipath_arequest(
211215
self,
212216
method: Literal["POST", "GET"] = "POST",
213217
url: URL | str = "/",
214218
*,
215219
request_body: dict[str, Any] | None = None,
220+
raise_status_error: bool = False,
216221
**kwargs: Any,
217222
) -> Response:
218223
"""Make an asynchronous HTTP request to the UiPath API."""
219-
return await self.uipath_async_client.request(method, url, json=request_body, **kwargs)
224+
response = await self.uipath_async_client.request(method, url, json=request_body, **kwargs)
225+
if raise_status_error:
226+
response.raise_for_status()
227+
return response
220228

221229
def uipath_stream(
222230
self,
@@ -225,6 +233,7 @@ def uipath_stream(
225233
*,
226234
request_body: dict[str, Any] | None = None,
227235
stream_type: Literal["text", "bytes", "lines", "raw"] = "lines",
236+
raise_status_error: bool = False,
228237
**kwargs: Any,
229238
) -> Iterator[str | bytes]:
230239
"""Make a synchronous streaming HTTP request to the UiPath API.
@@ -244,6 +253,8 @@ def uipath_stream(
244253
str | bytes: Chunks of the streaming response.
245254
"""
246255
with self.uipath_sync_client.stream(method, url, json=request_body, **kwargs) as response:
256+
if raise_status_error:
257+
response.raise_for_status()
247258
match stream_type:
248259
case "text":
249260
for chunk in response.iter_text():
@@ -265,6 +276,7 @@ async def uipath_astream(
265276
*,
266277
request_body: dict[str, Any] | None = None,
267278
stream_type: Literal["text", "bytes", "lines", "raw"] = "lines",
279+
raise_status_error: bool = False,
268280
**kwargs: Any,
269281
) -> AsyncIterator[str | bytes]:
270282
"""Make an asynchronous streaming HTTP request to the UiPath API.
@@ -286,6 +298,8 @@ async def uipath_astream(
286298
async with self.uipath_async_client.stream(
287299
method, url, json=request_body, **kwargs
288300
) as response:
301+
if raise_status_error:
302+
response.raise_for_status()
289303
match stream_type:
290304
case "text":
291305
async for chunk in response.aiter_text():

packages/uipath_langchain_client/src/uipath_langchain_client/clients/normalized/chat_models.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def _generate(
319319
**kwargs: Any,
320320
) -> ChatResult:
321321
request_body = self._preprocess_request(messages, **kwargs)
322-
response = self.uipath_request(request_body=request_body)
322+
response = self.uipath_request(request_body=request_body, raise_status_error=True)
323323
result = self._postprocess_response(response.json())
324324
if self.captured_headers:
325325
captured = extract_matching_headers(response.headers, self.captured_headers)
@@ -336,7 +336,7 @@ async def _agenerate(
336336
**kwargs: Any,
337337
) -> ChatResult:
338338
request_body = self._preprocess_request(messages, **kwargs)
339-
response = await self.uipath_arequest(request_body=request_body)
339+
response = await self.uipath_arequest(request_body=request_body, raise_status_error=True)
340340
result = self._postprocess_response(response.json())
341341
if self.captured_headers:
342342
captured = extract_matching_headers(response.headers, self.captured_headers)
@@ -413,7 +413,9 @@ def _stream(
413413
set_captured_response_headers({})
414414
try:
415415
first = True
416-
for chunk in self.uipath_stream(request_body=request_body, stream_type="lines"):
416+
for chunk in self.uipath_stream(
417+
request_body=request_body, stream_type="lines", raise_status_error=True
418+
):
417419
chunk = str(chunk)
418420
if chunk.startswith("data:"):
419421
chunk = chunk.split("data:")[1].strip()
@@ -442,7 +444,9 @@ async def _astream(
442444
set_captured_response_headers({})
443445
try:
444446
first = True
445-
async for chunk in self.uipath_astream(request_body=request_body, stream_type="lines"):
447+
async for chunk in self.uipath_astream(
448+
request_body=request_body, stream_type="lines", raise_status_error=True
449+
):
446450
chunk = str(chunk)
447451
if chunk.startswith("data:"):
448452
chunk = chunk.split("data:")[1].strip()

0 commit comments

Comments
 (0)