mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Add conversation ID to voice dialog (#4189)
This commit is contained in:
parent
5ca82fd39c
commit
ab476d2f1b
@ -9,6 +9,8 @@ interface ProcessResults {
|
||||
|
||||
export const processText = (
|
||||
hass: HomeAssistant,
|
||||
text: string
|
||||
text: string,
|
||||
// tslint:disable-next-line: variable-name
|
||||
conversation_id: string
|
||||
): Promise<ProcessResults> =>
|
||||
hass.callApi("POST", "conversation/process", { text });
|
||||
hass.callApi("POST", "conversation/process", { text, conversation_id });
|
||||
|
@ -22,6 +22,7 @@ import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import { haStyleDialog } from "../../resources/styles";
|
||||
// tslint:disable-next-line
|
||||
import { PaperDialogScrollableElement } from "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
|
||||
import { uid } from "../../common/util/uid";
|
||||
|
||||
interface Message {
|
||||
who: string;
|
||||
@ -62,6 +63,7 @@ export class HaVoiceCommandDialog extends LitElement {
|
||||
@property() private _opened = false;
|
||||
@query("#messages") private messages!: PaperDialogScrollableElement;
|
||||
private recognition?: SpeechRecognition;
|
||||
private _conversationId?: string;
|
||||
|
||||
public async showDialog(): Promise<void> {
|
||||
this._opened = true;
|
||||
@ -166,6 +168,7 @@ export class HaVoiceCommandDialog extends LitElement {
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues) {
|
||||
super.updated(changedProps);
|
||||
this._conversationId = uid();
|
||||
this._conversation = [
|
||||
{
|
||||
who: "hass",
|
||||
@ -258,7 +261,11 @@ export class HaVoiceCommandDialog extends LitElement {
|
||||
// To make sure the answer is placed at the right user text, we add it before we process it
|
||||
this._addMessage(message);
|
||||
try {
|
||||
const response = await processText(this.hass, text);
|
||||
const response = await processText(
|
||||
this.hass,
|
||||
text,
|
||||
this._conversationId!
|
||||
);
|
||||
const plain = response.speech.plain;
|
||||
message.text = plain.speech;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user