From 6ff814277735cb9e654cac1f8ffd533cc5798125 Mon Sep 17 00:00:00 2001 From: Nils Heuer Date: Mon, 25 Aug 2025 19:54:27 +0200 Subject: [PATCH] Provided working example for multimodal query The example initially provided, does not work and fails with a ValueError: Unable to coerce value: Part( text='what is in this image?' ) error. The provided example works correctly --- docs/deploy/agent-engine.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/deploy/agent-engine.md b/docs/deploy/agent-engine.md index 1fcb71ee2..e95e12103 100644 --- a/docs/deploy/agent-engine.md +++ b/docs/deploy/agent-engine.md @@ -245,20 +245,23 @@ To include an image, you can use `types.Part.from_uri`, providing a Google Cloud ```python from google.genai import types -image_part = types.Part.from_uri( - file_uri="gs://cloud-samples-data/generative-ai/image/scones.jpg", - mime_type="image/jpeg", -) -text_part = types.Part.from_text( - text="What is in this image?", -) +image_message = { + "role": "user", + "parts": [ + { + "file_data": { + "file_uri": "gs://cloud-samples-data/generative-ai/image/scones.jpg", + "mime_type": "image/jpeg", + }, + }, + { + "text": "what is in this image?", + }, + ] +} -for event in remote_app.stream_query( - user_id="u_456", - session_id=remote_session["id"], - message=[text_part, image_part], -): - print(event) +for event in agent_engine.stream_query(user_id="u_456", session_id=remote_session["id"], message=image_message): + print (event) ``` !!!note