Skip to content

Commit

Permalink
Fix names of runnable lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos committed Jan 6, 2024
1 parent d04004d commit e59248a
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions libs/core/langchain_core/runnables/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2745,6 +2745,7 @@ def __init__(
],
]
] = None,
name: Optional[str] = None,
) -> None:
"""Create a RunnableLambda from a callable, and async callable or both.
Expand Down Expand Up @@ -2778,7 +2779,9 @@ def __init__(
)

try:
if func_for_name.__name__ != "<lambda>":
if name is not None:
self.name = name
elif func_for_name.__name__ != "<lambda>":
self.name = func_for_name.__name__
except AttributeError:
pass
Expand Down Expand Up @@ -3057,17 +3060,7 @@ async def f(*args, **kwargs): # type: ignore[no-untyped-def]
def _config(
self, config: Optional[RunnableConfig], callable: Callable[..., Any]
) -> RunnableConfig:
config = ensure_config(config)

if config.get("run_name") is None:
try:
run_name = callable.__name__
except AttributeError:
run_name = None
if run_name is not None:
return patch_config(config, run_name=run_name)

return config
return ensure_config(config)

def invoke(
self,
Expand Down

0 comments on commit e59248a

Please sign in to comment.