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

embeddings/jina "parse" is not exported #7286

Open
5 tasks done
axuj opened this issue Nov 28, 2024 · 1 comment · May be fixed by #7292
Open
5 tasks done

embeddings/jina "parse" is not exported #7286

axuj opened this issue Nov 28, 2024 · 1 comment · May be fixed by #7292
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@axuj
Copy link

axuj commented Nov 28, 2024

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

const embeddings = new JinaEmbeddings({
...
})

Error Message and Stack Trace (if applicable)

node_modules/.pnpm/@langchain+community@0.3.16_@browserbasehq+sdk@2.0.0_@browserbasehq[email protected]_@playwrig_kt6rnhndxajs2oz6yl6vmflni4/node_modules/@langchain/community/dist/embeddings/jina.js (2:9): "parse" is not exported by "vite-browser-external:url", imported by "node_modules/.pnpm/@langchain[email protected]@[email protected]@[email protected]_@playwrig_kt6rnhndxajs2oz6yl6vmflni4/node_modules/@langchain/community/dist/embeddings/jina.js".

Description

I'm trying to use embeddings/jina in a browser, but when compiling, I get the error "parse" is not exported. The reason is that url.parse() has been deprecated. instead, we need to use the WHATWG URL API.

System Info

node v20.12.0
vite v5.4.11

Copy link

dosubot bot commented Nov 28, 2024

Hey @axuj! 👋 I'm here to help you with any bugs, questions, or contributions. Let's squash those bugs together!

To resolve the error "parse" is not exported when using embeddings/jina in a browser with LangChain.js, you should replace the deprecated url.parse() with the WHATWG URL API. Here's how you can modify the isLocal function:

function isLocal(url: string): boolean {
  const urlParsed = new URL(url);
  if (urlParsed.protocol === "file:") {
    return existsSync(urlParsed.pathname);
  }
  return false;
}

This change uses the URL constructor from the WHATWG URL API, which is the recommended approach for parsing URLs in modern JavaScript environments [1].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Nov 28, 2024
@axuj axuj linked a pull request Nov 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant