解説D1~D4: オプション機能
def get_current_temperature(location: str) -> str:
"""今日の気温を調べる関数"""
return "今日の気温は25度です"
response = client.models.generate_content(
model="gemini-2.5-flash",
contents=[
types.Part.from_bytes(data=image_bytes, mime_type="image/png"),
"画像の内容を説明してください",
],
config=types.GenerateContentConfig(
tools=[
types.Tool(google_search=types.GoogleSearch()),
types.Tool(code_execution=types.ToolCodeExecution),
get_current_temperature,
]
),
)
各々、1行加えるだけでできるので簡単!Web版Geminiで検証が不安ならAPIでも簡単