File size: 4,314 Bytes
85ba912
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
from dataclasses import dataclass
from typing import Dict


# --- Core platform config (caps, hashtags, emojis) ---


@dataclass
class PlatformConfig:
    """
    Basic platform constraints used by the validator and pipelines.
    """
    name: str
    char_cap: int
    hashtags_max: int
    emoji_max: int

    @property
    def cap(self) -> int:
        """
        Backwards-compatible alias for char_cap.
        Some older code might reference .cap instead of .char_cap.
        """
        return self.char_cap


# Character caps and simple rules per platform.
PLATFORM_RULES: Dict[str, PlatformConfig] = {
    "Instagram": PlatformConfig(
        name="Instagram",
        char_cap=2200,
        hashtags_max=5,
        emoji_max=5,
    ),
    "Facebook": PlatformConfig(
        name="Facebook",
        char_cap=125,
        hashtags_max=0,
        emoji_max=1,
    ),
    "LinkedIn": PlatformConfig(
        name="LinkedIn",
        char_cap=3000,
        hashtags_max=3,
        emoji_max=2,
    ),
    "Twitter": PlatformConfig(
        name="Twitter",
        char_cap=280,
        hashtags_max=2,
        emoji_max=2,
    ),
}

DEFAULT_PLATFORM_NAME: str = "Instagram"


# --- Banned phrase map (for safer language) ---


# Regex patterns mapped to replacement phrases.
# The validator will use this to make copy less spammy / risky.
BANNED_MAP: Dict[str, str] = {
    r"\bguarantee(d|s)?\b": "aim to",
    r"\bno[-\s]?risk\b": "low risk",
    # Add more patterns as needed
}


# --- Platform style profiles (Phase 3) ---


# Each entry describes how copy should "feel" on that platform.
# These are used at prompt level in chat_chain so the LLM
# clearly understands the expectations per platform.
PLATFORM_STYLES: Dict[str, Dict] = {
    "Instagram": {
        "name": "Instagram",
        "voice": (
            "fun, casual, and energetic. Speak like a friendly social media manager "
            "talking to followers."
        ),
        "emoji_guideline": (
            "Emojis are welcome. Use them to enhance the energy of the post, "
            "but avoid clutter."
        ),
        "hashtag_guideline": (
            "Use 3–5 relevant hashtags at the end of the post. "
            "Hashtags should be short, readable, and on-topic."
        ),
        "length_guideline": "Short to medium length caption is ideal.",
    },
    "Facebook": {
        "name": "Facebook",
        "voice": (
            "friendly and conversational, but slightly more explanatory than Instagram."
        ),
        "emoji_guideline": (
            "Emojis are allowed, but use them sparingly for emphasis only."
        ),
        "hashtag_guideline": (
            "One or two hashtags are okay, but they are optional. "
            "Focus more on clear, readable text."
        ),
        "length_guideline": "Short to medium length post with a clear main message.",
    },
    "LinkedIn": {
        "name": "LinkedIn",
        "voice": (
            "professional, clear, and value-focused. "
            "Write like a marketer speaking to working professionals."
        ),
        "emoji_guideline": (
            "Avoid or minimize emojis. If used at all, keep them professional and sparse."
        ),
        "hashtag_guideline": (
            "1–3 relevant, professional hashtags are acceptable at the end. "
            "Do not overuse hashtags."
        ),
        "length_guideline": (
            "Short to medium length update. Prioritize clarity and professionalism."
        ),
    },
    "Twitter": {
        "name": "Twitter",
        "voice": (
            "short, punchy, and attention-grabbing. "
            "Get to the point quickly."
        ),
        "emoji_guideline": (
            "Emojis are fine but keep them minimal and highly relevant."
        ),
        "hashtag_guideline": (
            "1–2 strong, relevant hashtags max. Avoid hashtag spam."
        ),
        "length_guideline": "Very concise. Every word should earn its place.",
    },
}

DEFAULT_PLATFORM_STYLE: Dict = PLATFORM_STYLES.get("Instagram")


def get_platform_style(name: str) -> Dict:
    """
    Return a style profile dict for a given platform name.

    If the platform is unknown, fall back to DEFAULT_PLATFORM_STYLE.
    """
    return PLATFORM_STYLES.get(name, DEFAULT_PLATFORM_STYLE)