Closed adifyr closed 1 year ago
Hi, can you confirm which version of typescript you're using, I can't see it in your package.json
I am using Typescript Version 4.8.2. Do I need to upgrade?
Also, here is my code in index.ts
. As you can see, I'm just doing the basic state_of_the_union
example:
import {OpenAI} from "langchain/llms";
import {RetrievalQAChain} from "langchain/chains";
import {readFileSync} from "fs";
import {RecursiveCharacterTextSplitter} from "langchain/text_splitter";
import {HNSWLib} from "langchain/vectorstores";
import {OpenAIEmbeddings} from "langchain/embeddings";
async function qaBot(query: string) {
const model = new OpenAI({});
const source = readFileSync("../assets/state_of_the_union.txt", "utf8");
const textSplitter = new RecursiveCharacterTextSplitter({chunkSize: 1000});
const docs = await textSplitter.createDocuments([source]);
const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());
const chain = RetrievalQAChain.fromLLM(model, vectorStore.asRetriever());
const res = await chain.call({query});
console.log(res);
}
qaBot("What did the president say about Justice Breyer?");
You can make it work by adding "skipLibCheck": true
to your tsconfig.json, see https://github.com/nfcampos/langchain-issue-602
i have the same issue and i want to use this repo for production, i cannot use skipLibCheck, any other idea?
@dorpex which version of langchain are you using?
Any solution to this issue?
@PublicTrades can you share the exact error you're getting along with a code snippet that is generating that error
Stumbled passed this issue today. I found for some reason my package.json
was had "langchain": "^0.0.39"
installed for some reason (old library doesn't know what the latest modules are, before it's time). Since I was using npm
I ran npm uninstall langchain
and then reinstalled with npm install -S langchain
. This installed "langchain": "^0.0.97",
Then my lost module party was over. Hope this helps.
Thanks @ianmcfall , Good work my friend, you are a time saver. Can't thank you enough.
@ianmcfall Thank you this solved my issue! Kudos to you!
This is still happening in the latest version 133 and is not solved for me with uninstall, reinstall (with or without -S), or wiping the npm cache. The missing packages are cohere-ai, @huggingface/inference, and replicate. If we look in the package.json file line 646 https://www.npmjs.com/package/langchain/v/0.0.133?activeTab=code
"cohere-ai": "^5.0.2",
we see that cohere is listed as a DEV dependency. I don't think langchain's dev dependencies are installed for npm i langchain
(the command given on the langchain homepage on npm). This is probably why people are hitting errors. I suppose to get around the problem the packages could be added to our own package.json files.
I am hitting the same errors where it is declaring types as what the OP showed. I have no idea how many packages will be needed to be installed to prevent the type errors.
I'm having the same issue as @ChrisChiasson with the same package (cohere-ai) and langchain version 0.0.134
I'm having the same issue as @ChrisChiasson with the same package (cohere-ai) and langchain version 0.0.134
BTW, adding the nominated packages should fix it @clashofphish
I'm having the same problem...
Can't find packages like AIMessage and HumanMessage.
Has anyone found a solution?
I was getting the same error but after installing the exact version "langchain": "^0.0.97"
given by @ianmcfall I was able to succeed! Make sure you have uninstalled the manually installed cohere-ai
when you do this
Hi. I installed langchain for my Node Typescript project. When I try to run the sample, I get the following errors in the terminal:
I did do
npm install -S langchain
. And I set all the parameters in the tsconfig.json & package.json to the recommended values.Here is my package.json:
And here is my tsconfig.json:
What's going on? Will I have to install all these modules separately?