The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
docs(core,groq,openai): nits for ref docs (#34243)
Mason Daugherty3ace4e368082
diff --git a/libs/core/langchain_core/callbacks/usage.py b/libs/core/langchain_core/callbacks/usage.pyindex b183a51383..5590a36fc7 100644--- a/libs/core/langchain_core/callbacks/usage.py+++ b/libs/core/langchain_core/callbacks/usage.py@@ -95,7 +95,7 @@ def get_usage_metadata_callback("""Get usage metadata callback.Get context manager for tracking usage metadata across chat model calls using- `AIMessage.usage_metadata`.+ [`AIMessage.usage_metadata`][langchain.messages.AIMessage.usage_metadata].Args:name: The name of the context variable.diff --git a/libs/core/langchain_core/language_models/__init__.py b/libs/core/langchain_core/language_models/__init__.pyindex ee83df7581..722597d410 100644--- a/libs/core/langchain_core/language_models/__init__.py+++ b/libs/core/langchain_core/language_models/__init__.py@@ -1,7 +1,7 @@-"""Language models.+"""Core language model abstractions.LangChain has two main classes to work with language models: chat models and-"old-fashioned" LLMs.+"old-fashioned" LLMs (string-in, string-out).**Chat models**@@ -11,14 +11,16 @@ as outputs (as opposed to using plain text).Chat models support the assignment of distinct roles to conversation messages, helpingto distinguish messages from the AI, users, and instructions such as system messages.-The key abstraction for chat models is `BaseChatModel`. Implementations should inherit-from this class.+The key abstraction for chat models is+[`BaseChatModel`][langchain_core.language_models.BaseChatModel]. Implementations should+inherit from this class.See existing [chat model integrations](https://docs.langchain.com/oss/python/integrations/chat).-**LLMs**+**LLMs (legacy)**Language models that takes a string as input and returns a string.+These are traditionally older models (newer models generally are chat models).Although the underlying models are string in, string out, the LangChain wrappers alsodiff --git a/libs/core/langchain_core/messages/ai.py b/libs/core/langchain_core/messages/ai.pyindex 19b07a44af..30ce46699e 100644--- a/libs/core/langchain_core/messages/ai.py+++ b/libs/core/langchain_core/messages/ai.py@@ -51,22 +51,22 @@ class InputTokenDetails(TypedDict, total=False):May also hold extra provider-specific keys.!!! version-added "Added in `langchain-core` 0.3.9"-"""audio: int"""Audio input tokens."""+cache_creation: int"""Input tokens that were cached and there was a cache miss.Since there was a cache miss, the cache was created from these tokens."""+cache_read: int"""Input tokens that were cached and there was a cache hit.Since there was a cache hit, the tokens were read from the cache. More precisely,the model state given these tokens was read from the cache.-"""@@ -91,12 +91,12 @@ class OutputTokenDetails(TypedDict, total=False):audio: int"""Audio output tokens."""+reasoning: int"""Reasoning output tokens.Tokens generated by the model in a chain of thought process (i.e. by OpenAI's o1models) that are not returned as part of model output.-"""@@ -136,15 +136,19 @@ class UsageMetadata(TypedDict):input_tokens: int"""Count of input (or prompt) tokens. Sum of all input token types."""+output_tokens: int"""Count of output (or completion) tokens. Sum of all output token types."""+total_tokens: int"""Total token count. Sum of `input_tokens` + `output_tokens`."""+input_token_details: NotRequired[InputTokenDetails]"""Breakdown of input token counts.Does *not* need to sum to full input token count. Does *not* need to have all keys."""+output_token_details: NotRequired[OutputTokenDetails]"""Breakdown of output token counts.@@ -164,8 +168,10 @@ class AIMessage(BaseMessage):tool_calls: list[ToolCall] = []"""If present, tool calls associated with the message."""+invalid_tool_calls: list[InvalidToolCall] = []"""If present, tool calls with parsing errors associated with the message."""+usage_metadata: UsageMetadata | None = None"""If present, usage metadata for a message, such as token counts.@@ -557,7 +563,7 @@ class AIMessageChunk(AIMessage, BaseMessageChunk):@model_validator(mode="after")def init_server_tool_calls(self) -> Self:- """Parse `server_tool_call_chunks`."""+ """Parse `server_tool_call_chunks` from [`ServerToolCallChunk`][langchain.messages.ServerToolCallChunk] objects.""" # noqa: E501if (self.chunk_position == "last"and self.response_metadata.get("output_version") == "v1"diff --git a/libs/core/langchain_core/messages/base.py b/libs/core/langchain_core/messages/base.pyindex 0cc7614e53..784a95703c 100644--- a/libs/core/langchain_core/messages/base.py+++ b/libs/core/langchain_core/messages/base.py@@ -391,12 +391,12 @@ class BaseMessageChunk(BaseMessage):Raises:TypeError: If the other object is not a message chunk.- For example,-- `AIMessageChunk(content="Hello") + AIMessageChunk(content=" World")`-- will give `AIMessageChunk(content="Hello World")`-+ Example:+ ```txt+ AIMessageChunk(content="Hello", ...)+ + AIMessageChunk(content=" World", ...)+ = AIMessageChunk(content="Hello World", ...)+ ```"""if isinstance(other, BaseMessageChunk):# If both are (subclasses of) BaseMessageChunk,diff --git a/libs/core/langchain_core/messages/tool.py b/libs/core/langchain_core/messages/tool.pyindex 6993ad61c6..e54953ff0d 100644--- a/libs/core/langchain_core/messages/tool.py+++ b/libs/core/langchain_core/messages/tool.py@@ -29,38 +29,39 @@ class ToolMessage(BaseMessage, ToolOutputMixin):`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage-- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ```python+ from langchain_core.messages import ToolMessage- ```python- from langchain_core.messages import ToolMessage-- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }-- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.+ ```python+ from langchain_core.messages import ToolMessage++ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }++ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```"""tool_call_id: strdiff --git a/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr b/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambrindex 56bce494ee..e323c92274 100644--- a/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr+++ b/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr@@ -1103,37 +1103,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage-- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }-- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ```python+ from langchain_core.messages import ToolMessage++ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }++ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({@@ -2519,37 +2521,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage-- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }-- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ```python+ from langchain_core.messages import ToolMessage++ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }++ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({diff --git a/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr b/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambrindex a9285b1caa..ec54153f05 100644--- a/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr+++ b/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr@@ -1527,37 +1527,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }+ ```python+ from langchain_core.messages import ToolMessage- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({diff --git a/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr b/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambrindex 1830e69317..c6201697c6 100644--- a/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr+++ b/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr@@ -3045,37 +3045,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }+ ```python+ from langchain_core.messages import ToolMessage- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({@@ -4523,37 +4525,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }+ ```python+ from langchain_core.messages import ToolMessage- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({@@ -6013,37 +6017,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }+ ```python+ from langchain_core.messages import ToolMessage- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({@@ -7359,37 +7365,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }+ ```python+ from langchain_core.messages import ToolMessage- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({@@ -8879,37 +8887,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }+ ```python+ from langchain_core.messages import ToolMessage- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({@@ -10270,37 +10280,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }+ ```python+ from langchain_core.messages import ToolMessage- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({@@ -11709,37 +11721,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }+ ```python+ from langchain_core.messages import ToolMessage- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({@@ -13149,37 +13163,39 @@`ToolMessage` objects contain the result of a tool invocation. Typically, the resultis encoded inside the `content` field.- Example: A `ToolMessage` representing a result of `42` from a tool call with id+ `tool_call_id` is used to associate the tool call request with the tool call+ response. Useful in situations where a chat model is able to request multiple tool+ calls in parallel.- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` representing a result of `42` from a tool call with id- ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")- ```+ ```python+ from langchain_core.messages import ToolMessage- Example: A `ToolMessage` where only part of the tool output is sent to the model- and the full output is passed in to artifact.+ ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")+ ```- ```python- from langchain_core.messages import ToolMessage+ Example:+ A `ToolMessage` where only part of the tool output is sent to the model+ and the full output is passed in to artifact.- tool_output = {- "stdout": "From the graph we can see that the correlation between "- "x and y is ...",- "stderr": None,- "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},- }+ ```python+ from langchain_core.messages import ToolMessage- ToolMessage(- content=tool_output["stdout"],- artifact=tool_output,- tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",- )- ```+ tool_output = {+ "stdout": "From the graph we can see that the correlation between "+ "x and y is ...",+ "stderr": None,+ "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},+ }- The `tool_call_id` field is used to associate the tool call request with the- tool call response. Useful in situations where a chat model is able- to request multiple tool calls in parallel.+ ToolMessage(+ content=tool_output["stdout"],+ artifact=tool_output,+ tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",+ )+ ```''','properties': dict({'additional_kwargs': dict({diff --git a/libs/core/uv.lock b/libs/core/uv.lockindex c9c088186d..8f925fb600 100644--- a/libs/core/uv.lock+++ b/libs/core/uv.lock@@ -983,7 +983,7 @@ wheels = [[[package]]name = "langchain-core"-version = "1.1.0"+version = "1.1.1"source = { editable = "." }dependencies = [{ name = "jsonpatch" },diff --git a/libs/partners/groq/langchain_groq/chat_models.py b/libs/partners/groq/langchain_groq/chat_models.pyindex 4b29dc8af3..6646ec7212 100644--- a/libs/partners/groq/langchain_groq/chat_models.py+++ b/libs/partners/groq/langchain_groq/chat_models.py@@ -417,8 +417,11 @@ class ChatGroq(BaseChatModel):"""Optional `httpx.Client`."""http_async_client: Any | None = None- """Optional `httpx.AsyncClient`. Only used for async invocations. Must specify- `http_client` as well if you'd like a custom client for sync invocations."""+ """Optional `httpx.AsyncClient`.++ Only used for async invocations. Must specify `http_client` as well if you'd like a+ custom client for sync invocations.+ """model_config = ConfigDict(populate_by_name=True,diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.pyindex 790867cae5..d2ff16912d 100644--- a/libs/partners/openai/langchain_openai/chat_models/base.py+++ b/libs/partners/openai/langchain_openai/chat_models/base.py@@ -647,14 +647,17 @@ class BaseChatOpenAI(BaseChatModel):tiktoken_model_name: str | None = None"""The model name to pass to tiktoken when using this class.+Tiktoken is used to count the number of tokens in documents to constrain- them to be under a certain limit. By default, when set to None, this will- be the same as the embedding model name. However, there are some cases- where you may want to use this Embedding class with a model name not- supported by tiktoken. This can include when using Azure embeddings or- when using one of the many model providers that expose an OpenAI-like+ them to be under a certain limit.++ By default, when set to `None`, this will be the same as the embedding model name.+ However, there are some cases where you may want to use this `Embedding` class with+ a model name not supported by tiktoken. This can include when using Azure embeddings+ or when using one of the many model providers that expose an OpenAI-likeAPI but with different models. In those cases, in order to avoid erroring- when tiktoken is called, you can specify a model name to use here."""+ when tiktoken is called, you can specify a model name to use here.+ """default_headers: Mapping[str, str] | None = None@@ -663,13 +666,18 @@ class BaseChatOpenAI(BaseChatModel):# Configure a custom httpx client. See the# [httpx documentation](https://www.python-httpx.org/api/#client) for more details.http_client: Any | None = Field(default=None, exclude=True)- """Optional `httpx.Client`. Only used for sync invocations. Must specify- `http_async_client` as well if you'd like a custom client for async invocations.+ """Optional `httpx.Client`.++ Only used for sync invocations. Must specify `http_async_client` as well if you'd+ like a custom client for async invocations."""http_async_client: Any | None = Field(default=None, exclude=True)- """Optional `httpx.AsyncClient`. Only used for async invocations. Must specify- `http_client` as well if you'd like a custom client for sync invocations."""+ """Optional `httpx.AsyncClient`.++ Only used for async invocations. Must specify `http_client` as well if you'd like a+ custom client for sync invocations.+ """stop: list[str] | str | None = Field(default=None, alias="stop_sequences")"""Default stop sequences."""@@ -729,7 +737,10 @@ class BaseChatOpenAI(BaseChatModel):"""service_tier: str | None = None- """Latency tier for request. Options are `'auto'`, `'default'`, or `'flex'`.+ """Latency tier for request.++ Options are `'auto'`, `'default'`, or `'flex'`.+Relevant for users of OpenAI's scale tier service."""@@ -742,7 +753,10 @@ class BaseChatOpenAI(BaseChatModel):"""truncation: str | None = None- """Truncation strategy (Responses API). Can be `'auto'` or `'disabled'` (default).+ """Truncation strategy (Responses API).++ Can be `'auto'` or `'disabled'` (default).+If `'auto'`, model may drop input items from the middle of the message sequence tofit the context window.diff --git a/libs/partners/openai/langchain_openai/embeddings/base.py b/libs/partners/openai/langchain_openai/embeddings/base.pyindex 4e01c18467..0f49e11e6d 100644--- a/libs/partners/openai/langchain_openai/embeddings/base.py+++ b/libs/partners/openai/langchain_openai/embeddings/base.py@@ -243,14 +243,17 @@ class OpenAIEmbeddings(BaseModel, Embeddings):tiktoken_model_name: str | None = None"""The model name to pass to tiktoken when using this class.+Tiktoken is used to count the number of tokens in documents to constrain- them to be under a certain limit. By default, when set to None, this will- be the same as the embedding model name. However, there are some cases- where you may want to use this Embedding class with a model name not- supported by tiktoken. This can include when using Azure embeddings or- when using one of the many model providers that expose an OpenAI-like+ them to be under a certain limit.++ By default, when set to `None`, this will be the same as the embedding model name.+ However, there are some cases where you may want to use this `Embedding` class with+ a model name not supported by tiktoken. This can include when using Azure embeddings+ or when using one of the many model providers that expose an OpenAI-likeAPI but with different models. In those cases, in order to avoid erroring- when tiktoken is called, you can specify a model name to use here."""+ when tiktoken is called, you can specify a model name to use here.+ """show_progress_bar: bool = False"""Whether to show a progress bar when embedding."""@@ -275,14 +278,18 @@ class OpenAIEmbeddings(BaseModel, Embeddings):"""Max number of seconds to wait between retries"""http_client: Any | None = None- """Optional `httpx.Client`. Only used for sync invocations. Must specify- `http_async_client` as well if you'd like a custom client for async- invocations.+ """Optional `httpx.Client`.++ Only used for sync invocations. Must specify `http_async_client` as well if you'd+ like a custom client for async invocations."""http_async_client: Any | None = None- """Optional `httpx.AsyncClient`. Only used for async invocations. Must specify- `http_client` as well if you'd like a custom client for sync invocations."""+ """Optional `httpx.AsyncClient`.++ Only used for async invocations. Must specify `http_client` as well if you'd like a+ custom client for sync invocations.+ """check_embedding_ctx_length: bool = True"""Whether to check the token length of inputs and automatically split inputsdiff --git a/libs/partners/openai/langchain_openai/llms/base.py b/libs/partners/openai/langchain_openai/llms/base.pyindex edd5c837e6..dc4e621e24 100644--- a/libs/partners/openai/langchain_openai/llms/base.py+++ b/libs/partners/openai/langchain_openai/llms/base.py@@ -254,14 +254,17 @@ class BaseOpenAI(BaseLLM):tiktoken_model_name: str | None = None"""The model name to pass to tiktoken when using this class.+Tiktoken is used to count the number of tokens in documents to constrain- them to be under a certain limit. By default, when set to None, this will- be the same as the embedding model name. However, there are some cases- where you may want to use this Embedding class with a model name not- supported by tiktoken. This can include when using Azure embeddings or- when using one of the many model providers that expose an OpenAI-like+ them to be under a certain limit.++ By default, when set to `None`, this will be the same as the embedding model name.+ However, there are some cases where you may want to use this `Embedding` class with+ a model name not supported by tiktoken. This can include when using Azure embeddings+ or when using one of the many model providers that expose an OpenAI-likeAPI but with different models. In those cases, in order to avoid erroring- when tiktoken is called, you can specify a model name to use here."""+ when tiktoken is called, you can specify a model name to use here.+ """default_headers: Mapping[str, str] | None = None@@ -270,14 +273,18 @@ class BaseOpenAI(BaseLLM):# Configure a custom httpx client. See the# [httpx documentation](https://www.python-httpx.org/api/#client) for more details.http_client: Any | None = None- """Optional `httpx.Client`. Only used for sync invocations. Must specify- `http_async_client` as well if you'd like a custom client for async- invocations.+ """Optional `httpx.Client`.++ Only used for sync invocations. Must specify `http_async_client` as well if you'd+ like a custom client for async invocations."""http_async_client: Any | None = None- """Optional `httpx.AsyncClient`. Only used for async invocations. Must specify- `http_client` as well if you'd like a custom client for sync invocations."""+ """Optional `httpx.AsyncClient`.++ Only used for async invocations. Must specify `http_client` as well if you'd like a+ custom client for sync invocations.+ """extra_body: Mapping[str, Any] | None = None"""Optional additional JSON properties to include in the request parameters when