fix: `RawImage.fromURL` error when input file url
Upstream: https://github.com/run-llama/LlamaIndexTS/pull/1855
fs.existSync(path) will assume path is a posix/win32 format if you give a string, so you will need pass url.pathname
/cc @xenova do you have a change to look at this? /
Hi @himself65 👋 Can you give an example of a URL which has this problem? The if clause should not allow invalid URLs to pass this step.
Hi @himself65 👋 Can you give an example of a URL which has this problem? The if clause should not allow invalid URLs to pass this step.
Yes, we were using file: protocol in node.js, and file protocol is a standard in node.js. And this is a regression because our test is working in <=4.0.0
const imageUrl = new URL(
"../../fixtures/img/llamaindex-white.png",
import.meta.url,
);
const nodes = [
new ImageNode({
image: imageUrl,
}),
];
Docs: https://nodejs.org/api/fs.html#file-url-paths
That's a valid use-case, thanks for reporting! This will be merged in v3.5.1 💪
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.