Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ def _normalize_function_call_output_to_tool_content(
# Ensure we include any accumulated text as text blocks too
return normalized_blocks
if text_acc:
return "".join(text_acc)
return "\n".join(text_acc)
try:
# last resort: keep something meaningful for providers that require a string
import json as _json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
)


def test_function_call_output_list_input_text_is_converted_to_tool_string_content():
def test_function_call_output_list_input_text_parts_reach_the_tool_message_on_separate_lines():
out = LiteLLMCompletionResponsesConfig._transform_responses_api_tool_call_output_to_chat_completion_message(
tool_call_output={
"type": "function_call_output",
"call_id": "call_1",
"output": [
{"type": "input_text", "text": "hello"},
{"type": "input_text", "text": " world"},
{"type": "input_text", "text": "Paris: 22 degrees"},
{"type": "input_text", "text": "clear skies"},
Comment thread
greptile-apps[bot] marked this conversation as resolved.
],
}
)
Expand All @@ -27,7 +27,22 @@ def test_function_call_output_list_input_text_is_converted_to_tool_string_conten
msg = out[0]
assert msg["role"] == "tool"
assert msg["tool_call_id"] == "call_1"
assert msg["content"] == "hello world"
assert msg["content"] == "Paris: 22 degrees\nclear skies"


def test_function_call_output_text_part_whitespace_survives_the_join():
out = LiteLLMCompletionResponsesConfig._transform_responses_api_tool_call_output_to_chat_completion_message(
tool_call_output={
"type": "function_call_output",
"call_id": "call_1",
"output": [
{"type": "input_text", "text": "hello"},
{"type": "input_text", "text": " world"},
],
}
)

assert out[0]["content"] == "hello\n world"


def test_function_call_output_string_passthrough():
Expand Down
Loading