opengpts
opengpts copied to clipboard
Great. But cannot delete items (items, threads, etc...)
It will be nice to delete items also ;).
Currently I am deleting in redis, which is hard.
Please, can you tell me how to remove threads from Redis? I am also facing the same problem. Thanks a lot.
I created a script that does it:
import os
from redis.client import Redis as RedisType
from langchain.utilities.redis import get_client
import sys
def _get_redis_client() -> RedisType:
"""Get a Redis client."""
url = os.environ.get("REDIS_URL")
if not url:
raise ValueError("REDIS_URL not set")
return get_client(url)
def clean(user_id: str) -> bool:
client = _get_redis_client()
keys_threads = client.keys(f"opengpts:{user_id}:thread:*")
client.delete(*keys_threads)
client.delete(f"opengpts:{user_id}:threads")
return True
if __name__ == "__main__":
user_id = sys.argv[1]
if not user_id:
raise ValueError("user_id not set")
clean(user_id)