make history key depended on room
This commit is contained in:
parent
144d456694
commit
44cf925e29
2 changed files with 4 additions and 4 deletions
|
@ -14,11 +14,11 @@ class History():
|
||||||
return f"gpt-history-user-{id}"
|
return f"gpt-history-user-{id}"
|
||||||
|
|
||||||
async def reset(self, userData):
|
async def reset(self, userData):
|
||||||
key = self.createCacheKey(userData["sender"])
|
key = self.createCacheKey(userData["sender"] + userData["room_id"])
|
||||||
await self.r.mset(key, null)
|
await self.r.mset(key, null)
|
||||||
|
|
||||||
async def get(self, userData):
|
async def get(self, userData):
|
||||||
key = self.createCacheKey(userData["sender"])
|
key = self.createCacheKey(userData["sender"] + userData["room_id"])
|
||||||
history = await self.r.get(key)
|
history = await self.r.get(key)
|
||||||
|
|
||||||
if history is not None:
|
if history is not None:
|
||||||
|
@ -33,7 +33,7 @@ class History():
|
||||||
history.append({ "role": "user", "content": userMessage })
|
history.append({ "role": "user", "content": userMessage })
|
||||||
history.append({ "role": "assistant", "content": assistantMessage })
|
history.append({ "role": "assistant", "content": assistantMessage })
|
||||||
|
|
||||||
key = self.createCacheKey(userData["sender"])
|
key = self.createCacheKey(userData["sender"] + userData["room_id"])
|
||||||
history = json.dumps(history)
|
history = json.dumps(history)
|
||||||
await self.r.psetex(key, 300_000, history) # 5 mins
|
await self.r.psetex(key, 300_000, history) # 5 mins
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
maubot: 0.1.0
|
maubot: 0.1.0
|
||||||
id: sh.boehm.gpt
|
id: sh.boehm.gpt
|
||||||
version: 0.0.041
|
version: 0.0.042
|
||||||
license: MIT
|
license: MIT
|
||||||
modules:
|
modules:
|
||||||
- gpt
|
- gpt
|
||||||
|
|
Loading…
Reference in a new issue