mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Google Gen AI: Copy messages to avoid changing the trace data (#118745)
This commit is contained in:
parent
299c0de968
commit
035e19be01
@ -225,7 +225,7 @@ class GoogleGenerativeAIConversationEntity(
|
|||||||
messages = self.history[conversation_id]
|
messages = self.history[conversation_id]
|
||||||
else:
|
else:
|
||||||
conversation_id = ulid.ulid_now()
|
conversation_id = ulid.ulid_now()
|
||||||
messages = [{}, {}]
|
messages = [{}, {"role": "model", "parts": "Ok"}]
|
||||||
|
|
||||||
if (
|
if (
|
||||||
user_input.context
|
user_input.context
|
||||||
@ -272,8 +272,11 @@ class GoogleGenerativeAIConversationEntity(
|
|||||||
response=intent_response, conversation_id=conversation_id
|
response=intent_response, conversation_id=conversation_id
|
||||||
)
|
)
|
||||||
|
|
||||||
messages[0] = {"role": "user", "parts": prompt}
|
# Make a copy, because we attach it to the trace event.
|
||||||
messages[1] = {"role": "model", "parts": "Ok"}
|
messages = [
|
||||||
|
{"role": "user", "parts": prompt},
|
||||||
|
*messages[1:],
|
||||||
|
]
|
||||||
|
|
||||||
LOGGER.debug("Input: '%s' with history: %s", user_input.text, messages)
|
LOGGER.debug("Input: '%s' with history: %s", user_input.text, messages)
|
||||||
trace.async_conversation_trace_append(
|
trace.async_conversation_trace_append(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user