gemini-code-assist[bot] commented on code in PR #35751:
URL: https://github.com/apache/beam/pull/35751#discussion_r2245158535
##########
sdks/python/apache_beam/examples/inference/gemini_text_classification.py:
##########
@@ -67,8 +67,11 @@ def parse_known_args(argv):
class PostProcessor(beam.DoFn):
def process(self, element: PredictionResult) -> Iterable[str]:
- yield "Input: " + str(element.example) + " Output: " + str(
- element.inference[1][0].content.parts[0].text)
+ try:
+ output_text = element.inference[1][0].content.parts[0].text
+ yield f"Input: {element.example}, Output: {output_text}"
+ except Exception:
+ yield f"Can't decode inference for element: {element.example}"
Review Comment:

Consider including the error details in the output for better visibility
into what went wrong. For production code, it would be better to log the
exception and catch more specific exception types (e.g., `IndexError`,
`AttributeError`).
```suggestion
except Exception as e:
yield f"Can't decode inference for element: {element.example}, error:
{e}"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]