langchain/libs/core/langchain_core/messages
ccurme 74c7198906
core, anthropic[patch]: support streaming tool calls when function has no arguments (#23915)
resolves https://github.com/langchain-ai/langchain/issues/23911

When an AIMessageChunk is instantiated, we attempt to parse tool calls
off of the tool_call_chunks.

Here we add a special-case to this parsing, where `""` will be parsed as
`{}`.

This is a reaction to how Anthropic streams tool calls in the case where
a function has no arguments:
```
{'id': 'toolu_01J8CgKcuUVrMqfTQWPYh64r', 'input': {}, 'name': 'magic_function', 'type': 'tool_use', 'index': 1}
{'partial_json': '', 'type': 'tool_use', 'index': 1}
```
The `partial_json` does not accumulate to a valid json string-- most
other providers tend to emit `"{}"` in this case.
2024-07-05 18:57:41 +00:00
..
__init__.py core: add RemoveMessage (#23636) 2024-06-28 14:40:02 -07:00
ai.py core, anthropic[patch]: support streaming tool calls when function has no arguments (#23915) 2024-07-05 18:57:41 +00:00
base.py core: docstrings messages (#23788) 2024-07-03 11:25:00 -04:00
chat.py core: docstrings messages (#23788) 2024-07-03 11:25:00 -04:00
function.py core: docstrings messages (#23788) 2024-07-03 11:25:00 -04:00
human.py core: docstrings messages (#23788) 2024-07-03 11:25:00 -04:00
modifier.py core: docstrings messages (#23788) 2024-07-03 11:25:00 -04:00
system.py core: docstrings messages (#23788) 2024-07-03 11:25:00 -04:00
tool.py core: docstrings messages (#23788) 2024-07-03 11:25:00 -04:00
utils.py core[minor]: update conversion utils to handle RemoveMessage (#23840) 2024-07-03 16:13:31 -04:00