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

Enable support for Browsers, Cloudflare Workers, Next.js Browser/Serverless/Edge #632

Merged
merged 83 commits into from Apr 10, 2023

Conversation

nfcampos
Copy link
Collaborator

@nfcampos nfcampos commented Apr 5, 2023

- [ ] Split File loaders from Blob loaders (File loaders remain with the existing name, Blob loaders are new) Will tackle later in #663

  • Fix Cannot find module '@fortaine/fetch-event-source/parse' from '../langchain/dist/util/axios-fetch-adapter.js' replace with eventsource-parser ?
  • Add package to test on CF Workers
  • Add package to test on browser with create-react-app template
  • Test when peer dependencies are not present (not sure how to do this in CI, but that's secondary)

@vercel
Copy link

vercel bot commented Apr 5, 2023

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

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 10, 2023 2:29pm

@nfcampos nfcampos changed the title Add test-exports-cf package to test using LangChain on Cloudflare Workers Enable support for CF Workers without node_compat flag, Add package to test using LangChain on Cloudflare Workers Apr 5, 2023
@nfcampos nfcampos changed the title Enable support for CF Workers without node_compat flag, Add package to test using LangChain on Cloudflare Workers Enable support for CF Workers without node_compat flag, Add package to test usage on Cloudflare Workers Apr 5, 2023
@nfcampos nfcampos changed the title Enable support for CF Workers without node_compat flag, Add package to test usage on Cloudflare Workers Enable support for CF Workers without node_compat flag, Add package to test on CF Workers Apr 5, 2023
@dankolesnikov
Copy link

this is very exciting

@BleedingDev
Copy link

I am hyped about this. Still have problems with streaming, this might be huge step forward. :)

@nfcampos nfcampos force-pushed the nc/test-exports-cf branch 2 times, most recently from 05088f4 to 1464380 Compare April 6, 2023 13:24
@rlancemartin
Copy link

+1, i will test w/ the lex-gpt app (https://lex-gpt.vercel.app/) as soon as this goes in :)

@Sameedahmad
Copy link

@PineappleExpress808 Any updates? Is it working and if so let us know of any roadblocks ahead.

@nfcampos nfcampos changed the title Enable support for CF Workers without node_compat flag, Add package to test on CF Workers Enable support for Browsers, and CF Workers without node_compat flag Apr 7, 2023
@rlancemartin
Copy link

rlancemartin commented Apr 7, 2023

@PineappleExpress808 Any updates? Is it working and if so let us know of any roadblocks ahead.

i haven't tested. will wait for this PR to go in and a new release is cut.

Vercel mentioned that streaming will work if:
1/ we are able to enable Vercel edge functions w/ Langchain (e.g., fs is not available in Edge runtime)

or

2/ users migrate Vercel apps to use route handlers (https://beta.nextjs.org/docs/routing/route-handlers)

in any case, i'll definitely test w/ this update.

@nfcampos nfcampos force-pushed the nc/test-exports-cf branch 3 times, most recently from b78d9e4 to 3999b76 Compare April 8, 2023 16:38
@agola11 agola11 self-requested a review April 9, 2023 23:30
Copy link
Collaborator

@agola11 agola11 left a comment

Choose a reason for hiding this comment

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

From my perspective (mostly looking at import refactoring) looks good! Thanks!

});

// Run the chain but don't await it
chain.run("hello").catch(console.error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why don't we await here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we need the response to start being sent to the user right away. If we await then we'll only start sending response after the chain run finishes, therefore no streaming

Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because there was some packaging issue with the dependency we were using for this and it was easiest to include a copy here. Same licence as we have

entryPoint = {
node: entryPoint,
};
} else if (fs.existsSync(litePath)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah should probably remove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment