test_fstring_template_allowed() — langchain Function Reference
Architecture documentation for the test_fstring_template_allowed() function in test_serializable.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2db10c8c_09be_b235_8f07_6f3a3e4433f3["test_fstring_template_allowed()"] 6eac7a3c_5af8_e95a_bd3e_ee52ea07b9b0["TestJinja2SecurityBlocking"] 2db10c8c_09be_b235_8f07_6f3a3e4433f3 -->|defined in| 6eac7a3c_5af8_e95a_bd3e_ee52ea07b9b0 style 2db10c8c_09be_b235_8f07_6f3a3e4433f3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/load/test_serializable.py lines 718–769
def test_fstring_template_allowed(self) -> None:
"""Test that f-string templates deserialize successfully."""
# Serialized ChatPromptTemplate with f-string format
serialized = {
"lc": 1,
"type": "constructor",
"id": ["langchain", "prompts", "chat", "ChatPromptTemplate"],
"kwargs": {
"input_variables": ["name"],
"messages": [
{
"lc": 1,
"type": "constructor",
"id": [
"langchain",
"prompts",
"chat",
"HumanMessagePromptTemplate",
],
"kwargs": {
"prompt": {
"lc": 1,
"type": "constructor",
"id": [
"langchain",
"prompts",
"prompt",
"PromptTemplate",
],
"kwargs": {
"input_variables": ["name"],
"template": "Hello {name}",
"template_format": "f-string",
},
}
},
}
],
},
}
# f-string should deserialize successfully
loaded = load(
serialized,
allowed_objects=[
ChatPromptTemplate,
HumanMessagePromptTemplate,
PromptTemplate,
],
)
assert isinstance(loaded, ChatPromptTemplate)
assert loaded.input_variables == ["name"]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_fstring_template_allowed() do?
test_fstring_template_allowed() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/load/test_serializable.py.
Where is test_fstring_template_allowed() defined?
test_fstring_template_allowed() is defined in libs/core/tests/unit_tests/load/test_serializable.py at line 718.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free