diff --git a/haystack_experimental/components/generators/chat/openai.py b/haystack_experimental/components/generators/chat/openai.py index 060c4174..f7a028f3 100644 --- a/haystack_experimental/components/generators/chat/openai.py +++ b/haystack_experimental/components/generators/chat/openai.py @@ -362,7 +362,7 @@ def _convert_chat_completion_to_chat_message(self, completion: ChatCompletion, c :return: The ChatMessage. """ message: ChatCompletionMessage = choice.message - text = message.content or "" + text = message.content tool_calls = [] if openai_tool_calls := message.tool_calls: for openai_tc in openai_tool_calls: diff --git a/test/components/generators/chat/test_openai.py b/test/components/generators/chat/test_openai.py index 0517168e..7f786ab4 100644 --- a/test/components/generators/chat/test_openai.py +++ b/test/components/generators/chat/test_openai.py @@ -556,6 +556,9 @@ def test_run_with_tools(self, tools): assert len(response["replies"]) == 1 message = response["replies"][0] + assert not message.texts + assert not message.text + assert message.tool_calls tool_call = message.tool_call assert isinstance(tool_call, ToolCall) @@ -641,6 +644,8 @@ def test_live_run_with_tools(self, tools): assert len(results["replies"]) == 1 message = results["replies"][0] + assert not message.texts + assert not message.text assert message.tool_calls tool_call = message.tool_call assert isinstance(tool_call, ToolCall)