mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-10 21:35:08 +00:00
run make format/lint
This commit is contained in:
parent
cc807d9b29
commit
fb2a134d7c
@ -5466,13 +5466,15 @@ def test_runnable_assign() -> None:
|
||||
result = runnable_assign.invoke({"input": 5})
|
||||
assert result == {"input": 5, "add_step": {"added": 15}}
|
||||
|
||||
|
||||
def test_runnable_typed_dict_schema() -> None:
|
||||
"""Testing that the schema is generated properly(not empty) when using TypedDict
|
||||
|
||||
subclasses to annotate the arguments of a RunnableParallel children.
|
||||
"""
|
||||
from typing_extensions import TypedDict
|
||||
from langchain_core.runnables import RunnableParallel, RunnableLambda
|
||||
|
||||
from langchain_core.runnables import RunnableLambda, RunnableParallel
|
||||
|
||||
class Foo(TypedDict):
|
||||
foo: str
|
||||
@ -5480,16 +5482,14 @@ def test_runnable_typed_dict_schema() -> None:
|
||||
class InputData(Foo):
|
||||
bar: str
|
||||
|
||||
def forward_foo(input_data: InputData):
|
||||
def forward_foo(input_data: InputData) -> str:
|
||||
return input_data["foo"]
|
||||
|
||||
def transform_input(input_data: InputData):
|
||||
def transform_input(input_data: InputData) -> dict[str, str]:
|
||||
foo = input_data["foo"]
|
||||
bar = input_data["bar"]
|
||||
|
||||
return {
|
||||
"transformed": foo + bar
|
||||
}
|
||||
return {"transformed": foo + bar}
|
||||
|
||||
foo_runnable = RunnableLambda(forward_foo)
|
||||
other_runnable = RunnableLambda(transform_input)
|
||||
@ -5498,4 +5498,7 @@ def test_runnable_typed_dict_schema() -> None:
|
||||
foo=foo_runnable,
|
||||
other=other_runnable,
|
||||
)
|
||||
assert(repr(parallel.input_schema.validate({ "foo": "Y", "bar": "Z" })) == "RunnableParallel<foo,other>Input(root={'foo': 'Y', 'bar': 'Z'})")
|
||||
assert (
|
||||
repr(parallel.input_schema.validate({"foo": "Y", "bar": "Z"}))
|
||||
== "RunnableParallel<foo,other>Input(root={'foo': 'Y', 'bar': 'Z'})"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user