Home / Function/ on_llm_new_token() — langchain Function Reference

on_llm_new_token() — langchain Function Reference

Architecture documentation for the on_llm_new_token() function in streaming_stdout.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  4e0b56bb_932c_190d_a84b_88093cab9f5b["on_llm_new_token()"]
  6b65bf57_0fa9_b411_5886_294d6dbe5842["StreamingStdOutCallbackHandler"]
  4e0b56bb_932c_190d_a84b_88093cab9f5b -->|defined in| 6b65bf57_0fa9_b411_5886_294d6dbe5842
  style 4e0b56bb_932c_190d_a84b_88093cab9f5b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/callbacks/streaming_stdout.py lines 50–58

    def on_llm_new_token(self, token: str, **kwargs: Any) -> None:
        """Run on new LLM token. Only available when streaming is enabled.

        Args:
            token: The new token.
            **kwargs: Additional keyword arguments.
        """
        sys.stdout.write(token)
        sys.stdout.flush()

Domain

Subdomains

Frequently Asked Questions

What does on_llm_new_token() do?
on_llm_new_token() is a function in the langchain codebase, defined in libs/core/langchain_core/callbacks/streaming_stdout.py.
Where is on_llm_new_token() defined?
on_llm_new_token() is defined in libs/core/langchain_core/callbacks/streaming_stdout.py at line 50.

Analyze Your Own Codebase

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

Try Supermodel Free