(snapshot: SnapshotAssertion)
| 4051 | |
| 4052 | |
| 4053 | def test_each(snapshot: SnapshotAssertion) -> None: |
| 4054 | prompt = ( |
| 4055 | SystemMessagePromptTemplate.from_template("You are a nice assistant.") |
| 4056 | + "{question}" |
| 4057 | ) |
| 4058 | first_llm = FakeStreamingListLLM(responses=["first item, second item, third item"]) |
| 4059 | parser = FakeSplitIntoListParser() |
| 4060 | second_llm = FakeStreamingListLLM(responses=["this", "is", "a", "test"]) |
| 4061 | |
| 4062 | chain = prompt | first_llm | parser | second_llm.map() |
| 4063 | |
| 4064 | assert dumps(chain, pretty=True) == snapshot |
| 4065 | output = chain.invoke({"question": "What up"}) |
| 4066 | assert output == ["this", "is", "a"] |
| 4067 | |
| 4068 | assert (parser | second_llm.map()).invoke("first item, second item") == [ |
| 4069 | "test", |
| 4070 | "this", |
| 4071 | ] |
| 4072 | |
| 4073 | |
| 4074 | def test_recursive_lambda() -> None: |
nothing calls this directly
no test coverage detected