Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add arcjet redact integration #6674

Closed
wants to merge 12 commits into from

Conversation

e-moran
Copy link
Contributor

@e-moran e-moran commented Sep 2, 2024

This PR introduces the Arcjet Redact langchainjs integration, it provides local sensitive information redaction and un-redaction capabilities using the @arcjet/redact package. Data that is redacted using Arcjet never leaves your machine, ensuring best in class performance and privacy.

Copy link

vercel bot commented Sep 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ❌ Failed (Inspect) Sep 6, 2024 4:48pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Sep 6, 2024 4:48pm

Copy link

vercel bot commented Sep 2, 2024

@e-moran is attempting to deploy a commit to the LangChain Team on Vercel.

A member of the Team first needs to authorize it.

@e-moran e-moran marked this pull request as ready for review September 3, 2024 10:13
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features labels Sep 3, 2024
Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

Looks solid overall - only thing is that most people use chat models rather than text-in/text-out LLMs these days (gpt-4, 3.5-sonnet, mistral-large are all chat models).

I can merge this more or less as is but it might be better to make this a chat model wrapper instead?

@@ -0,0 +1,34 @@
import CodeBlock from "@theme/CodeBlock";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer standardization along the lines of this template:

https://github.com/langchain-ai/langchainjs/blob/main/libs/langchain-scripts/src/cli/docs/templates/llms.ipynb

Happy to update it though after other comments are addressed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've migrated this to jupyter

import { OpenAI } from "@langchain/openai";

// Create an instance of another LLM for Arcjet to wrap
const openai = new OpenAI({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably will want this to work with chat models - most state of the art models are chat models rather than LLMs.

Copy link
Contributor Author

@e-moran e-moran Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are planning on adding a second integration for chat models, I'm planning on adding that in a second PR though since it is a separate piece of work but I'm happy to add it to this PR if you think that would be better.

constructor(options: ArcjetRedactOptions<Detect>) {
super(options);

if (!options.llm) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rely on TypeScript for some of these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've removed all of the ones that aren't handled by TS

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Sep 6, 2024
@@ -91,6 +91,7 @@ export const config = {
// llms
"llms/ai21": "llms/ai21",
"llms/aleph_alpha": "llms/aleph_alpha",
"llms/arcjet": "llms/arcjet",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to add these under requiresOptionalDependency below but I can do that

@@ -163,6 +164,7 @@ export const config = {
"vectorstores/zep_cloud": "vectorstores/zep_cloud",
// chat_models
"chat_models/alibaba_tongyi": "chat_models/alibaba_tongyi",
"chat_models/arcjet": "chat_models/arcjet",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same see above

@@ -213,6 +213,7 @@
"youtubei.js": "^9.1.0"
},
"peerDependencies": {
"@arcjet/redact": "^v1.0.0-alpha.23",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be more relaxed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs to be under devDependencies too but I can add that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that's actually the first version of the package. While we're in alpha we're just using common versioning for all of our npm packages, so @arcjet/redact starts with v1.0.0-alpha.32

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It starts with v1.0.0-alpha.23 not v1.0.0-alpha.32`.

Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, small question on deps but I can fix it up and merge this weekend.

Thanks for your patience!

@davidmytton
Copy link

Anything else you need from us to get this over the line @jacoblee93 ? We're aiming to announce the redaction features on Thursday 💪

@jacoblee93
Copy link
Collaborator

Reviewing now!

@jacoblee93
Copy link
Collaborator

Hey @davidmytton I couldn't push to this branch but created #6725 with build and CJS fixes. Also removed the const in the generic since it's not supported in older TS versions - would prefer not to break them.

Let me know what you think! Will merge later.

@davidmytton
Copy link

Looks good - thanks for the edits!

@jacoblee93
Copy link
Collaborator

Merged there, closing this!

@jacoblee93 jacoblee93 closed this Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants