How to redact sensitive information from your Ruby on Rails application before sending it to an AI

Our friends over at thoughtbot have just released Top Secret. Top Secret is a Rubygem that redacts sensitive information from free text before that text gets sent off to an AI LLM for processing. For example:

raw_text = "My SSN is 123-45-6789 and my name is Keyser Soze"

filtered_text = TopSecret::Text.filter(raw_text)

filtered_text.output

# => "My SSN is [SSN_1] and my name is [Name_1]"

You can check out Top Secret here on Github.