🐛 fix(types.py): handle case where prompt template is not present in PromptVertex

ℹ️ The code was modified to handle a case where the `template` attribute is not present in the `PromptVertex` class. If the `template` attribute is not found, the code checks if the `prompt` attribute is present and uses its `template` attribute instead. This change ensures that the code does not break when the `template` attribute is missing.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-14 17:16:54 -03:00
commit 2144e1ec91

View file

@ -226,7 +226,12 @@ class PromptVertex(Vertex):
# 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 + "}"