Skip to content

Commit

Permalink
feat: add content safety check for prompt injections ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 14, 2024
1 parent 40862ff commit f7a9321
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/sample/genaisrc/safety.genai.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

const contentSafefy = await host.contentSafety()
if (contentSafefy?.detectPromptInjection) {
const res = await contentSafefy.detectPromptInjection(env.files)
if (res.attackDetected)
throw new Error("Prompt injection detected in the files")
} else {
console.warn("Content safety not available")
}

$`Say all good!`

0 comments on commit f7a9321

Please sign in to comment.