This commit is contained in:
Mason Daugherty
2026-02-18 02:41:49 -05:00
parent 40efc2bdf3
commit da92c2df61
2 changed files with 9 additions and 2 deletions

View File

@@ -94,7 +94,9 @@ def trace_as_chain_group(
manager.on_chain_end({"output": res})
```
"""
from langchain_core.tracers.context import _get_trace_callbacks # noqa: PLC0415
from langchain_core.tracers.context import ( # noqa: PLC0415 -- deferred to avoid importing langsmith at module level
_get_trace_callbacks,
)
cb = _get_trace_callbacks(
project_name, example_id, callback_manager=callback_manager
@@ -175,7 +177,9 @@ async def atrace_as_chain_group(
await manager.on_chain_end({"output": res})
```
"""
from langchain_core.tracers.context import _get_trace_callbacks # noqa: PLC0415
from langchain_core.tracers.context import ( # noqa: PLC0415 -- deferred to avoid importing langsmith at module level
_get_trace_callbacks,
)
cb = _get_trace_callbacks(
project_name, example_id, callback_manager=callback_manager
@@ -2319,6 +2323,7 @@ def _configure(
Returns:
The configured callback manager.
"""
# Deferred to avoid importing langsmith at module level (~132ms).
from langsmith.run_helpers import get_tracing_context # noqa: PLC0415
from langchain_core.tracers.context import ( # noqa: PLC0415

View File

@@ -158,6 +158,7 @@ def _set_config_context(
Returns:
The token to reset the config and the previous tracing context.
"""
# Deferred to avoid importing langsmith at module level (~132ms).
from langsmith.run_helpers import ( # noqa: PLC0415
_set_tracing_context,
get_tracing_context,
@@ -199,6 +200,7 @@ def set_config_context(config: RunnableConfig) -> Generator[Context, None, None]
Yields:
The config context.
"""
# Deferred to avoid importing langsmith at module level (~132ms).
from langsmith.run_helpers import _set_tracing_context # noqa: PLC0415
ctx = copy_context()