test_configurable_fields() — langchain Function Reference
Architecture documentation for the test_configurable_fields() function in test_runnable.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 328b1c1f_dee3_6bdb_7bcd_9cb109ba1f9d["test_configurable_fields()"] 26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"] 328b1c1f_dee3_6bdb_7bcd_9cb109ba1f9d -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5 fb618d44_c03b_ea8b_385b_2278dfb173d4["invoke()"] 328b1c1f_dee3_6bdb_7bcd_9cb109ba1f9d -->|calls| fb618d44_c03b_ea8b_385b_2278dfb173d4 style 328b1c1f_dee3_6bdb_7bcd_9cb109ba1f9d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable.py lines 742–869
def test_configurable_fields(snapshot: SnapshotAssertion) -> None:
fake_llm = FakeListLLM(responses=["a"]) # str -> list[list[str]]
assert fake_llm.invoke("...") == "a"
fake_llm_configurable = fake_llm.configurable_fields(
responses=ConfigurableField(
id="llm_responses",
name="LLM Responses",
description="A list of fake responses for this LLM",
)
)
assert fake_llm_configurable.invoke("...") == "a"
if PYDANTIC_VERSION_AT_LEAST_29:
assert _normalize_schema(
fake_llm_configurable.get_config_jsonschema()
) == snapshot(name="schema2")
fake_llm_configured = fake_llm_configurable.with_config(
configurable={"llm_responses": ["b"]}
)
assert fake_llm_configured.invoke("...") == "b"
prompt = PromptTemplate.from_template("Hello, {name}!")
assert prompt.invoke({"name": "John"}) == StringPromptValue(text="Hello, John!")
prompt_configurable = prompt.configurable_fields(
template=ConfigurableField(
id="prompt_template",
name="Prompt Template",
description="The prompt template for this chain",
)
)
assert prompt_configurable.invoke({"name": "John"}) == StringPromptValue(
text="Hello, John!"
)
if PYDANTIC_VERSION_AT_LEAST_29:
assert _normalize_schema(
prompt_configurable.get_config_jsonschema()
) == snapshot(name="schema3")
prompt_configured = prompt_configurable.with_config(
configurable={"prompt_template": "Hello, {name}! {name}!"}
)
assert prompt_configured.invoke({"name": "John"}) == StringPromptValue(
text="Hello, John! John!"
)
assert prompt_configurable.with_config(
configurable={"prompt_template": "Hello {name} in {lang}"}
).get_input_jsonschema() == {
"title": "PromptInput",
"type": "object",
"properties": {
"lang": {"title": "Lang", "type": "string"},
"name": {"title": "Name", "type": "string"},
},
"required": ["lang", "name"],
}
chain_configurable = prompt_configurable | fake_llm_configurable | StrOutputParser()
assert chain_configurable.invoke({"name": "John"}) == "a"
if PYDANTIC_VERSION_AT_LEAST_29:
assert _normalize_schema(
chain_configurable.get_config_jsonschema()
) == snapshot(name="schema4")
assert (
chain_configurable.with_config(
configurable={
"prompt_template": "A very good morning to you, {name} {lang}!",
"llm_responses": ["c"],
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_configurable_fields() do?
test_configurable_fields() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_configurable_fields() defined?
test_configurable_fields() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 742.
What does test_configurable_fields() call?
test_configurable_fields() 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