Skip to content

Commit 4b40b68

Browse files
committed
Shorten warning message
1 parent 122b452 commit 4b40b68

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/__tests__/unit/checks/pii.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,10 @@ describe('pii guardrail', () => {
376376
await pii({}, 'test data', config);
377377

378378
expect(consoleWarnSpy).toHaveBeenCalledWith(
379-
expect.stringContaining('DEPRECATION WARNING: PIIEntity.NRP')
379+
expect.stringContaining('DEPRECATION: PIIEntity.NRP')
380380
);
381381
expect(consoleWarnSpy).toHaveBeenCalledWith(
382-
expect.stringContaining('https://github.com/openai/openai-guardrails-js/issues/47')
382+
expect.stringContaining('more robust implementation')
383383
);
384384

385385
consoleWarnSpy.mockRestore();
@@ -396,10 +396,10 @@ describe('pii guardrail', () => {
396396
await pii({}, 'test data', config);
397397

398398
expect(consoleWarnSpy).toHaveBeenCalledWith(
399-
expect.stringContaining('DEPRECATION WARNING: PIIEntity.PERSON')
399+
expect.stringContaining('DEPRECATION: PIIEntity.PERSON')
400400
);
401401
expect(consoleWarnSpy).toHaveBeenCalledWith(
402-
expect.stringContaining('https://github.com/openai/openai-guardrails-js/issues/47')
402+
expect.stringContaining('more robust implementation')
403403
);
404404

405405
consoleWarnSpy.mockRestore();

src/checks/pii.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -893,13 +893,15 @@ function _warnDeprecatedEntities(entities: PIIEntity[]): void {
893893

894894
shownDeprecationWarnings.add(entity);
895895

896+
const description =
897+
entity === PIIEntity.NRP
898+
? 'NRP matches any two consecutive words'
899+
: 'PERSON matches any two capitalized words';
900+
896901
console.warn(
897-
`[openai-guardrails-js] DEPRECATION WARNING: PIIEntity.${entity} has been removed from default entities due to high false positive rates.\n` +
898-
` - ${entity === PIIEntity.NRP ? 'NRP matches any two consecutive words (e.g., "nuevo cliente", "crea un")' : 'PERSON matches any two capitalized words (e.g., "New York", "The User")'}\n` +
899-
` - This pattern causes false positives in normal conversation, especially in non-English languages.\n` +
900-
` - Consider using more specific region-based patterns like SG_NRIC_FIN, UK_NINO, etc.\n` +
901-
` - To suppress this warning, remove PIIEntity.${entity} from your entities configuration.\n` +
902-
` - See: https://github.com/openai/openai-guardrails-js/issues/47`
902+
`[openai-guardrails-js] DEPRECATION: PIIEntity.${entity} removed from defaults (${description}).\n` +
903+
` A more robust implementation will be released in a future version.\n` +
904+
` To suppress: remove PIIEntity.${entity} from config. See: https://github.com/openai/openai-guardrails-js/issues/47`
903905
);
904906
}
905907
}

0 commit comments

Comments
 (0)