Skip to content

[bug] sensitiveTopic throws error #1193

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

Closed
railsstudent opened this issue Dec 10, 2024 · 5 comments
Closed

[bug] sensitiveTopic throws error #1193

railsstudent opened this issue Dec 10, 2024 · 5 comments
Labels
bug Something isn't working looking-into-this Stale

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.

@zsimjee
Copy link
Collaborator

zsimjee commented Jan 4, 2025

Hi @railsstudent , that PR has been merged, has your issue been resolved?

@railsstudent
Copy link
Author

Yes. I use the RestrictToTopic validator to validate sensitive topics

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 13, 2025
Copy link

This issue was closed because it has been stalled for 14 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2025
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 Stale
Projects
None yet
Development

No branches or pull requests

4 participants