Calonz
Calonz10mo ago

Uncaught Error: ENOENT: no such file or directory

Can someone help me point out my mistake on my code. I'm trying to load the url from PDFLoader from LangChain and I'm getting an error in the Convex Dashboard says no such file or directory
No description
No description
No description
20 Replies
erquhart
erquhart10mo ago
new PDFLoader() expects a file path, not a url If it supports blobs you can generate one with ctx.storage.get(), not sure if it does though Actually it doesn't look like blobs are supported
Calonz
CalonzOP10mo ago
is there any way to get around this?
erquhart
erquhart10mo ago
Forking the repo and swapping out fs for blob support :/ https://github.com/langchain-ai/langchainjs/issues/784 I don't know much about LangChain, maybe you could have a small service outside of Convex that does just this part?
Calonz
CalonzOP10mo ago
For sure, let me try to play it around a little bit. It actually worked before I just changed the code, maybe I'll bring the old code back and compare it.
erquhart
erquhart10mo ago
Interesting, would love to see how this was working
Calonz
CalonzOP10mo ago
I found a way, I don't know if this is the most efficient solution tho 😆
Calonz
CalonzOP10mo ago
No description
erquhart
erquhart10mo ago
okay so blobs are supported? weird (and great!) you should be able to just skip the url part and get the blob direct from convex then ctx.storage.get() accepts the file id and returns a blob It's mentioned here: https://docs.convex.dev/file-storage/serve-files#serving-files-from-http-actions
Calonz
CalonzOP10mo ago
I actually tried that but it still gave me the same error
erquhart
erquhart10mo ago
same error about file system access?
Calonz
CalonzOP10mo ago
yup exactly the same
erquhart
erquhart10mo ago
Did you do ctx.storage.get() or ctx.storage.getUrl()
Calonz
CalonzOP10mo ago
I did both
erquhart
erquhart10mo ago
same error as in both printed a convex url?
Calonz
CalonzOP10mo ago
yes, but let me try again just to make sure.
erquhart
erquhart10mo ago
yeah get() shouldn't be returning a string, let alone a url: https://docs.convex.dev/api/interfaces/server.StorageActionWriter#get
erquhart
erquhart10mo ago
Were you passing fileUrl to get() by chance? It needs the file id rather than the url
Calonz
CalonzOP10mo ago
that's weird the ctx.storage.get() works now, it wasn't working before
erquhart
erquhart10mo ago
I'm glad the loader supports it! It isn't documented to do so.
Calonz
CalonzOP10mo ago
I'm always thankful for your support @erquhart 🙏

Did you find this page helpful?