Make remaining time of timers available to LLMs (#118696)
* Include speech_slots in IntentResponse.as_dict * Populate speech_slots only if available * fix typo * Add test * test all fields * Fix another test --------- Co-authored-by: Paulus Schoutsen <balloob@gmail.com>pull/119742/head
parent
415bfb40a7
commit
7443878333
|
@ -1362,6 +1362,8 @@ class IntentResponse:
|
|||
|
||||
if self.reprompt:
|
||||
response_dict["reprompt"] = self.reprompt
|
||||
if self.speech_slots:
|
||||
response_dict["speech_slots"] = self.speech_slots
|
||||
|
||||
response_data: dict[str, Any] = {}
|
||||
|
||||
|
|
|
@ -149,8 +149,13 @@ async def test_assist_api(
|
|||
|
||||
assert test_context.json_fragment # To reproduce an error case in tracing
|
||||
intent_response = intent.IntentResponse("*")
|
||||
intent_response.matched_states = [State("light.matched", "on")]
|
||||
intent_response.unmatched_states = [State("light.unmatched", "on")]
|
||||
intent_response.async_set_states(
|
||||
[State("light.matched", "on")], [State("light.unmatched", "on")]
|
||||
)
|
||||
intent_response.async_set_speech("Some speech")
|
||||
intent_response.async_set_card("Card title", "card content")
|
||||
intent_response.async_set_speech_slots({"hello": 1})
|
||||
intent_response.async_set_reprompt("Do it again")
|
||||
tool_input = llm.ToolInput(
|
||||
tool_name="test_intent",
|
||||
tool_args={"area": "kitchen", "floor": "ground_floor"},
|
||||
|
@ -181,8 +186,22 @@ async def test_assist_api(
|
|||
"success": [],
|
||||
"targets": [],
|
||||
},
|
||||
"reprompt": {
|
||||
"plain": {
|
||||
"extra_data": None,
|
||||
"reprompt": "Do it again",
|
||||
},
|
||||
},
|
||||
"response_type": "action_done",
|
||||
"speech": {},
|
||||
"speech": {
|
||||
"plain": {
|
||||
"extra_data": None,
|
||||
"speech": "Some speech",
|
||||
},
|
||||
},
|
||||
"speech_slots": {
|
||||
"hello": 1,
|
||||
},
|
||||
}
|
||||
|
||||
# Call with a device/area/floor
|
||||
|
@ -227,7 +246,21 @@ async def test_assist_api(
|
|||
"targets": [],
|
||||
},
|
||||
"response_type": "action_done",
|
||||
"speech": {},
|
||||
"reprompt": {
|
||||
"plain": {
|
||||
"extra_data": None,
|
||||
"reprompt": "Do it again",
|
||||
},
|
||||
},
|
||||
"speech": {
|
||||
"plain": {
|
||||
"extra_data": None,
|
||||
"speech": "Some speech",
|
||||
},
|
||||
},
|
||||
"speech_slots": {
|
||||
"hello": 1,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue