File size: 2,712 Bytes
d77e9cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
082a8c7
 
 
 
d77e9cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
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)