pikamomo's picture
Claude Sonnet 4.6
Add configurable UI settings (colors, font, avatar) to config and admin panel
082a8c7
Raw History Blame Contribute Delete
2.71 kB
"""
Shared configuration helpers for chatbot settings.
Reads/writes config/chatbot_settings.json so that the admin panel
can update texts that the chatbot UI picks up.
"""
import json
import os
_CONFIG_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "config")
_CONFIG_PATH = os.path.join(_CONFIG_DIR, "chatbot_settings.json")
_DEFAULTS = {
"disclaimer": (
"**This tool is designed to provide general HR-related information "
"and draft policy suggestions.**\n\n"
"- This is **NOT** a substitute for professional legal or HR advice\n"
"- For legal compliance and important decisions, consult a qualified "
"attorney or HR professional\n"
"- Do **NOT** share personal information about specific individuals\n\n"
"By using this tool, you acknowledge that you understand these limitations."
),
"welcome_message": (
"👋 **Welcome to the HR Intervals AI Assistant!**\n\n"
"⚠️ **Important Disclaimer:**\n\n"
"This tool is designed to provide general HR-related information and "
"draft policy suggestions. It is not a substitute for professional "
"legal or HR advice. For legal compliance and to ensure the best "
"outcome for your organization, we recommend consulting a qualified "
"attorney or HR professional before implementing any policies or "
"making decisions based on the information provided.\n\n"
"---\n\n"
"How can I help you today? **Try asking:**\n\n"
"• What should I include in a remote work policy?\n"
"• How do I handle employee terminations properly?\n"
"• What are best practices for hiring in Canada?\n"
"• Tell me about workplace safety requirements"
),
"bot_avatar_url": "https://em-content.zobj.net/thumbs/120/apple/354/robot_1f916.png",
"primary_color": "#0066cc",
"secondary_color": "#f0f4f8",
"font_family": "Arial, sans-serif",
}
def load_settings() -> dict:
"""Return the current chatbot settings, falling back to defaults."""
if os.path.exists(_CONFIG_PATH):
try:
with open(_CONFIG_PATH, "r", encoding="utf-8") as f:
data = json.load(f)
for key, default_val in _DEFAULTS.items():
data.setdefault(key, default_val)
return data
except (json.JSONDecodeError, OSError):
pass
return dict(_DEFAULTS)
def save_settings(settings: dict) -> None:
"""Persist chatbot settings to disk."""
os.makedirs(_CONFIG_DIR, exist_ok=True)
with open(_CONFIG_PATH, "w", encoding="utf-8") as f:
json.dump(settings, f, ensure_ascii=False, indent=2)