Fix HumanMessagePromptTemplate bug (#763)
HumanMessagePromptTemplate and some other MessagePromptTemplates were not built correctly. This fixes SystemMessage Example.
This commit is contained in:
commit
cb47f7cf8e
2 changed files with 9 additions and 2 deletions
|
|
@ -226,7 +226,12 @@ class PromptVertex(Vertex):
|
||||||
# so the prompt format doesn't break
|
# so the prompt format doesn't break
|
||||||
artifacts.pop("handle_keys", None)
|
artifacts.pop("handle_keys", None)
|
||||||
try:
|
try:
|
||||||
template = self._built_object.template
|
if not hasattr(self._built_object, "template") and hasattr(
|
||||||
|
self._built_object, "prompt"
|
||||||
|
):
|
||||||
|
template = self._built_object.prompt.template
|
||||||
|
else:
|
||||||
|
template = self._built_object.template
|
||||||
for key, value in artifacts.items():
|
for key, value in artifacts.items():
|
||||||
if value:
|
if value:
|
||||||
replace_key = "{" + key + "}"
|
replace_key = "{" + key + "}"
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ def handle_partial_variables(prompt, format_kwargs: Dict):
|
||||||
}
|
}
|
||||||
# Remove handle_keys otherwise LangChain raises an error
|
# Remove handle_keys otherwise LangChain raises an error
|
||||||
partial_variables.pop("handle_keys", None)
|
partial_variables.pop("handle_keys", None)
|
||||||
return prompt.partial(**partial_variables)
|
if partial_variables and hasattr(prompt, "partial"):
|
||||||
|
return prompt.partial(**partial_variables)
|
||||||
|
return prompt
|
||||||
|
|
||||||
|
|
||||||
def handle_variable(params: Dict, input_variable: str, format_kwargs: Dict):
|
def handle_variable(params: Dict, input_variable: str, format_kwargs: Dict):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue