Closed ajoublin closed 6 months ago
Hey @ajoublin, good to see you diving into new challenges! 🚀
Based on the error message you provided, it seems like the issue is related to the file path you're providing to the PPTXLoader
. The error ENOENT: no such file or directory
typically indicates that the file you're trying to access doesn't exist at the specified path.
In your code, you're creating a Blob
from a Buffer
and passing it to the PPTXLoader
. However, the PPTXLoader
expects a file path as an argument, not a Blob
or Buffer
. This could be the reason why you're encountering the error.
Here's how you should use the PPTXLoader
:
import { PPTXLoader } from "langchain/document_loaders/fs/pptx";
const filePath = 'path/to/your/file.pptx'; // Replace with your file path
const loader = new PPTXLoader(filePath);
const docs = await loader.load();
Ensure that the file path you provide exists and is accessible. If you're trying to load the file from a POST request, you might need to save the file to your server first, and then pass the file path to the PPTXLoader
.
Regarding the 404 error, it's likely related to your NextJS routing configuration rather than the LangChain JS library. Make sure that the route you're trying to access is correctly defined in your NextJS project.
If you continue to encounter issues, please provide more details about your implementation, specifically how you're handling the file upload in your POST API and how you're passing the file to the PPTXLoader
.
For more information on how to use the PPTXLoader
, you can refer to the LangChain JS documentation and the example code in the repository.
Regarding the documentation provided by Langchain :
export class PPTXLoader extends BufferLoader {
constructor(filePathOrBlob: string | Blob) {
super(filePathOrBlob);
}
}
The PPTXLoader constructor accept a blob as an argument (which is working fine for TextLoader / CSVLoader / DocxLoader / PDFLoader by the way).
About the 404 error, this error only shows up when I add this piece of code : loader = new PPTXLoader(blobBuffer)
so I'm 100% sure it is not related to my NextJS configuration.
It's Node only: https://js.langchain.com/docs/integrations/document_loaders/file_loaders/pptx
This is going to sound really dumb, but you could try just adding a file at that path with that exact name at your project root:
https://github.com/jacoblee93/dlai-langchainjs/tree/main/test/data
That works for the PDF loader in some environments sometimes, and I am assuming that pdf-parse
is an indirect dep of the PPTX loader.
Regarding the documentation provided by Langchain :
export class PPTXLoader extends BufferLoader { constructor(filePathOrBlob: string | Blob) { super(filePathOrBlob); } }
The PPTXLoader constructor accept a blob as an argument (which is working fine for TextLoader / CSVLoader / DocxLoader / PDFLoader by the way).
About the 404 error, this error only shows up when I add this piece of code :
loader = new PPTXLoader(blobBuffer)
so I'm 100% sure it is not related to my NextJS configuration.
i have the same problem
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
I'm trying to use the langchain PPTX loader to create documents from a Powerpoint file via a POST call. I'm expected to retrieve docs with the load() function. I have a 404 error when trying to reach my route and I've got the error in the description when compiling my NextJS project.
System Info
Code executed on local environment and on a live version deployed on Vercel. Node version : v20.10.0