mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 09:58:07 -04:00
Fix llama.cpp streaming capability reporting (#179886)
This commit is contained in:
@@ -9,7 +9,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import LlamaCppConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .const import CONF_STREAMING, DOMAIN
|
||||
from .entity import LlamaCppBaseLLMEntity
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ class LlamaCppConversationEntity(
|
||||
def __init__(self, entry: ConfigEntry, subentry: ConfigSubentry) -> None:
|
||||
"""Initialize the agent."""
|
||||
super().__init__(entry, subentry)
|
||||
self._attr_supports_streaming = bool(entry.data.get(CONF_STREAMING, False))
|
||||
if self.subentry.data.get(CONF_LLM_HASS_API):
|
||||
self._attr_supported_features = (
|
||||
conversation.ConversationEntityFeature.CONTROL
|
||||
|
||||
@@ -102,6 +102,22 @@ async def test_conversation_entity(
|
||||
assert mock_chat_log.content[1:] == snapshot
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("config_entry_data", "supports_streaming"),
|
||||
[({CONF_STREAMING: True}, True), ({CONF_STREAMING: False}, False)],
|
||||
)
|
||||
async def test_conversation_entity_streaming_support(
|
||||
hass: HomeAssistant, supports_streaming: bool
|
||||
) -> None:
|
||||
"""Verify the conversation entity advertises streaming support."""
|
||||
agent_info = conversation.async_get_agent_info(
|
||||
hass, "conversation.llama_cpp_conversation"
|
||||
)
|
||||
|
||||
assert agent_info is not None
|
||||
assert agent_info.supports_streaming is supports_streaming
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("config_entry_options"), [ASSIST_OPTIONS])
|
||||
async def test_function_call(
|
||||
hass: HomeAssistant,
|
||||
|
||||
Reference in New Issue
Block a user