Home / Function/ set_default_max_tokens() — langchain Function Reference

set_default_max_tokens() — langchain Function Reference

Architecture documentation for the set_default_max_tokens() function in chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  63ba6ba9_c5fe_8164_078a_4bb8bff79792["set_default_max_tokens()"]
  977b57b2_5d0e_bcf4_a43e_b52857105005["ChatAnthropic"]
  63ba6ba9_c5fe_8164_078a_4bb8bff79792 -->|defined in| 977b57b2_5d0e_bcf4_a43e_b52857105005
  c689fcf8_a992_8317_e803_84f31b12e2a0["_get_default_model_profile()"]
  63ba6ba9_c5fe_8164_078a_4bb8bff79792 -->|calls| c689fcf8_a992_8317_e803_84f31b12e2a0
  style 63ba6ba9_c5fe_8164_078a_4bb8bff79792 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/langchain_anthropic/chat_models.py lines 986–994

    def set_default_max_tokens(cls, values: dict[str, Any]) -> Any:
        """Set default `max_tokens` from model profile with fallback."""
        if values.get("max_tokens") is None:
            model = values.get("model") or values.get("model_name")
            profile = _get_default_model_profile(model) if model else {}
            values["max_tokens"] = profile.get(
                "max_output_tokens", _FALLBACK_MAX_OUTPUT_TOKENS
            )
        return values

Domain

Subdomains

Frequently Asked Questions

What does set_default_max_tokens() do?
set_default_max_tokens() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/chat_models.py.
Where is set_default_max_tokens() defined?
set_default_max_tokens() is defined in libs/partners/anthropic/langchain_anthropic/chat_models.py at line 986.
What does set_default_max_tokens() call?
set_default_max_tokens() calls 1 function(s): _get_default_model_profile.

Analyze Your Own Codebase

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

Try Supermodel Free