indoxrouter 0.1.31__tar.gz → 0.1.33__tar.gz
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-0.1.31/indoxrouter.egg-info → indoxrouter-0.1.33}/PKG-INFO +1 -1
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/indoxrouter/client.py +38 -4
- {indoxrouter-0.1.31 → indoxrouter-0.1.33/indoxrouter.egg-info}/PKG-INFO +1 -1
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/pyproject.toml +1 -1
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/LICENSE +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/MANIFEST.in +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/README.md +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/examples/speech_to_text_example.py +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/indoxrouter/__init__.py +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/indoxrouter/constants.py +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/indoxrouter/exceptions.py +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/indoxrouter.egg-info/SOURCES.txt +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/indoxrouter.egg-info/dependency_links.txt +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/indoxrouter.egg-info/requires.txt +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/indoxrouter.egg-info/top_level.txt +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/setup.cfg +0 -0
- {indoxrouter-0.1.31 → indoxrouter-0.1.33}/tests/test_image.py +0 -0
@@ -300,9 +300,11 @@ class Client:
|
|
300
300
|
if hasattr(self, "access_token") and self.access_token:
|
301
301
|
headers["Authorization"] = f"Bearer {self.access_token}"
|
302
302
|
|
303
|
-
|
304
|
-
|
305
|
-
|
303
|
+
logger.debug(f"Making {method} request to {url} (stream={stream})")
|
304
|
+
if data and stream:
|
305
|
+
logger.debug(f"Streaming request data: {json.dumps(data, indent=2)}")
|
306
|
+
elif data and not stream:
|
307
|
+
logger.debug(f"Non-streaming request data: {json.dumps(data, indent=2)}")
|
306
308
|
|
307
309
|
# Diagnose potential issues with the request (only for non-file uploads)
|
308
310
|
if method == "POST" and data and not files:
|
@@ -335,18 +337,30 @@ class Client:
|
|
335
337
|
|
336
338
|
# Check if we need to reauthenticate (401 Unauthorized) - for both streaming and non-streaming
|
337
339
|
if response.status_code == 401:
|
338
|
-
logger.debug(
|
340
|
+
logger.debug(
|
341
|
+
f"Received 401 for {method} {url} (stream={stream}), attempting to reauthenticate"
|
342
|
+
)
|
339
343
|
self._authenticate()
|
340
344
|
|
341
345
|
# Update Authorization header with new token if available
|
342
346
|
if hasattr(self, "access_token") and self.access_token:
|
343
347
|
headers["Authorization"] = f"Bearer {self.access_token}"
|
344
348
|
request_params["headers"] = headers
|
349
|
+
logger.debug(
|
350
|
+
f"Updated Authorization header for retry (stream={stream})"
|
351
|
+
)
|
345
352
|
|
346
353
|
# Retry the request after reauthentication
|
347
354
|
response = self.session.request(**request_params)
|
355
|
+
logger.debug(
|
356
|
+
f"Retry response status: {response.status_code} (stream={stream})"
|
357
|
+
)
|
348
358
|
|
359
|
+
# For streaming requests, check if the response is successful before returning
|
349
360
|
if stream:
|
361
|
+
if response.status_code >= 400:
|
362
|
+
# If streaming request still fails after retry, raise an exception
|
363
|
+
response.raise_for_status()
|
350
364
|
return response
|
351
365
|
|
352
366
|
response.raise_for_status()
|
@@ -1409,6 +1423,26 @@ class Client:
|
|
1409
1423
|
# Parse JSON chunk
|
1410
1424
|
chunk = json.loads(data)
|
1411
1425
|
|
1426
|
+
# Check if this is an error chunk
|
1427
|
+
if "error" in chunk:
|
1428
|
+
logger.debug(
|
1429
|
+
f"Received error chunk during streaming: {chunk}"
|
1430
|
+
)
|
1431
|
+
# Extract error details
|
1432
|
+
error_info = chunk["error"]
|
1433
|
+
if isinstance(error_info, str):
|
1434
|
+
# Try to parse error details from the string
|
1435
|
+
if "Status 401" in error_info:
|
1436
|
+
raise AuthenticationError(
|
1437
|
+
f"Authentication failed during streaming: {error_info}"
|
1438
|
+
)
|
1439
|
+
else:
|
1440
|
+
raise APIError(
|
1441
|
+
f"API error during streaming: {error_info}"
|
1442
|
+
)
|
1443
|
+
else:
|
1444
|
+
raise APIError(f"Streaming error: {error_info}")
|
1445
|
+
|
1412
1446
|
# For chat responses, return the processed chunk
|
1413
1447
|
# with data field for backward compatibility
|
1414
1448
|
if "choices" in chunk:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|