googleapis / python-aiplatform

A Python SDK for Vertex AI, a fully managed, end-to-end platform for data science and machine learning.
Apache License 2.0
628 stars 340 forks source link

`list index out of range` when following function call with responses #3702

Open dudizimber opened 5 months ago

dudizimber commented 5 months ago

https://github.com/googleapis/python-aiplatform/blame/b8b589ce9fff29d1721450d32b4a84a7f69413c3/vertexai/generative_models/_generative_models.py#L920

The above line throws a list index out of range error when the response returns with no candidates.

Ark-kun commented 5 months ago

Can you please provide code that is causing this issue for you so that I can help you?

Are you using send_message or generate_content?

Responses lack candidates when they are blocked. A blocked response results in exception when using ChatSession. If you want to manually handle blocked responses, please use generate_content instead of send_message.