mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-13 05:25:07 +00:00
W.r.t recent changes, ChatPromptTemplate does not accepting partial variables. This PR should fix that issue. Fixes #6431 #### Who can review? @hwchase17 --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
This commit is contained in:
@@ -162,3 +162,31 @@ def test_infer_variables() -> None:
|
||||
messages = [HumanMessagePromptTemplate.from_template("{foo}")]
|
||||
prompt = ChatPromptTemplate(messages=messages)
|
||||
assert prompt.input_variables == ["foo"]
|
||||
|
||||
|
||||
def test_chat_valid_with_partial_variables() -> None:
|
||||
messages = [
|
||||
HumanMessagePromptTemplate.from_template(
|
||||
"Do something with {question} using {context} giving it like {formatins}"
|
||||
)
|
||||
]
|
||||
prompt = ChatPromptTemplate(
|
||||
messages=messages,
|
||||
input_variables=["question", "context"],
|
||||
partial_variables={"formatins": "some structure"},
|
||||
)
|
||||
assert set(prompt.input_variables) == set(["question", "context"])
|
||||
assert prompt.partial_variables == {"formatins": "some structure"}
|
||||
|
||||
|
||||
def test_chat_valid_infer_variables() -> None:
|
||||
messages = [
|
||||
HumanMessagePromptTemplate.from_template(
|
||||
"Do something with {question} using {context} giving it like {formatins}"
|
||||
)
|
||||
]
|
||||
prompt = ChatPromptTemplate(
|
||||
messages=messages, partial_variables={"formatins": "some structure"}
|
||||
)
|
||||
assert set(prompt.input_variables) == set(["question", "context"])
|
||||
assert prompt.partial_variables == {"formatins": "some structure"}
|
||||
|
Reference in New Issue
Block a user