Spaces:
Sleeping
Sleeping
Download utils.py from BATUTO-ART/Bot_batutoBAD: direct link, hf CLI and curl.
- Browser
- Download file 552 Bytes
-
https://huggingface.co/spaces/BATUTO-ART/Bot_batutoBAD/resolve/refs%2Fpr%2F1/utils.py
- Command line
-
hf download hf://spaces/BATUTO-ART/Bot_batutoBAD@refs/pr/1/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/BATUTO-ART/Bot_batutoBAD/resolve/refs%2Fpr%2F1/utils.py
552 Bytes
| import json | |
| import os | |
| from datetime import datetime | |
| def detect_language(text: str) -> str: | |
| if any(char in 'áéíóúñÁÉÍÓÚÑ¿¡' for char in text): | |
| return "es" | |
| return "en" | |
| def save_history(history, filename="chat_history.json"): | |
| with open(filename, "w", encoding="utf-8") as f: | |
| json.dump(history, f, ensure_ascii=False, indent=2) | |
| def load_history(filename="chat_history.json"): | |
| if os.path.exists(filename): | |
| with open(filename, "r", encoding="utf-8") as f: | |
| return json.load(f) | |
| return [] |