verifiers 0.3.2.dev136__py3-none-any.whl → 0.3.2.dev137__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.
@@ -4,7 +4,6 @@ import argparse
4
4
  import asyncio
5
5
  import json
6
6
  import logging
7
- import random
8
7
  import subprocess
9
8
  from contextlib import AsyncExitStack
10
9
  from pathlib import Path
@@ -13,6 +12,13 @@ from typing import TYPE_CHECKING
13
12
  import httpx
14
13
  from openai import APIConnectionError, APIStatusError, AsyncOpenAI, omit
15
14
  from openai.lib.streaming.chat import AsyncChatCompletionStream
15
+ from tenacity import (
16
+ AsyncRetrying,
17
+ before_sleep_log,
18
+ retry_if_exception_type,
19
+ stop_after_attempt,
20
+ wait_random_exponential,
21
+ )
16
22
 
17
23
  if TYPE_CHECKING:
18
24
  # The harness bundles this module into the generated script before execution.
@@ -247,9 +253,16 @@ async def chat(
247
253
  kwargs["tools"] = tools
248
254
  if tools and tool_choice is not None:
249
255
  kwargs["tool_choice"] = tool_choice
250
- for attempt in range(client.max_retries + 1):
256
+ async for attempt in AsyncRetrying(
257
+ retry=retry_if_exception_type((APIConnectionError, httpx.TransportError)),
258
+ stop=stop_after_attempt(client.max_retries + 1),
259
+ wait=wait_random_exponential(multiplier=0.5, max=8.0),
260
+ before_sleep=before_sleep_log(logging.getLogger(__name__), logging.WARNING),
261
+ reraise=True,
262
+ ):
251
263
  # Reuse the interception server's body-digest replay guard on stream retries.
252
- headers = {"x-stainless-retry-count": str(attempt)} if attempt else omit
264
+ retry_count = attempt.retry_state.attempt_number - 1
265
+ headers = {"x-stainless-retry-count": str(retry_count)} if retry_count else omit
253
266
  raw_stream = await client.chat.completions.create(
254
267
  **kwargs,
255
268
  stream=True,
@@ -257,19 +270,8 @@ async def chat(
257
270
  extra_headers=headers,
258
271
  )
259
272
  # The SDK retries request setup; only stream consumption is retried here.
260
- try:
273
+ with attempt:
261
274
  return await _read_chat_completion(raw_stream)
262
- except (APIConnectionError, httpx.TransportError) as error:
263
- cause = error.__cause__ or error
264
- if attempt == client.max_retries:
265
- raise
266
- logging.getLogger(__name__).warning(
267
- "Retrying interrupted model stream (%s/%s): %r",
268
- attempt + 1,
269
- client.max_retries,
270
- cause,
271
- )
272
- await asyncio.sleep(min(0.5 * 2**attempt, 8.0) * random.uniform(0.75, 1.0))
273
275
 
274
276
 
275
277
  async def _read_chat_completion(raw_stream):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: verifiers
3
- Version: 0.3.2.dev136
3
+ Version: 0.3.2.dev137
4
4
  Summary: Verifiers: Environments for LLM Reinforcement Learning
5
5
  Project-URL: Homepage, https://github.com/primeintellect-ai/verifiers
6
6
  Project-URL: Documentation, https://github.com/primeintellect-ai/verifiers
@@ -118,7 +118,7 @@ verifiers/v1/harnesses/terminus_2/harness.py,sha256=cKQJluW01mkxEccTLFwSWsVMavyi
118
118
  verifiers/v1/harnesses/terminus_2/program.py,sha256=X8MZdyItU3gbXGXnGOlJ9LWcUTnqIDaxlhkZvoRiqKY,2703
119
119
  verifiers/v1/harnesses/utils/__init__.py,sha256=eTS-Ft2HwoLiYn5u1t_KueLmaZB_W12cdYmcVsE-G5A,364
120
120
  verifiers/v1/harnesses/utils/compaction.py,sha256=DeY6CYLEsv7-vJm26sT2mRaPHu3W2ywiZhvFr_pi6Hg,10495
121
- verifiers/v1/harnesses/utils/core.py,sha256=Kqp0npmiJlGtT5vt7r2sX70R29W9d_ODR7gN-ufKrug,19642
121
+ verifiers/v1/harnesses/utils/core.py,sha256=A4B_TbZBQVd6IYQyytrO8gbmrO-aVqjRl0-w8GClWF4,19676
122
122
  verifiers/v1/harnesses/utils/install.py,sha256=BDkkUVZ1brSzCrbQOvMO5mVIE2DsV2pE7rTC5yROYUw,2992
123
123
  verifiers/v1/harnesses/utils/launch.py,sha256=RqPuUY-kT2XVuLSGtXW7kRQEaP-o2KzkiJ7vcoo2neM,2883
124
124
  verifiers/v1/harnesses/utils/mcp.py,sha256=oNhKfLjAW-wScJcDIsW_HfuvKY-JkaGBBZrRLqgRK1g,7355
@@ -190,8 +190,8 @@ verifiers/v1/utils/retries.py,sha256=Y2ZgrAjn-qNkRKZP_RVNL_7EK0iaRcZeCa404lpGYi4
190
190
  verifiers/v1/utils/scope.py,sha256=bzUEiWDOVdbj7dXOwGOlzsQ_-Xu0j9NR5TalQB-8TS8,838
191
191
  verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
192
192
  verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
193
- verifiers-0.3.2.dev136.dist-info/METADATA,sha256=Dody0KdHsobWBNx2Mc1KbvuGAH152EZaPxEonMGcoJ4,4161
194
- verifiers-0.3.2.dev136.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
195
- verifiers-0.3.2.dev136.dist-info/entry_points.txt,sha256=iugElcdWPKbQM7uFF0lZ8iUpHsNr17-BwEAAjJWxV3U,259
196
- verifiers-0.3.2.dev136.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
197
- verifiers-0.3.2.dev136.dist-info/RECORD,,
193
+ verifiers-0.3.2.dev137.dist-info/METADATA,sha256=VQI1rjxyohbv-YuGV_gy0Ej5r4i_AmPXzYM2FkPrmro,4161
194
+ verifiers-0.3.2.dev137.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
195
+ verifiers-0.3.2.dev137.dist-info/entry_points.txt,sha256=iugElcdWPKbQM7uFF0lZ8iUpHsNr17-BwEAAjJWxV3U,259
196
+ verifiers-0.3.2.dev137.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
197
+ verifiers-0.3.2.dev137.dist-info/RECORD,,