Skip to content

Commit

Permalink
Fix HumanMessagePromptTemplate bug (#763)
Browse files Browse the repository at this point in the history
HumanMessagePromptTemplate and some other MessagePromptTemplates were
not built correctly.

This fixes SystemMessage Example.
  • Loading branch information
gustavoschaedler committed Aug 14, 2023
2 parents 9df5e94 + e0f625e commit cb47f7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/backend/langflow/graph/vertex/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ def _built_object_repr(self):
# so the prompt format doesn't break
artifacts.pop("handle_keys", None)
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():
if value:
replace_key = "{" + key + "}"
Expand Down
4 changes: 3 additions & 1 deletion src/backend/langflow/interface/initialize/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def handle_partial_variables(prompt, format_kwargs: Dict):
}
# Remove handle_keys otherwise LangChain raises an error
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):
Expand Down

0 comments on commit cb47f7c

Please sign in to comment.