Home / Function/ _extract_reasoning_from_additional_kwargs() — langchain Function Reference

_extract_reasoning_from_additional_kwargs() — langchain Function Reference

Architecture documentation for the _extract_reasoning_from_additional_kwargs() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  973474a5_c7f4_8f37_cb1b_528808bd1a40["_extract_reasoning_from_additional_kwargs()"]
  323271a6_dbeb_1ac5_e224_a66bfb56191b["base.py"]
  973474a5_c7f4_8f37_cb1b_528808bd1a40 -->|defined in| 323271a6_dbeb_1ac5_e224_a66bfb56191b
  style 973474a5_c7f4_8f37_cb1b_528808bd1a40 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/messages/base.py lines 24–44

def _extract_reasoning_from_additional_kwargs(
    message: BaseMessage,
) -> types.ReasoningContentBlock | None:
    """Extract `reasoning_content` from `additional_kwargs`.

    Handles reasoning content stored in various formats:
    - `additional_kwargs["reasoning_content"]` (string) - Ollama, DeepSeek, XAI, Groq

    Args:
        message: The message to extract reasoning from.

    Returns:
        A `ReasoningContentBlock` if reasoning content is found, None otherwise.
    """
    additional_kwargs = getattr(message, "additional_kwargs", {})

    reasoning_content = additional_kwargs.get("reasoning_content")
    if reasoning_content is not None and isinstance(reasoning_content, str):
        return {"type": "reasoning", "reasoning": reasoning_content}

    return None

Subdomains

Frequently Asked Questions

What does _extract_reasoning_from_additional_kwargs() do?
_extract_reasoning_from_additional_kwargs() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/base.py.
Where is _extract_reasoning_from_additional_kwargs() defined?
_extract_reasoning_from_additional_kwargs() is defined in libs/core/langchain_core/messages/base.py at line 24.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free