Skip to content

Add Code Interpreter support for Gemini #85

Description

@Benjamin-Sayaque

Context

PR #71 added Code Interpreter support for OpenAI in the Chat class: activation through enableCodeInterpreter(containerId?), OpenAI payload construction, generated-file metadata extraction, container file download support, and public helper methods.

The goal is to extend the same capability to Gemini so that Gemini-based chat workflows can also execute code and expose generated artifacts where the Gemini API supports it.

Goal

Add Code Interpreter support for Gemini while keeping the existing public Chat API as consistent as possible with the OpenAI implementation:

  • enableCodeInterpreter(containerId?)
  • getGeneratedFiles()
  • downloadGeneratedFile(fileIdOrIndex) when Gemini exposes downloadable generated files or an equivalent artifact mechanism
  • getContainerId() or a documented Gemini-specific equivalent if the concept exists

Technical notes

  • Identify the Gemini payload format required to enable Code Interpreter.
  • Update Gemini payload construction so the tool is included when _codeInterpreterEnabled is enabled.
  • Handle Gemini/OpenAI differences, such as container IDs, file citation formats, generated artifact metadata, and download endpoints.
  • Extend response parsing so Gemini-generated files or artifacts are collected without changing existing OpenAI behavior.
  • Update JSDoc/documentation if behavior differs by provider.
  • Add Gemini-specific test helpers similar to the OpenAI helpers added in PR Add Code Interpreter tooling and generated file download support #71, for example Excel/PDF workflows if supported.

Acceptance criteria

  • A Gemini chat can call enableCodeInterpreter() without errors.
  • The Gemini request payload includes Code Interpreter correctly when enabled.
  • Gemini-generated files or artifacts are exposed through getGeneratedFiles() when supported by the API.
  • Downloading or retrieving Gemini artifacts is supported when the API allows it, or the limitation is clearly documented.
  • Existing OpenAI Code Interpreter behavior remains unchanged.
  • Test helpers or Apps Script tests are available to validate the Gemini flow.

Reference

Reference PR: #71, which implemented the OpenAI-side Code Interpreter support.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions