Skip to content

Commit 23ca570

Browse files
committed
Fix issue with PIL Image load
1 parent c87e825 commit 23ca570

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

genai/tools/tools_code_exec_with_txt_local_img.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def generate_content() -> GenerateContentResponse:
2020
from PIL import Image
2121
from google import genai
2222
from google.genai.types import (
23+
GenerateContentConfig,
2324
HttpOptions,
2425
Tool,
2526
ToolCodeExecution,
26-
GenerateContentConfig,
2727
)
2828

2929
client = genai.Client(http_options=HttpOptions(api_version="v1"))
@@ -45,14 +45,14 @@ def generate_content() -> GenerateContentResponse:
4545
with open("test_data/640px-Monty_open_door.svg.png", "rb") as image_file:
4646
image_data = Image.open(image_file)
4747

48-
response = client.models.generate_content(
49-
model="gemini-2.0-flash-001",
50-
contents=[image_data, prompt],
51-
config=GenerateContentConfig(
52-
tools=[code_execution_tool],
53-
temperature=0,
54-
),
55-
)
48+
response = client.models.generate_content(
49+
model="gemini-2.0-flash-001",
50+
contents=[image_data, prompt],
51+
config=GenerateContentConfig(
52+
tools=[code_execution_tool],
53+
temperature=0,
54+
),
55+
)
5656

5757
print("# Code:")
5858
for part in response.candidates[0].content.parts:

0 commit comments

Comments
 (0)