From ecd50b9a6a7c40ea7eeab2dd2fcd8bd73d5ddb4a Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Thu, 7 Dec 2023 02:38:49 -0800 Subject: [PATCH] Fix docs --- examples/src/experimental/masking/basic.ts | 2 +- examples/src/experimental/masking/kitchen_sink.ts | 2 +- examples/src/experimental/masking/next.ts | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/src/experimental/masking/basic.ts b/examples/src/experimental/masking/basic.ts index 77a5c78de2b2..094e35fed9e6 100644 --- a/examples/src/experimental/masking/basic.ts +++ b/examples/src/experimental/masking/basic.ts @@ -20,7 +20,7 @@ maskingParser.addTransformer(piiMaskingTransformer); const input = "Contact me at jane.doe@email.com or 555-123-4567. Also reach me at john.smith@email.com"; -const masked = await maskingParser.parse(input); +const masked = await maskingParser.mask(input); console.log(masked); // Contact me at [email-a31e486e324f6] or [phone-da8fc1584f224]. Also reach me at [email-d5b6237633d95] diff --git a/examples/src/experimental/masking/kitchen_sink.ts b/examples/src/experimental/masking/kitchen_sink.ts index 07e85e7fc50f..4743c20a7b2f 100644 --- a/examples/src/experimental/masking/kitchen_sink.ts +++ b/examples/src/experimental/masking/kitchen_sink.ts @@ -70,7 +70,7 @@ const message = // Mask and rehydrate the message maskingParser - .parse(message) + .mask(message) .then((maskedMessage: string) => { console.log(`Masked message: ${maskedMessage}`); return maskingParser.rehydrate(maskedMessage); diff --git a/examples/src/experimental/masking/next.ts b/examples/src/experimental/masking/next.ts index 85621a4b8dca..dac49a781978 100644 --- a/examples/src/experimental/masking/next.ts +++ b/examples/src/experimental/masking/next.ts @@ -36,11 +36,11 @@ export async function POST(req: Request) { const formattedPreviousMessages = messages.slice(0, -1).map(formatMessage); const currentMessageContent = messages[messages.length - 1].content; // Extract the content of the last message // Mask sensitive information in the current message - const guardedMessageContent = await maskingParser.parse( + const guardedMessageContent = await maskingParser.mask( currentMessageContent ); // Mask sensitive information in the chat history - const guardedHistory = await maskingParser.parse( + const guardedHistory = await maskingParser.mask( formattedPreviousMessages.join("\n") ); @@ -64,6 +64,11 @@ export async function POST(req: Request) { headers: { "content-type": "text/plain; charset=utf-8" }, }); } catch (e: any) { - return Response.json({ error: e.message }, { status: 500 }); + return new Response(JSON.stringify({ error: e.message }), { + status: 500, + headers: { + "content-type": "application/json", + }, + }); } }