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 base.py from the langchain codebase.

Function python Observability Tracers calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  5f880efa_8d4b_5819_bceb_8fbd0e5df60f["on_llm_new_token()"]
  b3ab8001_c14c_4191_ca53_2dbabc99917f["AsyncBaseTracer"]
  5f880efa_8d4b_5819_bceb_8fbd0e5df60f -->|defined in| b3ab8001_c14c_4191_ca53_2dbabc99917f
  bdbf79bf_1c51_df7e_a101_2d5bec39a8b4["on_llm_new_token()"]
  bdbf79bf_1c51_df7e_a101_2d5bec39a8b4 -->|calls| 5f880efa_8d4b_5819_bceb_8fbd0e5df60f
  a6b72ebe_4ebd_9d29_9fe1_f9e27948c7ff["_on_llm_new_token()"]
  5f880efa_8d4b_5819_bceb_8fbd0e5df60f -->|calls| a6b72ebe_4ebd_9d29_9fe1_f9e27948c7ff
  bdbf79bf_1c51_df7e_a101_2d5bec39a8b4["on_llm_new_token()"]
  5f880efa_8d4b_5819_bceb_8fbd0e5df60f -->|calls| bdbf79bf_1c51_df7e_a101_2d5bec39a8b4
  style 5f880efa_8d4b_5819_bceb_8fbd0e5df60f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tracers/base.py lines 617–632

    async def on_llm_new_token(
        self,
        token: str,
        *,
        chunk: GenerationChunk | ChatGenerationChunk | None = None,
        run_id: UUID,
        parent_run_id: UUID | None = None,
        **kwargs: Any,
    ) -> None:
        llm_run = self._llm_run_with_token_event(
            token=token,
            run_id=run_id,
            chunk=chunk,
            parent_run_id=parent_run_id,
        )
        await self._on_llm_new_token(llm_run, token, chunk)

Domain

Subdomains

Called By

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/tracers/base.py.
Where is on_llm_new_token() defined?
on_llm_new_token() is defined in libs/core/langchain_core/tracers/base.py at line 617.
What does on_llm_new_token() call?
on_llm_new_token() calls 2 function(s): _on_llm_new_token, on_llm_new_token.
What calls on_llm_new_token()?
on_llm_new_token() is called by 1 function(s): on_llm_new_token.

Analyze Your Own Codebase

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

Try Supermodel Free