From ece008f1179000068a6621f99800a4ee1e290f93 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov <145155732+smalyu@users.noreply.github.com> Date: Sun, 14 Apr 2024 02:23:32 +0300 Subject: [PATCH] docs: Refine RunnablePassthrough docstring (#19812) Description: This update refines the documentation for `RunnablePassthrough` by removing an unnecessary import and correcting a minor syntactical error in the example provided. This change enhances the clarity and correctness of the documentation, ensuring that users have a more accurate guide to follow. Issue: N/A Dependencies: None This PR focuses solely on documentation improvements, specifically targeting the `RunnablePassthrough` class within the `langchain_core` module. By clarifying the example provided in the docstring, users are offered a more straightforward and error-free guide to utilizing the `RunnablePassthrough` class effectively. As this is a documentation update, it does not include changes that require new integrations, tests, or modifications to dependencies. It adheres to the guidelines of minimal package interference and backward compatibility, ensuring that the overall integrity and functionality of the LangChain package remain unaffected. Thank you for considering this documentation refinement for inclusion in the LangChain project. --- libs/core/langchain_core/runnables/passthrough.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/core/langchain_core/runnables/passthrough.py b/libs/core/langchain_core/runnables/passthrough.py index 6b1b9ad564..55d61093ec 100644 --- a/libs/core/langchain_core/runnables/passthrough.py +++ b/libs/core/langchain_core/runnables/passthrough.py @@ -107,7 +107,7 @@ class RunnablePassthrough(RunnableSerializable[Other, Other]): .. code-block:: python - from langchain_core.runnables import RunnablePassthrough, RunnableParallel + from langchain_core.runnables import RunnablePassthrough def fake_llm(prompt: str) -> str: # Fake LLM for the example return "completion" @@ -115,10 +115,9 @@ class RunnablePassthrough(RunnableSerializable[Other, Other]): runnable = { 'llm1': fake_llm, 'llm2': fake_llm, - } - | RunnablePassthrough.assign( + } | RunnablePassthrough.assign( total_chars=lambda inputs: len(inputs['llm1'] + inputs['llm2']) - ) + ) runnable.invoke('hello') # {'llm1': 'completion', 'llm2': 'completion', 'total_chars': 20}