You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/libs/core/langchain_core
Bagatur 9514bc4d67
core[minor], ...: add tool calls message (#18947)
core[minor], langchain[patch], openai[minor], anthropic[minor], fireworks[minor], groq[minor], mistralai[minor]

```python
class ToolCall(TypedDict):
    name: str
    args: Dict[str, Any]
    id: Optional[str]

class InvalidToolCall(TypedDict):
    name: Optional[str]
    args: Optional[str]
    id: Optional[str]
    error: Optional[str]

class ToolCallChunk(TypedDict):
    name: Optional[str]
    args: Optional[str]
    id: Optional[str]
    index: Optional[int]


class AIMessage(BaseMessage):
    ...
    tool_calls: List[ToolCall] = []
    invalid_tool_calls: List[InvalidToolCall] = []
    ...


class AIMessageChunk(AIMessage, BaseMessageChunk):
    ...
    tool_call_chunks: Optional[List[ToolCallChunk]] = None
    ...
```
Important considerations:
- Parsing logic occurs within different providers;
- ~Changing output type is a breaking change for anyone doing explicit
type checking;~
- ~Langsmith rendering will need to be updated:
https://github.com/langchain-ai/langchainplus/pull/3561~
- ~Langserve will need to be updated~
- Adding chunks:
- ~AIMessage + ToolCallsMessage = ToolCallsMessage if either has
non-null .tool_calls.~
- Tool call chunks are appended, merging when having equal values of
`index`.
  - additional_kwargs accumulate the normal way.
- During streaming:
- ~Messages can change types (e.g., from AIMessageChunk to
AIToolCallsMessageChunk)~
- Output parsers parse additional_kwargs (during .invoke they read off
tool calls).

Packages outside of `partners/`:
- https://github.com/langchain-ai/langchain-cohere/pull/7
- https://github.com/langchain-ai/langchain-google/pull/123/files

---------

Co-authored-by: Chester Curme <chester.curme@gmail.com>
6 months ago
..
_api core[patch]: mypy ignore fixes #17048 (#19931) 6 months ago
beta core: Updated docstring for Context class (#19079) 6 months ago
callbacks core[patch]: remove requests (#19891) 6 months ago
document_loaders core[minor]: Add aload to document loader (#19936) 6 months ago
documents core[minor]: move document compressor base (#17910) 7 months ago
embeddings core[minor]: moved fake llms and embeddings to core (#19226) 6 months ago
example_selectors core[minor]: Add async methods to MaxMarginalRelevanceExampleSelector (#19639) 6 months ago
language_models [core] fix: manually specifying run_id for chat models.invoke() and .ainvoke() (#20082) 6 months ago
load core: Assign missing message ids in BaseChatModel (#19863) 6 months ago
messages core[minor], ...: add tool calls message (#18947) 6 months ago
output_parsers core[minor], ...: add tool calls message (#18947) 6 months ago
outputs docs: modules descriptions (#17844) 7 months ago
prompts core[minor]: Implement aformat_messages for _StringImageMessagePromptTemplate (#20036) 6 months ago
pydantic_v1 Separate out langchain_core package (#13577) 10 months ago
runnables core: fix return of draw_mermaid_png and change to not save image by default (#19950) 6 months ago
tracers core[patch]: remove requests (#19891) 6 months ago
utils core[minor], ...: add tool calls message (#18947) 6 months ago
__init__.py core[patch], community[patch]: mark runnable context, lc load as beta (#15603) 9 months ago
agents.py docs: modules descriptions (#17844) 7 months ago
caches.py core[patch]: Document BaseCache abstraction in code (#20046) 6 months ago
chat_history.py docs: modules descriptions (#17844) 7 months ago
chat_sessions.py docs: modules descriptions (#17844) 7 months ago
env.py core[patch]: update langchain-core runtime library name (#14884) 9 months ago
exceptions.py docs: modules descriptions (#17844) 7 months ago
globals.py core[patch]: Move `globals` to a module instead of a package (non breaking change) (#19159) 6 months ago
memory.py docs: modules descriptions (#17844) 7 months ago
prompt_values.py docs: modules descriptions (#17844) 7 months ago
py.typed core[minor], langchain[patch], experimental[patch]: Added missing `py.typed` to `langchain_core` (#14143) 10 months ago
retrievers.py [Enhancement] Add support for directly providing a run_id (#18990) 6 months ago
stores.py core: upgrade mypy to recent mypy (#18753) 7 months ago
sys_info.py docs: modules descriptions (#17844) 7 months ago
tools.py core[patch]: ToolException docs/exception message (#17590) 6 months ago
vectorstores.py core[minor]: Add async methods to MaxMarginalRelevanceExampleSelector (#19639) 6 months ago