mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-28 22:14:18 +00:00
Unset context to None in var (#30380)
This commit is contained in:
parent
4130e6476b
commit
8265be4d3e
@ -153,9 +153,7 @@ def _set_config_context(
|
|||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def set_config_context(
|
def set_config_context(config: RunnableConfig) -> Generator[Context, None, None]:
|
||||||
config: RunnableConfig, ctx: Optional[Context] = None
|
|
||||||
) -> Generator[Context, None, None]:
|
|
||||||
"""Set the child Runnable config + tracing context.
|
"""Set the child Runnable config + tracing context.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -163,14 +161,23 @@ def set_config_context(
|
|||||||
"""
|
"""
|
||||||
from langsmith.run_helpers import _set_tracing_context
|
from langsmith.run_helpers import _set_tracing_context
|
||||||
|
|
||||||
ctx = ctx if ctx is not None else copy_context()
|
ctx = copy_context()
|
||||||
config_token, current_context = ctx.run(_set_config_context, config)
|
config_token, _ = ctx.run(_set_config_context, config)
|
||||||
try:
|
try:
|
||||||
yield ctx
|
yield ctx
|
||||||
finally:
|
finally:
|
||||||
ctx.run(var_child_runnable_config.reset, config_token)
|
ctx.run(var_child_runnable_config.reset, config_token)
|
||||||
if current_context is not None:
|
ctx.run(
|
||||||
ctx.run(_set_tracing_context, current_context)
|
_set_tracing_context,
|
||||||
|
{
|
||||||
|
"parent": None,
|
||||||
|
"project_name": None,
|
||||||
|
"tags": None,
|
||||||
|
"metadata": None,
|
||||||
|
"enabled": None,
|
||||||
|
"client": None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def ensure_config(config: Optional[RunnableConfig] = None) -> RunnableConfig:
|
def ensure_config(config: Optional[RunnableConfig] = None) -> RunnableConfig:
|
||||||
|
Loading…
Reference in New Issue
Block a user