mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-04 06:37:58 +00:00
docs: Add docs for RouterRunnable (#19191)
- [x] **Docs for `RouterRunnable`**: core: Add docs for `RouterRunnable` - [x] **Add docs for `RouterRunnable`**: - **Description:** Add docs for `RouterRunnable`, which was previously missing documentation - **Issue:** #18803 - **Dependencies:** N/A - **Twitter handle:** None
This commit is contained in:
parent
8d2c34e655
commit
a1b26dd9b6
@ -49,6 +49,19 @@ class RouterRunnable(RunnableSerializable[RouterInput, Output]):
|
|||||||
"""
|
"""
|
||||||
Runnable that routes to a set of Runnables based on Input['key'].
|
Runnable that routes to a set of Runnables based on Input['key'].
|
||||||
Returns the output of the selected Runnable.
|
Returns the output of the selected Runnable.
|
||||||
|
|
||||||
|
For example,
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from langchain_core.runnables.router import RouterRunnable
|
||||||
|
from langchain_core.runnables import RunnableLambda
|
||||||
|
|
||||||
|
add = RunnableLambda(func=lambda x: x + 1)
|
||||||
|
square = RunnableLambda(func=lambda x: x**2)
|
||||||
|
|
||||||
|
router = RouterRunnable(runnables={"add": add, "square": square})
|
||||||
|
router.invoke({"key": "square", "input": 3})
|
||||||
"""
|
"""
|
||||||
|
|
||||||
runnables: Mapping[str, Runnable[Any, Output]]
|
runnables: Mapping[str, Runnable[Any, Output]]
|
||||||
|
Loading…
Reference in New Issue
Block a user