From 3c4529ac694e317c6ca499a662ae69f6fe487e56 Mon Sep 17 00:00:00 2001 From: Devesh Rahatekar <79015420+devesh-2002@users.noreply.github.com> Date: Wed, 20 Mar 2024 19:24:42 +0530 Subject: [PATCH] core: Updated docstring for RunnablePick (#18832) **Description:** : Updated the docstring for RunnablePick. Added Overview and an Example for RunnablePick class. **Issue:** : #18803 --- .../langchain_core/runnables/passthrough.py | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/libs/core/langchain_core/runnables/passthrough.py b/libs/core/langchain_core/runnables/passthrough.py index f3d4e5f78d..6b1b9ad564 100644 --- a/libs/core/langchain_core/runnables/passthrough.py +++ b/libs/core/langchain_core/runnables/passthrough.py @@ -610,8 +610,30 @@ class RunnableAssign(RunnableSerializable[Dict[str, Any], 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]]