Skip to content

Commit

Permalink
core: Updated docstring for RunnablePick (langchain-ai#18832)
Browse files Browse the repository at this point in the history
**Description:** : Updated the docstring for RunnablePick. Added
Overview and an Example for RunnablePick class.
   **Issue:** : langchain-ai#18803
  • Loading branch information
devesh-2002 authored Mar 20, 2024
1 parent e46419c commit 3c4529a
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions libs/core/langchain_core/runnables/passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,30 @@ async def input_aiter() -> AsyncIterator[Dict[str, Any]]:


class RunnablePick(RunnableSerializable[Dict[str, Any], Dict[str, Any]]):
"""
Runnable that picks keys from Dict[str, Any] inputs.
"""Runnable that picks keys from Dict[str, Any] inputs.
RunnablePick class represents a runnable that selectively picks keys from a
dictionary input. It allows you to specify one or more keys to extract
from the input dictionary. It returns a new dictionary containing only
the selected keys.
Example :
.. code-block:: python
from langchain_core.runnables.passthrough import RunnablePick
input_data = {
'name': 'John',
'age': 30,
'city': 'New York',
'country': 'USA'
}
runnable = RunnablePick(keys=['name', 'age'])
output_data = runnable.invoke(input_data)
print(output_data) # Output: {'name': 'John', 'age': 30}
"""

keys: Union[str, List[str]]
Expand Down

0 comments on commit 3c4529a

Please sign in to comment.