Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Amnah199 committed Jan 9, 2025
1 parent 9779bbd commit 94f9fd1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions haystack/components/routers/conditional_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,15 @@ def from_string(self, source, template_class=None):
template_class = self.template_class
return SandboxedEnvironment.from_string(self, source, template_class=template_class)

def is_safe_attribute(self, obj, attr, value):
def is_safe_attribute(self, obj):
"""
Whitelist attributes or slicing on your custom classes so the sandbox won't block them.
Whitelist Haystack dataclasses so the sandbox won't block them.
"""
# If it's a ChatMessage object, you can whitelist certain attributes:
if isinstance(obj, haystack_dataclass_types):
return True

# Otherwise, fallback to the default sandbox behavior
return super().is_safe_attribute(obj, attr, value)
return super().is_safe_attribute(obj)


@component
Expand Down

0 comments on commit 94f9fd1

Please sign in to comment.