@chatpanel/pii 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/pii-detect.js +7 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/pii",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "The canonical ChatPanel privacy engine — reversible PII redaction + pseudonymization with local entity detection. Pure, dependency-free ESM shared by the ChatPanel extension, gateway, and bridge.",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/pii-detect.js CHANGED
@@ -116,7 +116,13 @@ async function detectViaEndpoint(text, det, signal, fetchImpl) {
116
116
 
117
117
  async function detectViaOpenAI(text, det, signal, fetchImpl) {
118
118
  const base = String(det.url || '').replace(/\/$/, '');
119
- const url = /\/chat\/completions$/.test(base) ? base : `${base}/v1/chat/completions`;
119
+ // Build the chat URL the SAME way the chat path does. An OpenAI-compatible baseUrl
120
+ // already ends in /v1 (Ollama, OpenRouter, NVIDIA, OpenAI…) → only add
121
+ // /chat/completions (appending /v1/chat/completions would 404 on /v1/v1/…). A bare
122
+ // host gets /v1/chat/completions; a full chat URL is used as-is.
123
+ const url = /\/chat\/completions$/.test(base) ? base
124
+ : /\/v\d+$/.test(base) ? `${base}/chat/completions`
125
+ : `${base}/v1/chat/completions`;
120
126
  const res = await fetchImpl(url, {
121
127
  method: 'POST',
122
128
  headers: { 'Content-Type': 'application/json', ...(det.apiKey ? { Authorization: `Bearer ${det.apiKey}` } : {}) },