test_lambda_schemas() — langchain Function Reference
Architecture documentation for the test_lambda_schemas() function in test_runnable.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 508402c0_51c4_cda8_5e3f_75d302c7abe0["test_lambda_schemas()"] 26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"] 508402c0_51c4_cda8_5e3f_75d302c7abe0 -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5 style 508402c0_51c4_cda8_5e3f_75d302c7abe0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable.py lines 546–645
def test_lambda_schemas(snapshot: SnapshotAssertion) -> None:
first_lambda = lambda x: x["hello"] # noqa: E731
assert RunnableLambda(first_lambda).get_input_jsonschema() == {
"title": "RunnableLambdaInput",
"type": "object",
"properties": {"hello": {"title": "Hello"}},
"required": ["hello"],
}
second_lambda = lambda x, y: (x["hello"], x["bye"], y["bah"]) # noqa: E731
assert RunnableLambda(second_lambda).get_input_jsonschema() == {
"title": "RunnableLambdaInput",
"type": "object",
"properties": {"hello": {"title": "Hello"}, "bye": {"title": "Bye"}},
"required": ["bye", "hello"],
}
def get_value(value): # type: ignore[no-untyped-def] # noqa: ANN001,ANN202
return value["variable_name"]
assert RunnableLambda(get_value).get_input_jsonschema() == {
"title": "get_value_input",
"type": "object",
"properties": {"variable_name": {"title": "Variable Name"}},
"required": ["variable_name"],
}
async def aget_value(value): # type: ignore[no-untyped-def] # noqa: ANN001,ANN202
return (value["variable_name"], value.get("another"))
assert RunnableLambda(aget_value).get_input_jsonschema() == {
"title": "aget_value_input",
"type": "object",
"properties": {
"another": {"title": "Another"},
"variable_name": {"title": "Variable Name"},
},
"required": ["another", "variable_name"],
}
async def aget_values(value): # type: ignore[no-untyped-def] # noqa: ANN001,ANN202
return {
"hello": value["variable_name"],
"bye": value["variable_name"],
"byebye": value["yo"],
}
assert RunnableLambda(aget_values).get_input_jsonschema() == {
"title": "aget_values_input",
"type": "object",
"properties": {
"variable_name": {"title": "Variable Name"},
"yo": {"title": "Yo"},
},
"required": ["variable_name", "yo"],
}
class InputType(TypedDict):
variable_name: str
yo: int
class OutputType(TypedDict):
hello: str
bye: str
byebye: int
async def aget_values_typed(value: InputType) -> OutputType:
return {
"hello": value["variable_name"],
"bye": value["variable_name"],
"byebye": value["yo"],
}
assert _normalize_schema(
RunnableLambda(aget_values_typed).get_input_jsonschema()
) == _normalize_schema(
{
"$defs": {
"InputType": {
"properties": {
"variable_name": {
Domain
Subdomains
Source
Frequently Asked Questions
What does test_lambda_schemas() do?
test_lambda_schemas() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_lambda_schemas() defined?
test_lambda_schemas() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 546.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free