Skip to content

Commit

Permalink
Track if intent was processed locally (#132166)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbede authored and frenck committed Dec 4, 2024
1 parent 629c7a5 commit 49c40cd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
8 changes: 7 additions & 1 deletion homeassistant/components/assist_pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ async def recognize_intent(
"intent_input": intent_input,
"conversation_id": conversation_id,
"device_id": device_id,
"prefer_local_intents": self.pipeline.prefer_local_intents,
},
)
)
Expand All @@ -1031,6 +1032,7 @@ async def recognize_intent(
language=self.pipeline.language,
agent_id=self.intent_agent,
)
processed_locally = self.intent_agent == conversation.HOME_ASSISTANT_AGENT

conversation_result: conversation.ConversationResult | None = None
if user_input.agent_id != conversation.HOME_ASSISTANT_AGENT:
Expand Down Expand Up @@ -1061,6 +1063,7 @@ async def recognize_intent(
response=intent_response,
conversation_id=user_input.conversation_id,
)
processed_locally = True

if conversation_result is None:
# Fall back to pipeline conversation agent
Expand All @@ -1085,7 +1088,10 @@ async def recognize_intent(
self.process_event(
PipelineEvent(
PipelineEventType.INTENT_END,
{"intent_output": conversation_result.as_dict()},
{
"processed_locally": processed_locally,
"intent_output": conversation_result.as_dict(),
},
)
)

Expand Down
8 changes: 8 additions & 0 deletions tests/components/assist_pipeline/snapshots/test_init.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'test transcript',
'language': 'en',
'prefer_local_intents': False,
}),
'type': <PipelineEventType.INTENT_START: 'intent-start'>,
}),
Expand All @@ -60,6 +61,7 @@
}),
}),
}),
'processed_locally': True,
}),
'type': <PipelineEventType.INTENT_END: 'intent-end'>,
}),
Expand Down Expand Up @@ -126,6 +128,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'test transcript',
'language': 'en-US',
'prefer_local_intents': False,
}),
'type': <PipelineEventType.INTENT_START: 'intent-start'>,
}),
Expand All @@ -149,6 +152,7 @@
}),
}),
}),
'processed_locally': True,
}),
'type': <PipelineEventType.INTENT_END: 'intent-end'>,
}),
Expand Down Expand Up @@ -215,6 +219,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'test transcript',
'language': 'en-US',
'prefer_local_intents': False,
}),
'type': <PipelineEventType.INTENT_START: 'intent-start'>,
}),
Expand All @@ -238,6 +243,7 @@
}),
}),
}),
'processed_locally': True,
}),
'type': <PipelineEventType.INTENT_END: 'intent-end'>,
}),
Expand Down Expand Up @@ -328,6 +334,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'test transcript',
'language': 'en',
'prefer_local_intents': False,
}),
'type': <PipelineEventType.INTENT_START: 'intent-start'>,
}),
Expand All @@ -351,6 +358,7 @@
}),
}),
}),
'processed_locally': True,
}),
'type': <PipelineEventType.INTENT_END: 'intent-end'>,
}),
Expand Down
16 changes: 16 additions & 0 deletions tests/components/assist_pipeline/snapshots/test_websocket.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'test transcript',
'language': 'en',
'prefer_local_intents': False,
})
# ---
# name: test_audio_pipeline.4
Expand All @@ -58,6 +59,7 @@
}),
}),
}),
'processed_locally': True,
})
# ---
# name: test_audio_pipeline.5
Expand Down Expand Up @@ -117,6 +119,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'test transcript',
'language': 'en',
'prefer_local_intents': False,
})
# ---
# name: test_audio_pipeline_debug.4
Expand All @@ -139,6 +142,7 @@
}),
}),
}),
'processed_locally': True,
})
# ---
# name: test_audio_pipeline_debug.5
Expand Down Expand Up @@ -210,6 +214,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'test transcript',
'language': 'en',
'prefer_local_intents': False,
})
# ---
# name: test_audio_pipeline_with_enhancements.4
Expand All @@ -232,6 +237,7 @@
}),
}),
}),
'processed_locally': True,
})
# ---
# name: test_audio_pipeline_with_enhancements.5
Expand Down Expand Up @@ -313,6 +319,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'test transcript',
'language': 'en',
'prefer_local_intents': False,
})
# ---
# name: test_audio_pipeline_with_wake_word_no_timeout.6
Expand All @@ -335,6 +342,7 @@
}),
}),
}),
'processed_locally': True,
})
# ---
# name: test_audio_pipeline_with_wake_word_no_timeout.7
Expand Down Expand Up @@ -519,6 +527,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'Are the lights on?',
'language': 'en',
'prefer_local_intents': False,
})
# ---
# name: test_intent_failed.2
Expand All @@ -541,6 +550,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'Are the lights on?',
'language': 'en',
'prefer_local_intents': False,
})
# ---
# name: test_intent_timeout.2
Expand Down Expand Up @@ -569,6 +579,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'never mind',
'language': 'en',
'prefer_local_intents': False,
})
# ---
# name: test_pipeline_empty_tts_output.2
Expand All @@ -592,6 +603,7 @@
}),
}),
}),
'processed_locally': True,
})
# ---
# name: test_pipeline_empty_tts_output.3
Expand Down Expand Up @@ -680,6 +692,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'Are the lights on?',
'language': 'en',
'prefer_local_intents': False,
})
# ---
# name: test_text_only_pipeline[extra_msg0].2
Expand All @@ -702,6 +715,7 @@
}),
}),
}),
'processed_locally': True,
})
# ---
# name: test_text_only_pipeline[extra_msg0].3
Expand All @@ -724,6 +738,7 @@
'engine': 'conversation.home_assistant',
'intent_input': 'Are the lights on?',
'language': 'en',
'prefer_local_intents': False,
})
# ---
# name: test_text_only_pipeline[extra_msg1].2
Expand All @@ -746,6 +761,7 @@
}),
}),
}),
'processed_locally': True,
})
# ---
# name: test_text_only_pipeline[extra_msg1].3
Expand Down

0 comments on commit 49c40cd

Please sign in to comment.