Spaces:
Sleeping
Sleeping
Download scripts/llm/services.py from ayushsinghal1510/cropf-ai-api: direct link, hf CLI and curl.
- Browser
- Download file 963 Bytes
-
https://huggingface.co/spaces/ayushsinghal1510/cropf-ai-api/resolve/main/scripts/llm/services.py
- Command line
-
hf download hf://spaces/ayushsinghal1510/cropf-ai-api/scripts/llm/services.py
-
curl -L -o services.py https://huggingface.co/spaces/ayushsinghal1510/cropf-ai-api/resolve/main/scripts/llm/services.py
963 Bytes
| import json | |
| async def load_history(redis_client , session_id) : | |
| # ! ----------------------------only for dev---------------------------- | |
| with open('assets/history/chat.json') as chat_file : history = json.load(chat_file) | |
| if session_id in history : return history[session_id] | |
| else : return [] | |
| # ! -------------------------------------------------------- | |
| # messages = redis_client.get(session_id) | |
| # if messages : return json.loads(messages) | |
| # return [] | |
| async def save_history(redis_client , row , session_id) : | |
| # ! ----------------------------only for Dev---------------------------- | |
| with open('assets/history/chat.json') as chat_file : history = json.load(chat_file) | |
| history[session_id] = row | |
| with open('assets/history/chat.json' , 'w') as chat_file : json.dump(history , chat_file) | |
| # ! -------------------------------------------------------- | |
| # redis_client.set(session_id , json.dumps(row)) |