1 """Agent foundation for conversation integration."""
3 from __future__
import annotations
5 from abc
import ABC, abstractmethod
6 from dataclasses
import dataclass
7 from typing
import Any, Literal
13 @dataclass(frozen=True)
15 """Container for conversation agent info."""
21 @dataclass(slots=True)
23 """User input to be processed."""
26 """User spoken text."""
29 """Context of the request."""
31 conversation_id: str |
None
32 """Unique identifier for the conversation."""
35 """Unique identifier for the device."""
38 """Language of the request."""
40 agent_id: str |
None =
None
41 """Agent to use for processing."""
44 @dataclass(slots=True)
46 """Result of async_process."""
48 response: intent.IntentResponse
49 conversation_id: str |
None =
None
52 """Return result as a dict."""
54 "response": self.response.
as_dict(),
55 "conversation_id": self.conversation_id,
60 """Abstract conversation agent."""
65 """Return a list of supported languages."""
68 async
def async_process(self, user_input: ConversationInput) -> ConversationResult:
69 """Process a sentence."""
72 """Clear cached intents for a language."""
75 """Load intents for a language."""
None async_prepare(self, str|None language=None)
None async_reload(self, str|None language=None)
ConversationResult async_process(self, ConversationInput user_input)
list[str]|Literal["*"] supported_languages(self)
dict[str, Any] as_dict(self)