Skip to content

Commit

Permalink
Keyword-like runnable config (langchain-ai#26295)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored and Sheepsta300 committed Oct 1, 2024
1 parent a99b3f7 commit fa5edac
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions libs/core/langchain_core/runnables/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
List,
Mapping,
Optional,
Protocol,
Sequence,
Set,
Tuple,
Expand Down Expand Up @@ -5519,12 +5520,36 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
return attr


class _RunnableCallableSync(Protocol[Input, Output]):
def __call__(self, __in: Input, *, config: RunnableConfig) -> Output: ...


class _RunnableCallableAsync(Protocol[Input, Output]):
def __call__(self, __in: Input, *, config: RunnableConfig) -> Awaitable[Output]: ...


class _RunnableCallableIterator(Protocol[Input, Output]):
def __call__(
self, __in: Iterator[Input], *, config: RunnableConfig
) -> Iterator[Output]: ...


class _RunnableCallableAsyncIterator(Protocol[Input, Output]):
def __call__(
self, __in: AsyncIterator[Input], *, config: RunnableConfig
) -> AsyncIterator[Output]: ...


RunnableLike = Union[
Runnable[Input, Output],
Callable[[Input], Output],
Callable[[Input], Awaitable[Output]],
Callable[[Iterator[Input]], Iterator[Output]],
Callable[[AsyncIterator[Input]], AsyncIterator[Output]],
_RunnableCallableSync[Input, Output],
_RunnableCallableAsync[Input, Output],
_RunnableCallableIterator[Input, Output],
_RunnableCallableAsyncIterator[Input, Output],
Mapping[str, Any],
]

Expand Down

0 comments on commit fa5edac

Please sign in to comment.