Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions verifiers/v1/clients/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
"""

from collections.abc import Mapping
import math
import re

import httpx
from pydantic_core import from_json, to_json

from verifiers.v1.clients.client import SESSION_ID_HEADER, Client, RelayReply
from verifiers.v1.dialects import ChatDialect, Dialect
Expand Down Expand Up @@ -91,7 +89,7 @@ async def get_response(
dialect.apply_overrides(body, model, sampling_args),
self._headers(dialect, headers, session_id),
)
raw = from_json(resp.content)
raw = resp.json()
response = dialect.parse_response(dialect.validate_response(raw))
response.raw = raw # the program gets the provider's bytes back 1:1
return response
Expand Down Expand Up @@ -128,22 +126,7 @@ async def _request(
*,
stream: bool = False,
) -> httpx.Response:
# HTTPX rejects non-finite floats. Preserve that policy without inspecting or copying
# string payloads, which commonly dominate large upstream requests.
pending = [body]
while pending:
value = pending.pop()
if isinstance(value, float) and not math.isfinite(value):
raise ValueError(
f"Out of range float values are not JSON compliant: {value}"
)
if isinstance(value, dict):
pending.extend(value.values())
elif isinstance(value, (list, tuple)):
pending.extend(value)
content = to_json(body)
headers.setdefault("content-type", "application/json")
request = self.http.build_request("POST", url, content=content, headers=headers)
request = self.http.build_request("POST", url, json=body, headers=headers)
try:
response = await self.http.send(request, stream=stream)
except httpx.TimeoutException as e:
Expand Down Expand Up @@ -217,7 +200,7 @@ async def relay_aux(self, dialect: Dialect, route: str, body: dict) -> dict:
body,
self._headers(dialect, None, None),
)
return from_json(resp.content)
return resp.json()

async def close(self) -> None:
await self.http.aclose()
Loading