home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.03k stars 28.28k forks source link

Avoid exceptions when Gemini responses are blocked #116847

Closed tronikos closed 1 week ago

tronikos commented 1 week ago

Breaking change

Proposed change

For offensive queries the library sometimes throws BlockedPromptException or StopCandidateException which are already caught but other times it just returns empty parts which causes a ValueError when converted to text. Avoid that by responding with: "Sorry, I had a problem talking to Google Generative AI. Likely blocked"

(Ignore the dependency upgrade, that is being done in https://github.com/home-assistant/core/pull/116845)

Type of change

Additional information

Checklist

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

To help with the load of incoming pull requests: