langchain-ai / langchainjs

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

RecursiveCharacterTextSplit import on nodejs #3578

Closed ZakaCoding closed 7 months ago

ZakaCoding commented 10 months ago
          > Import like this:
import {
  RecursiveCharacterTextSplitter,
} from "langchain/text_splitter";

Please reopen if that doesn't fix it!

I am already using that code, it still error. However when I just refactor my code from JavaScript into Typescript it solved

btw. If you guys can fix that on JavaScript with module system, it will be better

Originally posted by @ZakaCoding in https://github.com/langchain-ai/langchainjs/issues/3566#issuecomment-1843789921

dosubot[bot] commented 10 months ago

🤖

That's great to hear that refactoring your code into TypeScript solved the issue! It's always satisfying when a change like that resolves a problem. If you have any further ideas or suggestions for improving the JavaScript module system in langchainjs, we'd love to hear them. Your feedback and contributions are valuable to us!


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.

jayampathiadhikari commented 10 months ago

@ZakaCoding Hi, you can import like this if its okay const { RecursiveCharacterTextSplitter } = require("langchain/text_splitter");

ZakaCoding commented 10 months ago

@ZakaCoding Hi, you can import like this if its okay const { RecursiveCharacterTextSplitter } = require("langchain/text_splitter");

I don't know this is will work, btw I am using ES module on express project.

But now i am already refactor my project into Typescript. And there no errors about this RecursiveTextSpillter

dosubot[bot] commented 7 months ago

Hi, @ZakaCoding,

I'm helping the langchainjs team manage their backlog and am marking this issue as stale. From what I understand, you encountered an error when importing RecursiveCharacterTextSplitter in JavaScript, but found that refactoring the code to TypeScript resolved the issue. There were suggestions for alternative import methods, and you confirmed that refactoring the project into TypeScript eliminated the error.

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!