🐛 fix(types.py): handle KeyError when formatting prompt with artifacts to prevent application crash
🔀 refactor(types.py): remove "handle_keys" from artifacts before formatting prompt to avoid format errors
This commit is contained in:
parent
df348b019d
commit
f56e31163a
1 changed files with 8 additions and 1 deletions
|
|
@ -220,7 +220,14 @@ class PromptVertex(Vertex):
|
||||||
# We'll build the prompt with the artifacts
|
# We'll build the prompt with the artifacts
|
||||||
# to show the user what the prompt looks like
|
# to show the user what the prompt looks like
|
||||||
# with the variables filled in
|
# with the variables filled in
|
||||||
return self._built_object.format(**self.artifacts)
|
artifacts = self.artifacts.copy()
|
||||||
|
# Remove the handle_keys from the artifacts
|
||||||
|
# so the prompt format doesn't break
|
||||||
|
artifacts.pop("handle_keys", None)
|
||||||
|
try:
|
||||||
|
return self._built_object.format(**self.artifacts)
|
||||||
|
except KeyError:
|
||||||
|
return super()._built_object_repr()
|
||||||
else:
|
else:
|
||||||
return super()._built_object_repr()
|
return super()._built_object_repr()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue