gemini_image plugin: return generated text together with generated images #679

Closed
opened 2026-02-16 10:20:10 -05:00 by yindo · 0 comments
Owner

Originally created by @acro-k-tanaka on GitHub (Sep 29, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Environment

  • Dify version: 1.9.0
  • Plugin version: Gemini Image 0.1.1
  • Cloud or Self Hosted: Self Hosted (AWS ECS)

Description

Currently the gemini_image tool only yields generated image blobs back to Dify workflows. For example it uses:

yield self.create_blob_message(
    blob=blob,
    meta={
        "filename": f"output{i}.png",
        "mime_type": "image/png",
    },
)

(see: tools/gemini_image/tools/image_generate.py).

This means generated text (if any) from the model is not available to Dify flows as the text output. I would like the tool to also return the generated text so workflows (and downstream nodes) can use it — similar to the user experience of Nano Banana in Google AI Studio where both image and generated caption/text are available.

Expected behavior

  • The tool should return the generated text (when present) via Dify's text message interface (create_text_message) in addition to returning the image blob. This will populate the tool's text output variable and make it available in flows. See Dify tool message helpers: create_text_message, create_blob_message. ([Dify Docs][3])

Proposed change

After obtaining the generated text from the model response, yield a text message before/after yielding the blob. Example (pseudo patch):

# extract generated_text from model response (adjust according to actual response schema)
generated_text = ...  # e.g. response.get("candidates", [])[0].get("content", {}).get("text")

if generated_text:
    yield self.create_text_message(text=generated_text)

for i, blob in enumerate(generated_blobs):
    yield self.create_blob_message(
        blob=blob,
        meta={
            "filename": f"output{i}.png",
            "mime_type": "image/png",
        },
    )

Notes:

  • Exact extraction depends on the model API response schema — the implementation should safely check the response and fall back if no text is present.
  • This change keeps backward compatibility (images still produced) while exposing text for flows.

Steps to reproduce

  1. Use the current gemini_image tool in a workflow.
  2. Generate an image with a prompt that also produces a text caption.
  3. Observe that the workflow text output is empty / only files are returned.

Self Checks (please fill before submitting PR)

  • I have read the contribution guide and language policy. (I will submit this issue in English per repo guidelines). ([GitHub][1])
  • I have searched for existing issues and did not find a duplicate.
  • I can provide a PR to implement this change if maintainers agree.

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @acro-k-tanaka on GitHub (Sep 29, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. ## Environment * Dify version: 1.9.0 * Plugin version: Gemini Image 0.1.1 * Cloud or Self Hosted: Self Hosted (AWS ECS) ## Description Currently the gemini_image tool only yields generated image blobs back to Dify workflows. For example it uses: ```python yield self.create_blob_message( blob=blob, meta={ "filename": f"output{i}.png", "mime_type": "image/png", }, ) ```` (see: tools/gemini_image/tools/image_generate.py). This means generated text (if any) from the model is not available to Dify flows as the `text` output. I would like the tool to also return the generated text so workflows (and downstream nodes) can use it — similar to the user experience of Nano Banana in Google AI Studio where both image and generated caption/text are available. ## Expected behavior * The tool should return the generated text (when present) via Dify's text message interface (`create_text_message`) in addition to returning the image blob. This will populate the tool's `text` output variable and make it available in flows. See Dify tool message helpers: `create_text_message`, `create_blob_message`. ([Dify Docs][3]) ## Proposed change After obtaining the generated text from the model response, yield a text message before/after yielding the blob. Example (pseudo patch): ```python # extract generated_text from model response (adjust according to actual response schema) generated_text = ... # e.g. response.get("candidates", [])[0].get("content", {}).get("text") if generated_text: yield self.create_text_message(text=generated_text) for i, blob in enumerate(generated_blobs): yield self.create_blob_message( blob=blob, meta={ "filename": f"output{i}.png", "mime_type": "image/png", }, ) ``` Notes: * Exact extraction depends on the model API response schema — the implementation should safely check the response and fall back if no text is present. * This change keeps backward compatibility (images still produced) while exposing `text` for flows. ## Steps to reproduce 1. Use the current gemini_image tool in a workflow. 2. Generate an image with a prompt that also produces a text caption. 3. Observe that the workflow `text` output is empty / only files are returned. ## Self Checks (please fill before submitting PR) * [x] I have read the contribution guide and language policy. (I will submit this issue in English per repo guidelines). ([GitHub][1]) * [x] I have searched for existing issues and did not find a duplicate. * [x] I can provide a PR to implement this change if maintainers agree. ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo added the enhancement label 2026-02-16 10:20:10 -05:00
yindo closed this issue 2026-02-16 10:20:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#679