From 6d530481c1048102a62ae508332ce0ffb42f4982 Mon Sep 17 00:00:00 2001 From: ccurme Date: Thu, 18 Apr 2024 22:12:57 -0400 Subject: [PATCH] openai: fix allowed block types (#20636) --- libs/partners/openai/langchain_openai/chat_models/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 7c132a3cb7c..915557baa56 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -154,7 +154,11 @@ def _format_message_content(content: Any) -> Any: # Remove unexpected block types formatted_content = [] for block in content: - if isinstance(block, dict) and "type" in block and block["type"] != "text": + if ( + isinstance(block, dict) + and "type" in block + and block["type"] == "tool_use" + ): continue else: formatted_content.append(block)