mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-21 10:26:57 +00:00
Apply lint
This commit is contained in:
parent
84f8b99cf5
commit
4b74e35532
@ -138,7 +138,7 @@ class PromptTemplate(StringPromptTemplate):
|
|||||||
# Allow for easy combining
|
# Allow for easy combining
|
||||||
if isinstance(other, PromptTemplate):
|
if isinstance(other, PromptTemplate):
|
||||||
if self.template_format != other.template_format:
|
if self.template_format != other.template_format:
|
||||||
msg = "Cannot add two templates of different formats"
|
msg = "Cannot add templates of different formats"
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
input_variables = list(
|
input_variables = list(
|
||||||
set(self.input_variables) | set(other.input_variables)
|
set(self.input_variables) | set(other.input_variables)
|
||||||
@ -160,7 +160,10 @@ class PromptTemplate(StringPromptTemplate):
|
|||||||
validate_template=validate_template,
|
validate_template=validate_template,
|
||||||
)
|
)
|
||||||
if isinstance(other, str):
|
if isinstance(other, str):
|
||||||
prompt = PromptTemplate.from_template(other, template_format=self.template_format)
|
prompt = PromptTemplate.from_template(
|
||||||
|
other,
|
||||||
|
template_format=self.template_format,
|
||||||
|
)
|
||||||
return self + prompt
|
return self + prompt
|
||||||
msg = f"Unsupported operand type for +: {type(other)}"
|
msg = f"Unsupported operand type for +: {type(other)}"
|
||||||
raise NotImplementedError(msg)
|
raise NotImplementedError(msg)
|
||||||
|
@ -684,7 +684,7 @@ def test_prompt_with_template_variable_name_jinja2() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def test_prompt_template_add_with_with_another_format():
|
def test_prompt_template_add_with_with_another_format():
|
||||||
with pytest.raises(match=r"Cannot add two templates"):
|
with pytest.raises(match=r"Cannot add templates"):
|
||||||
PromptTemplate.from_template("This is a {template}") + PromptTemplate.from_template("So {{this}} is", template_format="mustache")
|
PromptTemplate.from_template("This is a {template}") + PromptTemplate.from_template("So {{this}} is", template_format="mustache")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user