mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
langchain[patch]: Fix config
arg detection for wrapped lambdarunnable (#14230)
**Description:**
When a RunnableLambda only receives a synchronous callback, this
callback is wrapped into an async one since #13408. However, this
wrapping with `(*args, **kwargs)` causes the `accepts_config` check at
[/libs/core/langchain_core/runnables/config.py#L342](ee94ef55ee/libs/core/langchain_core/runnables/config.py (L342)
)
to fail, as this checks for the presence of a "config" argument in the
method signature.
Adding a `functools.wraps` around it, resolves it.
This commit is contained in:
parent
de86b84a70
commit
67662564f3
@ -6,7 +6,7 @@ import threading
|
||||
from abc import ABC, abstractmethod
|
||||
from concurrent.futures import FIRST_COMPLETED, wait
|
||||
from copy import deepcopy
|
||||
from functools import partial
|
||||
from functools import partial, wraps
|
||||
from itertools import tee
|
||||
from operator import itemgetter
|
||||
from typing import (
|
||||
@ -2518,6 +2518,7 @@ class RunnableLambda(Runnable[Input, Output]):
|
||||
afunc = self.afunc
|
||||
else:
|
||||
|
||||
@wraps(self.func)
|
||||
async def f(*args, **kwargs): # type: ignore[no-untyped-def]
|
||||
return await asyncio.get_running_loop().run_in_executor(
|
||||
None, partial(self.func, **kwargs), *args
|
||||
|
Loading…
Reference in New Issue
Block a user