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 memory_scope == "device":
|
||||||
if user_input.device_id:
|
if user_input.device_id:
|
||||||
memory_key = f"device:{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:
|
elif user_input.context and user_input.context.user_id:
|
||||||
memory_key = f"user:{user_input.context.user_id}"
|
memory_key = f"user:{user_input.context.user_id}"
|
||||||
else:
|
else:
|
||||||
|
|
@ -200,28 +202,22 @@ class GroqdConversationEntity(
|
||||||
elif memory_scope == "user":
|
elif memory_scope == "user":
|
||||||
if user_input.context and user_input.context.user_id:
|
if user_input.context and user_input.context.user_id:
|
||||||
memory_key = f"user:{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:
|
else:
|
||||||
memory_key = "global"
|
memory_key = "global"
|
||||||
elif memory_scope == "global":
|
elif memory_scope == "global":
|
||||||
memory_key = "global"
|
memory_key = "global"
|
||||||
|
|
||||||
if user_input.conversation_id is None:
|
if user_input.conversation_id is not None:
|
||||||
if memory_key and memory_key in self._memory_index:
|
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]
|
conversation_id = self._memory_index[memory_key]
|
||||||
history = self.history.get(conversation_id, [])
|
history = self.history.get(conversation_id, [])
|
||||||
else:
|
else:
|
||||||
conversation_id = ulid.ulid_now()
|
conversation_id = ulid.ulid_now()
|
||||||
history = []
|
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 (
|
if (
|
||||||
user_input.context
|
user_input.context
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue