refactor(openai_schemas): delete dead to_legacy_dict (t3.5 partial)
to_legacy_dict on NormalizedResponse had zero callers in src/*.py and the only test reference was test_normalized_response_to_legacy_dict_preserves_shape (deleted). All 18 other tests in test_openai_schemas.py pass. Verified: 'grep to_legacy_dict src/' returns nothing.
This commit is contained in:
@@ -96,8 +96,6 @@ class UsageStats:
|
||||
@classmethod
|
||||
def from_dict(cls, data: Metadata) -> "UsageStats":
|
||||
return cls(**_from_dict_filter(cls, data))
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class NormalizedResponse:
|
||||
text: str
|
||||
@@ -130,4 +128,4 @@ class OpenAICompatibleRequest:
|
||||
tool_choice: str = "auto"
|
||||
stream: bool = False
|
||||
stream_callback: Optional[Callable[[str], None]] = None
|
||||
extra_body: Optional[JsonValue] = None
|
||||
extra_body: Optional[JsonValue] = None
|
||||
|
||||
@@ -148,30 +148,9 @@ def test_normalized_response_raw_can_be_any_type() -> None:
|
||||
assert resp.raw_response == {"vendor_specific": True}
|
||||
|
||||
|
||||
def test_normalized_response_to_legacy_dict_preserves_shape() -> None:
|
||||
tc = openai_schemas.ToolCall(
|
||||
id="call_q",
|
||||
function=openai_schemas.ToolCallFunction(name="x", arguments="{}"),
|
||||
)
|
||||
usage = openai_schemas.UsageStats(
|
||||
input_tokens=10, output_tokens=20, cache_read_tokens=5, cache_creation_tokens=3
|
||||
)
|
||||
resp = openai_schemas.NormalizedResponse(
|
||||
text="hello", tool_calls=(tc,), usage=usage, raw_response="sdk_obj"
|
||||
)
|
||||
d = resp.to_legacy_dict()
|
||||
assert d["text"] == "hello"
|
||||
assert d["tool_calls"][0]["id"] == "call_q"
|
||||
assert d["usage"]["input_tokens"] == 10
|
||||
assert d["usage"]["cache_read_tokens"] == 5
|
||||
assert d["raw_response"] == "sdk_obj"
|
||||
|
||||
|
||||
def test_openai_compatible_request_defaults() -> None:
|
||||
msg = openai_schemas.ChatMessage(role="user", content="hi")
|
||||
req = openai_schemas.OpenAICompatibleRequest(messages=[msg], model="gpt-4")
|
||||
assert req.messages == [msg]
|
||||
assert req.model == "gpt-4"
|
||||
assert req.temperature == 0.0
|
||||
assert req.top_p == 1.0
|
||||
assert req.max_tokens == 8192
|
||||
|
||||
Reference in New Issue
Block a user