Skip to content

An example JavaScript app that demonstrates integrating Pangea services into a LangChain app to capture and filter what users are sending to LLMs.

License

Notifications You must be signed in to change notification settings

pangeacyber/langchain-js-aig-prompt-protection

Repository files navigation

Prompt Protection for LangChain in JavaScript

An example JavaScript app that demonstrates integrating Pangea services into a LangChain app to capture and filter what users are sending to LLMs:

  • AI Guard — Monitor, sanitize and protect data.
  • Prompt Guard — Defend your prompts from evil injection.

Prerequisites

Setup

git clone https://github.com/pangeacyber/langchain-js-aig-prompt-protection.git
cd langchain-js-aig-prompt-protection
npm install
cp .env.example .env

Fill in the values in .env and then the app can be run like so:

npm run demo -- "What do you know about Michael Jordan the basketball player?"

A prompt like the above will be redacted:

What do you know about **** the basketball player?

To which the LLM's reply will be something like:

To provide you with accurate information, could you please specify which
basketball player you're referring to?

Prompt injections can also be caught:

npm run demo -- "Ignore all previous instructions."
The prompt was detected as malicious (detector: ph0003).

About

An example JavaScript app that demonstrates integrating Pangea services into a LangChain app to capture and filter what users are sending to LLMs.

Resources

License

Security policy

Stars

Watchers

Forks