mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-05 09:25:14 +03:00
chore: update Sphinx links to markdown (#33386)
This commit is contained in:
1 parent
057ac361ef
commit
3576e690fa
31 files changed
+105
-107
No files matched your search
@@ -32,7 +32,7 @@ to be included without breaking the standard structure.
|
||||
is subject to deprecation in future releases as we move towards PEP 728.
|
||||
|
||||
!!! note
|
||||
Following widespread adoption of `PEP 728 <https://peps.python.org/pep-0728/>`__, we
|
||||
Following widespread adoption of [PEP 728](https://peps.python.org/pep-0728/), we
|
||||
will add ``extra_items=Any`` as a param to Content Blocks. This will signify to type
|
||||
checkers that additional provider-specific fields are allowed outside of the
|
||||
``extras`` field, and that will become the new standard approach to adding
|
||||
@@ -525,7 +525,7 @@ class ImageContentBlock(TypedDict):
|
||||
mime_type: NotRequired[str]
|
||||
"""MIME type of the image. Required for base64.
|
||||
|
||||
`Examples from IANA <https://www.iana.org/assignments/media-types/media-types.xhtml#image>`__
|
||||
[Examples from IANA](https://www.iana.org/assignments/media-types/media-types.xhtml#image)
|
||||
|
||||
"""
|
||||
|
||||
@@ -572,7 +572,7 @@ class VideoContentBlock(TypedDict):
|
||||
mime_type: NotRequired[str]
|
||||
"""MIME type of the video. Required for base64.
|
||||
|
||||
`Examples from IANA <https://www.iana.org/assignments/media-types/media-types.xhtml#video>`__
|
||||
[Examples from IANA](https://www.iana.org/assignments/media-types/media-types.xhtml#video)
|
||||
|
||||
"""
|
||||
|
||||
@@ -618,7 +618,7 @@ class AudioContentBlock(TypedDict):
|
||||
mime_type: NotRequired[str]
|
||||
"""MIME type of the audio. Required for base64.
|
||||
|
||||
`Examples from IANA <https://www.iana.org/assignments/media-types/media-types.xhtml#audio>`__
|
||||
[Examples from IANA](https://www.iana.org/assignments/media-types/media-types.xhtml#audio)
|
||||
|
||||
"""
|
||||
|
||||
@@ -646,7 +646,7 @@ class PlainTextContentBlock(TypedDict):
|
||||
|
||||
!!! note
|
||||
Title and context are optional fields that may be passed to the model. See
|
||||
Anthropic `example <https://docs.anthropic.com/en/docs/build-with-claude/citations#citable-vs-non-citable-content>`__.
|
||||
Anthropic [example](https://docs.anthropic.com/en/docs/build-with-claude/citations#citable-vs-non-citable-content).
|
||||
|
||||
!!! note
|
||||
``create_plaintext_block`` may also be used as a factory to create a
|
||||
@@ -734,7 +734,7 @@ class FileContentBlock(TypedDict):
|
||||
mime_type: NotRequired[str]
|
||||
"""MIME type of the file. Required for base64.
|
||||
|
||||
`Examples from IANA <https://www.iana.org/assignments/media-types/media-types.xhtml>`__
|
||||
[Examples from IANA](https://www.iana.org/assignments/media-types/media-types.xhtml)
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@@ -1697,11 +1697,11 @@ def count_tokens_approximately(
|
||||
chars_per_token: Number of characters per token to use for the approximation.
|
||||
Default is 4 (one token corresponds to ~4 chars for common English text).
|
||||
You can also specify float values for more fine-grained control.
|
||||
`See more here. <https://platform.openai.com/tokenizer>`__
|
||||
[See more here](https://platform.openai.com/tokenizer).
|
||||
extra_tokens_per_message: Number of extra tokens to add per message.
|
||||
Default is 3 (special tokens, including beginning/end of message).
|
||||
You can also specify float values for more fine-grained control.
|
||||
`See more here. <https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb>`__
|
||||
[See more here](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb).
|
||||
count_name: Whether to include message names in the count.
|
||||
Enabled by default.
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ class Runnable(ABC, Generic[Input, Output]):
|
||||
chain.invoke(..., config={"callbacks": [ConsoleCallbackHandler()]})
|
||||
```
|
||||
|
||||
For a UI (and much more) checkout `LangSmith <https://docs.smith.langchain.com/>`__.
|
||||
For a UI (and much more) checkout [LangSmith](https://docs.smith.langchain.com/).
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ AGENT_DEPRECATION_WARNING = (
|
||||
"full-featured framework for building agents, including support for "
|
||||
"tool-calling, persistence of state, and human-in-the-loop workflows. For "
|
||||
"details, refer to the "
|
||||
"`LangGraph documentation <https://langchain-ai.github.io/langgraph/>`_"
|
||||
"[LangGraph documentation](https://langchain-ai.github.io/langgraph/)"
|
||||
" as well as guides for "
|
||||
"`Migrating from AgentExecutor <https://python.langchain.com/docs/how_to/migrate_agent/>`_"
|
||||
"[Migrating from AgentExecutor](https://python.langchain.com/docs/how_to/migrate_agent/)"
|
||||
" and LangGraph's "
|
||||
"`Pre-built ReAct agent <https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/>`_."
|
||||
"[Pre-built ReAct agent](https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/)."
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ def create_react_agent(
|
||||
For a more robust and feature-rich implementation, we recommend using the
|
||||
`create_react_agent` function from the LangGraph library.
|
||||
See the
|
||||
`reference doc <https://langchain-ai.github.io/langgraph/reference/prebuilt/#langgraph.prebuilt.chat_agent_executor.create_react_agent>`__
|
||||
[reference doc](https://langchain-ai.github.io/langgraph/reference/prebuilt/#langgraph.prebuilt.chat_agent_executor.create_react_agent)
|
||||
for more information.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -80,7 +80,7 @@ def init_chat_model(
|
||||
|
||||
!!! note
|
||||
Must have the integration package corresponding to the model provider installed.
|
||||
You should look at the `provider integration's API reference <https://docs.langchain.com/oss/python/integrations/providers>`__
|
||||
You should look at the [provider integration's API reference](https://docs.langchain.com/oss/python/integrations/providers)
|
||||
to see what parameters are supported by the model.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -50,7 +50,7 @@ from langchain_classic.evaluation.string_distance.base import (
|
||||
|
||||
|
||||
def load_dataset(uri: str) -> list[dict]:
|
||||
"""Load a dataset from the `LangChainDatasets on HuggingFace <https://huggingface.co/LangChainDatasets>`_.
|
||||
"""Load a dataset from the [LangChainDatasets on HuggingFace](https://huggingface.co/LangChainDatasets).
|
||||
|
||||
Args:
|
||||
uri: The uri of the dataset to load.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Interface with the `LangChain Hub <https://smith.langchain.com/hub>`__."""
|
||||
"""Interface with the [LangChain Hub](https://smith.langchain.com/hub)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""**LangSmith** utilities.
|
||||
|
||||
This module provides utilities for connecting to
|
||||
`LangSmith <https://smith.langchain.com/>`_.
|
||||
[LangSmith](https://smith.langchain.com/).
|
||||
For more information on LangSmith,
|
||||
see the `LangSmith documentation <https://docs.smith.langchain.com/>`_.
|
||||
see the [LangSmith documentation](https://docs.smith.langchain.com/).
|
||||
|
||||
**Evaluation**
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ This module provides utilities for evaluating Chains and other language model
|
||||
applications using LangChain evaluators and LangSmith.
|
||||
|
||||
For more information on the LangSmith API, see the
|
||||
`LangSmith API documentation <https://docs.smith.langchain.com/docs/>`_.
|
||||
[LangSmith API documentation](https://docs.smith.langchain.com/docs/).
|
||||
|
||||
**Example**
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class AnthropicPromptCachingMiddleware(AgentMiddleware):
|
||||
Optimizes API usage by caching conversation prefixes for Anthropic models.
|
||||
|
||||
Learn more about Anthropic prompt caching
|
||||
`here <https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching>`__.
|
||||
[here](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching).
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -565,7 +565,7 @@ def _handle_anthropic_bad_request(e: anthropic.BadRequestError) -> None:
|
||||
class ChatAnthropic(BaseChatModel):
|
||||
"""Anthropic chat models.
|
||||
|
||||
See `Anthropic's docs <https://docs.anthropic.com/en/docs/about-claude/models/overview>`__ for a
|
||||
See [Anthropic's docs](https://docs.anthropic.com/en/docs/about-claude/models/overview) for a
|
||||
list of the latest models.
|
||||
|
||||
Setup:
|
||||
@@ -805,7 +805,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
See ``ChatAnthropic.with_structured_output()`` for more.
|
||||
|
||||
Image input:
|
||||
See `multimodal guides <https://python.langchain.com/docs/how_to/multimodal_inputs/>`__
|
||||
See [multimodal guides](https://python.langchain.com/docs/how_to/multimodal_inputs/)
|
||||
for more detail.
|
||||
|
||||
.. code-block:: python
|
||||
@@ -847,7 +847,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
??? note "Files API"
|
||||
|
||||
You can also pass in files that are managed through Anthropic's
|
||||
`Files API <https://docs.anthropic.com/en/docs/build-with-claude/files>`__:
|
||||
[Files API](https://docs.anthropic.com/en/docs/build-with-claude/files):
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -873,7 +873,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
llm.invoke([input_message])
|
||||
|
||||
PDF input:
|
||||
See `multimodal guides <https://python.langchain.com/docs/how_to/multimodal_inputs/>`__
|
||||
See [multimodal guides](https://python.langchain.com/docs/how_to/multimodal_inputs/)
|
||||
for more detail.
|
||||
|
||||
.. code-block:: python
|
||||
@@ -910,7 +910,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
??? note "Files API"
|
||||
|
||||
You can also pass in files that are managed through Anthropic's
|
||||
`Files API <https://docs.anthropic.com/en/docs/build-with-claude/files>`__:
|
||||
[Files API](https://docs.anthropic.com/en/docs/build-with-claude/files):
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -937,7 +937,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
|
||||
Extended thinking:
|
||||
Claude 3.7 Sonnet supports an
|
||||
`extended thinking <https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking>`__
|
||||
[extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
||||
feature, which will output the step-by-step reasoning process that led to its
|
||||
final answer.
|
||||
|
||||
@@ -972,10 +972,10 @@ class ChatAnthropic(BaseChatModel):
|
||||
|
||||
Citations:
|
||||
Anthropic supports a
|
||||
`citations <https://docs.anthropic.com/en/docs/build-with-claude/citations>`__
|
||||
[citations](https://docs.anthropic.com/en/docs/build-with-claude/citations)
|
||||
feature that lets Claude attach context to its answers based on source
|
||||
documents supplied by the user. When
|
||||
`document content blocks <https://docs.anthropic.com/en/docs/build-with-claude/citations#document-types>`__
|
||||
[document content blocks](https://docs.anthropic.com/en/docs/build-with-claude/citations#document-types)
|
||||
with ``"citations": {"enabled": True}`` are included in a query, Claude may
|
||||
generate citations in its response.
|
||||
|
||||
@@ -1077,7 +1077,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
|
||||
!!! note
|
||||
Only certain models support prompt caching.
|
||||
See the `Claude documentation <https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching#supported-models>`__
|
||||
See the [Claude documentation](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching#supported-models)
|
||||
for a full list.
|
||||
|
||||
.. code-block:: python
|
||||
@@ -1174,7 +1174,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
},
|
||||
}
|
||||
|
||||
See `Claude documentation <https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching#1-hour-cache-duration-beta>`__
|
||||
See [Claude documentation](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching#1-hour-cache-duration-beta)
|
||||
for detail.
|
||||
|
||||
Extended context windows (beta):
|
||||
@@ -1208,12 +1208,12 @@ class ChatAnthropic(BaseChatModel):
|
||||
|
||||
response = llm.invoke(messages)
|
||||
|
||||
See `Claude documentation <https://docs.anthropic.com/en/docs/build-with-claude/context-windows#1m-token-context-window>`__
|
||||
See [Claude documentation](https://docs.anthropic.com/en/docs/build-with-claude/context-windows#1m-token-context-window)
|
||||
for detail.
|
||||
|
||||
|
||||
Token-efficient tool use (beta):
|
||||
See LangChain `docs <https://python.langchain.com/docs/integrations/chat/anthropic/>`__
|
||||
See LangChain [docs](https://python.langchain.com/docs/integrations/chat/anthropic/)
|
||||
for more detail.
|
||||
|
||||
.. code-block:: python
|
||||
@@ -1253,7 +1253,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
Anthropic supports a context editing feature that will automatically manage the
|
||||
model's context window (e.g., by clearing tool results).
|
||||
|
||||
See `Anthropic documentation <https://docs.claude.com/en/docs/build-with-claude/context-editing>`__
|
||||
See [Anthropic documentation](https://docs.claude.com/en/docs/build-with-claude/context-editing)
|
||||
for details and configuration options.
|
||||
|
||||
.. code-block:: python
|
||||
@@ -1269,7 +1269,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
response = llm_with_tools.invoke("Search for recent developments in AI")
|
||||
|
||||
Built-in tools:
|
||||
See LangChain `docs <https://python.langchain.com/docs/integrations/chat/anthropic/#built-in-tools>`__
|
||||
See LangChain [docs](https://python.langchain.com/docs/integrations/chat/anthropic/#built-in-tools)
|
||||
for more detail.
|
||||
|
||||
??? note "Web search"
|
||||
@@ -1503,7 +1503,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
|
||||
context_management: dict[str, Any] | None = None
|
||||
"""Configuration for
|
||||
`context management <https://docs.claude.com/en/docs/build-with-claude/context-editing>`__.
|
||||
[context management](https://docs.claude.com/en/docs/build-with-claude/context-editing).
|
||||
"""
|
||||
|
||||
@property
|
||||
@@ -2397,7 +2397,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
403
|
||||
|
||||
!!! warning "Behavior changed in 0.3.0"
|
||||
Uses Anthropic's `token counting API <https://docs.anthropic.com/en/docs/build-with-claude/token-counting>`__ to count tokens in messages.
|
||||
Uses Anthropic's [token counting API](https://docs.anthropic.com/en/docs/build-with-claude/token-counting) to count tokens in messages.
|
||||
|
||||
""" # noqa: D214,E501
|
||||
formatted_system, formatted_messages = _format_messages(messages)
|
||||
|
||||
@@ -395,9 +395,9 @@ class ChatDeepSeek(BaseChatOpenAI):
|
||||
method: The method for steering model generation, one of:
|
||||
|
||||
- ``'function_calling'``:
|
||||
Uses DeepSeek's `tool-calling features <https://api-docs.deepseek.com/guides/function_calling>`_.
|
||||
Uses DeepSeek's [tool-calling features](https://api-docs.deepseek.com/guides/function_calling).
|
||||
- ``'json_mode'``:
|
||||
Uses DeepSeek's `JSON mode feature <https://api-docs.deepseek.com/guides/json_mode>`_.
|
||||
Uses DeepSeek's [JSON mode feature](https://api-docs.deepseek.com/guides/json_mode).
|
||||
|
||||
!!! warning "Behavior changed in 0.1.3"
|
||||
Added support for ``'json_mode'``.
|
||||
|
||||
@@ -693,11 +693,11 @@ class ChatFireworks(BaseChatModel):
|
||||
method: The method for steering model generation, one of:
|
||||
|
||||
- ``'function_calling'``:
|
||||
Uses Fireworks's `tool-calling features <https://docs.fireworks.ai/guides/function-calling>`_.
|
||||
Uses Fireworks's [tool-calling features](https://docs.fireworks.ai/guides/function-calling).
|
||||
- ``'json_schema'``:
|
||||
Uses Fireworks's `structured output feature <https://docs.fireworks.ai/structured-responses/structured-response-formatting>`_.
|
||||
Uses Fireworks's [structured output feature](https://docs.fireworks.ai/structured-responses/structured-response-formatting).
|
||||
- ``'json_mode'``:
|
||||
Uses Fireworks's `JSON mode feature <https://docs.fireworks.ai/structured-responses/structured-response-formatting>`_.
|
||||
Uses Fireworks's [JSON mode feature](https://docs.fireworks.ai/structured-responses/structured-response-formatting).
|
||||
|
||||
!!! warning "Behavior changed in 0.2.8"
|
||||
Added support for ``'json_schema'``.
|
||||
|
||||
@@ -24,11 +24,11 @@ logger = logging.getLogger(__name__)
|
||||
class Fireworks(LLM):
|
||||
"""LLM models from `Fireworks`.
|
||||
|
||||
To use, you'll need an `API key <https://fireworks.ai>`__. This can be passed in as
|
||||
To use, you'll need an [API key](https://fireworks.ai). This can be passed in as
|
||||
init param ``fireworks_api_key`` or set as environment variable
|
||||
``FIREWORKS_API_KEY``.
|
||||
|
||||
`Fireworks AI API reference <https://readme.fireworks.ai/>`__
|
||||
[Fireworks AI API reference](https://readme.fireworks.ai/)
|
||||
|
||||
Example:
|
||||
|
||||
@@ -55,7 +55,7 @@ class Fireworks(LLM):
|
||||
Automatically read from env variable ``FIREWORKS_API_KEY`` if not provided.
|
||||
"""
|
||||
model: str
|
||||
"""Model name. `(Available models) <https://readme.fireworks.ai/>`__"""
|
||||
"""Model name. [(Available models)](https://readme.fireworks.ai/)"""
|
||||
temperature: float | None = None
|
||||
"""Model temperature."""
|
||||
top_p: float | None = None
|
||||
|
||||
@@ -98,9 +98,8 @@ class ChatGroq(BaseChatModel):
|
||||
supresses reasoning content in the response; the model will still perform
|
||||
reasoning unless overridden in ``reasoning_effort``.
|
||||
|
||||
See the `Groq documentation
|
||||
<https://console.groq.com/docs/reasoning#reasoning>`__ for more
|
||||
details and a list of supported models.
|
||||
See the [Groq documentation](https://console.groq.com/docs/reasoning#reasoning)
|
||||
for more details and a list of supported models.
|
||||
model_kwargs: Dict[str, Any]
|
||||
Holds any model parameters valid for create call not
|
||||
explicitly specified.
|
||||
@@ -322,16 +321,16 @@ class ChatGroq(BaseChatModel):
|
||||
reasoning content in the response; the model will still perform reasoning unless
|
||||
overridden in ``reasoning_effort``.
|
||||
|
||||
See the `Groq documentation <https://console.groq.com/docs/reasoning#reasoning>`__
|
||||
See the [Groq documentation](https://console.groq.com/docs/reasoning#reasoning)
|
||||
for more details and a list of supported models.
|
||||
"""
|
||||
reasoning_effort: str | None = Field(default=None)
|
||||
"""The level of effort the model will put into reasoning. Groq will default to
|
||||
enabling reasoning if left undefined.
|
||||
|
||||
See the `Groq documentation
|
||||
<https://console.groq.com/docs/reasoning#options-for-reasoning-effort>`__ for more
|
||||
details and a list of options and models that support setting a reasoning effort.
|
||||
See the [Groq documentation](https://console.groq.com/docs/reasoning#options-for-reasoning-effort)
|
||||
for more details and a list of options and models that support setting a reasoning
|
||||
effort.
|
||||
"""
|
||||
model_kwargs: dict[str, Any] = Field(default_factory=dict)
|
||||
"""Holds any model parameters valid for `create` call not explicitly specified."""
|
||||
@@ -370,9 +369,8 @@ class ChatGroq(BaseChatModel):
|
||||
- `'auto'`: Uses on-demand rate limits, then falls back to ``'flex'`` if those
|
||||
limits are exceeded
|
||||
|
||||
See the `Groq documentation
|
||||
<https://console.groq.com/docs/flex-processing>`__ for more details and a list of
|
||||
service tiers and descriptions.
|
||||
See the [Groq documentation](https://console.groq.com/docs/flex-processing) for more
|
||||
details and a list of service tiers and descriptions.
|
||||
"""
|
||||
default_headers: Mapping[str, str] | None = None
|
||||
default_query: Mapping[str, object] | None = None
|
||||
@@ -851,20 +849,20 @@ class ChatGroq(BaseChatModel):
|
||||
method: The method for steering model generation, one of:
|
||||
|
||||
- ``'function_calling'``:
|
||||
Uses Groq's tool-calling `API <https://console.groq.com/docs/tool-use>`__
|
||||
Uses Groq's tool-calling [API](https://console.groq.com/docs/tool-use)
|
||||
- ``'json_schema'``:
|
||||
Uses Groq's `Structured Output API <https://console.groq.com/docs/structured-outputs>`__.
|
||||
Uses Groq's [Structured Output API](https://console.groq.com/docs/structured-outputs).
|
||||
Supported for a subset of models, including ``openai/gpt-oss``,
|
||||
``moonshotai/kimi-k2-instruct-0905``, and some ``meta-llama/llama-4``
|
||||
models. See `docs <https://console.groq.com/docs/structured-outputs>`__
|
||||
models. See [docs](https://console.groq.com/docs/structured-outputs)
|
||||
for details.
|
||||
- ``'json_mode'``:
|
||||
Uses Groq's `JSON mode <https://console.groq.com/docs/structured-outputs#json-object-mode>`__.
|
||||
Uses Groq's [JSON mode](https://console.groq.com/docs/structured-outputs#json-object-mode).
|
||||
Note that if using JSON mode then you must include instructions for
|
||||
formatting the output into the desired schema into the model call
|
||||
|
||||
Learn more about the differences between the methods and which models
|
||||
support which methods `here <https://console.groq.com/docs/structured-outputs>`__.
|
||||
support which methods [here](https://console.groq.com/docs/structured-outputs).
|
||||
|
||||
method:
|
||||
The method for steering model generation, either ``'function_calling'``
|
||||
|
||||
@@ -766,13 +766,13 @@ class ChatMistralAI(BaseChatModel):
|
||||
|
||||
- ``'function_calling'``:
|
||||
Uses Mistral's
|
||||
`function-calling feature <https://docs.mistral.ai/capabilities/function_calling/>`_.
|
||||
[function-calling feature](https://docs.mistral.ai/capabilities/function_calling/).
|
||||
- ``'json_schema'``:
|
||||
Uses Mistral's
|
||||
`structured output feature <https://docs.mistral.ai/capabilities/structured-output/custom_structured_output/>`_.
|
||||
[structured output feature](https://docs.mistral.ai/capabilities/structured-output/custom_structured_output/).
|
||||
- ``'json_mode'``:
|
||||
Uses Mistral's
|
||||
`JSON mode <https://docs.mistral.ai/capabilities/structured-output/json_mode/>`_.
|
||||
[JSON mode](https://docs.mistral.ai/capabilities/structured-output/json_mode/).
|
||||
Note that if using JSON mode then you
|
||||
must include instructions for formatting the output into the
|
||||
desired schema into the model call.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""This is the langchain_ollama package.
|
||||
|
||||
Provides infrastructure for interacting with the `Ollama <https://ollama.com/>`__
|
||||
Provides infrastructure for interacting with the [Ollama](https://ollama.com/)
|
||||
service.
|
||||
|
||||
!!! note
|
||||
|
||||
@@ -271,7 +271,7 @@ class ChatOllama(BaseChatModel):
|
||||
Name of Ollama model to use.
|
||||
reasoning: bool | None
|
||||
Controls the reasoning/thinking mode for
|
||||
`supported models <https://ollama.com/search?c=thinking>`__.
|
||||
[supported models](https://ollama.com/search?c=thinking).
|
||||
|
||||
- `True`: Enables reasoning mode. The model's reasoning process will be
|
||||
captured and returned separately in the ``additional_kwargs`` of the
|
||||
@@ -492,7 +492,7 @@ class ChatOllama(BaseChatModel):
|
||||
as think tags (``<think>`` and ``</think>``).
|
||||
|
||||
!!! note
|
||||
This feature is only available for `models that support reasoning <https://ollama.com/search?c=thinking>`__.
|
||||
This feature is only available for [models that support reasoning](https://ollama.com/search?c=thinking).
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -524,7 +524,7 @@ class ChatOllama(BaseChatModel):
|
||||
"""Model name to use."""
|
||||
|
||||
reasoning: bool | str | None = None
|
||||
"""Controls the reasoning/thinking mode for `supported models <https://ollama.com/search?c=thinking>`__.
|
||||
"""Controls the reasoning/thinking mode for [supported models](https://ollama.com/search?c=thinking).
|
||||
|
||||
- `True`: Enables reasoning mode. The model's reasoning process will be
|
||||
captured and returned separately in the ``additional_kwargs`` of the
|
||||
@@ -538,7 +538,7 @@ class ChatOllama(BaseChatModel):
|
||||
unless you set ``reasoning`` to `True`.
|
||||
- `str`: e.g. `'low'`, ``'medium'``, `'high'`. Enables reasoning with a custom
|
||||
intensity level. Currently, this is only supported ``gpt-oss``. See the
|
||||
`Ollama docs <https://github.com/ollama/ollama-python/blob/da79e987f0ac0a4986bf396f043b36ef840370bc/ollama/_types.py#L210>`__
|
||||
[Ollama docs](https://github.com/ollama/ollama-python/blob/da79e987f0ac0a4986bf396f043b36ef840370bc/ollama/_types.py#L210)
|
||||
for more information.
|
||||
"""
|
||||
|
||||
@@ -699,7 +699,7 @@ class ChatOllama(BaseChatModel):
|
||||
|
||||
These are clients unique to the async client; for shared args use `client_kwargs`.
|
||||
|
||||
For a full list of the params, see the `httpx documentation <https://www.python-httpx.org/api/#asyncclient>`__.
|
||||
For a full list of the params, see the [httpx documentation](https://www.python-httpx.org/api/#asyncclient).
|
||||
"""
|
||||
|
||||
sync_client_kwargs: dict | None = {}
|
||||
@@ -707,7 +707,7 @@ class ChatOllama(BaseChatModel):
|
||||
|
||||
These are clients unique to the sync client; for shared args use `client_kwargs`.
|
||||
|
||||
For a full list of the params, see the `httpx documentation <https://www.python-httpx.org/api/#client>`__.
|
||||
For a full list of the params, see the [httpx documentation](https://www.python-httpx.org/api/#client).
|
||||
"""
|
||||
|
||||
_client: Client = PrivateAttr()
|
||||
@@ -1275,7 +1275,7 @@ class ChatOllama(BaseChatModel):
|
||||
method: The method for steering model generation, one of:
|
||||
|
||||
- ``'json_schema'``:
|
||||
Uses Ollama's `structured output API <https://ollama.com/blog/structured-outputs>`__
|
||||
Uses Ollama's [structured output API](https://ollama.com/blog/structured-outputs)
|
||||
- ``'function_calling'``:
|
||||
Uses Ollama's tool-calling API
|
||||
- ``'json_mode'``:
|
||||
|
||||
@@ -16,12 +16,12 @@ class OllamaEmbeddings(BaseModel, Embeddings):
|
||||
"""Ollama embedding model integration.
|
||||
|
||||
Set up a local Ollama instance:
|
||||
`Install the Ollama package <https://github.com/ollama/ollama>`__ and set up a
|
||||
[Install the Ollama package](https://github.com/ollama/ollama) and set up a
|
||||
local Ollama instance.
|
||||
|
||||
You will need to choose a model to serve.
|
||||
|
||||
You can view a list of available models via `the model library <https://ollama.com/library>`__.
|
||||
You can view a list of available models via [the model library](https://ollama.com/library).
|
||||
|
||||
To fetch a model from the Ollama model library use ``ollama pull <name-of-model>``.
|
||||
|
||||
@@ -164,7 +164,7 @@ class OllamaEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
These are clients unique to the async client; for shared args use `client_kwargs`.
|
||||
|
||||
For a full list of the params, see the `httpx documentation <https://www.python-httpx.org/api/#asyncclient>`__.
|
||||
For a full list of the params, see the [httpx documentation](https://www.python-httpx.org/api/#asyncclient).
|
||||
"""
|
||||
|
||||
sync_client_kwargs: dict | None = {}
|
||||
@@ -172,7 +172,7 @@ class OllamaEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
These are clients unique to the sync client; for shared args use `client_kwargs`.
|
||||
|
||||
For a full list of the params, see the `httpx documentation <https://www.python-httpx.org/api/#client>`__.
|
||||
For a full list of the params, see the [httpx documentation](https://www.python-httpx.org/api/#client).
|
||||
"""
|
||||
|
||||
_client: Client | None = PrivateAttr(default=None)
|
||||
|
||||
@@ -114,7 +114,7 @@ class OllamaLLM(BaseLLM):
|
||||
|
||||
reasoning: bool | None = None
|
||||
"""Controls the reasoning/thinking mode for
|
||||
`supported models <https://ollama.com/search?c=thinking>`__.
|
||||
[supported models](https://ollama.com/search?c=thinking).
|
||||
|
||||
- `True`: Enables reasoning mode. The model's reasoning process will be
|
||||
captured and returned separately in the ``additional_kwargs`` of the
|
||||
@@ -243,7 +243,7 @@ class OllamaLLM(BaseLLM):
|
||||
|
||||
These are clients unique to the async client; for shared args use `client_kwargs`.
|
||||
|
||||
For a full list of the params, see the `httpx documentation <https://www.python-httpx.org/api/#asyncclient>`__.
|
||||
For a full list of the params, see the [httpx documentation](https://www.python-httpx.org/api/#asyncclient).
|
||||
"""
|
||||
|
||||
sync_client_kwargs: dict | None = {}
|
||||
@@ -251,7 +251,7 @@ class OllamaLLM(BaseLLM):
|
||||
|
||||
These are clients unique to the sync client; for shared args use `client_kwargs`.
|
||||
|
||||
For a full list of the params, see the `httpx documentation <https://www.python-httpx.org/api/#client>`__.
|
||||
For a full list of the params, see the [httpx documentation](https://www.python-httpx.org/api/#client).
|
||||
"""
|
||||
|
||||
_client: Client | None = PrivateAttr(default=None)
|
||||
|
||||
@@ -35,7 +35,7 @@ class AzureChatOpenAI(BaseChatOpenAI):
|
||||
r"""Azure OpenAI chat model integration.
|
||||
|
||||
Setup:
|
||||
Head to the Azure `OpenAI quickstart guide <https://learn.microsoft.com/en-us/azure/ai-foundry/openai/chatgpt-quickstart?tabs=keyless%2Ctypescript-keyless%2Cpython-new%2Ccommand-line&pivots=programming-language-python>`__
|
||||
Head to the Azure [OpenAI quickstart guide](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/chatgpt-quickstart?tabs=keyless%2Ctypescript-keyless%2Cpython-new%2Ccommand-line&pivots=programming-language-python)
|
||||
to create your Azure OpenAI deployment.
|
||||
|
||||
Then install `langchain-openai` and set environment variables
|
||||
@@ -61,7 +61,7 @@ class AzureChatOpenAI(BaseChatOpenAI):
|
||||
Key init args — client params:
|
||||
api_version: str
|
||||
Azure OpenAI REST API version to use (distinct from the version of the
|
||||
underlying model). `See more on the different versions. <https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versioning>`__
|
||||
underlying model). [See more on the different versions.](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versioning)
|
||||
timeout: Union[float, Tuple[float, float], Any, None]
|
||||
Timeout for requests.
|
||||
max_retries: int | None
|
||||
@@ -501,7 +501,7 @@ class AzureChatOpenAI(BaseChatOpenAI):
|
||||
|
||||
Automatically inferred from env var ``AZURE_OPENAI_AD_TOKEN`` if not provided.
|
||||
|
||||
For more, see `this page <https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id>`__.
|
||||
For more, see [this page](https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id).
|
||||
"""
|
||||
azure_ad_token_provider: Callable[[], str] | None = None
|
||||
"""A function that returns an Azure Active Directory token.
|
||||
@@ -852,19 +852,19 @@ class AzureChatOpenAI(BaseChatOpenAI):
|
||||
method: The method for steering model generation, one of:
|
||||
|
||||
- ``'json_schema'``:
|
||||
Uses OpenAI's `Structured Output API <https://platform.openai.com/docs/guides/structured-outputs>`__.
|
||||
Uses OpenAI's [Structured Output API](https://platform.openai.com/docs/guides/structured-outputs).
|
||||
Supported for ``'gpt-4o-mini'``, ``'gpt-4o-2024-08-06'``, ``'o1'``, and later
|
||||
models.
|
||||
- ``'function_calling'``:
|
||||
Uses OpenAI's tool-calling (formerly called function calling)
|
||||
`API <https://platform.openai.com/docs/guides/function-calling>`__
|
||||
[API](https://platform.openai.com/docs/guides/function-calling)
|
||||
- ``'json_mode'``:
|
||||
Uses OpenAI's `JSON mode <https://platform.openai.com/docs/guides/structured-outputs/json-mode>`__.
|
||||
Uses OpenAI's [JSON mode](https://platform.openai.com/docs/guides/structured-outputs/json-mode).
|
||||
Note that if using JSON mode then you must include instructions for
|
||||
formatting the output into the desired schema into the model call
|
||||
|
||||
Learn more about the differences between the methods and which models
|
||||
support which methods `here <https://platform.openai.com/docs/guides/structured-outputs/function-calling-vs-response-format>`__.
|
||||
support which methods [here](https://platform.openai.com/docs/guides/structured-outputs/function-calling-vs-response-format).
|
||||
|
||||
include_raw:
|
||||
If `False` then only the parsed structured output is returned. If
|
||||
@@ -877,7 +877,7 @@ class AzureChatOpenAI(BaseChatOpenAI):
|
||||
|
||||
- True:
|
||||
Model output is guaranteed to exactly match the schema.
|
||||
The input schema will also be validated according to the `supported schemas <https://platform.openai.com/docs/guides/structured-outputs/supported-schemas?api-mode=responses#supported-schemas>`__.
|
||||
The input schema will also be validated according to the [supported schemas](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas?api-mode=responses#supported-schemas).
|
||||
- False:
|
||||
Input schema will not be validated and model output will not be
|
||||
validated.
|
||||
@@ -972,7 +972,7 @@ class AzureChatOpenAI(BaseChatOpenAI):
|
||||
specify any Field metadata (like min/max constraints) and fields cannot
|
||||
have default values.
|
||||
|
||||
See all constraints `here <https://platform.openai.com/docs/guides/structured-outputs/supported-schemas>`__.
|
||||
See all constraints [here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ class AzureOpenAIEmbeddings(OpenAIEmbeddings): # type: ignore[override]
|
||||
|
||||
Automatically inferred from env var ``AZURE_OPENAI_AD_TOKEN`` if not provided.
|
||||
|
||||
`For more, see this page. <https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id>`__
|
||||
[For more, see this page.](https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id)
|
||||
"""
|
||||
azure_ad_token_provider: Callable[[], str] | None = None
|
||||
"""A function that returns an Azure Active Directory token.
|
||||
|
||||
@@ -405,7 +405,7 @@ class ChatPerplexity(BaseChatModel):
|
||||
) -> Runnable[LanguageModelInput, _DictOrPydantic]:
|
||||
"""Model wrapper that returns outputs formatted to match the given schema for Preplexity.
|
||||
Currently, Perplexity only supports "json_schema" method for structured output
|
||||
as per their `official documentation <https://docs.perplexity.ai/guides/structured-outputs>`__.
|
||||
as per their [official documentation](https://docs.perplexity.ai/guides/structured-outputs).
|
||||
|
||||
Args:
|
||||
schema: The output schema. Can be passed in as:
|
||||
|
||||
@@ -23,9 +23,9 @@ class FastEmbedSparse(SparseEmbeddings):
|
||||
) -> None:
|
||||
"""Sparse encoder implementation using FastEmbed.
|
||||
|
||||
Uses `FastEmbed <https://qdrant.github.io/fastembed/>`__ for sparse text
|
||||
Uses [FastEmbed](https://qdrant.github.io/fastembed/) for sparse text
|
||||
embeddings.
|
||||
For a list of available models, see `the Qdrant docs <https://qdrant.github.io/fastembed/examples/Supported_Models/>`__.
|
||||
For a list of available models, see [the Qdrant docs](https://qdrant.github.io/fastembed/examples/Supported_Models/).
|
||||
|
||||
Args:
|
||||
model_name (str): The name of the model to use. Defaults to `"Qdrant/bm25"`.
|
||||
|
||||
@@ -26,7 +26,7 @@ _DictOrPydantic: TypeAlias = dict | BaseModel
|
||||
class ChatXAI(BaseChatOpenAI): # type: ignore[override]
|
||||
r"""ChatXAI chat model.
|
||||
|
||||
Refer to `xAI's documentation <https://docs.x.ai/docs/api-reference#chat-completions>`__
|
||||
Refer to [xAI's documentation](https://docs.x.ai/docs/api-reference#chat-completions)
|
||||
for more nuanced details on the API's behavior and supported parameters.
|
||||
|
||||
Setup:
|
||||
@@ -46,7 +46,7 @@ class ChatXAI(BaseChatOpenAI): # type: ignore[override]
|
||||
while lower values (like `0.2`) mean more focused and deterministic completions.
|
||||
(Default: `1`.)
|
||||
max_tokens: int | None
|
||||
Max number of tokens to generate. Refer to your `model's documentation <https://docs.x.ai/docs/models#model-pricing>`__
|
||||
Max number of tokens to generate. Refer to your [model's documentation](https://docs.x.ai/docs/models#model-pricing)
|
||||
for the maximum number of tokens it can generate.
|
||||
logprobs: bool | None
|
||||
Whether to return logprobs.
|
||||
@@ -163,7 +163,7 @@ class ChatXAI(BaseChatOpenAI): # type: ignore[override]
|
||||
)
|
||||
|
||||
Reasoning:
|
||||
`Certain xAI models <https://docs.x.ai/docs/models#model-pricing>`__ support reasoning,
|
||||
[Certain xAI models](https://docs.x.ai/docs/models#model-pricing) support reasoning,
|
||||
which allows the model to provide reasoning content along with the response.
|
||||
|
||||
If provided, reasoning content is returned under the ``additional_kwargs`` field of the
|
||||
@@ -182,10 +182,10 @@ class ChatXAI(BaseChatOpenAI): # type: ignore[override]
|
||||
|
||||
!!! note
|
||||
As of 2025-07-10, ``reasoning_content`` is only returned in Grok 3 models, such as
|
||||
`Grok 3 Mini <https://docs.x.ai/docs/models/grok-3-mini>`__.
|
||||
[Grok 3 Mini](https://docs.x.ai/docs/models/grok-3-mini).
|
||||
|
||||
!!! note
|
||||
Note that in `Grok 4 <https://docs.x.ai/docs/models/grok-4-0709>`__, as of 2025-07-10,
|
||||
Note that in [Grok 4](https://docs.x.ai/docs/models/grok-4-0709), as of 2025-07-10,
|
||||
reasoning is not exposed in ``reasoning_content`` (other than initial ``'Thinking...'`` text),
|
||||
reasoning cannot be disabled, and the ``reasoning_effort`` cannot be specified.
|
||||
|
||||
@@ -323,7 +323,7 @@ class ChatXAI(BaseChatOpenAI): # type: ignore[override]
|
||||
)
|
||||
|
||||
Live Search:
|
||||
xAI supports a `Live Search <https://docs.x.ai/docs/guides/live-search>`__
|
||||
xAI supports a [Live Search](https://docs.x.ai/docs/guides/live-search)
|
||||
feature that enables Grok to ground its answers using results from web searches.
|
||||
|
||||
.. code-block:: python
|
||||
@@ -344,8 +344,8 @@ class ChatXAI(BaseChatOpenAI): # type: ignore[override]
|
||||
llm.invoke("Provide me a digest of world news in the last 24 hours.")
|
||||
|
||||
!!! note
|
||||
`Citations <https://docs.x.ai/docs/guides/live-search#returning-citations>`__
|
||||
are only available in `Grok 3 <https://docs.x.ai/docs/models/grok-3>`__.
|
||||
[Citations](https://docs.x.ai/docs/guides/live-search#returning-citations)
|
||||
are only available in [Grok 3](https://docs.x.ai/docs/models/grok-3).
|
||||
|
||||
Token usage:
|
||||
.. code-block:: python
|
||||
@@ -604,9 +604,9 @@ class ChatXAI(BaseChatOpenAI): # type: ignore[override]
|
||||
method: The method for steering model generation, one of:
|
||||
|
||||
- ``'function_calling'``:
|
||||
Uses xAI's `tool-calling features <https://docs.x.ai/docs/guides/function-calling>`__.
|
||||
Uses xAI's [tool-calling features](https://docs.x.ai/docs/guides/function-calling).
|
||||
- ``'json_schema'``:
|
||||
Uses xAI's `structured output feature <https://docs.x.ai/docs/guides/structured-outputs>`__.
|
||||
Uses xAI's [structured output feature](https://docs.x.ai/docs/guides/structured-outputs).
|
||||
- ``'json_mode'``:
|
||||
Uses xAI's JSON mode feature.
|
||||
|
||||
@@ -621,7 +621,7 @@ class ChatXAI(BaseChatOpenAI): # type: ignore[override]
|
||||
strict:
|
||||
- `True`:
|
||||
Model output is guaranteed to exactly match the schema.
|
||||
The input schema will also be validated according to the `supported schemas <https://platform.openai.com/docs/guides/structured-outputs/supported-schemas?api-mode=responses#supported-schemas>`__.
|
||||
The input schema will also be validated according to the [supported schemas](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas?api-mode=responses#supported-schemas).
|
||||
- `False`:
|
||||
Input schema will not be validated and model output will not be
|
||||
validated.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Base Test classes for standard testing.
|
||||
|
||||
To learn how to use these classes, see the
|
||||
`integration standard testing <https://python.langchain.com/docs/contributing/how_to/integrations/standard_tests/>`__
|
||||
[integration standard testing](https://python.langchain.com/docs/contributing/how_to/integrations/standard_tests/)
|
||||
guide.
|
||||
"""
|
||||
@@ -563,7 +563,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
??? note "`enable_vcr_tests`"
|
||||
|
||||
Property controlling whether to enable select tests that rely on
|
||||
`VCR <https://vcrpy.readthedocs.io/en/latest/>`_ caching of HTTP calls, such
|
||||
[VCR](https://vcrpy.readthedocs.io/en/latest/) caching of HTTP calls, such
|
||||
as benchmarking tests.
|
||||
|
||||
To enable these tests, follow these steps:
|
||||
@@ -2287,7 +2287,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
assert isinstance(result, dict)
|
||||
|
||||
def test_json_mode(self, model: BaseChatModel) -> None:
|
||||
"""Test structured output via `JSON mode. <https://python.langchain.com/docs/concepts/structured_outputs/#json-mode>`_.
|
||||
"""Test structured output via [JSON mode.](https://python.langchain.com/docs/concepts/structured_outputs/#json-mode).
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
the JSON mode feature (see Configuration below).
|
||||
|
||||
@@ -14,7 +14,7 @@ class ToolsIntegrationTests(ToolsTests):
|
||||
|
||||
If invoked with a ToolCall, the tool should return a valid ToolMessage content.
|
||||
|
||||
If you have followed the `custom tool guide <https://python.langchain.com/docs/how_to/custom_tools/>`_,
|
||||
If you have followed the [custom tool guide](https://python.langchain.com/docs/how_to/custom_tools/),
|
||||
this test should always pass because ToolCall inputs are handled by the
|
||||
`langchain_core.tools.BaseTool` class.
|
||||
|
||||
|
||||
@@ -684,7 +684,7 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
??? note "`enable_vcr_tests`"
|
||||
|
||||
Property controlling whether to enable select tests that rely on
|
||||
`VCR <https://vcrpy.readthedocs.io/en/latest/>`_ caching of HTTP calls, such
|
||||
[VCR](https://vcrpy.readthedocs.io/en/latest/) caching of HTTP calls, such
|
||||
as benchmarking tests.
|
||||
|
||||
To enable these tests, follow these steps:
|
||||
|
||||
@@ -105,7 +105,7 @@ class ToolsUnitTests(ToolsTests):
|
||||
If this fails, add an `args_schema` to your tool.
|
||||
|
||||
See
|
||||
`this guide <https://python.langchain.com/docs/how_to/custom_tools/#subclass-basetool>`_
|
||||
[this guide](https://python.langchain.com/docs/how_to/custom_tools/#subclass-basetool)
|
||||
and see how `CalculatorInput` is configured in the
|
||||
`CustomCalculatorTool.args_schema` attribute
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user