verifiers 0.4.2.dev22__py3-none-any.whl → 0.4.2.dev24__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/dialects/chat.py +15 -2
- verifiers/v1/graph.py +22 -0
- verifiers/v1/interception/server.py +14 -1
- verifiers/v1/session.py +3 -0
- {verifiers-0.4.2.dev22.dist-info → verifiers-0.4.2.dev24.dist-info}/METADATA +1 -1
- {verifiers-0.4.2.dev22.dist-info → verifiers-0.4.2.dev24.dist-info}/RECORD +9 -9
- {verifiers-0.4.2.dev22.dist-info → verifiers-0.4.2.dev24.dist-info}/WHEEL +0 -0
- {verifiers-0.4.2.dev22.dist-info → verifiers-0.4.2.dev24.dist-info}/entry_points.txt +0 -0
- {verifiers-0.4.2.dev22.dist-info → verifiers-0.4.2.dev24.dist-info}/licenses/LICENSE +0 -0
verifiers/v1/dialects/chat.py
CHANGED
|
@@ -509,12 +509,25 @@ class ChatDialect(Dialect[ChatCompletion]):
|
|
|
509
509
|
)
|
|
510
510
|
return mediated, capabilities
|
|
511
511
|
|
|
512
|
-
def parse_request(
|
|
512
|
+
def parse_request(
|
|
513
|
+
self, body: RawRequest, last: tuple[list, Messages] = ((), [])
|
|
514
|
+
) -> Request:
|
|
515
|
+
"""`last`: an earlier request's raw messages and their parse; the messages this one
|
|
516
|
+
begins with that are equal to its, as sent, are taken from it."""
|
|
513
517
|
if body.get("n", 1) != 1:
|
|
514
518
|
raise ValueError("chat completions require n=1")
|
|
515
519
|
messages: Messages = []
|
|
516
520
|
tool_names: dict[str, str] = {}
|
|
517
|
-
|
|
521
|
+
before, parsed = last
|
|
522
|
+
for index, raw in enumerate(body.get("messages", [])):
|
|
523
|
+
if index < len(before) and raw == before[index]:
|
|
524
|
+
message = parsed[index]
|
|
525
|
+
messages.append(message)
|
|
526
|
+
if isinstance(message, AssistantMessage):
|
|
527
|
+
for call in message.tool_calls or []:
|
|
528
|
+
tool_names[call.id] = call.name
|
|
529
|
+
continue
|
|
530
|
+
before = ()
|
|
518
531
|
message = parse_message(raw)
|
|
519
532
|
if isinstance(message, ToolMessage) and message.name is None:
|
|
520
533
|
name = tool_names.get(message.tool_call_id)
|
verifiers/v1/graph.py
CHANGED
|
@@ -24,6 +24,7 @@ import binascii
|
|
|
24
24
|
import hashlib
|
|
25
25
|
import json
|
|
26
26
|
import time
|
|
27
|
+
import weakref
|
|
27
28
|
from dataclasses import dataclass, fields
|
|
28
29
|
from typing import TYPE_CHECKING, Any
|
|
29
30
|
|
|
@@ -309,7 +310,28 @@ def _canonical_tool_arguments(arguments: str) -> str:
|
|
|
309
310
|
_PROVIDER_STATE_FIELDS = frozenset({"encrypted_content", "signature", "data", "phase"})
|
|
310
311
|
|
|
311
312
|
|
|
313
|
+
_HASHES: dict[int, tuple[weakref.ref, str]] = {}
|
|
314
|
+
"""`message_hash` per live message, by id: a message is never changed in place (a change is a
|
|
315
|
+
copy), and a harness re-sends its whole conversation every turn, which is hashed three times."""
|
|
316
|
+
|
|
317
|
+
|
|
312
318
|
def message_hash(message: Message) -> str:
|
|
319
|
+
"""`_message_hash`, kept with the message while it lives."""
|
|
320
|
+
kept = _HASHES.get(id(message))
|
|
321
|
+
if kept is not None and kept[0]() is message:
|
|
322
|
+
return kept[1]
|
|
323
|
+
digest = _message_hash(message)
|
|
324
|
+
key = id(message)
|
|
325
|
+
|
|
326
|
+
def forget(ref: weakref.ref) -> None:
|
|
327
|
+
if (entry := _HASHES.get(key)) is not None and entry[0] is ref:
|
|
328
|
+
del _HASHES[key]
|
|
329
|
+
|
|
330
|
+
_HASHES[key] = weakref.ref(message, forget), digest
|
|
331
|
+
return digest
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def _message_hash(message: Message) -> str:
|
|
313
335
|
"""Stable content hash on the fields that round-trip through a prompt — role, content
|
|
314
336
|
(None and "" equal), assistant reasoning content when present, assistant tool calls,
|
|
315
337
|
opaque continuation state, tool call id. Two messages hash equal iff they're the same
|
|
@@ -54,6 +54,7 @@ from verifiers.v1.dialects.base import (
|
|
|
54
54
|
PROVIDER_CAPABILITY_POLICY_CODE,
|
|
55
55
|
is_sse_done_event,
|
|
56
56
|
)
|
|
57
|
+
from verifiers.v1.dialects.chat import ChatDialect
|
|
57
58
|
from verifiers.v1.errors import (
|
|
58
59
|
ProviderError,
|
|
59
60
|
RolloutError,
|
|
@@ -817,7 +818,19 @@ class InterceptionServer(Interception):
|
|
|
817
818
|
return _replay_response(idempotent.response)
|
|
818
819
|
|
|
819
820
|
try:
|
|
820
|
-
|
|
821
|
+
if isinstance(dialect, ChatDialect) and isinstance(
|
|
822
|
+
body.get("messages"), list
|
|
823
|
+
):
|
|
824
|
+
model_request = dialect.parse_request(body, session.last_request)
|
|
825
|
+
session.last_request = (
|
|
826
|
+
[
|
|
827
|
+
dict(raw) if isinstance(raw, dict) else raw
|
|
828
|
+
for raw in body["messages"]
|
|
829
|
+
],
|
|
830
|
+
list(model_request.messages),
|
|
831
|
+
)
|
|
832
|
+
else:
|
|
833
|
+
model_request = dialect.parse_request(body)
|
|
821
834
|
except ValueError as error:
|
|
822
835
|
return _error_response(dialect, str(error), status=400)
|
|
823
836
|
if session.released:
|
verifiers/v1/session.py
CHANGED
|
@@ -216,6 +216,9 @@ class RolloutSession:
|
|
|
216
216
|
gated_tools: set[tuple[str, str]] = field(default_factory=set)
|
|
217
217
|
"""Calls the harness's gate asked about before executing."""
|
|
218
218
|
prepared_users: Counter[str] = field(default_factory=Counter)
|
|
219
|
+
last_request: tuple[list, Messages] = ((), [])
|
|
220
|
+
"""The last chat request's raw messages (copied: the server rewrites a body in place) and
|
|
221
|
+
their parse, which the next request's equal prefix reuses instead of parsing again."""
|
|
219
222
|
|
|
220
223
|
@property
|
|
221
224
|
def stopped(self) -> bool:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: verifiers
|
|
3
|
-
Version: 0.4.2.
|
|
3
|
+
Version: 0.4.2.dev24
|
|
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
|
|
@@ -6,12 +6,12 @@ verifiers/v1/env.py,sha256=UA1FdNd64XywIevJliNyL54afa2StN1ND6ro9HrjlVo,20566
|
|
|
6
6
|
verifiers/v1/episode.py,sha256=ExeTkNEBsDuG40m6VogV6Gd4IHdO4SMPIzQSpt_V96U,6984
|
|
7
7
|
verifiers/v1/errors.py,sha256=OieUBIOZ6FW7oKygbXIRoag6RrPxKYpMPfEYPcCnVVE,5863
|
|
8
8
|
verifiers/v1/grading.py,sha256=RV-j71EIeQNC1AeKIDQkS1Y_KTtjJg9x8zF7n2cWr_Y,10100
|
|
9
|
-
verifiers/v1/graph.py,sha256=
|
|
9
|
+
verifiers/v1/graph.py,sha256=ifZoODILT1Ek7vM55VZrxHiJErrTvvz-Ihg7oolMTig,48271
|
|
10
10
|
verifiers/v1/harness.py,sha256=b4FDauO87VF6DfEyr0VgO8UvZB0weHZt9zPfgPiCe_c,17150
|
|
11
11
|
verifiers/v1/judge.py,sha256=T-TyYVcLGIoyUADYKy_pCBj2CTLhERlct5pmmWqPpTA,10507
|
|
12
12
|
verifiers/v1/rollout.py,sha256=zSKxyz7dvosNBYy7hOQ9Tj7k1aPNRyvpiJJZQcbW-qg,49982
|
|
13
13
|
verifiers/v1/semantic.py,sha256=nqKPPUoPL5Oh8Es_XjtcbDiQiIMKTYayXEm-EPB-jAE,5129
|
|
14
|
-
verifiers/v1/session.py,sha256=
|
|
14
|
+
verifiers/v1/session.py,sha256=Vu7YPopaiTEdmDup-aXaUIFVtPAojl5XXdcOHjrcrdI,30157
|
|
15
15
|
verifiers/v1/state.py,sha256=EckF2bWp-vV4b1jYJ9sLI5xrfGuI5spIgYYwW926toI,595
|
|
16
16
|
verifiers/v1/task.py,sha256=zcWjBjhJrkGIL29JTnxxw6v2pbJoiek_tF5RVAVV2ZY,15919
|
|
17
17
|
verifiers/v1/taskset.py,sha256=tkv74x1TMrZWDkcIKBo8XvpAo_ehynWJ5koT3QEK5zQ,9510
|
|
@@ -55,7 +55,7 @@ verifiers/v1/configs/cli/validate.py,sha256=j6qRi2EvacXTCARnVhkFRtX9xF3IP3eVVt-Z
|
|
|
55
55
|
verifiers/v1/dialects/__init__.py,sha256=MNOYM2NdTlSxGK4VtoEjMtD5zya2MpjPDX5jMvZUWEo,736
|
|
56
56
|
verifiers/v1/dialects/anthropic.py,sha256=5FZyAV2Aa9UU_tmoSJi4_FYxSw_QFk5e0v0v6LNxKk0,27338
|
|
57
57
|
verifiers/v1/dialects/base.py,sha256=9C0Co6XAQrZsIWnJiAMtwPF5B00z-c20_RiSs51-TG4,16227
|
|
58
|
-
verifiers/v1/dialects/chat.py,sha256=
|
|
58
|
+
verifiers/v1/dialects/chat.py,sha256=J3Q1DF6_armq8NWJ1AAlUgAveNuX-LFDaArUIRMYyfY,24487
|
|
59
59
|
verifiers/v1/dialects/responses.py,sha256=jd8-xZ65MOtnHnnH295s4TCUgvDbfyYg0ialKo3HvgE,31259
|
|
60
60
|
verifiers/v1/envs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
61
61
|
verifiers/v1/envs/agentic_judge/__init__.py,sha256=6vwtMCQ_cuvuubCF5-nrE5W7gGgzE-LIPKorkM5DXdw,309
|
|
@@ -128,7 +128,7 @@ verifiers/v1/harnesses/utils/replay.py,sha256=RJMzD-3K0oz_Q0zhjSH4nhwxn95R8e9Q_C
|
|
|
128
128
|
verifiers/v1/interception/__init__.py,sha256=PMysLlBer-tRpMO2J_ffetK6H77T_lmhJuRwYZb8y3I,4018
|
|
129
129
|
verifiers/v1/interception/base.py,sha256=KlXpWgcpAs_vzJxXRTVArZ9ilSV_vNfsX6vlZ35Y7kc,2249
|
|
130
130
|
verifiers/v1/interception/pool.py,sha256=Ao3iFTOcPZDfTfPH_sApVzA23u-FIaX6-FPIKOWo3c8,6701
|
|
131
|
-
verifiers/v1/interception/server.py,sha256=
|
|
131
|
+
verifiers/v1/interception/server.py,sha256=IUG55-27qahz1mrZiFyvJZnBCK444St7ULURMEIhBIQ,53236
|
|
132
132
|
verifiers/v1/interception/tunnel/__init__.py,sha256=4ZqR9F7cmLUg17qvk4sXtLpWAN4epdiMgA2l9jetMbU,721
|
|
133
133
|
verifiers/v1/interception/tunnel/base.py,sha256=UrHXwbpB_qdh4WHWZHpi2D-wEHcHgg06_0U66XFqm3M,2370
|
|
134
134
|
verifiers/v1/interception/tunnel/custom.py,sha256=SJ3F592zwmrLKrbNktWgkB_84Xfozf6tUWoGmWCitLk,817
|
|
@@ -193,8 +193,8 @@ verifiers/v1/utils/scope.py,sha256=zbs4pj6AVk4jywlAJ3AX0Q0_kzB9dBB02nY-9H4ELdQ,8
|
|
|
193
193
|
verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
|
|
194
194
|
verifiers/v1/utils/trace_store.py,sha256=Qo9qvsJAl8PoRUavjQAfUB2VNxmUtYQtU2ejLKPzY9c,3382
|
|
195
195
|
verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
|
|
196
|
-
verifiers-0.4.2.
|
|
197
|
-
verifiers-0.4.2.
|
|
198
|
-
verifiers-0.4.2.
|
|
199
|
-
verifiers-0.4.2.
|
|
200
|
-
verifiers-0.4.2.
|
|
196
|
+
verifiers-0.4.2.dev24.dist-info/METADATA,sha256=5rhZUAdmgchfoISvjY_eBNkP7WaVBKByCmiJT0fZip8,5142
|
|
197
|
+
verifiers-0.4.2.dev24.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
198
|
+
verifiers-0.4.2.dev24.dist-info/entry_points.txt,sha256=3M8Wr0w1cUKiB-fJ6YHB6eK5WuKYg-Y3OC4wCuUje_c,174
|
|
199
|
+
verifiers-0.4.2.dev24.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
|
|
200
|
+
verifiers-0.4.2.dev24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|