Home / Function/ _llm_run_with_token_event() — langchain Function Reference

_llm_run_with_token_event() — langchain Function Reference

Architecture documentation for the _llm_run_with_token_event() function in core.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d319bd66_22d4_60ab_e147_6c3250c3db36["_llm_run_with_token_event()"]
  70348e44_de0f_ccb4_c06a_8453289ed93e["_TracerCore"]
  d319bd66_22d4_60ab_e147_6c3250c3db36 -->|defined in| 70348e44_de0f_ccb4_c06a_8453289ed93e
  66392709_99c4_1a2e_dfac_aed34eebe5f5["_get_run()"]
  d319bd66_22d4_60ab_e147_6c3250c3db36 -->|calls| 66392709_99c4_1a2e_dfac_aed34eebe5f5
  style d319bd66_22d4_60ab_e147_6c3250c3db36 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tracers/core.py lines 224–244

    def _llm_run_with_token_event(
        self,
        token: str,
        run_id: UUID,
        chunk: GenerationChunk | ChatGenerationChunk | None = None,
        parent_run_id: UUID | None = None,
    ) -> Run:
        """Append token event to LLM run and return the run."""
        _ = parent_run_id
        llm_run = self._get_run(run_id, run_type={"llm", "chat_model"})
        event_kwargs: dict[str, Any] = {"token": token}
        if chunk:
            event_kwargs["chunk"] = chunk
        llm_run.events.append(
            {
                "name": "new_token",
                "time": datetime.now(timezone.utc),
                "kwargs": event_kwargs,
            },
        )
        return llm_run

Domain

Subdomains

Calls

Frequently Asked Questions

What does _llm_run_with_token_event() do?
_llm_run_with_token_event() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/core.py.
Where is _llm_run_with_token_event() defined?
_llm_run_with_token_event() is defined in libs/core/langchain_core/tracers/core.py at line 224.
What does _llm_run_with_token_event() call?
_llm_run_with_token_event() calls 1 function(s): _get_run.

Analyze Your Own Codebase

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

Try Supermodel Free