indoxrouter 0.1.29__py3-none-any.whl → 0.1.32__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.
- indoxrouter/client.py +24 -6
- {indoxrouter-0.1.29.dist-info → indoxrouter-0.1.32.dist-info}/METADATA +1 -1
- indoxrouter-0.1.32.dist-info/RECORD +9 -0
- indoxrouter-0.1.29.dist-info/RECORD +0 -9
- {indoxrouter-0.1.29.dist-info → indoxrouter-0.1.32.dist-info}/WHEEL +0 -0
- {indoxrouter-0.1.29.dist-info → indoxrouter-0.1.32.dist-info}/licenses/LICENSE +0 -0
- {indoxrouter-0.1.29.dist-info → indoxrouter-0.1.32.dist-info}/top_level.txt +0 -0
indoxrouter/client.py
CHANGED
@@ -333,10 +333,7 @@ class Client:
|
|
333
333
|
|
334
334
|
response = self.session.request(**request_params)
|
335
335
|
|
336
|
-
if
|
337
|
-
return response
|
338
|
-
|
339
|
-
# Check if we need to reauthenticate (401 Unauthorized)
|
336
|
+
# Check if we need to reauthenticate (401 Unauthorized) - for both streaming and non-streaming
|
340
337
|
if response.status_code == 401:
|
341
338
|
logger.debug("Received 401, attempting to reauthenticate")
|
342
339
|
self._authenticate()
|
@@ -349,8 +346,12 @@ class Client:
|
|
349
346
|
# Retry the request after reauthentication
|
350
347
|
response = self.session.request(**request_params)
|
351
348
|
|
352
|
-
|
353
|
-
|
349
|
+
# For streaming requests, check if the response is successful before returning
|
350
|
+
if stream:
|
351
|
+
if response.status_code >= 400:
|
352
|
+
# If streaming request still fails after retry, raise an exception
|
353
|
+
response.raise_for_status()
|
354
|
+
return response
|
354
355
|
|
355
356
|
response.raise_for_status()
|
356
357
|
return response.json()
|
@@ -1412,6 +1413,23 @@ class Client:
|
|
1412
1413
|
# Parse JSON chunk
|
1413
1414
|
chunk = json.loads(data)
|
1414
1415
|
|
1416
|
+
# Check if this is an error chunk
|
1417
|
+
if "error" in chunk:
|
1418
|
+
# Extract error details
|
1419
|
+
error_info = chunk["error"]
|
1420
|
+
if isinstance(error_info, str):
|
1421
|
+
# Try to parse error details from the string
|
1422
|
+
if "Status 401" in error_info:
|
1423
|
+
raise AuthenticationError(
|
1424
|
+
f"Authentication failed during streaming: {error_info}"
|
1425
|
+
)
|
1426
|
+
else:
|
1427
|
+
raise APIError(
|
1428
|
+
f"API error during streaming: {error_info}"
|
1429
|
+
)
|
1430
|
+
else:
|
1431
|
+
raise APIError(f"Streaming error: {error_info}")
|
1432
|
+
|
1415
1433
|
# For chat responses, return the processed chunk
|
1416
1434
|
# with data field for backward compatibility
|
1417
1435
|
if "choices" in chunk:
|
@@ -0,0 +1,9 @@
|
|
1
|
+
indoxrouter/__init__.py,sha256=P_2eiiAi-DrkkeeJndQdEMqnVheWzOZIjWkDayrwxuk,1561
|
2
|
+
indoxrouter/client.py,sha256=dDay5HgPcHwSy4svv-xUstPxExHpHRqqQkpiJxfFtyA,56483
|
3
|
+
indoxrouter/constants.py,sha256=rBTeOojwiokuN4F5DEt3DAmryXiCCtT7BBq9Gtc0arg,1590
|
4
|
+
indoxrouter/exceptions.py,sha256=cGlXNF8dd4X8UBWgxTA099nRhEkIjcqE_4iGOlIVVp8,1632
|
5
|
+
indoxrouter-0.1.32.dist-info/licenses/LICENSE,sha256=5n28CfoynFakg-QJIHnecEXcveN8gq-ZwhC0h7ATse0,24232
|
6
|
+
indoxrouter-0.1.32.dist-info/METADATA,sha256=PlwkdLDOG8LV9Ur2mRSD-cJcPyHOtNPCYJokolrcufo,5740
|
7
|
+
indoxrouter-0.1.32.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
+
indoxrouter-0.1.32.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
|
9
|
+
indoxrouter-0.1.32.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
indoxrouter/__init__.py,sha256=P_2eiiAi-DrkkeeJndQdEMqnVheWzOZIjWkDayrwxuk,1561
|
2
|
-
indoxrouter/client.py,sha256=dzeLN-DKHiHORhXA0zI_fFg5_Rvrd98uNXqpIFKobBQ,55234
|
3
|
-
indoxrouter/constants.py,sha256=rBTeOojwiokuN4F5DEt3DAmryXiCCtT7BBq9Gtc0arg,1590
|
4
|
-
indoxrouter/exceptions.py,sha256=cGlXNF8dd4X8UBWgxTA099nRhEkIjcqE_4iGOlIVVp8,1632
|
5
|
-
indoxrouter-0.1.29.dist-info/licenses/LICENSE,sha256=5n28CfoynFakg-QJIHnecEXcveN8gq-ZwhC0h7ATse0,24232
|
6
|
-
indoxrouter-0.1.29.dist-info/METADATA,sha256=2nYiD1nqnzRfjSqNWi6txEp075hE9XpnIoN1f7POUBk,5740
|
7
|
-
indoxrouter-0.1.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
-
indoxrouter-0.1.29.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
|
9
|
-
indoxrouter-0.1.29.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|