Spaces:
Sleeping
Sleeping
File size: 552 Bytes
bfdc0fb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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 [] |