diff --git a/homeassistant/components/google_generative_ai_conversation/conversation.py b/homeassistant/components/google_generative_ai_conversation/conversation.py index f84bd81f80c..ed50ed69a02 100644 --- a/homeassistant/components/google_generative_ai_conversation/conversation.py +++ b/homeassistant/components/google_generative_ai_conversation/conversation.py @@ -221,7 +221,7 @@ class GoogleGenerativeAIConversationEntity( api_prompt = await llm_api.async_get_api_prompt(empty_tool_input) else: - api_prompt = llm.PROMPT_NO_API_CONFIGURED + api_prompt = llm.async_render_no_api_prompt(self.hass) prompt = "\n".join( ( diff --git a/homeassistant/components/openai_conversation/conversation.py b/homeassistant/components/openai_conversation/conversation.py index be3b8ea9126..eb2f0911a20 100644 --- a/homeassistant/components/openai_conversation/conversation.py +++ b/homeassistant/components/openai_conversation/conversation.py @@ -138,7 +138,7 @@ class OpenAIConversationEntity( api_prompt = await llm_api.async_get_api_prompt(empty_tool_input) else: - api_prompt = llm.PROMPT_NO_API_CONFIGURED + api_prompt = llm.async_render_no_api_prompt(self.hass) prompt = "\n".join( ( diff --git a/homeassistant/helpers/llm.py b/homeassistant/helpers/llm.py index 08125acc0da..e09af97620c 100644 --- a/homeassistant/helpers/llm.py +++ b/homeassistant/helpers/llm.py @@ -23,10 +23,14 @@ from .singleton import singleton LLM_API_ASSIST = "assist" -PROMPT_NO_API_CONFIGURED = ( - "Only if the user wants to control a device, tell them to edit the AI configuration " - "and allow access to Home Assistant." -) + +@callback +def async_render_no_api_prompt(hass: HomeAssistant) -> str: + """Return the prompt to be used when no API is configured.""" + return ( + "Only if the user wants to control a device, tell them to edit the AI configuration " + "and allow access to Home Assistant." + ) @singleton("llm")