diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 6c752df73be8f..75f5e340ba3de 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -166,10 +166,9 @@ def _convert_message_to_dict(message: BaseMessage) -> dict: message_dict["role"] = "tool" message_dict["tool_call_id"] = message.tool_call_id - warnings - # tool message doesn't have name: https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages - del message_dict["name"] + if message_dict["name"] is None: + del message_dict["name"] else: raise TypeError(f"Got unknown type {message}") if "name" in message.additional_kwargs: