test_configurable_fields_example() — langchain Function Reference
Architecture documentation for the test_configurable_fields_example() function in test_runnable.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2f48bb67_be06_63b0_47d4_f590a7b778f8["test_configurable_fields_example()"] 26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"] 2f48bb67_be06_63b0_47d4_f590a7b778f8 -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5 fb618d44_c03b_ea8b_385b_2278dfb173d4["invoke()"] 2f48bb67_be06_63b0_47d4_f590a7b778f8 -->|calls| fb618d44_c03b_ea8b_385b_2278dfb173d4 style 2f48bb67_be06_63b0_47d4_f590a7b778f8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable.py lines 937–1000
def test_configurable_fields_example(snapshot: SnapshotAssertion) -> None:
fake_chat = FakeListChatModel(responses=["b"]).configurable_fields(
responses=ConfigurableFieldMultiOption(
id="chat_responses",
name="Chat Responses",
options={
"hello": "A good morning to you!",
"bye": "See you later!",
"helpful": "How can I help you?",
},
default=["hello", "bye"],
)
)
fake_llm = (
FakeListLLM(responses=["a"])
.configurable_fields(
responses=ConfigurableField(
id="llm_responses",
name="LLM Responses",
description="A list of fake responses for this LLM",
)
)
.configurable_alternatives(
ConfigurableField(id="llm", name="LLM"),
chat=fake_chat | StrOutputParser(),
)
)
prompt = PromptTemplate.from_template("Hello, {name}!").configurable_fields(
template=ConfigurableFieldSingleOption(
id="prompt_template",
name="Prompt Template",
description="The prompt template for this chain",
options={
"hello": "Hello, {name}!",
"good_morning": "A very good morning to you, {name}!",
},
default="hello",
)
)
# deduplication of configurable fields
chain_configurable = prompt | fake_llm | (lambda x: {"name": x}) | prompt | fake_llm
assert chain_configurable.invoke({"name": "John"}) == "a"
if PYDANTIC_VERSION_AT_LEAST_29:
assert _normalize_schema(
chain_configurable.get_config_jsonschema()
) == snapshot(name="schema7")
assert (
chain_configurable.with_config(configurable={"llm": "chat"}).invoke(
{"name": "John"}
)
== "A good morning to you!"
)
assert (
chain_configurable.with_config(
configurable={"llm": "chat", "chat_responses": ["helpful"]}
).invoke({"name": "John"})
== "How can I help you?"
)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_configurable_fields_example() do?
test_configurable_fields_example() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_configurable_fields_example() defined?
test_configurable_fields_example() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 937.
What does test_configurable_fields_example() call?
test_configurable_fields_example() calls 1 function(s): invoke.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free