tanaike - Google Apps Script, Gemini API, and Developer Tips

The Thinker

Gemini API: Revolutionizing Content Generation with Direct PDF Input

Gists

Abstract

Gemini API now enables direct PDF processing for content generation, eliminating image conversion and reducing costs. This report provides a sample script to demonstrate this new capability and its potential applications.

Introduction

Gemini API has recently introduced the ability to directly process PDF data for content generation, significantly enhancing its capabilities. Previously, to utilize PDF data for content creation, it was necessary to convert each PDF page into a separate image format. This time-consuming and resource-intensive process has been eliminated, resulting in substantially reduced processing costs.

Convert Google Document to Markdown and vice versa using Google Apps Script

Gists

Description

Great news for fans of both Google Docs and Markdown! Google Docs recently acquired the ability to export documents directly into the markdown format. Ref

This functionality extends beyond the user interface, with early indications suggesting the Google Drive API might also be capable of converting between Google Docs and Markdown. I confirmed that this could also be achieved by Drive API. This opens exciting possibilities for automated workflows.

Updated: GAS Application - UnlockSmartInvoiceManagementWithGeminiAPI

UnlockSmartInvoiceManagementWithGeminiAPI was updated to v1.0.2.

  • v1.0.2 (July 23, 2024)

    1. On July 23, 2024, I noticed that PDF data could be directly parsed by Gemini API. It is considered that this is due to the update by the Google side. So, I updated setBlobs([blob], true) to setBlobs([blob], false) of the method parseInvoiceByGemini_. By this modification, the PDF blob is directly used with Gemini API. Ref

You can see the detail information here https://github.com/tanaikech/UnlockSmartInvoiceManagementWithGeminiAPI

Uploading Large Files to Gemini with Google Apps Script: Overcoming 50 MB Limit

Gists

Abstract

Uploads in Google Apps Script are limited to 50 MB, hindering work with large datasets. This report introduces a script with uploadType=resumable to overcome this limit, enabling uploads over 50 MB to Gemini and other services.

Introduction

This report explores the limitations of data upload size using Google Apps Script and introduces a script to overcome these limitations. In the current stage, Gemini API can generate content using the uploaded data to Gemini. You can find more information on this in a previous report. Ref As mentioned in the report, Google Apps Script uses uploadType=multipart for uploading files. However, the maximum file size is limited to 5 MB with this method for Drive API. Ref While I confirmed that the Gemini API allows for uploading over about 20 MB with uploadType=multipart, Google Apps Script enforces a stricter 50 MB limit for both uploads and downloads. Ref This can be inconvenient when working with larger datasets, such as movie or text data, which often exceed this limit.

Updated: GAS Library - GeminiWithFiles

GeminiWithFiles was updated to v1.0.7.

  • v1.0.7 (July 4, 2024)

    1. From this version, when doCountToken: true and exportTotalTokens: true are used in the object of the argument of geminiWithFiles, the total tokens are returned. In this case, the returned value is an object like {returnValue: "###", totalTokens: ###}. Ref

You can see the detail information here https://github.com/tanaikech/GeminiWithFiles

Analyzing Folder Structures with Google Apps Script

Gists

Abstract

This report provides a Google Apps Script to retrieve all files, including those within subfolders, for a designated folder. It addresses the challenges of retrieving files within deeply nested folder structures and obtaining complete file paths.

Introduction

Google Apps Script empowers developers to interact with Google Drive data programmatically, unlocking a wide range of functionalities. A core component of this interaction is the Drive service (DriveApp) and Drive API. These services provide programmatic control over files and folders within your Drive.

Updated: GAS Library - MoveFolder

MoveFolder was updated to v1.0.1.

  • v1.0.1 (June 18, 2024)

    1. In the recent update on the Google side, it was found that in the current stage, when the other libraries are loaded from a library, an error like We're sorry, a server error occurred while reading from storage. Error code NOT_FOUND occurs. So, from v1.0.1, the library of BatchRequest is included in this library.

You can see the detail information here https://github.com/tanaikech/MoveFolder

Updated: GAS Application - UnlockSmartInvoiceManagementWithGeminiAPI

UnlockSmartInvoiceManagementWithGeminiAPI was updated to v1.0.1.

  • v1.0.1 (June 17, 2024)

    1. In order to easily customize the value of “jsonSchema” for generating content with Gemini API, I added it as a new sheet of “jsonSchema” sheet in the Spreadsheet. When you customize it, you can edit the cell “A1” of the “jsonSchema” sheet. By this, the script generates content with Gemini API using your customized JSON schema. The cell “A2” is the number of characters of “A1”.

You can see the detail information here https://github.com/tanaikech/UnlockSmartInvoiceManagementWithGeminiAPI