middleware.tracing_notebook =========================== .. py:module:: middleware.tracing_notebook .. autoapi-nested-parse:: Notebook helpers that live-render correlated LangChain turn traces. Classes ------- .. autoapisummary:: middleware.tracing_notebook.NotebookTraceRenderer middleware.tracing_notebook.LiveNotebookTrace Module Contents --------------- .. py:class:: NotebookTraceRenderer(sink: middleware.tracing.TraceSink, *, heading: str = 'Trace') Render trace sink snapshots in a notebook cell. .. py:attribute:: sink .. py:attribute:: heading :value: 'Trace' .. py:method:: refresh() -> None Render the current sink snapshot into the notebook output. .. py:class:: LiveNotebookTrace(*, heading: str = 'Trace', max_events: int = 500, refresh_interval_seconds: float = 0.25) Own a recorder and live-render notebook trace updates. .. py:attribute:: sink .. py:attribute:: recorder .. py:attribute:: renderer .. py:attribute:: refresh_interval_seconds :value: 0.25 .. py:property:: callbacks :type: tuple[middleware.tracing.TraceRecorder, Ellipsis] Return callback handlers suitable for LangChain config injection. .. py:method:: start() -> None Begin periodic notebook refreshes until stopped. .. py:method:: stop() -> None Stop periodic refreshes and flush any remaining trace events. .. py:method:: attach(runnable: Any) -> Any Return a runnable configured with this trace recorder. .. py:method:: refresh() -> None Force a notebook refresh immediately. .. py:method:: dump(path: str | pathlib.Path | os.PathLike[str] | None = None, *, indent: int | None = 2) -> str Persist correlated :class:`~.tracing.TurnTrace` rows as JSON. When ``path`` is ``None``, returns the transcript as a string and does not write to disk. Otherwise writes UTF-8 JSON and returns the path as a string.