Skip to content

Commit

Permalink
core[runnables]: docstring for class RunnableSerializable, method con…
Browse files Browse the repository at this point in the history
…figurable_fields (langchain-ai#19722)

**Description:** Update to the docstring for class RunnableSerializable,
method configurable_fields
**Issue:** [Add in code documentation to core Runnable methods
langchain-ai#18804](langchain-ai#18804)
**Dependencies:** None

---------

Co-authored-by: Chester Curme <[email protected]>
  • Loading branch information
2 people authored and gkorland committed Mar 30, 2024
1 parent 8d2e5c6 commit 1708029
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions libs/core/langchain_core/runnables/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,33 @@ def to_json(self) -> Union[SerializedConstructor, SerializedNotImplemented]:
def configurable_fields(
self, **kwargs: AnyConfigurableField
) -> RunnableSerializable[Input, Output]:
"""Configure particular runnable fields at runtime.
.. code-block:: python
from langchain_core.runnables import ConfigurableField
from langchain_openai import ChatOpenAI
model = ChatOpenAI(max_tokens=20).configurable_fields(
max_tokens=ConfigurableField(
id="output_token_number",
name="Max tokens in the output",
description="The maximum number of tokens in the output",
)
)
# max_tokens = 20
print(
"max_tokens_20: ",
model.invoke("tell me something about chess").content
)
# max_tokens = 200
print("max_tokens_200: ", model.with_config(
configurable={"output_token_number": 200}
).invoke("tell me something about chess").content
)
"""
from langchain_core.runnables.configurable import RunnableConfigurableFields

for key in kwargs:
Expand Down

0 comments on commit 1708029

Please sign in to comment.