Spaces:
Sleeping
Sleeping
Download redis_utils.py from taha454/CodeBuddyAI: direct link, hf CLI and curl.
- Browser
- Download file 382 Bytes
-
https://huggingface.co/spaces/taha454/CodeBuddyAI/resolve/main/redis_utils.py
- Command line
-
hf download hf://spaces/taha454/CodeBuddyAI/redis_utils.py
-
curl -L -o redis_utils.py https://huggingface.co/spaces/taha454/CodeBuddyAI/resolve/main/redis_utils.py
382 Bytes
| import json | |
| import os | |
| import redis | |
| import yaml | |
| from utils import yaml_path | |
| def redis_send(redis_conn,user_id, chat_id, answer): | |
| with open(yaml_path, 'r') as file: | |
| parameters_obj = yaml.safe_load(file) | |
| REDIS_TTL = parameters_obj.get("REDIS_TTL", 7200) | |
| return redis_conn.set(f"ANSWER_FOR_USER_ID{user_id}_OF_{chat_id}", json.dumps(answer), ex=REDIS_TTL) | |