-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Errors when loading @langchain/core/messages in a typescript ES module #4645
Comments
Hey @marc-weber1! Long time no see in the digital corridors of GitHub issues. 🚀 Based on the information you've provided, it seems like you're encountering an issue with importing the '@langchain/core/messages' module in a TypeScript ES module while developing a VSCode extension with LangChain.js version 0.1.25. This issue could be related to the Given the context of your
To troubleshoot and potentially resolve this issue, consider the following steps:
Without specific error messages or more detailed information about how you're attempting to import '@langchain/core/messages', these suggestions are based on common issues related to module resolution and compatibility in TypeScript projects targeting ES modules in a Node.js environment. Regarding similar issues in the langchainjs repository, there are several open and closed issues that seem to be related to your problem. The most relevant one is Unable to import anything, which is still open and was last updated on March 02, 2024. The suggested solutions in this issue include reinstalling langchainjs, checking the LangChain version, and updating the I hope this information helps you in resolving the issue. If you need further assistance, please provide more details about the error messages you're receiving and how you're attempting to import '@langchain/core/messages'. Sources
|
Hey @marc-weber1, can you share your |
https://github.com/marc-weber1/langchain-vscode/blob/master/package.json entire source code is on github, master branch as is should reproduce the error, may need vscode installed |
Sat |
BaseMessage and ChatMessage are types, and I can't convert a VSCode extension to an ES6 module; How am I supposed to import types with a require statement? |
microsoft/vscode#201935 - looks like they will fix this soon, but maybe include some documentation about either CommonJS not being supported or how to use it |
Oh hmm interesting. How do people usually require types in CJS? Haven't worked with it in a long time. Would something like this work? const { ChatPromptTemplate, LengthBasedExampleSelectorInput } = await import("@langchain/core/prompts"); |
Checked other resources
Example Code
tsconfig:
Error Message and Stack Trace (if applicable)
@langchain/core/messages.d.cts:
The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./dist/messages/index.js")' call instead.
Description
Trying to make a VSCode extension, but can't with the required settings and langchain's cjs dependencies.
System Info
langchain@0.1.25 | MIT | deps: 18 | versions: 255
Typescript bindings for langchain
https://github.com/langchain-ai/langchainjs/tree/main/langchain/
keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores
dist
.tarball: https://registry.npmjs.org/langchain/-/langchain-0.1.25.tgz
.shasum: afd0faf2eadfb5e6e1d57bb3bbc5731918e62135
.integrity: sha512-sfEChvr4H2CklHdSByNBbytwBrFhgtA5kPOnwcBrxuXGg1iOaTzhVxQA0QcNcQucI3hZrsNbZjxGp+Can1ooZQ==
.unpackedSize: 4.0 MB
dependencies:
@anthropic-ai/sdk: ^0.9.1 js-tiktoken: ^1.0.7 openapi-types: ^12.1.3
@langchain/community: ~0.0.33 js-yaml: ^4.1.0 p-retry: 4
@langchain/core: ~0.1.36 jsonpointer: ^5.0.1 uuid: ^9.0.0
@langchain/openai: ~0.0.14 langchainhub: ~0.0.8 yaml: ^2.2.1
binary-extensions: ^2.2.0 langsmith: ~0.1.7 zod-to-json-schema: ^3.22.3
expr-eval: ^2.0.2 ml-distance: ^4.0.0 zod: ^3.22.4
maintainers:
dist-tags:
latest: 0.1.25 next: 0.1.19-rc.2
published 5 days ago by basproul braceasproul@gmail.com
Windows 10 Pro
npm v10.2.4
NodeJS v20.11.1
The text was updated successfully, but these errors were encountered: