The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
fix(openai): improve error message for null choices in OpenAI-compatible APIs (#35236)
nightcitybladeecac3d891c2a
diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.pyindex 19ad16d4d3..52dc6f9ba2 100644--- a/libs/partners/openai/langchain_openai/chat_models/base.py+++ b/libs/partners/openai/langchain_openai/chat_models/base.py@@ -1520,7 +1520,15 @@ class BaseChatOpenAI(BaseChatModel):raise KeyError(msg) from eif choices is None:- msg = "Received response with null value for `choices`."+ # Some OpenAI-compatible APIs (e.g., vLLM) may return null choices+ # when the response format differs or an error occurs without+ # populating the error field. Provide a more helpful error message.+ msg = (+ "Received response with null value for `choices`. "+ "This can happen when using OpenAI-compatible APIs (e.g., vLLM) "+ "that return a response in an unexpected format. "+ f"Full response keys: {list(response_dict.keys())}"+ )raise TypeError(msg)token_usage = response_dict.get("usage")