mirror of
https://github.com/sudoxreboot/groqd
synced 2026-04-14 11:36:49 +00:00
Honor conversation_id and use browser fallback for device memory
This commit is contained in:
parent
ab9bd057e8
commit
b964c74a9e
1 changed files with 10 additions and 14 deletions
|
|
@ -193,6 +193,8 @@ class GroqdConversationEntity(
|
|||
if memory_scope == "device":
|
||||
if user_input.device_id:
|
||||
memory_key = f"device:{user_input.device_id}"
|
||||
elif user_input.conversation_id:
|
||||
memory_key = f"conv:{user_input.conversation_id}"
|
||||
elif user_input.context and user_input.context.user_id:
|
||||
memory_key = f"user:{user_input.context.user_id}"
|
||||
else:
|
||||
|
|
@ -200,28 +202,22 @@ class GroqdConversationEntity(
|
|||
elif memory_scope == "user":
|
||||
if user_input.context and user_input.context.user_id:
|
||||
memory_key = f"user:{user_input.context.user_id}"
|
||||
elif user_input.conversation_id:
|
||||
memory_key = f"conv:{user_input.conversation_id}"
|
||||
else:
|
||||
memory_key = "global"
|
||||
elif memory_scope == "global":
|
||||
memory_key = "global"
|
||||
|
||||
if user_input.conversation_id is None:
|
||||
if memory_key and memory_key in self._memory_index:
|
||||
if user_input.conversation_id is not None:
|
||||
conversation_id = user_input.conversation_id
|
||||
history = self.history.get(conversation_id, [])
|
||||
elif memory_key and memory_key in self._memory_index:
|
||||
conversation_id = self._memory_index[memory_key]
|
||||
history = self.history.get(conversation_id, [])
|
||||
else:
|
||||
conversation_id = ulid.ulid_now()
|
||||
history = []
|
||||
elif user_input.conversation_id in self.history:
|
||||
conversation_id = user_input.conversation_id
|
||||
history = self.history[conversation_id]
|
||||
else:
|
||||
try:
|
||||
ulid.ulid_to_bytes(user_input.conversation_id)
|
||||
conversation_id = ulid.ulid_now()
|
||||
except ValueError:
|
||||
conversation_id = user_input.conversation_id
|
||||
history = []
|
||||
|
||||
if (
|
||||
user_input.context
|
||||
|
|
|
|||
Loading…
Reference in a new issue