Files
2024-12-12 13:21:43 +01:00

17 lines
469 B
Python

import redis
def cache_prompt_to_redis(prompt, response):
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
r.set(prompt, response)
r.close()
def load_response_from_redis(prompt):
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
response = r.get(prompt)
r.close()
return response
def flush_redis():
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
r.flushall()
r.close()