Home / Function/ _on_run_update() — langchain Function Reference

_on_run_update() — langchain Function Reference

Architecture documentation for the _on_run_update() function in log_stream.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  dd086141_42ce_3053_f911_051099488c1c["_on_run_update()"]
  78fc514f_5439_00c6_7e00_021af9ce4e07["LogStreamCallbackHandler"]
  dd086141_42ce_3053_f911_051099488c1c -->|defined in| 78fc514f_5439_00c6_7e00_021af9ce4e07
  c5f1fbd2_23b6_75cb_1f29_b9e028c332a0["send()"]
  dd086141_42ce_3053_f911_051099488c1c -->|calls| c5f1fbd2_23b6_75cb_1f29_b9e028c332a0
  999c00c5_f6b7_32ae_2290_ef3266811aab["_get_standardized_inputs()"]
  dd086141_42ce_3053_f911_051099488c1c -->|calls| 999c00c5_f6b7_32ae_2290_ef3266811aab
  0943f408_8b28_69b3_fbf5_b8fae15394f4["_get_standardized_outputs()"]
  dd086141_42ce_3053_f911_051099488c1c -->|calls| 0943f408_8b28_69b3_fbf5_b8fae15394f4
  style dd086141_42ce_3053_f911_051099488c1c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tracers/log_stream.py lines 490–534

    def _on_run_update(self, run: Run) -> None:
        """Finish a `Run`."""
        try:
            index = self._key_map_by_run_id.get(run.id)

            if index is None:
                return

            ops = []

            if self._schema_format == "streaming_events":
                ops.append(
                    {
                        "op": "replace",
                        "path": f"/logs/{index}/inputs",
                        "value": _get_standardized_inputs(run, self._schema_format),
                    }
                )

            ops.extend(
                [
                    # Replace 'inputs' with final inputs
                    # This is needed because in many cases the inputs are not
                    # known until after the run is finished and the entire
                    # input stream has been processed by the runnable.
                    {
                        "op": "add",
                        "path": f"/logs/{index}/final_output",
                        # to undo the dumpd done by some runnables / tracer / etc
                        "value": _get_standardized_outputs(run, self._schema_format),
                    },
                    {
                        "op": "add",
                        "path": f"/logs/{index}/end_time",
                        "value": run.end_time.isoformat(timespec="milliseconds")
                        if run.end_time is not None
                        else None,
                    },
                ]
            )

            self.send(*ops)
        finally:
            if run.id == self.root_id and self.auto_close:
                self.send_stream.close()

Domain

Subdomains

Frequently Asked Questions

What does _on_run_update() do?
_on_run_update() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/log_stream.py.
Where is _on_run_update() defined?
_on_run_update() is defined in libs/core/langchain_core/tracers/log_stream.py at line 490.
What does _on_run_update() call?
_on_run_update() calls 3 function(s): _get_standardized_inputs, _get_standardized_outputs, send.

Analyze Your Own Codebase

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

Try Supermodel Free