Arcjet and LangChain work together to redact
sensitive information from prompts locally before it is sent to a third-party
LLM or Chat Model.
What is Arcjet?Arcjet helps developers protect their apps
in just a few lines of code. Implement rate limiting, bot protection, email
validation, and defense against common attacks.
The Arcjet LangChain integration wraps your
LLM and Chat
Model calls to
perform redaction and un-redaction on sensitive information that is being sent
to and from third party AI services.
chatModel or llm: The chat model or llm that you are wrapping. (eg:
OpenAIChat)
entities: The list of entities that you wish to redact. If undefined then
all entities are redacted. Valid values are: email, phone-number,
ip-address, credit-card, or any string returned from detect.
contextWindowSize - How many tokens to pass to the detect function at a
time. Setting this to a higher value allows for more context to be used when
determing if a token is sensitive or not.
detect - An optional function that allows you to detect custom entities. It
will be passed a list of tokens as big as contextWindowSize and should
return a list of detected entities of the same length.
replace - An optional function that allows you to define your own
replacements for detected entities. It is passed a string with the type of
entity detected and it should either return a replacement for that entity type
or undefined.