indoxrouter 0.1.31__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 CHANGED
@@ -346,7 +346,11 @@ class Client:
346
346
  # Retry the request after reauthentication
347
347
  response = self.session.request(**request_params)
348
348
 
349
+ # For streaming requests, check if the response is successful before returning
349
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()
350
354
  return response
351
355
 
352
356
  response.raise_for_status()
@@ -1409,6 +1413,23 @@ class Client:
1409
1413
  # Parse JSON chunk
1410
1414
  chunk = json.loads(data)
1411
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
+
1412
1433
  # For chat responses, return the processed chunk
1413
1434
  # with data field for backward compatibility
1414
1435
  if "choices" in chunk:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: indoxrouter
3
- Version: 0.1.31
3
+ Version: 0.1.32
4
4
  Summary: A unified client for various AI providers
5
5
  Author-email: indoxRouter Team <ashkan.eskandari.dev@gmail.com>
6
6
  License: MIT
@@ -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=357muF784CQYT8Vf0a5z4mT0uW6YOJrYkIwdNIXBl1w,55209
3
- indoxrouter/constants.py,sha256=rBTeOojwiokuN4F5DEt3DAmryXiCCtT7BBq9Gtc0arg,1590
4
- indoxrouter/exceptions.py,sha256=cGlXNF8dd4X8UBWgxTA099nRhEkIjcqE_4iGOlIVVp8,1632
5
- indoxrouter-0.1.31.dist-info/licenses/LICENSE,sha256=5n28CfoynFakg-QJIHnecEXcveN8gq-ZwhC0h7ATse0,24232
6
- indoxrouter-0.1.31.dist-info/METADATA,sha256=fyvGflgnrL_o2vReOiCOvh2tZybQPKmIZ0kJaBTRzZw,5740
7
- indoxrouter-0.1.31.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- indoxrouter-0.1.31.dist-info/top_level.txt,sha256=v6FGWkw0QAnXhyYtnXLI1cxzna0iveNvZUotVzCWabM,12
9
- indoxrouter-0.1.31.dist-info/RECORD,,