-
Notifications
You must be signed in to change notification settings - Fork 902
fix: RawImage.fromURL
error when input file url
#1288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
/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. |
Yes, we were using const imageUrl = new URL(
"../../fixtures/img/llamaindex-white.png",
import.meta.url,
);
const nodes = [
new ImageNode({
image: imageUrl,
}),
]; |
That's a valid use-case, thanks for reporting! This will be merged in v3.5.1 💪 |
@@ -215,8 +215,7 @@ function isValidHfModelId(string) { | |||
export async function getFile(urlOrPath) { | |||
|
|||
if (env.useFS && !isValidUrl(urlOrPath, ['http:', 'https:', 'blob:'])) { | |||
return new FileResponse(urlOrPath.toString()); | |||
|
|||
return new FileResponse(urlOrPath instanceof URL ? urlOrPath.pathname : urlOrPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we perhaps check that the URL uses a valid file://
schema? Is there any other case where .pathname
would be valid (on a non-file URL?)
Upstream: run-llama/LlamaIndexTS#1855
fs.existSync(path)
will assume path is a posix/win32 format if you give a string, so you will need passurl.pathname