Skip to content

Commit 6be70ef

Browse files
committed
Intialize the client on an executor thread
1 parent 2208650 commit 6be70ef

File tree

1 file changed

+8
-1
lines changed
  • homeassistant/components/google_generative_ai_conversation

1 file changed

+8
-1
lines changed

homeassistant/components/google_generative_ai_conversation/__init__.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,14 @@ async def async_setup_entry(
139139
"""Set up Google Generative AI Conversation from a config entry."""
140140

141141
try:
142-
client = genai.Client(api_key=entry.data[CONF_API_KEY])
142+
client: genai.Client | None = None
143+
144+
def init_client():
145+
nonlocal client
146+
client = genai.Client(api_key=entry.data[CONF_API_KEY])
147+
148+
await hass.async_add_executor_job(init_client)
149+
143150
await client.aio.models.get(
144151
model=entry.options.get(CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL),
145152
config={"http_options": {"timeout": TIMEOUT_MILLIS}},

0 commit comments

Comments
 (0)