core[patch]: Fix one unit test for chat prompt template (#24362)

Minor change that fixes a unit test that had missing assertions.
This commit is contained in:
Eugene Yurtsev 2024-07-17 14:56:48 -04:00 committed by GitHub
parent 81639243e2
commit 9e4a0e76f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -794,14 +794,15 @@ def test_chat_input_schema(snapshot: SnapshotAssertion) -> None:
prompt_all_required = ChatPromptTemplate.from_messages(
messages=[MessagesPlaceholder("history", optional=False), ("user", "${input}")]
)
prompt_all_required.input_variables == {"input"}
prompt_all_required.optional_variables == {"history"}
assert set(prompt_all_required.input_variables) == {"input", "history"}
assert prompt_all_required.optional_variables == []
with pytest.raises(ValidationError):
prompt_all_required.input_schema(input="")
assert prompt_all_required.input_schema.schema() == snapshot(name="required")
prompt_optional = ChatPromptTemplate.from_messages(
messages=[MessagesPlaceholder("history", optional=True), ("user", "${input}")]
)
prompt_optional.input_variables == {"history", "input"}
# input variables only lists required variables
assert set(prompt_optional.input_variables) == {"input"}
prompt_optional.input_schema(input="") # won't raise error
prompt_optional.input_schema.schema() == snapshot(name="partial")
assert prompt_optional.input_schema.schema() == snapshot(name="partial")