generative-ai-js icon indicating copy to clipboard operation
generative-ai-js copied to clipboard

File URL option for the GenAI File API

Open TecEash1 opened this issue 9 months ago • 9 comments

At the moment a file path has to be utilised: mimeType: mime.lookup(filePath),. However it would be helpful if a file URL could also be used instead of a local file path: mimeType: mime.lookup(rawfileURL),

TecEash1 avatar May 07 '24 15:05 TecEash1

So the use of mime.lookup here was a little confusing as it refers to another library I wasn't familiar with.

I think what you're trying to request is that our method GoogleAIFileManager.uploadFile(filePath, fileMetadata) should also accept a fileURL as the first argument, is that correct? That seems like a reasonable feature request.

hsubox76 avatar May 08 '24 21:05 hsubox76

That is correct, sorry about saying mime.lookup, what you mentioned about using the GoogleAIFileManager.uploadFile method with a fileURL is what I meant to say. 😅

TecEash1 avatar May 08 '24 22:05 TecEash1

Hey @TecEash1 just to clarify, by file URL do you mean a url that starts with the file:// protocol?

lahirumaramba avatar May 09 '24 18:05 lahirumaramba

sorry, thats not what I initially meant. I meant a raw file starting with the https/http protocol. Such as:

https://www.google.com/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png

TecEash1 avatar May 09 '24 18:05 TecEash1

+1. We, at Zapier, would love the ability to pass in a file via the https/http protocol. Especially with the new ability to upload Videos. If we could just pass a URL to a video instead of having to download it ourselves, just to re-package it up and upload it to you, if we could just pass along the same URL that we have access too, that would be amazing.

mynamebrody avatar May 10 '24 18:05 mynamebrody

+1 to be able to send image/video urls instead of fetching them to resend them to you would be brilliant!

EmilyYond avatar May 14 '24 14:05 EmilyYond

+1 here as well—thank you!

jin-ds avatar May 14 '24 15:05 jin-ds

Unfortunately this would be beyond a simple SDK fix and would require a change to the Gemini API.

If we provided this functionality in the SDK, we'd be doing the same thing as you would - downloading the image and uploading it somewhere, but doing it invisibly, under the hood, which I don't think provides that much value and introduces more room for error.

I will pass along to the Gemini team that users are interested in this feature, or you may get more visibility posting in the Gemini API discussion forum: https://discuss.ai.google.dev/

hsubox76 avatar May 14 '24 17:05 hsubox76

Also, can everyone use the "thumbs up" emote on the first post to indicate "+1" on interest? It will be a handy way for us to see the total interest in this feature request and avoid making this issue thread too long.

hsubox76 avatar May 14 '24 17:05 hsubox76