make history key depended on room

This commit is contained in:
Philipp 2024-04-08 23:25:00 +02:00
parent 144d456694
commit 44cf925e29
Signed by: Philipp
GPG key ID: 9EBD8439AFBAB750
2 changed files with 4 additions and 4 deletions

View file

@ -14,11 +14,11 @@ class History():
return f"gpt-history-user-{id}"
async def reset(self, userData):
key = self.createCacheKey(userData["sender"])
key = self.createCacheKey(userData["sender"] + userData["room_id"])
await self.r.mset(key, null)
async def get(self, userData):
key = self.createCacheKey(userData["sender"])
key = self.createCacheKey(userData["sender"] + userData["room_id"])
history = await self.r.get(key)
if history is not None:
@ -33,7 +33,7 @@ class History():
history.append({ "role": "user", "content": userMessage })
history.append({ "role": "assistant", "content": assistantMessage })
key = self.createCacheKey(userData["sender"])
key = self.createCacheKey(userData["sender"] + userData["room_id"])
history = json.dumps(history)
await self.r.psetex(key, 300_000, history) # 5 mins

View file

@ -1,6 +1,6 @@
maubot: 0.1.0
id: sh.boehm.gpt
version: 0.0.041
version: 0.0.042
license: MIT
modules:
- gpt