Skip to content

Conversation

@Erol444
Copy link
Contributor

@Erol444 Erol444 commented Feb 2, 2026

What does this PR do?

Add support for Gemini's code execution (tool use)

Type of Change

  • New feature (non-breaking change that adds functionality)

Testing

  • I have tested this change locally

  • I have added/updated tests for this change

  • Tested locally both with gemini 3.0 flash and pro, they both support code execution

  • Issue: if we do rf_key:roboflow (api key passthrough), seems like our passthroguh server strips away the code execution code, and it won't do code execution

Tested with code below.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

Additional Context

Test code

import cv2
import traceback
from unittest.mock import MagicMock
from inference.core.workflows.core_steps.models.foundation.google_gemini.v3 import GoogleGeminiBlockV3
from inference.core.workflows.execution_engine.entities.base import WorkflowImageData

# Configuration
google_api_key = "GEMINI_API_KEY"
roboflow_api_key = "ROBOFLOW_API_KEY"
img_path = "sc-highway.png"
prompt = "what's the license plate number of the third (furthest away) car? return just the license plate num."

# Load and prepare image
img = cv2.imread(img_path)
if img is None:
    raise FileNotFoundError(f"Could not load image at {img_path}")
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

# Initialize Block
block = GoogleGeminiBlockV3(
    model_manager=MagicMock(),
    api_key=roboflow_api_key
)

image_data = WorkflowImageData(
    parent_metadata=MagicMock(),
    numpy_image=img
)

try:
    result = block.run(
        images=[image_data],
        task_type="unconstrained",
        prompt=prompt,
        output_structure=None,
        classes=None,
        model_version="gemini-3-flash-preview",
        max_tokens=8192,
        temperature=0.0,
        thinking_level="high",
        max_concurrent_requests=1,
        google_code_execution=True, # <-- Added this
        api_key=google_api_key
    )

    print("\n✅ Execution Successful!")
    print("Response:", result[0]['output'])

except Exception:
    print("\n❌ Execution Failed")
    traceback.print_exc()

And test img:
sc-highway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants