From 44cf925e290ad48a8611c788d0e4a3e8c933aa40 Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 8 Apr 2024 23:25:00 +0200 Subject: [PATCH] make history key depended on room --- gpt/history.py | 6 +++--- maubot.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gpt/history.py b/gpt/history.py index 6721a31..4c0cfd4 100644 --- a/gpt/history.py +++ b/gpt/history.py @@ -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 diff --git a/maubot.yaml b/maubot.yaml index 846fded..60ccd19 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: sh.boehm.gpt -version: 0.0.041 +version: 0.0.042 license: MIT modules: - gpt