From ff5461c84af49ee577a24a922de2fc44578deba2 Mon Sep 17 00:00:00 2001 From: ltechdnb <93867035+ltechdnb@users.noreply.github.com> Date: Tue, 1 Dec 2026 17:36:29 +0000 Subject: [PATCH] Move llama.cpp chat initialization off the event loop (#195244) --- homeassistant/components/llama_cpp/api.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/llama_cpp/api.py b/homeassistant/components/llama_cpp/api.py index 6fce2905f2fa..ba259d29b33f 100644 --- a/homeassistant/components/llama_cpp/api.py +++ b/homeassistant/components/llama_cpp/api.py @@ -64,9 +64,13 @@ async def async_create_client( base_url=config_entry_data[CONF_BASE_URL], http_client=get_async_client(hass), ) - # Cache current platform data which gets added to each request - # (caching done by library) - _ = await hass.async_add_executor_job(client.platform_headers) + + def warm_up_client() -> None: + """Cache platform headers and resolve the SDK's lazy chat resources.""" + client.platform_headers() + _ = client.chat.completions + + await hass.async_add_executor_job(warm_up_client) return client