mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
Use traceable context (#11896)
Example ``` from langchain.schema.runnable import RunnableLambda from langsmith import traceable chain = RunnableLambda(lambda x: x) @traceable(run_type = "chain") def my_traceable(a): chain.invoke(a) my_traceable(5) ``` Would have a nested result. This would NOT work for interleaving chains and traceables. E.g., things like thiswould still not work well ``` from langchain.schema.runnable import RunnableLambda from langsmith import traceable @traceable() def other_traceable(a): return a def foo(x): return other_traceable(x) chain = RunnableLambda(foo) @traceable(run_type = "chain") def my_traceable(a): chain.invoke(a) my_traceable(5) ```
This commit is contained in:
parent
dcd0392423
commit
a27fa9bf10
@ -25,6 +25,7 @@ from typing import (
|
||||
)
|
||||
from uuid import UUID
|
||||
|
||||
from langsmith.run_helpers import get_run_tree_context
|
||||
from tenacity import RetryCallState
|
||||
|
||||
from langchain.callbacks.base import (
|
||||
@ -1882,7 +1883,9 @@ def _configure(
|
||||
Returns:
|
||||
T: The configured callback manager.
|
||||
"""
|
||||
callback_manager = callback_manager_cls(handlers=[])
|
||||
run_tree = get_run_tree_context()
|
||||
parent_run_id = None if run_tree is None else getattr(run_tree, "id")
|
||||
callback_manager = callback_manager_cls(handlers=[], parent_run_id=parent_run_id)
|
||||
if inheritable_callbacks or local_callbacks:
|
||||
if isinstance(inheritable_callbacks, list) or inheritable_callbacks is None:
|
||||
inheritable_callbacks_ = inheritable_callbacks or []
|
||||
|
Loading…
Reference in New Issue
Block a user