feat: add cached prompt tokens and reported model to response types
This commit is contained in:
@@ -49,6 +49,29 @@ class TestLLMResponse:
|
||||
assert resp.usage_source == "measured"
|
||||
assert resp.structured_data is None
|
||||
|
||||
def test_observability_fields_default_to_none(self):
|
||||
"""issue #3: None = 该源未上报,与"上报了但是 0"区分(0 是真实零命中)。"""
|
||||
resp = LLMResponse("c", "t", "m", "p", 1, 2, 3, None, None, False, "cid")
|
||||
assert resp.cached_prompt_tokens is None
|
||||
assert resp.model_reported is None
|
||||
filled = LLMResponse(
|
||||
"c",
|
||||
"t",
|
||||
"m",
|
||||
"p",
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
None,
|
||||
None,
|
||||
False,
|
||||
"cid",
|
||||
cached_prompt_tokens=0,
|
||||
model_reported="MiniMax-Text-01-250321",
|
||||
)
|
||||
assert filled.cached_prompt_tokens == 0 # 真实零命中,不得与 None 混同
|
||||
assert filled.model_reported == "MiniMax-Text-01-250321"
|
||||
|
||||
def test_frozen(self):
|
||||
resp = LLMResponse("c", "t", "m", "p", 1, 2, 3, None, None, False, "cid")
|
||||
with pytest.raises(dataclasses.FrozenInstanceError):
|
||||
@@ -222,6 +245,8 @@ class TestAuxTypes:
|
||||
raw={"id": "x"},
|
||||
)
|
||||
assert s.raw["id"] == "x"
|
||||
# issue #3: 新字段带默认值,不填也能构造(OCR 等其他 transport 零改动)
|
||||
assert s.cached_prompt_tokens is None and s.model_reported is None
|
||||
|
||||
|
||||
class TestOcrTypes:
|
||||
|
||||
Reference in New Issue
Block a user