[TAN-7987] Remove regex PII detection and use LLM call#14210
Open
amanda-anderson wants to merge 4 commits into
Open
[TAN-7987] Remove regex PII detection and use LLM call#14210amanda-anderson wants to merge 4 commits into
amanda-anderson wants to merge 4 commits into
Conversation
Collaborator
|
amanda-anderson
commented
Jul 2, 2026
| @@ -91,14 +91,15 @@ def survey_results | |||
| # registration/personal-data fields so the UI can pre-select them for | |||
Contributor
Author
There was a problem hiding this comment.
(Flagging use of Claude code to help implement).
kogre
approved these changes
Jul 13, 2026
| end | ||
|
|
||
| def structural_pii?(field) | ||
| field.resource_type == 'User' || field.key.start_with?('u_') |
Contributor
There was a problem hiding this comment.
field.key.start_with?('u_') maybe there is already a helper available on the model class to detect these embedded fields? If not would probably be better if it lived om the model.
| end | ||
|
|
||
| def llm | ||
| @llm ||= LLMSelector.new.llm_class_for_use_case(USE_CASE).new |
| <title><%= field[:title] %></title> | ||
| <% if field[:description].present? %><description><%= field[:description] %></description><% end %> | ||
| <type><%= field[:input_type] %></type> | ||
| <% if field[:options].present? %><options><%= field[:options].join(', ') %></options><% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace regex PII detection with an LLM classification
Description:
Replaces the hardcoded English-only regex PII detection in the PDF responses export with a single LLM call (field_pii_detection use case, Claude Haiku by default): all export fields — form questions and user/registration fields — are classified by title, description and options, so detection is language-independent and user fields are no longer auto-flagged. If the LLM is unavailable, we fall back to flagging the structurally-known personal fields (registration fields), and the admin always makes the final call in the review UI. The detector moved to Export::PiiDetector (it's format-agnostic) and the FE shows a spinner while fields load.