mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix: simplify delta type checks in AnthropicStreamWrapper and update related tests
This commit is contained in:
parent
5e8a7ec19d
commit
3cb9200577
2 changed files with 4 additions and 23 deletions
|
|
@ -438,15 +438,8 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper):
|
|||
if processed_chunk.get("type") != "content_block_delta":
|
||||
return False
|
||||
delta = processed_chunk.get("delta", {})
|
||||
delta_type = delta.get("type", "")
|
||||
if delta_type == "input_json_delta":
|
||||
if delta.get("type") == "input_json_delta":
|
||||
return bool(delta.get("partial_json"))
|
||||
elif delta_type == "text_delta":
|
||||
return bool(delta.get("text"))
|
||||
elif delta_type == "thinking_delta":
|
||||
return bool(delta.get("thinking"))
|
||||
elif delta_type == "signature_delta":
|
||||
return bool(delta.get("signature"))
|
||||
return False
|
||||
|
||||
def _increment_content_block_index(self):
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ def test_has_meaningful_delta():
|
|||
is False
|
||||
)
|
||||
|
||||
# text_delta with content -> meaningful
|
||||
# text_delta is not emitted during block transitions
|
||||
assert (
|
||||
wrapper._has_meaningful_delta(
|
||||
{
|
||||
|
|
@ -317,18 +317,6 @@ def test_has_meaningful_delta():
|
|||
"delta": {"type": "text_delta", "text": "hello"},
|
||||
}
|
||||
)
|
||||
is True
|
||||
)
|
||||
|
||||
# text_delta with empty string -> not meaningful
|
||||
assert (
|
||||
wrapper._has_meaningful_delta(
|
||||
{
|
||||
"type": "content_block_delta",
|
||||
"index": 0,
|
||||
"delta": {"type": "text_delta", "text": ""},
|
||||
}
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
|
|
@ -340,7 +328,7 @@ def test_has_meaningful_delta():
|
|||
is False
|
||||
)
|
||||
|
||||
# thinking_delta with content -> meaningful
|
||||
# thinking_delta is not emitted during block transitions
|
||||
assert (
|
||||
wrapper._has_meaningful_delta(
|
||||
{
|
||||
|
|
@ -349,7 +337,7 @@ def test_has_meaningful_delta():
|
|||
"delta": {"type": "thinking_delta", "thinking": "Let me think..."},
|
||||
}
|
||||
)
|
||||
is True
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue