Update intent response (#83962)

* Add language to conversation and intent response

* Move language to intent response instead of speech

* Extend intent response for voice MVP

* Add tests for error conditions in conversation/process

* Move intent response type data into "data" field

* Move intent response error message back to speech

* Remove "success" from intent response

* Add id to target in intent response

* target defaults to None

* Update homeassistant/helpers/intent.py

* Fix test

* Return conversation_id and multiple targets

* Clean up git mess

* Fix linting errors

* Fix more async_handle signatures

* Separate conversation_id and IntentResponse

* Add unknown error code

* Add ConversationResult

* Don't set domain on single entity

* Language is required for intent response

* Add partial_action_done

* Default language in almond agent

* Remove partial_action_done

* Fix linting

* Rename success/fail targets

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Michael Hansen 2022-12-13 22:32:30 -06:00 committed by GitHub
parent da62528526
commit 98eabd2f68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 38 deletions

View file

@ -143,13 +143,13 @@ async def test_http_processing_intent(hass, hass_client, hass_admin_user):
}
},
"language": hass.config.language,
"data": {"targets": []},
"data": {"targets": [], "success": [], "failed": []},
},
"conversation_id": None,
}
async def test_http_partial_action(hass, hass_client, hass_admin_user):
async def test_http_failed_action(hass, hass_client, hass_admin_user):
"""Test processing intent via HTTP API with a partial completion."""
class TestIntentHandler(intent.IntentHandler):
@ -161,24 +161,24 @@ async def test_http_partial_action(hass, hass_client, hass_admin_user):
"""Handle the intent."""
response = handle_intent.create_response()
area = handle_intent.slots["area"]["value"]
# Mark some targets as successful, others as failed
response.async_set_targets(
[
intent_targets=[
intent.IntentResponseTarget(
type=intent.IntentResponseTargetType.AREA, name=area, id=area
)
]
)
# Mark some targets as successful, others as failed
response.async_set_partial_action_done(
success_targets=[
response.async_set_results(
success_results=[
intent.IntentResponseTarget(
type=intent.IntentResponseTargetType.ENTITY,
name="light1",
id="light.light1",
)
],
failed_targets=[
failed_results=[
intent.IntentResponseTarget(
type=intent.IntentResponseTargetType.ENTITY,
name="light2",
@ -186,6 +186,7 @@ async def test_http_partial_action(hass, hass_client, hass_admin_user):
)
],
)
return response
intent.async_register(hass, TestIntentHandler())
@ -211,7 +212,7 @@ async def test_http_partial_action(hass, hass_client, hass_admin_user):
assert data == {
"response": {
"response_type": "partial_action_done",
"response_type": "action_done",
"card": {},
"speech": {},
"language": hass.config.language,
@ -298,13 +299,15 @@ async def test_http_api(hass, init_components, hass_client):
"language": hass.config.language,
"response_type": "action_done",
"data": {
"targets": [
"targets": [],
"success": [
{
"type": "entity",
"name": "kitchen",
"id": "light.kitchen",
},
]
],
"failed": [],
},
},
"conversation_id": None,
@ -468,7 +471,7 @@ async def test_custom_agent(hass, hass_client, hass_admin_user):
}
},
"language": "test-language",
"data": {"targets": []},
"data": {"targets": [], "success": [], "failed": []},
},
"conversation_id": "test-conv-id",
}