Fallback memory scope when device/user id missing

This commit is contained in:
Your Name 2025-12-20 12:21:47 -06:00
parent ac18969018
commit ab9bd057e8

View file

@ -190,10 +190,18 @@ class GroqdConversationEntity(
memory_scope = options.get(CONF_MEMORY_SCOPE, DEFAULT_MEMORY_SCOPE) memory_scope = options.get(CONF_MEMORY_SCOPE, DEFAULT_MEMORY_SCOPE)
memory_key = None memory_key = None
if memory_scope == "device" and user_input.device_id: if memory_scope == "device":
memory_key = f"device:{user_input.device_id}" if user_input.device_id:
elif memory_scope == "user" and user_input.context and user_input.context.user_id: memory_key = f"device:{user_input.device_id}"
memory_key = f"user:{user_input.context.user_id}" elif user_input.context and user_input.context.user_id:
memory_key = f"user:{user_input.context.user_id}"
else:
memory_key = "global"
elif memory_scope == "user":
if user_input.context and user_input.context.user_id:
memory_key = f"user:{user_input.context.user_id}"
else:
memory_key = "global"
elif memory_scope == "global": elif memory_scope == "global":
memory_key = "global" memory_key = "global"