Spaces:
Sleeping
Sleeping
feat(prospection): ICP constants with all paid providers off by default
Browse files- .env.example +11 -0
- prospection/config.py +69 -0
- requirements.txt +2 -0
- tests/test_prospection_config.py +40 -0
.env.example
CHANGED
|
@@ -15,3 +15,14 @@ TAVILY_API_KEY=
|
|
| 15 |
# Two keys rotate to stay under the per-key rate limit
|
| 16 |
ALPHAVANTAGE_API_KEY_1=
|
| 17 |
ALPHAVANTAGE_API_KEY_2=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Two keys rotate to stay under the per-key rate limit
|
| 16 |
ALPHAVANTAGE_API_KEY_1=
|
| 17 |
ALPHAVANTAGE_API_KEY_2=
|
| 18 |
+
|
| 19 |
+
# --- prospection (tous les providers payants sont opt-in) ---
|
| 20 |
+
PROSPECTION_EXPLORIUM_ENABLED=false
|
| 21 |
+
PROSPECTION_DROPCONTACT_ENABLED=false
|
| 22 |
+
PROSPECTION_DROPCONTACT_API_KEY=
|
| 23 |
+
PROSPECTION_LINKEDIN_ENABLED=false
|
| 24 |
+
PROSPECTION_LINKEDIN_PROVIDER=
|
| 25 |
+
PROSPECTION_LINKEDIN_API_KEY=
|
| 26 |
+
PROSPECTION_SENDER_NAME=
|
| 27 |
+
PROSPECTION_SENDER_EMAIL=
|
| 28 |
+
PROSPECTION_OPTOUT_EMAIL=
|
prospection/config.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""prospection/config.py — constantes de ciblage, plafonds et drapeaux providers.
|
| 2 |
+
|
| 3 |
+
Toute valeur numérique reprise de la spec y figure verbatim : ce module est
|
| 4 |
+
la seule source de vérité, aucun autre fichier ne code un seuil en dur.
|
| 5 |
+
"""
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
import os
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
AMF_CSV_URL = "https://www.data.gouv.fr/api/1/datasets/r/2220f808-8908-4afc-98e3-cf74a25678e2"
|
| 12 |
+
CACHE_DIR = Path("data/prospection_cache")
|
| 13 |
+
|
| 14 |
+
TIER1_PROVISIONAL_CAP = 60
|
| 15 |
+
TIER1_FINAL_CAP = 40
|
| 16 |
+
TIER1_MIN_SCORE = 65
|
| 17 |
+
MIN_FIT = 25
|
| 18 |
+
TIER2_MIN_SCORE = 40
|
| 19 |
+
MAX_EMAIL_WORDS = 150
|
| 20 |
+
RETENTION_YEARS = 3
|
| 21 |
+
|
| 22 |
+
# Exclusions dures : classes d'actifs sans émetteur coté à dépôts périodiques.
|
| 23 |
+
EXCLUDED_ACTIVITY_KEYWORDS = frozenset({
|
| 24 |
+
"immobilier", "scpi", "opci", "capital investissement", "private equity",
|
| 25 |
+
"dette privée", "infrastructure", "actifs forestiers", "actifs numériques",
|
| 26 |
+
"titrisation", "capital-investissement",
|
| 27 |
+
})
|
| 28 |
+
|
| 29 |
+
# Marqueurs de filiale de grand groupe → Tier 3, conservé mais non travaillé.
|
| 30 |
+
GROUP_PARENT_MARKERS = (
|
| 31 |
+
"amundi", "bnp paribas", "axa investment", "ostrum", "natixis",
|
| 32 |
+
"indosuez", "la banque postale", "rothschild & co", "société générale",
|
| 33 |
+
"credit agricole", "crédit agricole", "bpce", "candriam", "edmond de rothschild",
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
# Marqueurs de poche actions cotées dans les libellés d'activité AMF.
|
| 37 |
+
EQUITY_ACTIVITY_MARKERS = ("opcvm", "fia", "actions", "gestion sous mandat")
|
| 38 |
+
|
| 39 |
+
# type -> (points, durée de vie en jours)
|
| 40 |
+
SIGNAL_WEIGHTS: dict[str, tuple[int, int]] = {
|
| 41 |
+
"job_posting": (15, 60),
|
| 42 |
+
"leadership_hire": (12, 90),
|
| 43 |
+
"new_fund": (10, 120),
|
| 44 |
+
"recent_licence": (8, 540),
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
# Adresses qui n'identifient personne : hors champ RGPD, mais non nominatives.
|
| 48 |
+
GENERIC_LOCAL_PARTS = frozenset({
|
| 49 |
+
"contact", "info", "accueil", "communication", "commercial",
|
| 50 |
+
"hello", "bonjour", "service-client", "reporting",
|
| 51 |
+
})
|
| 52 |
+
|
| 53 |
+
_ALWAYS_ON = frozenset({"pattern"})
|
| 54 |
+
_TRUTHY = frozenset({"1", "true", "yes", "on"})
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def provider_enabled(name: str) -> bool:
|
| 58 |
+
"""`pattern` est gratuit et toujours actif ; tout provider payant est opt-in."""
|
| 59 |
+
if name in _ALWAYS_ON:
|
| 60 |
+
return True
|
| 61 |
+
return os.getenv(f"PROSPECTION_{name.upper()}_ENABLED", "").strip().lower() in _TRUTHY
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def sender_identity() -> dict:
|
| 65 |
+
return {
|
| 66 |
+
"name": os.getenv("PROSPECTION_SENDER_NAME", ""),
|
| 67 |
+
"email": os.getenv("PROSPECTION_SENDER_EMAIL", ""),
|
| 68 |
+
"optout_email": os.getenv("PROSPECTION_OPTOUT_EMAIL", ""),
|
| 69 |
+
}
|
requirements.txt
CHANGED
|
@@ -18,4 +18,6 @@ pytest>=8.0.0
|
|
| 18 |
pytest-mock>=3.12.0
|
| 19 |
plotly>=5.20.0
|
| 20 |
langgraph-cli[inmem]>=0.1.0
|
|
|
|
|
|
|
| 21 |
fpdf2>=2.7.0
|
|
|
|
| 18 |
pytest-mock>=3.12.0
|
| 19 |
plotly>=5.20.0
|
| 20 |
langgraph-cli[inmem]>=0.1.0
|
| 21 |
+
pdfplumber>=0.11.0
|
| 22 |
+
dnspython>=2.6.0
|
| 23 |
fpdf2>=2.7.0
|
tests/test_prospection_config.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""tests/test_prospection_config.py — constantes ICP et drapeaux providers."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
from prospection import config
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def test_paid_providers_are_disabled_when_env_absent(monkeypatch):
|
| 8 |
+
for var in ("PROSPECTION_EXPLORIUM_ENABLED", "PROSPECTION_DROPCONTACT_ENABLED",
|
| 9 |
+
"PROSPECTION_LINKEDIN_ENABLED"):
|
| 10 |
+
monkeypatch.delenv(var, raising=False)
|
| 11 |
+
assert config.provider_enabled("explorium") is False
|
| 12 |
+
assert config.provider_enabled("dropcontact") is False
|
| 13 |
+
assert config.provider_enabled("linkedin") is False
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def test_provider_enabled_accepts_common_truthy_spellings(monkeypatch):
|
| 17 |
+
for value in ("true", "TRUE", "1", "yes"):
|
| 18 |
+
monkeypatch.setenv("PROSPECTION_EXPLORIUM_ENABLED", value)
|
| 19 |
+
assert config.provider_enabled("explorium") is True
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def test_pattern_provider_is_always_enabled():
|
| 23 |
+
assert config.provider_enabled("pattern") is True
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def test_caps_match_the_spec():
|
| 27 |
+
assert config.TIER1_PROVISIONAL_CAP == 60
|
| 28 |
+
assert config.TIER1_FINAL_CAP == 40
|
| 29 |
+
assert config.TIER1_MIN_SCORE == 65
|
| 30 |
+
assert config.MIN_FIT == 25
|
| 31 |
+
assert config.TIER2_MIN_SCORE == 40
|
| 32 |
+
assert config.MAX_EMAIL_WORDS == 150
|
| 33 |
+
assert config.RETENTION_YEARS == 3
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def test_signal_weights_carry_weight_and_ttl_days():
|
| 37 |
+
assert config.SIGNAL_WEIGHTS["job_posting"] == (15, 60)
|
| 38 |
+
assert config.SIGNAL_WEIGHTS["leadership_hire"] == (12, 90)
|
| 39 |
+
assert config.SIGNAL_WEIGHTS["new_fund"] == (10, 120)
|
| 40 |
+
assert config.SIGNAL_WEIGHTS["recent_licence"] == (8, 540)
|