From 47b79c30c0063471332b61591e3289d16281e1c9 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Fri, 21 Nov 2025 23:58:21 -0600 Subject: [PATCH] chore(docs): fix a few refs syntax errors (#34044) missing whitespace for some admonitions --- libs/core/langchain_core/indexing/api.py | 2 + .../langchain_core/language_models/_utils.py | 1 + .../language_models/chat_models.py | 1 + libs/core/langchain_core/messages/ai.py | 2 + libs/core/langchain_core/runnables/base.py | 318 +++++++++--------- libs/core/langchain_core/runnables/branch.py | 2 +- .../langchain_core/utils/function_calling.py | 4 + .../prompts/__snapshots__/test_chat.ambr | 4 + .../runnables/__snapshots__/test_graph.ambr | 2 + .../__snapshots__/test_runnable.ambr | 16 + .../langchain_classic/chat_models/base.py | 4 + libs/langchain_v1/uv.lock | 4 +- .../langchain_anthropic/chat_models.py | 1 + .../langchain_fireworks/chat_models.py | 1 + .../groq/langchain_groq/chat_models.py | 1 + .../langchain_mistralai/chat_models.py | 1 + .../ollama/langchain_ollama/chat_models.py | 2 + .../langchain_openai/chat_models/azure.py | 3 + .../langchain_openai/chat_models/base.py | 7 + .../integration_tests/chat_models.py | 2 + 20 files changed, 223 insertions(+), 155 deletions(-) diff --git a/libs/core/langchain_core/indexing/api.py b/libs/core/langchain_core/indexing/api.py index 860d34f3356..65d04381630 100644 --- a/libs/core/langchain_core/indexing/api.py +++ b/libs/core/langchain_core/indexing/api.py @@ -302,6 +302,7 @@ def index( are not able to specify the uid of the document. !!! warning "Behavior changed in `langchain-core` 0.3.25" + Added `scoped_full` cleanup mode. !!! warning @@ -640,6 +641,7 @@ async def aindex( are not able to specify the uid of the document. !!! warning "Behavior changed in `langchain-core` 0.3.25" + Added `scoped_full` cleanup mode. !!! warning diff --git a/libs/core/langchain_core/language_models/_utils.py b/libs/core/langchain_core/language_models/_utils.py index d777425dde6..c134e7cd842 100644 --- a/libs/core/langchain_core/language_models/_utils.py +++ b/libs/core/langchain_core/language_models/_utils.py @@ -140,6 +140,7 @@ def _normalize_messages( - LangChain v0 standard content blocks for backward compatibility !!! warning "Behavior changed in `langchain-core` 1.0.0" + In previous versions, this function returned messages in LangChain v0 format. Now, it returns messages in LangChain v1 format, which upgraded chat models now expect to receive when passing back in message history. For backward diff --git a/libs/core/langchain_core/language_models/chat_models.py b/libs/core/langchain_core/language_models/chat_models.py index 3c0ddbcf6c0..520783115df 100644 --- a/libs/core/langchain_core/language_models/chat_models.py +++ b/libs/core/langchain_core/language_models/chat_models.py @@ -1660,6 +1660,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC): ``` !!! warning "Behavior changed in `langchain-core` 0.2.26" + Added support for `TypedDict` class. """ # noqa: E501 diff --git a/libs/core/langchain_core/messages/ai.py b/libs/core/langchain_core/messages/ai.py index fb85027b142..19b07a44af0 100644 --- a/libs/core/langchain_core/messages/ai.py +++ b/libs/core/langchain_core/messages/ai.py @@ -124,9 +124,11 @@ class UsageMetadata(TypedDict): ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. diff --git a/libs/core/langchain_core/runnables/base.py b/libs/core/langchain_core/runnables/base.py index 71fb4978cc0..9910eb6fbd8 100644 --- a/libs/core/langchain_core/runnables/base.py +++ b/libs/core/langchain_core/runnables/base.py @@ -707,51 +707,53 @@ class Runnable(ABC, Generic[Input, Output]): def pick(self, keys: str | list[str]) -> RunnableSerializable[Any, Any]: """Pick keys from the output `dict` of this `Runnable`. - Pick a single key: + !!! example "Pick a single key" - ```python - import json + ```python + import json - from langchain_core.runnables import RunnableLambda, RunnableMap + from langchain_core.runnables import RunnableLambda, RunnableMap - as_str = RunnableLambda(str) - as_json = RunnableLambda(json.loads) - chain = RunnableMap(str=as_str, json=as_json) + as_str = RunnableLambda(str) + as_json = RunnableLambda(json.loads) + chain = RunnableMap(str=as_str, json=as_json) - chain.invoke("[1, 2, 3]") - # -> {"str": "[1, 2, 3]", "json": [1, 2, 3]} + chain.invoke("[1, 2, 3]") + # -> {"str": "[1, 2, 3]", "json": [1, 2, 3]} - json_only_chain = chain.pick("json") - json_only_chain.invoke("[1, 2, 3]") - # -> [1, 2, 3] - ``` + json_only_chain = chain.pick("json") + json_only_chain.invoke("[1, 2, 3]") + # -> [1, 2, 3] + ``` - Pick a list of keys: + !!! example "Pick a list of keys" - ```python - from typing import Any + ```python + from typing import Any - import json + import json - from langchain_core.runnables import RunnableLambda, RunnableMap + from langchain_core.runnables import RunnableLambda, RunnableMap - as_str = RunnableLambda(str) - as_json = RunnableLambda(json.loads) + as_str = RunnableLambda(str) + as_json = RunnableLambda(json.loads) - def as_bytes(x: Any) -> bytes: - return bytes(x, "utf-8") + def as_bytes(x: Any) -> bytes: + return bytes(x, "utf-8") - chain = RunnableMap(str=as_str, json=as_json, bytes=RunnableLambda(as_bytes)) + chain = RunnableMap( + str=as_str, json=as_json, bytes=RunnableLambda(as_bytes) + ) - chain.invoke("[1, 2, 3]") - # -> {"str": "[1, 2, 3]", "json": [1, 2, 3], "bytes": b"[1, 2, 3]"} + chain.invoke("[1, 2, 3]") + # -> {"str": "[1, 2, 3]", "json": [1, 2, 3], "bytes": b"[1, 2, 3]"} - json_and_bytes_chain = chain.pick(["json", "bytes"]) - json_and_bytes_chain.invoke("[1, 2, 3]") - # -> {"json": [1, 2, 3], "bytes": b"[1, 2, 3]"} - ``` + json_and_bytes_chain = chain.pick(["json", "bytes"]) + json_and_bytes_chain.invoke("[1, 2, 3]") + # -> {"json": [1, 2, 3], "bytes": b"[1, 2, 3]"} + ``` Args: keys: A key or list of keys to pick from the output dict. @@ -1372,48 +1374,50 @@ class Runnable(ABC, Generic[Input, Output]): ).with_config({"run_name": "my_template", "tags": ["my_template"]}) ``` - For instance: + !!! example - ```python - from langchain_core.runnables import RunnableLambda + ```python + from langchain_core.runnables import RunnableLambda - async def reverse(s: str) -> str: - return s[::-1] + async def reverse(s: str) -> str: + return s[::-1] - chain = RunnableLambda(func=reverse) + chain = RunnableLambda(func=reverse) - events = [event async for event in chain.astream_events("hello", version="v2")] + events = [ + event async for event in chain.astream_events("hello", version="v2") + ] - # Will produce the following events - # (run_id, and parent_ids has been omitted for brevity): - [ - { - "data": {"input": "hello"}, - "event": "on_chain_start", - "metadata": {}, - "name": "reverse", - "tags": [], - }, - { - "data": {"chunk": "olleh"}, - "event": "on_chain_stream", - "metadata": {}, - "name": "reverse", - "tags": [], - }, - { - "data": {"output": "olleh"}, - "event": "on_chain_end", - "metadata": {}, - "name": "reverse", - "tags": [], - }, - ] - ``` + # Will produce the following events + # (run_id, and parent_ids has been omitted for brevity): + [ + { + "data": {"input": "hello"}, + "event": "on_chain_start", + "metadata": {}, + "name": "reverse", + "tags": [], + }, + { + "data": {"chunk": "olleh"}, + "event": "on_chain_stream", + "metadata": {}, + "name": "reverse", + "tags": [], + }, + { + "data": {"output": "olleh"}, + "event": "on_chain_end", + "metadata": {}, + "name": "reverse", + "tags": [], + }, + ] + ``` - ```python title="Example: Dispatch Custom Event" + ```python title="Dispatch custom event" from langchain_core.callbacks.manager import ( adispatch_custom_event, ) @@ -1447,10 +1451,13 @@ class Runnable(ABC, Generic[Input, Output]): Args: input: The input to the `Runnable`. config: The config to use for the `Runnable`. - version: The version of the schema to use either `'v2'` or `'v1'`. + version: The version of the schema to use, either `'v2'` or `'v1'`. + Users should use `'v2'`. + `'v1'` is for backwards compatibility and will be deprecated in `0.4.0`. + No default will be assigned until the API is stabilized. custom events will only be surfaced in `'v2'`. include_names: Only include events from `Runnable` objects with matching names. @@ -1460,6 +1467,7 @@ class Runnable(ABC, Generic[Input, Output]): exclude_types: Exclude events from `Runnable` objects with matching types. exclude_tags: Exclude events from `Runnable` objects with matching tags. **kwargs: Additional keyword arguments to pass to the `Runnable`. + These will be passed to `astream_log` as this implementation of `astream_events` is built on top of `astream_log`. @@ -2476,82 +2484,82 @@ class Runnable(ABC, Generic[Input, Output]): Returns: A `BaseTool` instance. - Typed dict input: + !!! example "`TypedDict` input" - ```python - from typing_extensions import TypedDict - from langchain_core.runnables import RunnableLambda + ```python + from typing_extensions import TypedDict + from langchain_core.runnables import RunnableLambda - class Args(TypedDict): - a: int - b: list[int] + class Args(TypedDict): + a: int + b: list[int] - def f(x: Args) -> str: - return str(x["a"] * max(x["b"])) + def f(x: Args) -> str: + return str(x["a"] * max(x["b"])) - runnable = RunnableLambda(f) - as_tool = runnable.as_tool() - as_tool.invoke({"a": 3, "b": [1, 2]}) - ``` + runnable = RunnableLambda(f) + as_tool = runnable.as_tool() + as_tool.invoke({"a": 3, "b": [1, 2]}) + ``` - `dict` input, specifying schema via `args_schema`: + !!! example "`dict` input, specifying schema via `args_schema`" - ```python - from typing import Any - from pydantic import BaseModel, Field - from langchain_core.runnables import RunnableLambda + ```python + from typing import Any + from pydantic import BaseModel, Field + from langchain_core.runnables import RunnableLambda - def f(x: dict[str, Any]) -> str: - return str(x["a"] * max(x["b"])) + def f(x: dict[str, Any]) -> str: + return str(x["a"] * max(x["b"])) - class FSchema(BaseModel): - \"\"\"Apply a function to an integer and list of integers.\"\"\" + class FSchema(BaseModel): + \"\"\"Apply a function to an integer and list of integers.\"\"\" - a: int = Field(..., description="Integer") - b: list[int] = Field(..., description="List of ints") + a: int = Field(..., description="Integer") + b: list[int] = Field(..., description="List of ints") - runnable = RunnableLambda(f) - as_tool = runnable.as_tool(FSchema) - as_tool.invoke({"a": 3, "b": [1, 2]}) - ``` + runnable = RunnableLambda(f) + as_tool = runnable.as_tool(FSchema) + as_tool.invoke({"a": 3, "b": [1, 2]}) + ``` - `dict` input, specifying schema via `arg_types`: + !!! example "`dict` input, specifying schema via `arg_types`" - ```python - from typing import Any - from langchain_core.runnables import RunnableLambda + ```python + from typing import Any + from langchain_core.runnables import RunnableLambda - def f(x: dict[str, Any]) -> str: - return str(x["a"] * max(x["b"])) + def f(x: dict[str, Any]) -> str: + return str(x["a"] * max(x["b"])) - runnable = RunnableLambda(f) - as_tool = runnable.as_tool(arg_types={"a": int, "b": list[int]}) - as_tool.invoke({"a": 3, "b": [1, 2]}) - ``` + runnable = RunnableLambda(f) + as_tool = runnable.as_tool(arg_types={"a": int, "b": list[int]}) + as_tool.invoke({"a": 3, "b": [1, 2]}) + ``` - `str` input: + !!! example "`str` input" - ```python - from langchain_core.runnables import RunnableLambda + ```python + from langchain_core.runnables import RunnableLambda - def f(x: str) -> str: - return x + "a" + def f(x: str) -> str: + return x + "a" - def g(x: str) -> str: - return x + "z" + def g(x: str) -> str: + return x + "z" - runnable = RunnableLambda(f) | g - as_tool = runnable.as_tool() - as_tool.invoke("b") - ``` + runnable = RunnableLambda(f) | g + as_tool = runnable.as_tool() + as_tool.invoke("b") + ``` """ # Avoid circular import from langchain_core.tools import convert_runnable_to_tool # noqa: PLC0415 @@ -2603,29 +2611,33 @@ class RunnableSerializable(Serializable, Runnable[Input, Output]): Returns: A new `Runnable` with the fields configured. - ```python - from langchain_core.runnables import ConfigurableField - from langchain_openai import ChatOpenAI + !!! example - model = ChatOpenAI(max_tokens=20).configurable_fields( - max_tokens=ConfigurableField( - id="output_token_number", - name="Max tokens in the output", - description="The maximum number of tokens in the output", + ```python + from langchain_core.runnables import ConfigurableField + from langchain_openai import ChatOpenAI + + model = ChatOpenAI(max_tokens=20).configurable_fields( + max_tokens=ConfigurableField( + id="output_token_number", + name="Max tokens in the output", + description="The maximum number of tokens in the output", + ) ) - ) - # max_tokens = 20 - print("max_tokens_20: ", model.invoke("tell me something about chess").content) + # max_tokens = 20 + print( + "max_tokens_20: ", model.invoke("tell me something about chess").content + ) - # max_tokens = 200 - print( - "max_tokens_200: ", - model.with_config(configurable={"output_token_number": 200}) - .invoke("tell me something about chess") - .content, - ) - ``` + # max_tokens = 200 + print( + "max_tokens_200: ", + model.with_config(configurable={"output_token_number": 200}) + .invoke("tell me something about chess") + .content, + ) + ``` """ # Import locally to prevent circular import from langchain_core.runnables.configurable import ( # noqa: PLC0415 @@ -2664,29 +2676,31 @@ class RunnableSerializable(Serializable, Runnable[Input, Output]): Returns: A new `Runnable` with the alternatives configured. - ```python - from langchain_anthropic import ChatAnthropic - from langchain_core.runnables.utils import ConfigurableField - from langchain_openai import ChatOpenAI + !!! example - model = ChatAnthropic( - model_name="claude-sonnet-4-5-20250929" - ).configurable_alternatives( - ConfigurableField(id="llm"), - default_key="anthropic", - openai=ChatOpenAI(), - ) + ```python + from langchain_anthropic import ChatAnthropic + from langchain_core.runnables.utils import ConfigurableField + from langchain_openai import ChatOpenAI - # uses the default model ChatAnthropic - print(model.invoke("which organization created you?").content) + model = ChatAnthropic( + model_name="claude-sonnet-4-5-20250929" + ).configurable_alternatives( + ConfigurableField(id="llm"), + default_key="anthropic", + openai=ChatOpenAI(), + ) - # uses ChatOpenAI - print( - model.with_config(configurable={"llm": "openai"}) - .invoke("which organization created you?") - .content - ) - ``` + # uses the default model ChatAnthropic + print(model.invoke("which organization created you?").content) + + # uses ChatOpenAI + print( + model.with_config(configurable={"llm": "openai"}) + .invoke("which organization created you?") + .content + ) + ``` """ # Import locally to prevent circular import from langchain_core.runnables.configurable import ( # noqa: PLC0415 diff --git a/libs/core/langchain_core/runnables/branch.py b/libs/core/langchain_core/runnables/branch.py index e9396ce5c25..ca3dfd99da6 100644 --- a/libs/core/langchain_core/runnables/branch.py +++ b/libs/core/langchain_core/runnables/branch.py @@ -303,7 +303,7 @@ class RunnableBranch(RunnableSerializable[Input, Output]): Args: input: The input to the `Runnable`. - config: The configuration for the Runna`ble. + config: The configuration for the `Runnable`. **kwargs: Additional keyword arguments to pass to the `Runnable`. Yields: diff --git a/libs/core/langchain_core/utils/function_calling.py b/libs/core/langchain_core/utils/function_calling.py index 6fe3e35a610..18373e3b3b8 100644 --- a/libs/core/langchain_core/utils/function_calling.py +++ b/libs/core/langchain_core/utils/function_calling.py @@ -353,6 +353,7 @@ def convert_to_openai_function( ValueError: If function is not in a supported format. !!! warning "Behavior changed in `langchain-core` 0.3.16" + `description` and `parameters` keys are now optional. Only `name` is required and guaranteed to be part of the output. """ @@ -477,15 +478,18 @@ def convert_to_openai_tool( OpenAI tool-calling API. !!! warning "Behavior changed in `langchain-core` 0.3.16" + `description` and `parameters` keys are now optional. Only `name` is required and guaranteed to be part of the output. !!! warning "Behavior changed in `langchain-core` 0.3.44" + Return OpenAI Responses API-style tools unchanged. This includes any dict with `"type"` in `"file_search"`, `"function"`, `"computer_use_preview"`, `"web_search_preview"`. !!! warning "Behavior changed in `langchain-core` 0.3.63" + Added support for OpenAI's image generation built-in tool. """ # Import locally to prevent circular import diff --git a/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr b/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr index 964aa8817b9..56bce494eec 100644 --- a/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr +++ b/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr @@ -1320,9 +1320,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. @@ -2734,9 +2736,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. diff --git a/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr b/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr index 0f788aeef95..a9285b1caa8 100644 --- a/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr +++ b/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr @@ -1744,9 +1744,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. diff --git a/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr b/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr index ef6f6f8089b..1830e693179 100644 --- a/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr +++ b/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr @@ -3260,9 +3260,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. @@ -4736,9 +4738,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. @@ -6224,9 +6228,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. @@ -7568,9 +7574,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. @@ -9086,9 +9094,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. @@ -10475,9 +10485,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. @@ -11912,9 +11924,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. @@ -13350,9 +13364,11 @@ ``` !!! warning "Behavior changed in `langchain-core` 0.3.9" + Added `input_token_details` and `output_token_details`. !!! note "LangSmith SDK" + The LangSmith SDK also has a `UsageMetadata` class. While the two share fields, LangSmith's `UsageMetadata` has additional fields to capture cost information used by the LangSmith platform. diff --git a/libs/langchain/langchain_classic/chat_models/base.py b/libs/langchain/langchain_classic/chat_models/base.py index 03be5b2718b..4541294bacb 100644 --- a/libs/langchain/langchain_classic/chat_models/base.py +++ b/libs/langchain/langchain_classic/chat_models/base.py @@ -319,9 +319,11 @@ def init_chat_model( ``` !!! warning "Behavior changed in `langchain` 0.2.8" + Support for `configurable_fields` and `config_prefix` added. !!! warning "Behavior changed in `langchain` 0.2.12" + Support for Ollama via langchain-ollama package added (`langchain_ollama.ChatOllama`). Previously, the now-deprecated langchain-community version of Ollama was imported @@ -331,9 +333,11 @@ def init_chat_model( (`model_provider="bedrock_converse"`). !!! warning "Behavior changed in `langchain` 0.3.5" + Out of beta. !!! warning "Behavior changed in `langchain` 0.3.19" + Support for Deepseek, IBM, Nvidia, and xAI models added. """ # noqa: E501 diff --git a/libs/langchain_v1/uv.lock b/libs/langchain_v1/uv.lock index e23542d5008..0b0ba65d23e 100644 --- a/libs/langchain_v1/uv.lock +++ b/libs/langchain_v1/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 2 +revision = 3 requires-python = ">=3.10.0, <4.0.0" resolution-markers = [ "python_full_version >= '3.14' and platform_python_implementation == 'PyPy'", @@ -2166,7 +2166,7 @@ wheels = [ [[package]] name = "langchain-core" -version = "1.0.7" +version = "1.1.0" source = { editable = "../core" } dependencies = [ { name = "jsonpatch" }, diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py index 0315c8c0e1b..429e215a235 100644 --- a/libs/partners/anthropic/langchain_anthropic/chat_models.py +++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py @@ -2506,6 +2506,7 @@ class ChatAnthropic(BaseChatModel): ``` !!! warning "Behavior changed in `langchain-anthropic` 0.3.0" + Uses Anthropic's [token counting API](https://docs.claude.com/en/docs/build-with-claude/token-counting) to count tokens in messages. """ # noqa: D214,E501 diff --git a/libs/partners/fireworks/langchain_fireworks/chat_models.py b/libs/partners/fireworks/langchain_fireworks/chat_models.py index e366e9876e1..e2d183faebe 100644 --- a/libs/partners/fireworks/langchain_fireworks/chat_models.py +++ b/libs/partners/fireworks/langchain_fireworks/chat_models.py @@ -742,6 +742,7 @@ class ChatFireworks(BaseChatModel): Uses Fireworks's [JSON mode feature](https://docs.fireworks.ai/structured-responses/structured-response-formatting). !!! warning "Behavior changed in `langchain-fireworks` 0.2.8" + Added support for `'json_schema'`. include_raw: diff --git a/libs/partners/groq/langchain_groq/chat_models.py b/libs/partners/groq/langchain_groq/chat_models.py index 83dbdcf8b30..4b29dc8af35 100644 --- a/libs/partners/groq/langchain_groq/chat_models.py +++ b/libs/partners/groq/langchain_groq/chat_models.py @@ -892,6 +892,7 @@ class ChatGroq(BaseChatModel): when specifying a Pydantic or `TypedDict` class. !!! warning "Behavior changed in `langchain-groq` 0.3.8" + Added support for Groq's dedicated structured output feature via `method="json_schema"`. diff --git a/libs/partners/mistralai/langchain_mistralai/chat_models.py b/libs/partners/mistralai/langchain_mistralai/chat_models.py index 4823e1230df..c56c4deb271 100644 --- a/libs/partners/mistralai/langchain_mistralai/chat_models.py +++ b/libs/partners/mistralai/langchain_mistralai/chat_models.py @@ -867,6 +867,7 @@ class ChatMistralAI(BaseChatModel): desired schema into the model call. !!! warning "Behavior changed in `langchain-mistralai` 0.2.5" + Added method="json_schema" include_raw: diff --git a/libs/partners/ollama/langchain_ollama/chat_models.py b/libs/partners/ollama/langchain_ollama/chat_models.py index 21567e73eca..fb8901fa8bd 100644 --- a/libs/partners/ollama/langchain_ollama/chat_models.py +++ b/libs/partners/ollama/langchain_ollama/chat_models.py @@ -1314,9 +1314,11 @@ class ChatOllama(BaseChatModel): - `'parsing_error'`: `BaseException | None` !!! warning "Behavior changed in `langchain-ollama` 0.2.2" + Added support for structured output API via `format` parameter. !!! warning "Behavior changed in `langchain-ollama` 0.3.0" + Updated default `method` to `'json_schema'`. ??? note "Example: `schema=Pydantic` class, `method='json_schema'`, `include_raw=False`" diff --git a/libs/partners/openai/langchain_openai/chat_models/azure.py b/libs/partners/openai/langchain_openai/chat_models/azure.py index f65257a81a8..9d95a82e75c 100644 --- a/libs/partners/openai/langchain_openai/chat_models/azure.py +++ b/libs/partners/openai/langchain_openai/chat_models/azure.py @@ -967,12 +967,15 @@ class AzureChatOpenAI(BaseChatOpenAI): - `'parsing_error'`: `BaseException | None` !!! warning "Behavior changed in `langchain-openai` 0.3.0" + `method` default changed from "function_calling" to "json_schema". !!! warning "Behavior changed in `langchain-openai` 0.3.12" + Support for `tools` added. !!! warning "Behavior changed in `langchain-openai` 0.3.21" + Pass `kwargs` through to the model. ??? note "Example: `schema=Pydantic` class, `method='json_schema'`, `include_raw=False`, `strict=True`" diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 9d43429c352..56d9db2b7e2 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -573,6 +573,7 @@ class BaseChatOpenAI(BaseChatModel): !!! version-added "Added in `langchain-openai` 0.3.9" !!! warning "Behavior changed in `langchain-openai` 0.3.35" + Enabled for default base URL and client. """ @@ -803,6 +804,7 @@ class BaseChatOpenAI(BaseChatModel): - `'v1'`: v1 of LangChain cross-provider standard. !!! warning "Behavior changed in `langchain-openai` 1.0.0" + Default updated to `"responses/v1"`. """ @@ -2007,9 +2009,11 @@ class BaseChatOpenAI(BaseChatModel): - `'parsing_error'`: `BaseException | None` !!! warning "Behavior changed in `langchain-openai` 0.3.12" + Support for `tools` added. !!! warning "Behavior changed in `langchain-openai` 0.3.21" + Pass `kwargs` through to the model. """ if strict is not None and method == "json_mode": @@ -3129,12 +3133,15 @@ class ChatOpenAI(BaseChatOpenAI): # type: ignore[override] - `'parsing_error'`: `BaseException | None` !!! warning "Behavior changed in `langchain-openai` 0.3.0" + `method` default changed from `"function_calling"` to `"json_schema"`. !!! warning "Behavior changed in `langchain-openai` 0.3.12" + Support for `tools` added. !!! warning "Behavior changed in `langchain-openai` 0.3.21" + Pass `kwargs` through to the model. ??? note "Example: `schema=Pydantic` class, `method='json_schema'`, `include_raw=False`, `strict=True`" diff --git a/libs/standard-tests/langchain_tests/integration_tests/chat_models.py b/libs/standard-tests/langchain_tests/integration_tests/chat_models.py index fcd34e153a4..5b2cf22a221 100644 --- a/libs/standard-tests/langchain_tests/integration_tests/chat_models.py +++ b/libs/standard-tests/langchain_tests/integration_tests/chat_models.py @@ -1002,6 +1002,7 @@ class ChatModelIntegrationTests(ChatModelTests): usage metadata (see configuration below). !!! warning "Behavior changed in `langchain-tests` 0.3.17" + Additionally check for the presence of `model_name` in the response metadata, which is needed for usage tracking in callback handlers. @@ -1176,6 +1177,7 @@ class ChatModelIntegrationTests(ChatModelTests): Test to verify that the model returns correct usage metadata in streaming mode. !!! warning "Behavior changed in `langchain-tests` 0.3.17" + Additionally check for the presence of `model_name` in the response metadata, which is needed for usage tracking in callback handlers.