Skip to content

Commit b90a53d

Browse files
info-wordcabclaude
andcommitted
Fix Windows PII model crash by enabling ONNX Runtime dynamic loading
- Enable load-dynamic feature for gline-rs to prevent hard linking to ONNX Runtime - Add Windows DLL path configuration to automatically locate bundled ONNX Runtime DLLs - Implement Windows-specific error handling with user-friendly messages - Update build workflow to download and bundle ONNX Runtime DLLs for Windows releases - Add API server functionality with WebSocket support for external integrations - Clean up obsolete files (RUN_INSTRUCTIONS.md, RUN_WITH_PII.sh, test_pii.py) - Filter GLiNER models from transcription model selector (they're PII-only) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2bd0a8d commit b90a53d

File tree

20 files changed

+577
-195
lines changed

20 files changed

+577
-195
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,32 @@ jobs:
101101
version: 1.4.309.0
102102
cache: true
103103

104+
- name: Download ONNX Runtime for Windows
105+
if: contains(inputs.platform, 'windows')
106+
shell: pwsh
107+
run: |
108+
New-Item -ItemType Directory -Force -Path "src-tauri/resources/onnxruntime"
109+
$onnxUrl = "https://github.com/microsoft/onnxruntime/releases/download/v1.22.0/onnxruntime-win-x64-1.22.0.zip"
110+
$onnxZip = "src-tauri/resources/onnxruntime/onnxruntime-win-x64-1.22.0.zip"
111+
112+
Write-Host "Downloading ONNX Runtime from: $onnxUrl"
113+
Invoke-WebRequest -Uri $onnxUrl -OutFile $onnxZip -TimeoutSec 300
114+
115+
Write-Host "Extracting ONNX Runtime..."
116+
Expand-Archive -Path $onnxZip -DestinationPath "src-tauri/resources/onnxruntime/temp" -Force
117+
118+
# Move the lib directory to the expected location
119+
$libSource = "src-tauri/resources/onnxruntime/temp/onnxruntime-win-x64-1.22.0/lib"
120+
$libDest = "src-tauri/resources/onnxruntime/lib"
121+
Move-Item -Path $libSource -Destination $libDest -Force
122+
123+
# Clean up
124+
Remove-Item -Path "src-tauri/resources/onnxruntime/temp" -Recurse -Force
125+
Remove-Item -Path $onnxZip -Force
126+
127+
Write-Host "ONNX Runtime DLLs prepared for bundling"
128+
Get-ChildItem -Path "src-tauri/resources/onnxruntime/lib" -Name
129+
104130
- name: Install trusted-signing-cli
105131
if: contains(inputs.platform, 'windows')
106132
run: cargo install trusted-signing-cli

README_BRIDGE.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Handy-Claude PII Bridge
2+
3+
A Python script that connects to Handy's API server, processes PII-redacted transcriptions, and forwards them to Claude API with privacy protection.
4+
5+
## Features
6+
7+
- **Real-time transcription processing** via Handy's WebSocket API
8+
- **Entity mapping** with numbered placeholders (e.g., `[NAME_0]`, `[NAME_1]`)
9+
- **Privacy-aware Claude integration** with system prompts
10+
- **Conversation history** with anonymized storage
11+
- **Entity restoration** in responses for natural display
12+
13+
## Setup
14+
15+
1. **Install dependencies:**
16+
```bash
17+
pip install -r requirements.txt
18+
```
19+
20+
2. **Set up Claude API key:**
21+
```bash
22+
export ANTHROPIC_API_KEY="your_api_key_here"
23+
```
24+
25+
3. **Enable Handy API server:**
26+
- Open Handy settings → Advanced Settings
27+
- Toggle "Enable API Server" ON
28+
- Ensure it shows: `API running at: ws://localhost:7878/ws`
29+
30+
4. **Enable PII redaction (recommended):**
31+
- In Handy settings → Advanced Settings
32+
- Toggle "Enable PII Redaction" ON
33+
- Configure which entity types to redact
34+
35+
## Usage
36+
37+
```bash
38+
python claude_pii_bridge.py
39+
```
40+
41+
The script will:
42+
1. Connect to Handy's WebSocket API
43+
2. Listen for transcriptions
44+
3. Process PII-redacted text with entity mapping
45+
4. Send to Claude with privacy-aware system prompt
46+
5. Display Claude's response with entities restored
47+
48+
## How It Works
49+
50+
### Example Flow:
51+
52+
1. **Original transcription:** `"Hi, my name is John Smith and my phone is 555-0123"`
53+
54+
2. **Handy PII redaction:** `"Hi, my name is [PERSON] and my phone is [PHONE_NUMBER]"`
55+
56+
3. **Entity mapping:**
57+
```
58+
[PERSON_0] → John Smith
59+
[PHONE_NUMBER_0] → 555-0123
60+
```
61+
62+
4. **Processed for Claude:** `"Hi, my name is [PERSON_0] and my phone is [PHONE_NUMBER_0]"`
63+
64+
5. **System prompt:**
65+
```
66+
This user message has been processed for privacy protection.
67+
68+
PRIVACY NOTICE: Personal information has been redacted:
69+
• [PERSON_0] represents a real person
70+
• [PHONE_NUMBER_0] represents a real phone number
71+
72+
Treat each bracketed placeholder as if it were the real entity.
73+
```
74+
75+
6. **Claude's response:** `"Nice to meet you, [PERSON_0]! I can help you with your inquiry."`
76+
77+
7. **Displayed to user:** `"Nice to meet you, John Smith! I can help you with your inquiry."`
78+
79+
## Privacy Benefits
80+
81+
- **Your PII never reaches Claude's servers** in original form
82+
- **Numbered entities** allow referencing across conversation
83+
- **Local restoration** shows natural responses
84+
- **Conversation history** stays anonymized
85+
- **Entity consistency** across multiple interactions
86+
87+
## Configuration
88+
89+
Edit the script to customize:
90+
- `CLAUDE_API_URL` - Claude API endpoint
91+
- `HANDY_WEBSOCKET_URL` - Handy WebSocket URL
92+
- `max_tokens` - Claude response length
93+
- Model selection (`claude-3-5-sonnet-20241022`)
94+
- Conversation history length
95+
96+
## Troubleshooting
97+
98+
- **"Failed to connect to Handy"** - Ensure Handy is running with API server enabled
99+
- **"ANTHROPIC_API_KEY not set"** - Set your Claude API key as environment variable
100+
- **Entity mapping issues** - The word alignment algorithm is simplified; complex redactions may need manual adjustment
101+
102+
## Security Notes
103+
104+
- API key is loaded from environment variable (secure)
105+
- PII entities are only mapped locally
106+
- Original text never sent to external APIs
107+
- Conversation history stored in memory only (not persistent)

RUN_INSTRUCTIONS.md

Lines changed: 0 additions & 90 deletions
This file was deleted.

RUN_WITH_PII.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
websockets>=12.0
2+
requests>=2.31.0

0 commit comments

Comments
 (0)