mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Add LLM tools (#115464)
* Add llm helper * break out Tool.specification as class members * Format state output * Fix intent tests * Removed auto initialization of intents - let conversation platforms do that * Handle DynamicServiceIntentHandler.extra_slots * Add optional description to IntentTool init * Add device_id and conversation_id parameters * intent tests * Add LLM tools tests * coverage * add agent_id parameter * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Fix tests * Fix intent schema * Allow a Python function to be registered as am LLM tool * Add IntentHandler.effective_slot_schema * Ensure IntentHandler.slot_schema to be vol.Schema * Raise meaningful error on tool not found * Move this change to a separate PR * Update todo integration intent * Remove Tool constructor * Move IntentTool to intent helper * Convert custom serializer into class method * Remove tool_input from FunctionTool auto arguments to avoid recursion * Remove conversion into Open API format * Apply suggestions from code review * Fix tests * Use HassKey for helpers (see #117012) * Add support for functions with typed lists, dicts, and sets as type hints * Remove FunctionTool * Added API to get registered intents * Move IntentTool to the llm library * Return only handlers in intents.async.get * Removed llm tool registration from intent library * Removed tool registration * Add bind_hass back for now * removed area and floor resolving * fix test * Apply suggestions from code review * Improve coverage * Fix intent_type type * Temporary disable HassClimateGetTemperature intent * Remove bind_hass * Fix usage of slot schema * Fix test * Revert some test changes * Don't mutate tool_input --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
@@ -610,7 +610,7 @@ def test_async_register(hass: HomeAssistant) -> None:
|
||||
|
||||
intent.async_register(hass, handler)
|
||||
|
||||
assert hass.data[intent.DATA_KEY]["test_intent"] == handler
|
||||
assert list(intent.async_get(hass)) == [handler]
|
||||
|
||||
|
||||
def test_async_register_overwrite(hass: HomeAssistant) -> None:
|
||||
@@ -629,7 +629,7 @@ def test_async_register_overwrite(hass: HomeAssistant) -> None:
|
||||
"Intent %s is being overwritten by %s", "test_intent", handler2
|
||||
)
|
||||
|
||||
assert hass.data[intent.DATA_KEY]["test_intent"] == handler2
|
||||
assert list(intent.async_get(hass)) == [handler2]
|
||||
|
||||
|
||||
def test_async_remove(hass: HomeAssistant) -> None:
|
||||
@@ -640,7 +640,7 @@ def test_async_remove(hass: HomeAssistant) -> None:
|
||||
intent.async_register(hass, handler)
|
||||
intent.async_remove(hass, "test_intent")
|
||||
|
||||
assert "test_intent" not in hass.data[intent.DATA_KEY]
|
||||
assert not list(intent.async_get(hass))
|
||||
|
||||
|
||||
def test_async_remove_no_existing_entry(hass: HomeAssistant) -> None:
|
||||
@@ -651,7 +651,7 @@ def test_async_remove_no_existing_entry(hass: HomeAssistant) -> None:
|
||||
|
||||
intent.async_remove(hass, "test_intent2")
|
||||
|
||||
assert "test_intent2" not in hass.data[intent.DATA_KEY]
|
||||
assert list(intent.async_get(hass)) == [handler]
|
||||
|
||||
|
||||
def test_async_remove_no_existing(hass: HomeAssistant) -> None:
|
||||
|
||||
Reference in New Issue
Block a user