verifiers 0.3.2.dev95__py3-none-any.whl → 0.3.2.dev96__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.
- verifiers/v1/harnesses/utils/core.py +64 -3
- {verifiers-0.3.2.dev95.dist-info → verifiers-0.3.2.dev96.dist-info}/METADATA +1 -1
- {verifiers-0.3.2.dev95.dist-info → verifiers-0.3.2.dev96.dist-info}/RECORD +6 -6
- {verifiers-0.3.2.dev95.dist-info → verifiers-0.3.2.dev96.dist-info}/WHEEL +0 -0
- {verifiers-0.3.2.dev95.dist-info → verifiers-0.3.2.dev96.dist-info}/entry_points.txt +0 -0
- {verifiers-0.3.2.dev95.dist-info → verifiers-0.3.2.dev96.dist-info}/licenses/LICENSE +0 -0
|
@@ -181,6 +181,57 @@ def run_edit(path: str, old_str: str, new_str: str) -> str:
|
|
|
181
181
|
return f"Edited {path}"
|
|
182
182
|
|
|
183
183
|
|
|
184
|
+
_STREAMED_MESSAGE_FIELDS = (
|
|
185
|
+
"role",
|
|
186
|
+
"reasoning",
|
|
187
|
+
"reasoning_content",
|
|
188
|
+
"reasoning_details",
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def _accumulate_streamed_message(accumulated: dict, delta: dict) -> None:
|
|
193
|
+
"""Accumulate message fields whose stream semantics differ from the SDK defaults."""
|
|
194
|
+
if role := delta.get("role"):
|
|
195
|
+
accumulated["role"] = role
|
|
196
|
+
|
|
197
|
+
for field_name in ("reasoning", "reasoning_content"):
|
|
198
|
+
if value := delta.get(field_name):
|
|
199
|
+
accumulated[field_name] = accumulated.get(field_name, "") + value
|
|
200
|
+
|
|
201
|
+
delta_details = delta.get("reasoning_details") or []
|
|
202
|
+
if not delta_details:
|
|
203
|
+
return
|
|
204
|
+
reasoning_details = accumulated.setdefault("reasoning_details", [])
|
|
205
|
+
for detail in delta_details:
|
|
206
|
+
previous = reasoning_details[-1] if reasoning_details else {}
|
|
207
|
+
detail_type = detail.get("type")
|
|
208
|
+
content_field = {
|
|
209
|
+
"reasoning.summary": "summary",
|
|
210
|
+
"reasoning.text": "text",
|
|
211
|
+
}.get(detail_type)
|
|
212
|
+
if (
|
|
213
|
+
content_field
|
|
214
|
+
and detail_type == previous.get("type")
|
|
215
|
+
and all(
|
|
216
|
+
previous.get(field_name) is None
|
|
217
|
+
or detail.get(field_name) is None
|
|
218
|
+
or previous[field_name] == detail[field_name]
|
|
219
|
+
for field_name in ("id", "index", "format")
|
|
220
|
+
)
|
|
221
|
+
):
|
|
222
|
+
previous[content_field] = (previous.get(content_field) or "") + (
|
|
223
|
+
detail.get(content_field) or ""
|
|
224
|
+
)
|
|
225
|
+
for field_name in ("id", "index", "signature", "format"):
|
|
226
|
+
if (
|
|
227
|
+
previous.get(field_name) is None
|
|
228
|
+
and detail.get(field_name) is not None
|
|
229
|
+
):
|
|
230
|
+
previous[field_name] = detail[field_name]
|
|
231
|
+
else:
|
|
232
|
+
reasoning_details.append(dict(detail))
|
|
233
|
+
|
|
234
|
+
|
|
184
235
|
async def chat(
|
|
185
236
|
client: AsyncOpenAI,
|
|
186
237
|
model: str,
|
|
@@ -201,9 +252,18 @@ async def chat(
|
|
|
201
252
|
raw_stream=raw_stream, response_format=omit, input_tools=[]
|
|
202
253
|
) as response:
|
|
203
254
|
completion = None
|
|
255
|
+
message_overrides: dict[int, dict] = {}
|
|
204
256
|
async for event in response:
|
|
205
257
|
if event.type == "chunk":
|
|
206
258
|
completion = event.snapshot
|
|
259
|
+
for choice in event.chunk.choices:
|
|
260
|
+
delta = choice.delta.model_dump(exclude_none=True)
|
|
261
|
+
if any(
|
|
262
|
+
delta.get(field_name) for field_name in _STREAMED_MESSAGE_FIELDS
|
|
263
|
+
):
|
|
264
|
+
_accumulate_streamed_message(
|
|
265
|
+
message_overrides.setdefault(choice.index, {}), delta
|
|
266
|
+
)
|
|
207
267
|
if (
|
|
208
268
|
completion is None
|
|
209
269
|
or not completion.choices
|
|
@@ -211,9 +271,10 @@ async def chat(
|
|
|
211
271
|
):
|
|
212
272
|
raise RuntimeError("model stream ended before a completion finished")
|
|
213
273
|
for choice in completion.choices:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
274
|
+
overrides = message_overrides.setdefault(choice.index, {})
|
|
275
|
+
overrides.setdefault("role", "assistant")
|
|
276
|
+
for field_name, value in overrides.items():
|
|
277
|
+
setattr(choice.message, field_name, value)
|
|
217
278
|
return completion
|
|
218
279
|
|
|
219
280
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: verifiers
|
|
3
|
-
Version: 0.3.2.
|
|
3
|
+
Version: 0.3.2.dev96
|
|
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
|
|
@@ -116,7 +116,7 @@ verifiers/v1/harnesses/terminus_2/harness.py,sha256=DMTY1bzvydyjHqzmvBSBGKJsmUzY
|
|
|
116
116
|
verifiers/v1/harnesses/terminus_2/program.py,sha256=X8MZdyItU3gbXGXnGOlJ9LWcUTnqIDaxlhkZvoRiqKY,2703
|
|
117
117
|
verifiers/v1/harnesses/utils/__init__.py,sha256=eTS-Ft2HwoLiYn5u1t_KueLmaZB_W12cdYmcVsE-G5A,364
|
|
118
118
|
verifiers/v1/harnesses/utils/compaction.py,sha256=DeY6CYLEsv7-vJm26sT2mRaPHu3W2ywiZhvFr_pi6Hg,10495
|
|
119
|
-
verifiers/v1/harnesses/utils/core.py,sha256=
|
|
119
|
+
verifiers/v1/harnesses/utils/core.py,sha256=srPo7xopHCjEhJzYoaG73LmhYstfqLoDQ9M_focQ74U,18332
|
|
120
120
|
verifiers/v1/harnesses/utils/install.py,sha256=BDkkUVZ1brSzCrbQOvMO5mVIE2DsV2pE7rTC5yROYUw,2992
|
|
121
121
|
verifiers/v1/harnesses/utils/launch.py,sha256=RqPuUY-kT2XVuLSGtXW7kRQEaP-o2KzkiJ7vcoo2neM,2883
|
|
122
122
|
verifiers/v1/harnesses/utils/mcp.py,sha256=oNhKfLjAW-wScJcDIsW_HfuvKY-JkaGBBZrRLqgRK1g,7355
|
|
@@ -188,8 +188,8 @@ verifiers/v1/utils/prime.py,sha256=UTYRjp9cbjNb6CVmBHda-1wWZAIIfxNOmTyNuT7_wL4,9
|
|
|
188
188
|
verifiers/v1/utils/retries.py,sha256=Y2ZgrAjn-qNkRKZP_RVNL_7EK0iaRcZeCa404lpGYi4,5417
|
|
189
189
|
verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
|
|
190
190
|
verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
|
|
191
|
-
verifiers-0.3.2.
|
|
192
|
-
verifiers-0.3.2.
|
|
193
|
-
verifiers-0.3.2.
|
|
194
|
-
verifiers-0.3.2.
|
|
195
|
-
verifiers-0.3.2.
|
|
191
|
+
verifiers-0.3.2.dev96.dist-info/METADATA,sha256=_JcPK6eauhHohsKe7E6GUgkYL_lb8xL008z6FkACIyY,4237
|
|
192
|
+
verifiers-0.3.2.dev96.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
193
|
+
verifiers-0.3.2.dev96.dist-info/entry_points.txt,sha256=uqQje0TMsr7k6nXlWxlPs13Si0evb3pVCEDF6c-YL80,241
|
|
194
|
+
verifiers-0.3.2.dev96.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
|
|
195
|
+
verifiers-0.3.2.dev96.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|