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

@langchain/core not installed by default? #3990

Closed
garmeeh opened this issue Jan 11, 2024 · 6 comments
Closed

@langchain/core not installed by default? #3990

garmeeh opened this issue Jan 11, 2024 · 6 comments
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@garmeeh
Copy link

garmeeh commented Jan 11, 2024

In the docs it states:

The @langchain/core package contains base abstractions that the rest of the LangChain ecosystem uses, along with the LangChain Expression Language. It is automatically installed along with langchain, but can also be used separately.

But if I want to import a type, for example:

import type { VectorStoreRetriever } from '@langchain/core/vectorstores';

myRetriever(): VectorStoreRetriever<SupabaseVectorStore>

I need to install it separately.

Copy link

dosubot bot commented Jan 11, 2024

🤖

Hey @garmeeh! How's it going? I'm Dosu, a friendly bot here to help you out while we wait for a human maintainer to step in. I'm equipped to assist with bug resolutions, answer questions, and generally help you become a contributor. Looking forward to helping you navigate through this issue!

The @langchain/core package is indeed automatically installed along with langchainjs. However, when you are using other packages that extend @langchain/core, such as @langchain/google-genai or @langchain/community, it's important that they all use the same version of @langchain/core to ensure proper interaction of types and integrations.

This is why the documentation suggests adding a "resolutions" or "overrides" field in your project's package.json to specify the version of @langchain/core to be used. This way, you can guarantee that all packages are using the same version of @langchain/core.

Here's the relevant excerpt from the documentation:

"These packages, as well as the main LangChain package, all depend on @langchain/core, which contains the base abstractions that these integration packages extend. To ensure that all integrations and their types interact with each other properly, it is important that they all use the same version of @langchain/core. The best way to guarantee this is to add a "resolutions" or "overrides" field like the following in your project's package.json."

So, while you don't need to install @langchain/core separately for basic usage of langchainjs, you may need to specify its version in your package.json when using other packages that extend it.

As for the exact relationship between the langchainjs and @langchain/core packages in terms of dependencies, they are part of the same workspace as indicated by the "workspaces" field in the package.json file. This means they are part of a monorepo setup where multiple packages live within the same repository and can depend on each other.

However, the package.json file does not explicitly specify a dependency relationship between langchainjs and @langchain/core. The dependencies of a package are usually listed under the "dependencies" or "devDependencies" fields, but neither of these fields mention @langchain/core.

The scripts section does show that @langchain/core is built and tested as part of the test script for langchainjs, which suggests that langchainjs may rely on @langchain/core in some way, but without more information, it's not possible to determine the exact nature of this relationship.

Therefore, based on the provided context, the exact relationship in terms of dependencies between langchainjs and @langchain/core cannot be determined.

I hope this clarifies your question. If you have any more questions or need further clarification, feel free to ask.

Best,
Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Jan 11, 2024
@jacoblee93
Copy link
Collaborator

It is a dependency of all packages:

https://github.com/langchain-ai/langchainjs/blob/main/langchain/package.json#L1206

What is the error you're seeing?

@garmeeh
Copy link
Author

garmeeh commented Jan 12, 2024

For example, in a fresh project I installed langchain then I try import this package:

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

I get this errro:

Cannot find module '@langchain/openai' or its corresponding type declarations.

CleanShot 2024-01-12 at 19 21 36@2x

CleanShot 2024-01-12 at 19 21 52@2x

@jacoblee93
Copy link
Collaborator

Could be some Typescript setting?

If you look in your node modules is it there? The fix for now is to just install them manually and possibly set overrides.

@JakubKontra
Copy link
Contributor

I am facing same issue

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label May 6, 2024
Copy link

dosubot bot commented May 6, 2024

Hi, @garmeeh,

I'm helping the langchainjs team manage their backlog and am marking this issue as stale. From what I understand, the issue you raised regarding the installation of the @langchain/core package has been resolved. It was clarified that @langchain/core is automatically installed along with langchainjs and is a dependency of all packages. Users may need to specify its version in their package.json when using other packages that extend it.

Could you please confirm if this issue is still relevant to the latest version of the langchainjs repository? If it is, please let the langchainjs team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you for your understanding and contribution to the langchainjs project.

I (Dosu)

@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label May 13, 2024
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

No branches or pull requests

3 participants