mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 06:33:41 +00:00
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.
This commit is contained in:
committed by
William Fu-Hinthorn
parent
3eff22c3c1
commit
e07c444285
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user