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:
Nikhil Kumar 2024-03-16 17:48:00 -07:00 committed by GitHub
parent 8d2c34e655
commit a1b26dd9b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,6 +49,19 @@ class RouterRunnable(RunnableSerializable[RouterInput, Output]):
"""
Runnable that routes to a set of Runnables based on Input['key'].
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]]