Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.llm Namespace Reference

Classes

class  API
 
class  APIInstance
 
class  AssistAPI
 
class  IntentTool
 
class  LLMContext
 
class  ScriptTool
 
class  Tool
 
class  ToolInput
 

Functions

dict[str, API_async_get_apis (HomeAssistant hass)
 
tuple[str|None, vol.Schema] _get_cached_script_parameters (HomeAssistant hass, str entity_id)
 
dict[str, dict[str, Any]] _get_exposed_entities (HomeAssistant hass, str assistant)
 
Any _selector_serializer (Any schema)
 
APIInstance async_get_api (HomeAssistant hass, str api_id, LLMContext llm_context)
 
list[APIasync_get_apis (HomeAssistant hass)
 
None async_register_api (HomeAssistant hass, API api)
 
str async_render_no_api_prompt (HomeAssistant hass)
 

Variables

tuple BASE_PROMPT
 
string DEFAULT_INSTRUCTIONS_PROMPT
 
string LLM_API_ASSIST = "assist"
 

Detailed Description

Module to coordinate llm tools.

Function Documentation

◆ _async_get_apis()

dict[str, API] homeassistant.helpers.llm._async_get_apis ( HomeAssistant  hass)
private
Get all the LLM APIs.

Definition at line 80 of file llm.py.

◆ _get_cached_script_parameters()

tuple[str | None, vol.Schema] homeassistant.helpers.llm._get_cached_script_parameters ( HomeAssistant  hass,
str   entity_id 
)
private
Get script description and schema.

Definition at line 611 of file llm.py.

◆ _get_exposed_entities()

dict[str, dict[str, Any]] homeassistant.helpers.llm._get_exposed_entities ( HomeAssistant  hass,
str   assistant 
)
private
Get exposed entities.

Definition at line 422 of file llm.py.

◆ _selector_serializer()

Any homeassistant.helpers.llm._selector_serializer ( Any  schema)
private
Convert selectors into OpenAPI schema.

Definition at line 503 of file llm.py.

◆ async_get_api()

APIInstance homeassistant.helpers.llm.async_get_api ( HomeAssistant  hass,
str  api_id,
LLMContext   llm_context 
)
Get an API.

Definition at line 98 of file llm.py.

◆ async_get_apis()

list[API] homeassistant.helpers.llm.async_get_apis ( HomeAssistant  hass)
Get all the LLM APIs.

Definition at line 111 of file llm.py.

◆ async_register_api()

None homeassistant.helpers.llm.async_register_api ( HomeAssistant  hass,
API  api 
)
Register an API to be exposed to LLMs.

Definition at line 88 of file llm.py.

◆ async_render_no_api_prompt()

str homeassistant.helpers.llm.async_render_no_api_prompt ( HomeAssistant  hass)
Return the prompt to be used when no API is configured.

No longer used since Home Assistant 2024.7.

Definition at line 70 of file llm.py.

Variable Documentation

◆ BASE_PROMPT

tuple homeassistant.helpers.llm.BASE_PROMPT
Initial value:
1 = (
2  'Current time is {{ now().strftime("%H:%M:%S") }}. '
3  'Today\'s date is {{ now().strftime("%Y-%m-%d") }}.\n'
4 )

Definition at line 58 of file llm.py.

◆ DEFAULT_INSTRUCTIONS_PROMPT

string homeassistant.helpers.llm.DEFAULT_INSTRUCTIONS_PROMPT
Initial value:
1 = """You are a voice assistant for Home Assistant.
2 Answer questions about the world truthfully.
3 Answer in plain text. Keep it simple and to the point.
4 """

Definition at line 63 of file llm.py.

◆ LLM_API_ASSIST

string homeassistant.helpers.llm.LLM_API_ASSIST = "assist"

Definition at line 56 of file llm.py.