mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-14 17:07:25 +00:00
partners[openai]: Add name field to tool message to match OpenAI spec (#23551)
Discovered alongside @t968914 - **Description:** According to OpenAI docs, tool messages (response from calling tools) must have a 'name' field. https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models - **Issue:** N/A (as of right now) - **Dependencies:** N/A - **Twitter handle:** N/A Additional guidelines: - Make sure optional dependencies are imported within a function. - Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. - Most PRs should not touch more than one package. - Changes should be backwards compatible. - If you are adding something to community, do not re-import it in langchain. If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.
This commit is contained in:
parent
85e36b0f50
commit
9f0f3c7e29
@ -219,7 +219,7 @@ def _convert_message_to_dict(message: BaseMessage) -> dict:
|
||||
message_dict["role"] = "tool"
|
||||
message_dict["tool_call_id"] = message.tool_call_id
|
||||
|
||||
supported_props = {"content", "role", "tool_call_id"}
|
||||
supported_props = {"content", "role", "tool_call_id", "name"}
|
||||
message_dict = {k: v for k, v in message_dict.items() if k in supported_props}
|
||||
else:
|
||||
raise TypeError(f"Got unknown type {message}")
|
||||
|
Loading…
Reference in New Issue
Block a user