feat: preserve governed OpenAI tool messages in 1.4.0
Add faithful single-choice chat results, tool stream activity, error-frame retries, and isolated protocol caching. Reject empty cached completions with the same value predicate as transport, add regression coverage, and adopt Apache-2.0.
This commit is contained in:
@@ -172,3 +172,22 @@ class TestClientWithRealRedis:
|
||||
second = await client.chat(_MSGS)
|
||||
assert first.cache_hit is False and second.cache_hit is True
|
||||
assert second.content == "hello"
|
||||
|
||||
|
||||
async def test_real_completion_roundtrip(redis_cache, namespace):
|
||||
"""真实 Redis 保存完整嵌套协议对象,命中仍为值类型。"""
|
||||
from dataclasses import replace
|
||||
|
||||
from tests.unit.test_openai_completion import accumulate
|
||||
|
||||
completion = accumulate().finish()
|
||||
mw = CacheMW(backend=redis_cache, model_fingerprint="m", default_namespace=namespace, ttl_s=60)
|
||||
|
||||
async def terminal(_):
|
||||
return replace(_resp(), completion=completion)
|
||||
|
||||
request = ChatRequest(messages=_MSGS, response_mode="openai")
|
||||
first = await mw(request, terminal)
|
||||
second = await mw(request, terminal)
|
||||
assert second.cache_hit and second.completion == first.completion
|
||||
assert second.completion is not first.completion
|
||||
|
||||
Reference in New Issue
Block a user