Skip to content

Commit 651a69b

Browse files
test: Add unit test for reasoning content
1 parent ae02a5c commit 651a69b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/unittests/models/test_litellm.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,28 @@ def test_message_to_generate_content_response_tool_call():
11381138
assert response.content.parts[0].function_call.id == "test_tool_call_id"
11391139

11401140

1141+
def test_message_to_generate_content_response_with_reasoning_content():
1142+
message = ChatCompletionAssistantMessage(
1143+
role="assistant",
1144+
reasoning_content="Thinking step-by-step...",
1145+
content="Hello!",
1146+
)
1147+
1148+
response = _message_to_generate_content_response(message)
1149+
assert response.content.role == "model"
1150+
assert len(response.content.parts) == 2
1151+
1152+
# Check that thought part is created first
1153+
thought_part = response.content.parts[0]
1154+
assert thought_part.text == message["reasoning_content"]
1155+
assert thought_part.thought is True
1156+
1157+
# Check that regular content follows
1158+
text_part = response.content.parts[1]
1159+
assert text_part.text == message["content"]
1160+
assert text_part.thought is False
1161+
1162+
11411163
def test_get_content_text():
11421164
parts = [types.Part.from_text(text="Test text")]
11431165
content = _get_content(parts)

0 commit comments

Comments
 (0)