Skip to content

Update webviewer-redaction-ai per demo meeting#88

Open
Mohammed-AbdulRahman-Apryse wants to merge 9 commits intomainfrom
new-webviewer-ai-redaction-as208
Open

Update webviewer-redaction-ai per demo meeting#88
Mohammed-AbdulRahman-Apryse wants to merge 9 commits intomainfrom
new-webviewer-ai-redaction-as208

Conversation

@Mohammed-AbdulRahman-Apryse
Copy link
Copy Markdown
Collaborator

Description

Identify person names with middle initials.

Resources

Checklist

  • [✓] I understand that this is a public repo and my changes will be publicly visible

If you are adding a new sample

  • I have added an entry to the root level README
  • The name of my sample is consistent with the other samples
  • I have added a README to my sample
  • The sample is fully functional
  • I have updated lerna.json with the new sample name

If you are removing an old sample

  • I have removed the entry from the root level README
  • I have removed the sample from lerna.json

This re-engineering serves:
1. Capture unidentifiable fields, e.g. unlabeled phone number in the document text.
2. Classify result, e.g. Person: Linda Nelson, Phone: 291 555 5555, Address: 18th Floor, 2822 Glenoaks St.
3. Redaction processing reads the classified results.
Expose live information while performing PII redaction:
- Document name
- LLM Model name
- LLM input (prompt submission)
- Response messages
- Status
…s for

The sample parses the PII result using classification, so this has been reflected to the mocked data to use by e2e tests.
1. Configuration - describe the credential parameters.
2. Chat Model Swapping - how to swap the default used chat model (OpenAI) by other chat models.
3. Sample architecture.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the webviewer-redaction-ai sample to improve person-name extraction (including middle initials) and to support a labeled “Type: Value” response format, along with adding an AI panel UI for visibility into prompts/results.

Changes:

  • Switch guardrail prompting from assistantPrompt to systemPrompt, and update PII classification details/rules to produce labeled findings.
  • Add an AI Panel (UI + styles) and a new server /api/config endpoint to surface model/prompt info to the client.
  • Update redaction parsing to use labeled output (Label: value) and adjust mocks/tests accordingly.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
webviewer-redaction-ai/server/handler.js Builds system prompt, validates analysis results, adds /api/config endpoint for client configuration display.
webviewer-redaction-ai/server/config.json Updates prompt key to systemPrompt, expands person-name detail to include middle initials, revises rules to require labels.
webviewer-redaction-ai/client/redaction.js Parses labeled AI output and uses the value portion for searching/redaction; sets overlay/contents to label.
webviewer-redaction-ai/client/document/analyzer.js Stores the latest API step result in globalThis.aiAnalysisResult.
webviewer-redaction-ai/client/document/manager.js Tracks loaded document filename for display in the AI panel.
webviewer-redaction-ai/client/index.js Loads AI panel, fetches config, shows panel on document load, and adds CSS file.
webviewer-redaction-ai/client/globals.js Adds globalThis.aiPanel.
webviewer-redaction-ai/client/ui/custom.json Registers the new aiPanel modular panel.
webviewer-redaction-ai/client/ui/functionMap.js Adds aiPanelRender and updates the AI redaction click handler to add chat bubbles + status.
webviewer-redaction-ai/client/ui/aiPanel.js New AI panel component that renders model/document info and chat bubbles.
webviewer-redaction-ai/client/ui/styles.css New styles for AI panel and message bubbles.
webviewer-redaction-ai/mocks/webviewer-redaction-ai.mock.js Updates mocked analysis output to labeled Type: Value lines.
webviewer-redaction-ai/tests/e2e/webviewer-redaction-ai.spec.js Adds an e2e test for AI panel visibility and mocked workflow calls.
webviewer-redaction-ai/README.md Expands setup/configuration docs and adds a sample image; adds chat-model swapping and architecture notes.
webviewer-redaction-ai/mainsamplesource.json Adds new UI files to the sample source manifest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread webviewer-redaction-ai/README.md
Comment thread webviewer-redaction-ai/README.md
Comment thread webviewer-redaction-ai/README.md Outdated
Comment thread webviewer-redaction-ai/server/handler.js Outdated
Comment thread webviewer-redaction-ai/client/redaction.js Outdated
Comment thread webviewer-redaction-ai/client/ui/functionMap.js Outdated
Comment thread webviewer-redaction-ai/__tests__/e2e/webviewer-redaction-ai.spec.js Outdated
1. Removed periods and added ".html" occurrence to the link in Readme.
2. Adding security level to control exposing LLM model name and the passed prompt to LLM. The affected files are server/handler.js and .env.example.
3. Corrected the description of Playwright e2e test 'AI Panel renders the expected results'.
4. Improved the splitting of piiEntity on the first colon only and skipping/handling lines that don't match the expected Label: value format.
5. Fixed a potential null reference by handling analyzeDocumentForPII() failure cases.
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@DavidEGutierrez DavidEGutierrez left a comment

Choose a reason for hiding this comment

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

Tested locally passes e2e, code works, and PIIs are found and redacted, panel works.
There is an error message that would be related to my environment as I get an error message on the panel: "Unauthorized access to systems prompt".

@DavidEGutierrez
Copy link
Copy Markdown
Collaborator

Tested locally passes e2e, code works, and PIIs are found and redacted, panel works. There is an error message that would be related to my environment as I get an error message on the panel: "Unauthorized access to systems prompt".

Unauthorized

Copy link
Copy Markdown
Collaborator

@AminDodin-Apryse AminDodin-Apryse left a comment

Choose a reason for hiding this comment

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

Demo ran successfully on my Windows laptop.

Image

e2e tests executed successfully.

Image

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.

4 participants