This commit is contained in:
devin-ai-integration[bot] 2026-10-17 08:01:48 -07:00 • committed by GitHub
commit e7d4aa3375
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View file

@ -7514,7 +7514,7 @@ class TextCompletionStreamWrapper:
if isinstance(chunk, Choices): # chunk should always be of type StreamingChoices
raise Exception
delta: Final = chunk["choices"][0]["delta"]
text_choices["text"] = delta["content"]
text_choices["text"] = delta["content"] or ""
text_choices["reasoning_content"] = delta.get("reasoning_content")
text_choices["index"] = chunk["choices"][0]["index"]
text_choices["finish_reason"] = chunk["choices"][0]["finish_reason"]

View file

@ -846,7 +846,7 @@ def _thinking_reply(thinking: str) -> Reply:
def _completion_texts(chunks: Sequence[Completion]) -> Iterator[str]:
for chunk in chunks:
yield from (choice.text or "" for choice in chunk.choices)
yield from (choice.text for choice in chunk.choices)
def _raw_stream_frames(gateway: Gateway, path: str, body: dict[str, JsonValue]) -> tuple[str, ...]:

View file

@ -2535,6 +2535,23 @@ def test_reasoning_content_preserved_in_text_completion_wrapper():
assert choice["reasoning_content"] == "Here's my chain of thought..."
def test_text_completion_wrapper_sends_empty_text_on_finish_chunk():
finish_chunk: Final = ModelResponseStream(
id="test-id",
created=1234567890,
model="test-model",
object="chat.completion.chunk",
choices=[StreamingChoices(finish_reason="stop", index=0, delta=Delta(content=None, role=None))],
)
wrapper: Final = TextCompletionStreamWrapper(completion_stream=None, model="test-model", stream_options=None)
choice: Final = wrapper.convert_to_text_completion_object(finish_chunk)["choices"][0]
assert choice["text"] == ""
assert choice["finish_reason"] == "stop"
assert choice["index"] == 0
def test_anthropic_claude_4_invoke_chat_provider_config():
"""Test that the Anthropic Claude 4 Invoke chat provider config is correct."""
from litellm.llms.bedrock.chat.invoke_transformations.anthropic_claude3_transformation import (