Closed
Description
Describe the bug
When disable_classifier is False and disable_llm is True, the _inference_local method returns error on
candidate_topics = model_input["valid_topics"] + model_input["invalid_topics"]
The error message is
TypeError: unsupported operand type(s) for +: 'set' and 'set'
It is because
valid_topics = set(metadata.get('valid_topics', self._valid_topics))
invalid_topics = set(metadata.get('invalid_topics', self._invalid_topics))
return two sets and + operator cannot form a new array
To Reproduce
Steps to reproduce the behavior:
restrictToTopic = RestrictToTopic(
valid_topics=["environment"],
invalid_topics=["conspiracy", "food", "entertainment", "politics", "religion", "violence", "hate"],
disable_classifier=False,
disable_llm=True,
on_fail=OnFailAction.EXCEPTION
)
result = restrictToTopic.validate(value="Large corporations should act responsibly socially and environmentally. They should reduce carbon emission. One way to monitor their behavior is by reading their ESG Report.")
print(result.outcome)
Expected behavior
The _inference_local should return a found_topics
array.
Library version:
Version 0.5.2
Additional context
Add any other context about the problem here.