MCPcopy
hub / github.com/simstudioai/sim / maskPIIBatchViaHttp

Function maskPIIBatchViaHttp

apps/sim/lib/guardrails/mask-client.ts:32–54  ·  view source on GitHub ↗
(
  texts: string[],
  entityTypes: string[],
  language?: string
)

Source from the content-addressed store, hash-verified

30 * its own fail-safe (scrubbing rather than leaking).
31 */
32export async function maskPIIBatchViaHttp(
33 texts: string[],
34 entityTypes: string[],
35 language?: string
36): Promise<string[]> {
37 if (texts.length === 0) return []
38
39 const url = `${getInternalApiBaseUrl()}/api/guardrails/mask-batch`
40 const masked = new Array<string>(texts.length)
41
42 await mapWithConcurrency(chunkIndicesByBudget(texts), CHUNK_CONCURRENCY, async (indices) => {
43 const chunk = indices.map((i) => texts[i])
44 const out = await postChunk(url, chunk, entityTypes, language)
45 if (out.length !== chunk.length) {
46 throw new Error('PII mask-batch returned an unexpected result')
47 }
48 indices.forEach((originalIndex, k) => {
49 masked[originalIndex] = out[k]
50 })
51 })
52
53 return masked
54}
55
56async function postChunk(
57 url: string,

Callers 2

maskCollectedFunction · 0.90

Calls 4

getInternalApiBaseUrlFunction · 0.90
mapWithConcurrencyFunction · 0.90
chunkIndicesByBudgetFunction · 0.90
postChunkFunction · 0.85

Tested by

no test coverage detected