TecEash1 / Taurus

An AI Discord Bot leveraging Googles Gemini 1.5 Model & Prodia!
GNU General Public License v3.0
14 stars 6 forks source link

[FEATURE] Image/File Viewing Support #9

Open TecEash1 opened 6 months ago

TecEash1 commented 6 months ago

๐Ÿ“‚ What category is this feature in?

AI

๐Ÿ“ Description of Feature

Allow support for images/files to be passed to model along with text.

This is possible because of Googles Gemini Pro 1.5 Model

Discord supports all of the mime types and fetching them for images. It is specified under content in attachments in the message object. Some mime types are different between Gemini and Discord so a converter will need to be made.

This update should add support to unlock all of Gemini 1.5s Multimodal capabilities:

TecEash1 commented 4 months ago

Relevant example docs: https://github.com/google-gemini/generative-ai-js/blob/main/samples/node/file-upload.js https://github.com/google-gemini/cookbook/blob/main/quickstarts/file-api/sample.js

This method was just introduced to the Google Generative AI npm package recently, so was not possible before. The bot should auto detect what the mime_type is, it should support image files and utf-8 encoded text files. It should also potentially support other file types such as .pdf, and maybe videos eventually.

TecEash1 commented 4 months ago

This commit adds file viewing support. However the file is not uploaded directly and is instead made into a string. This issue will stay open until Image/Files are uploaded properly

TecEash1 commented 4 months ago

Relevant example docs: https://github.com/google-gemini/generative-ai-js/blob/main/samples/node/file-upload.js https://github.com/google-gemini/cookbook/blob/main/quickstarts/file-api/sample.js

This method was just introduced to the Google Generative AI npm package recently, so was not possible before. The bot should auto detect what the mime_type is, it should support image files and utf-8 encoded text files. It should also potentially support other file types such as .pdf, and maybe videos eventually.

When this feature is added to the GoogleGenerativeAI package work on this will begin. This is due to the package relying on a local file parameter at the moment, however discord returns a file link to be utilised. In the case that this file URL option is not added to the package a workaround to this will be made by temporarily storing the file locally.

Update: Due to there being no definitive date when the feature will come to the API the update will most likely include downloading all of the users files locally and uploading them to the FileAPI.

For history - Function modification needed to fetch mime type from file and upload it, and pass an array of file ids to the handleGeminiResponse function. For running - With the file ids and mime types to go in the inline data along with any that may be from history it can be passed into the model for the request, after the request has been sent the files should be deleted as the FileAPI has a 20GB limit that is cleared every 48 hours.

Additional notes: Should, in the rare case that the users files amount to more than 20GB or there has been a failure with uploading their files the model should be passed a message along with the system instruction or users message saying โ€œThe user tried to upload a file, unfortunately the 20GB file limit was reached or uploading failed, please take this into account when replyingโ€