mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
core[runnables]: docstring for class RunnableSerializable, method configurable_fields (#19722)
**Description:** Update to the docstring for class RunnableSerializable, method configurable_fields **Issue:** [Add in code documentation to core Runnable methods #18804](https://github.com/langchain-ai/langchain/issues/18804) **Dependencies:** None --------- Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
parent
e1f10a697e
commit
263ee78886
@ -2034,6 +2034,33 @@ class RunnableSerializable(Serializable, Runnable[Input, Output]):
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user