Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] sensitiveTopic throws error #1193

Open
railsstudent opened this issue Dec 10, 2024 · 1 comment
Open

[bug] sensitiveTopic throws error #1193

railsstudent opened this issue Dec 10, 2024 · 1 comment
Labels
bug Something isn't working looking-into-this

Comments

@railsstudent
Copy link

Describe the bug
After I instantiated a sensitiveTopic validator and called its validate method, error message was issued.

    found_topics = self.get_topics_zero_shot(value, invalid_topics)
AttributeError: 'SensitiveTopic' object has no attribute 'get_topics_zero_shot'

To Reproduce
Steps to reproduce the behavior:

sensitiveTopic = SensitiveTopic(
    sensitive_topics=["conspiracy", "food", "entertainment", "politics", "religion", "violence", "hate"],
    disable_classifier=False,
    disable_llm=True,
    on_fail=OnFailAction.EXCEPTION
)

result = sensitiveTopic.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 guard should return a valid result

Library version:
0.5.2

Additional context
Add any other context about the problem here.

@railsstudent railsstudent added the bug Something isn't working label Dec 10, 2024
@railsstudent railsstudent changed the title [bug] sensitiveTopic throw error [bug] sensitiveTopic throws error Dec 10, 2024
@brianlai98
Copy link

Hi @railsstudent, thanks for flagging this. The issue is that the SensitiveTopic validator currently inherits from the RestrictToTopic validator and the get_topics_zero_shot function (as well as a number of other functions) have since been removed/changed.

We are looking into the best way to handle this.

Since SensitiveTopic and RestrictToTopic use the same underlying models to identify topics, you could try using the RestrictToTopic validator and only specifying the off-topic entries which would achieve the same effect. There is a PR here that will allow you to only specify off-topic (sensitive) entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working looking-into-this
Projects
None yet
Development

No branches or pull requests

3 participants