This is an automated email from the ASF dual-hosted git repository.

vterentev pushed a commit to branch fix-postcommit-python
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/fix-postcommit-python by this 
push:
     new c0201c23388 Fix gemini post processor
c0201c23388 is described below

commit c0201c233887e82110d9f664775e57b747b3f983
Author: Vitaly Terentyev <[email protected]>
AuthorDate: Sat Jul 26 23:27:13 2025 +0400

    Fix gemini post processor
---
 .../examples/inference/gemini_text_classification.py         | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git 
a/sdks/python/apache_beam/examples/inference/gemini_text_classification.py 
b/sdks/python/apache_beam/examples/inference/gemini_text_classification.py
index ea7ff235716..428f86f0e69 100644
--- a/sdks/python/apache_beam/examples/inference/gemini_text_classification.py
+++ b/sdks/python/apache_beam/examples/inference/gemini_text_classification.py
@@ -77,6 +77,18 @@ class PostProcessor(beam.DoFn):
       yield inference.text
       return
 
+    if hasattr(inference[1], "text"):
+      yield inference[1].text
+      return
+
+    if hasattr(inference[1][0], "text"):
+      yield inference[1][0].text
+      return
+
+    if hasattr(inference[1][0].content, "text"):
+      yield inference[1][0].content.text
+      return
+
     yield "Input: " + str(element.example) + " Output: " + str(
         element.inference[1][0].content.parts[0].text)
 

Reply via email to