langchain/libs/partners
ccurme 868cfc4a8f
openai: ignore function_calls if tool_calls are present (#31198)
Some providers include (legacy) function calls in `additional_kwargs` in
addition to tool calls. We currently unpack both function calls and tool
calls if present, but OpenAI will raise 400 in this case.

This can come up if providers are mixed in a tool-calling loop. Example:
```python
from langchain.chat_models import init_chat_model
from langchain_core.messages import HumanMessage
from langchain_core.tools import tool


@tool
def get_weather(location: str) -> str:
    """Get weather at a location."""
    return "It's sunny."



gemini = init_chat_model("google_genai:gemini-2.0-flash-001").bind_tools([get_weather])
openai = init_chat_model("openai:gpt-4.1-mini").bind_tools([get_weather])

input_message = HumanMessage("What's the weather in Boston?")
tool_call_message = gemini.invoke([input_message])

assert len(tool_call_message.tool_calls) == 1
tool_call = tool_call_message.tool_calls[0]
tool_message = get_weather.invoke(tool_call)

response = openai.invoke(  # currently raises 400 / BadRequestError
    [input_message, tool_call_message, tool_message]
)
```

Here we ignore function calls if tool calls are present.
2025-05-12 13:50:56 -04:00
..
ai21
anthropic docs: add web search to anthropic docs (#31169) 2025-05-08 16:20:11 -04:00
astradb
azure-dynamic-sessions
chroma DOCS: partners/chroma: Fix documentation around chroma query filter syntax (#31058) 2025-04-30 17:51:07 -04:00
couchbase couchbase: Migrate couchbase partner package to different repo (#29239) 2025-01-15 12:37:27 -08:00
deepseek partners: (langchain-deepseek) fix deepseek-r1 always returns an empty reasoning_content when reasoning (#31065) 2025-05-05 22:31:58 +00:00
exa packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
fireworks packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
groq packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
huggingface huggingface: release 0.2 (#31153) 2025-05-07 15:33:07 -04:00
ibm
milvus
mistralai packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
mongodb mongodb[patch]: fix link in readme (#29738) 2025-02-11 18:19:59 +00:00
nomic packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
ollama packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
openai openai: ignore function_calls if tool_calls are present (#31198) 2025-05-12 13:50:56 -04:00
perplexity packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
pinecone pinecone: delete from monorepo (#29889) 2025-02-19 12:55:15 -05:00
prompty packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
qdrant packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
together
unstructured
voyageai packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00
xai packaging: remove Python upper bound for langchain and co libs (#31025) 2025-04-28 14:44:28 -04:00