together 1.2.4__tar.gz → 1.2.5__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.
- {together-1.2.4 → together-1.2.5}/PKG-INFO +1 -1
- {together-1.2.4 → together-1.2.5}/pyproject.toml +1 -1
- {together-1.2.4 → together-1.2.5}/src/together/abstract/api_requestor.py +30 -18
- {together-1.2.4 → together-1.2.5}/LICENSE +0 -0
- {together-1.2.4 → together-1.2.5}/README.md +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/__init__.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/abstract/__init__.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/cli/__init__.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/cli/api/__init__.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/cli/api/chat.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/cli/api/completions.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/cli/api/files.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/cli/api/finetune.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/cli/api/images.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/cli/api/models.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/cli/cli.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/client.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/constants.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/error.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/filemanager.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/legacy/__init__.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/legacy/base.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/legacy/complete.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/legacy/embeddings.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/legacy/files.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/legacy/finetune.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/legacy/images.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/legacy/models.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/resources/__init__.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/resources/chat/__init__.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/resources/chat/completions.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/resources/completions.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/resources/embeddings.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/resources/files.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/resources/finetune.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/resources/images.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/resources/models.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/together_response.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/__init__.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/abstract.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/chat_completions.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/common.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/completions.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/embeddings.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/error.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/files.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/finetune.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/images.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/types/models.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/utils/__init__.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/utils/_log.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/utils/api_helpers.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/utils/files.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/utils/tools.py +0 -0
- {together-1.2.4 → together-1.2.5}/src/together/version.py +0 -0
|
@@ -121,7 +121,7 @@ class APIRequestor:
|
|
|
121
121
|
See also
|
|
122
122
|
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#syntax
|
|
123
123
|
"""
|
|
124
|
-
if response_headers
|
|
124
|
+
if not response_headers:
|
|
125
125
|
return None
|
|
126
126
|
|
|
127
127
|
# First, try the non-standard `retry-after-ms` header for milliseconds,
|
|
@@ -485,6 +485,8 @@ class APIRequestor:
|
|
|
485
485
|
_thread_context.session.close()
|
|
486
486
|
_thread_context.session = _make_session(MAX_CONNECTION_RETRIES)
|
|
487
487
|
_thread_context.session_create_time = time.time()
|
|
488
|
+
|
|
489
|
+
result = None
|
|
488
490
|
try:
|
|
489
491
|
result = _thread_context.session.request(
|
|
490
492
|
options.method,
|
|
@@ -500,11 +502,13 @@ class APIRequestor:
|
|
|
500
502
|
except requests.exceptions.Timeout as e:
|
|
501
503
|
utils.log_debug("Encountered requests.exceptions.Timeout")
|
|
502
504
|
|
|
505
|
+
result_headers = dict(result.headers) if result is not None else {}
|
|
506
|
+
|
|
503
507
|
if remaining_retries > 0:
|
|
504
508
|
return self._retry_request(
|
|
505
509
|
options,
|
|
506
510
|
remaining_retries=remaining_retries,
|
|
507
|
-
response_headers=
|
|
511
|
+
response_headers=result_headers,
|
|
508
512
|
stream=stream,
|
|
509
513
|
request_timeout=request_timeout,
|
|
510
514
|
)
|
|
@@ -513,11 +517,13 @@ class APIRequestor:
|
|
|
513
517
|
except requests.exceptions.RequestException as e:
|
|
514
518
|
utils.log_debug("Encountered requests.exceptions.RequestException")
|
|
515
519
|
|
|
520
|
+
result_headers = dict(result.headers) if result is not None else {}
|
|
521
|
+
|
|
516
522
|
if remaining_retries > 0:
|
|
517
523
|
return self._retry_request(
|
|
518
524
|
options,
|
|
519
525
|
remaining_retries=remaining_retries,
|
|
520
|
-
response_headers=
|
|
526
|
+
response_headers=result_headers,
|
|
521
527
|
stream=stream,
|
|
522
528
|
request_timeout=request_timeout,
|
|
523
529
|
)
|
|
@@ -527,26 +533,32 @@ class APIRequestor:
|
|
|
527
533
|
) from e
|
|
528
534
|
|
|
529
535
|
# retry on 5XX error or rate-limit
|
|
530
|
-
if
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
if remaining_retries > 0:
|
|
536
|
-
return self._retry_request(
|
|
537
|
-
options,
|
|
538
|
-
remaining_retries=remaining_retries,
|
|
539
|
-
response_headers=dict(result.headers),
|
|
540
|
-
stream=stream,
|
|
541
|
-
request_timeout=request_timeout,
|
|
536
|
+
if result is not None:
|
|
537
|
+
if 500 <= result.status_code < 600 or result.status_code == 429:
|
|
538
|
+
utils.log_debug(
|
|
539
|
+
f"Encountered requests.exceptions.HTTPError. Error code: {result.status_code}"
|
|
542
540
|
)
|
|
543
541
|
|
|
542
|
+
result_headers = dict(result.headers) if result is not None else {}
|
|
543
|
+
|
|
544
|
+
if remaining_retries > 0:
|
|
545
|
+
return self._retry_request(
|
|
546
|
+
options,
|
|
547
|
+
remaining_retries=remaining_retries,
|
|
548
|
+
response_headers=result_headers,
|
|
549
|
+
stream=stream,
|
|
550
|
+
request_timeout=request_timeout,
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
status_code = result.status_code if result is not None else 0
|
|
554
|
+
result_headers = dict(result.headers) if result is not None else {}
|
|
555
|
+
|
|
544
556
|
utils.log_debug(
|
|
545
557
|
"Together API response",
|
|
546
558
|
path=abs_url,
|
|
547
|
-
response_code=
|
|
548
|
-
processing_ms=
|
|
549
|
-
request_id=
|
|
559
|
+
response_code=status_code,
|
|
560
|
+
processing_ms=result_headers.get("x-total-time"),
|
|
561
|
+
request_id=result_headers.get("CF-RAY"),
|
|
550
562
|
)
|
|
551
563
|
|
|
552
564
|
return result # type: ignore
|
|
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
|
|
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
|
|
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
|
|
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
|