langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
12.29k stars 2.08k forks source link

TypeScript error: Cannot find module './import_type.js' #2228

Closed sinedied closed 9 months ago

sinedied commented 1 year ago

Using langchain 0.0.125, if I try to use this import:

import { load } from "langchain/load";

I get a TS compilation error:

node_modules/langchain/dist/load/index.d.ts:1:46 - error TS2307: Cannot find module './import_type.js' or its corresponding type declarations.

1 import { OptionalImportMap, SecretMap } from "./import_type.js";
                                               ~~~~~~~~~~~~~~~~~~

The import_type.js file doesn't seem to exists?

Or is there another function I should use to deserialize data? Thanks

dosubot[bot] commented 1 year ago

Answer generated by a 🤖

Answer

Hello,

The error message you're seeing is indicating that TypeScript is unable to locate the import_type.js module. This module is indeed imported in the langchain/src/load/index.ts file, which suggests that the module might have been removed, renamed, or moved to a different location in the LangChain version 0.0.125.

As for the load function, it is used to deserialize data. It takes three parameters: text, secretsMap, and optionalImportsMap. The text parameter is the serialized data in string format, secretsMap is an object that maps secret keys to their values, and optionalImportsMap is an object that maps optional import entry points to their modules.

Here's an example of how you can use the load function:

import { load } from "langchain/load";

const text = /* serialized data */;
const secretsMap = /* map of secret keys to values */;
const optionalImportsMap = /* map of optional import entry points to modules */;

const data = await load(text, secretsMap, optionalImportsMap);

Please replace the comments with actual values. If this doesn't solve your problem, could you please provide more information about the load function and the import_type.js module?

Unfortunately, I wasn't able to find any changes made to the LangChain codebase in version 0.0.125 that could have affected the import_type.js module. If you have more information about this, it would be helpful.

Let me know if you have any other questions or need further clarification.

Best, Dosu

Sources


This response is meant to be useful, save you time, and share context. 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.

jacoblee93 commented 1 year ago

Looks like a bug - will have a look tomorrow!

jacoblee93 commented 1 year ago

Hey sorry for the delay - just tried with the latest version and it worked fine. Can you give me any other info on your setup?

dosubot[bot] commented 10 months ago

Hi, @sinedied! I'm Dosu, and I'm here to help the langchainjs team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the issue you reported is related to a TypeScript compilation error when importing from langchain/load in version 0.0.125. The error specifically mentions that it cannot find the module ./import_type.js. Jacoblee93 has confirmed this as a bug and has requested more information about your setup.

Before we proceed, we would like to know if this issue is still relevant to the latest version of the langchainjs repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and cooperation!