Skip to content

Conversation

@sunyuhan1998
Copy link
Contributor

As mentioned in the issue, currently when SafeGuardAdvisor matches sensitive words, there is a lack of logs indicating which sensitive words were matched. This PR adds debug logging for that purpose.

Fixes #3586

…tput the matched sensitive words in debug log level when a sensitive word is hit.

Signed-off-by: Sun Yuhan <[email protected]>
@YunKuiLu
Copy link
Contributor

Other than logging the sensitive words, can we also put the matched sensitive words into the context of ChatClientResponse, so that we can get them?

@sunyuhan1998
Copy link
Contributor Author

Hi @ilayaperumalg , Can you help review this PR?

if (!CollectionUtils.isEmpty(this.sensitiveWords)) {
String content = chatClientRequest.prompt().getContents();
Set<String> hitWords = this.sensitiveWords.stream().filter(content::contains).collect(Collectors.toSet());
if (!hitWords.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, for if (!hitWords.isEmpty()).

IMO, If you enter this if (!CollectionUtils.isEmpty(this.sensitiveWords)) branch, the following conditions must be true is. means hitWords is not null.I think this if case can be deleted.

@ilayaperumalg
Copy link
Member

@sunyuhan1998 We don't want to log any sensitive information as they are indeed sensitive. Perhaps, you can create a custom advisor for your use case.

@sunyuhan1998
Copy link
Contributor Author

@sunyuhan1998 We don't want to log any sensitive information as they are indeed sensitive. Perhaps, you can create a custom advisor for your use case.

Oh, okay, I see. I think I misunderstood its function before, but now I completely understand. Thank you for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SafeGuardAdvisor lacks logs

4 participants