mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Avoid duplicate chat log content (#139679)
This commit is contained in:
parent
03cb177e7c
commit
dca77e8232
@ -49,7 +49,11 @@ def async_get_chat_log(
|
||||
raise RuntimeError(
|
||||
"Cannot attach chat log delta listener unless initial caller"
|
||||
)
|
||||
if user_input is not None:
|
||||
if user_input is not None and (
|
||||
(content := chat_log.content[-1]).role != "user"
|
||||
# MyPy doesn't understand that content is a UserContent here
|
||||
or content.content != user_input.text # type: ignore[union-attr]
|
||||
):
|
||||
chat_log.async_add_user_content(UserContent(content=user_input.text))
|
||||
|
||||
yield chat_log
|
||||
|
@ -86,7 +86,9 @@ async def test_default_content(
|
||||
with (
|
||||
chat_session.async_get_chat_session(hass) as session,
|
||||
async_get_chat_log(hass, session, mock_conversation_input) as chat_log,
|
||||
async_get_chat_log(hass, session, mock_conversation_input) as chat_log2,
|
||||
):
|
||||
assert chat_log is chat_log2
|
||||
assert len(chat_log.content) == 2
|
||||
assert chat_log.content[0].role == "system"
|
||||
assert chat_log.content[0].content == ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user