diff --git a/python/semantic_kernel/contents/function_result_content.py b/python/semantic_kernel/contents/function_result_content.py index b881371a398f..d253aa292b02 100644 --- a/python/semantic_kernel/contents/function_result_content.py +++ b/python/semantic_kernel/contents/function_result_content.py @@ -8,7 +8,6 @@ from semantic_kernel.const import DEFAULT_FULLY_QUALIFIED_NAME_SEPARATOR from semantic_kernel.contents.const import FUNCTION_RESULT_CONTENT_TAG, TEXT_CONTENT_TAG, ContentTypes -from semantic_kernel.contents.image_content import ImageContent from semantic_kernel.contents.kernel_content import KernelContent from semantic_kernel.contents.text_content import TextContent from semantic_kernel.contents.utils.author_role import AuthorRole @@ -138,12 +137,6 @@ def from_function_call_content_and_result( if isinstance(result, TextContent): res = result.text elif isinstance(result, ChatMessageContent): - if isinstance(result.items[0], TextContent): - res = result.items[0].text - elif isinstance(result.items[0], ImageContent): - res = result.items[0].data_uri - elif isinstance(result.items[0], FunctionResultContent): - res = result.items[0].result res = str(result) else: res = result diff --git a/python/tests/unit/contents/test_function_result_content.py b/python/tests/unit/contents/test_function_result_content.py index 2e83dc9737a9..a72b0bf8f827 100644 --- a/python/tests/unit/contents/test_function_result_content.py +++ b/python/tests/unit/contents/test_function_result_content.py @@ -116,6 +116,16 @@ def test_from_fcc_and_result(result: any): assert frc.metadata == {"test": "test", "test2": "test2"} +def test_from_fcc_and_empty_chat_message_result(): + fcc = FunctionCallContent(id="test", name="test-function") + result = ChatMessageContent(role="assistant") + + frc = FunctionResultContent.from_function_call_content_and_result(fcc, result) + + assert frc.result == "" + assert frc.inner_content is result + + def test_to_cmc(): frc = FunctionResultContent(id="test", name="test-function", result="test-result") cmc = frc.to_chat_message_content()