Spaces:
Sleeping
Sleeping
Piers Lyon Claude Opus 4.6 commited on
Commit ·
b8f40ca
1
Parent(s): 7922906
Refactor into multipage Streamlit app with new intelligence features
Browse filesSplit monolithic app.py into multipage architecture with dedicated pages
for Dashboard, Approach Brief, Tenders, Councils, LinkedIn Hub,
Intelligence Query, and Source Health. Extract shared UI components into
ui_components.py. Add AI query engine (query_engine.py) for natural-language
lookups and LinkedIn activity generator (linkedin_activity.py) for daily
engagement playbooks. Remove deprecated cqc_radar.py. Expand config.yaml
with new source definitions and enhance collator, email engine, network
loader, hunter, and LinkedIn modules.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- app.py +153 -1241
- collator.py +225 -18
- config.yaml +497 -99
- cqc_radar.py +0 -350
- email_engine.py +85 -0
- financials.py +4 -0
- hunter.py +8 -8
- linkedin_activity.py +635 -0
- linkedin_intel.py +9 -3
- linkedin_relationship.py +7 -8
- network_loader.py +89 -0
- pages/2_Approach_Brief.py +502 -0
- pages/3_Tenders.py +130 -0
- pages/4_Councils.py +165 -0
- pages/6_Intelligence.py +227 -0
- pages/7_Source_Health.py +181 -0
- query_engine.py +0 -0
- requirements.txt +1 -0
- ui_components.py +1157 -0
app.py
CHANGED
|
@@ -1,14 +1,10 @@
|
|
| 1 |
"""
|
| 2 |
-
Curium
|
| 3 |
-
|
| 4 |
"""
|
| 5 |
|
| 6 |
import streamlit as st
|
| 7 |
import time
|
| 8 |
-
import json as _json
|
| 9 |
-
from datetime import datetime
|
| 10 |
-
from urllib.parse import quote as url_quote
|
| 11 |
-
import pandas as pd
|
| 12 |
import os
|
| 13 |
from pathlib import Path
|
| 14 |
from dotenv import load_dotenv
|
|
@@ -19,15 +15,8 @@ load_dotenv(dotenv_path=env_path, override=True)
|
|
| 19 |
|
| 20 |
# Import modules
|
| 21 |
from network_loader import init_network_tables, get_network_stats, load_master_csv
|
| 22 |
-
from
|
| 23 |
-
|
| 24 |
-
draft_colleague_intro_request, draft_batch_colleague_summary,
|
| 25 |
-
)
|
| 26 |
-
from collator import (
|
| 27 |
-
init_company_db, get_top_companies, get_company_stats,
|
| 28 |
-
get_company_dossier, clear_all_data as clear_collator_data,
|
| 29 |
-
get_top_linkedin_actions
|
| 30 |
-
)
|
| 31 |
|
| 32 |
|
| 33 |
def check_api_key():
|
|
@@ -45,507 +34,165 @@ def run_autonomous_hunt(status_container=None):
|
|
| 45 |
return run_hunt(min_score=50, progress_callback=progress_callback)
|
| 46 |
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
if value >= 1_000_000:
|
| 52 |
-
return f"£{value/1_000_000:.1f}M"
|
| 53 |
-
elif value >= 1_000:
|
| 54 |
-
return f"£{value/1_000:.0f}K"
|
| 55 |
-
return f"£{value:.0f}"
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
def render_dossier_tabs(dossier, company_id_prefix, show_network=True, show_action=True):
|
| 59 |
-
"""Shared tab renderer for company dossiers.
|
| 60 |
-
|
| 61 |
-
Eliminates duplicated tab rendering code between Network Opportunities
|
| 62 |
-
and Company Dossiers sections.
|
| 63 |
-
"""
|
| 64 |
-
tab_labels = ["💼 Jobs", "📰 News", "📄 Reports", "🏥 CQC", "😐 Sentiment", "🤝 M&A", "🔍 LI Intel"]
|
| 65 |
-
if show_network:
|
| 66 |
-
tab_labels.append("🔗 Network")
|
| 67 |
-
if show_action:
|
| 68 |
-
tab_labels.append("✉️ Action")
|
| 69 |
-
|
| 70 |
-
detail_tabs = st.tabs(tab_labels)
|
| 71 |
-
|
| 72 |
-
# Jobs tab
|
| 73 |
-
with detail_tabs[0]:
|
| 74 |
-
if dossier.jobs:
|
| 75 |
-
for job in dossier.jobs:
|
| 76 |
-
job_score = job.get('score', 0)
|
| 77 |
-
job_emoji = "🔥" if job_score >= 80 else "✅" if job_score >= 60 else "📋"
|
| 78 |
-
st.markdown(f"**{job_emoji} {job.get('title', 'Unknown Role')}** (Score: {job_score})")
|
| 79 |
-
if job.get('analysis'):
|
| 80 |
-
analysis = job['analysis']
|
| 81 |
-
st.caption(analysis[:200] + "..." if len(analysis) > 200 else analysis)
|
| 82 |
-
if job.get('url'):
|
| 83 |
-
st.markdown(f"[View Job →]({job['url']})")
|
| 84 |
-
st.divider()
|
| 85 |
-
else:
|
| 86 |
-
st.caption("No job signals")
|
| 87 |
-
|
| 88 |
-
# News tab
|
| 89 |
-
with detail_tabs[1]:
|
| 90 |
-
if dossier.news:
|
| 91 |
-
for news in dossier.news:
|
| 92 |
-
urgency = news.get('urgency', 'low')
|
| 93 |
-
urgency_emoji = "🔴" if urgency == 'high' else "🟡" if urgency == 'medium' else "🟢"
|
| 94 |
-
st.markdown(f"**{urgency_emoji} {news.get('headline', 'Unknown')}**")
|
| 95 |
-
if news.get('trigger'):
|
| 96 |
-
reason = news.get('reason', '')
|
| 97 |
-
st.caption(f"**Trigger:** {news['trigger']} | {reason[:100]}" if reason else f"**Trigger:** {news['trigger']}")
|
| 98 |
-
if news.get('url'):
|
| 99 |
-
st.markdown(f"[Read Article →]({news['url']})")
|
| 100 |
-
st.divider()
|
| 101 |
-
else:
|
| 102 |
-
st.caption("No news signals")
|
| 103 |
-
|
| 104 |
-
# Annual Reports tab
|
| 105 |
-
with detail_tabs[2]:
|
| 106 |
-
if dossier.annual_reports:
|
| 107 |
-
for report in dossier.annual_reports:
|
| 108 |
-
report_score = report.get('score', 0)
|
| 109 |
-
score_emoji = "🔥" if report_score >= 60 else "📄"
|
| 110 |
-
urgency = report.get('urgency', 'low')
|
| 111 |
-
urgency_emoji = "🔴" if urgency == 'high' else "🟡" if urgency == 'medium' else "🟢"
|
| 112 |
-
|
| 113 |
-
st.markdown(f"**{score_emoji} Annual Report** (Score: {report_score}) {urgency_emoji}")
|
| 114 |
-
st.caption(f"Filing date: {report.get('filing_date', 'Unknown')}")
|
| 115 |
-
|
| 116 |
-
if report.get('summary'):
|
| 117 |
-
st.markdown(report['summary'])
|
| 118 |
-
|
| 119 |
-
signals = report.get('signals_found', '')
|
| 120 |
-
if signals:
|
| 121 |
-
try:
|
| 122 |
-
signal_list = _json.loads(signals) if isinstance(signals, str) else signals
|
| 123 |
-
if signal_list:
|
| 124 |
-
st.markdown("**Signals:** " + ", ".join(signal_list))
|
| 125 |
-
except Exception:
|
| 126 |
-
st.markdown(f"**Signals:** {signals}")
|
| 127 |
-
|
| 128 |
-
quotes = report.get('key_quotes', '')
|
| 129 |
-
if quotes:
|
| 130 |
-
try:
|
| 131 |
-
quote_list = _json.loads(quotes) if isinstance(quotes, str) else quotes
|
| 132 |
-
if quote_list:
|
| 133 |
-
st.markdown("**Key Quotes:**")
|
| 134 |
-
for q in quote_list[:3]:
|
| 135 |
-
st.caption(f'> "{q}"')
|
| 136 |
-
except Exception:
|
| 137 |
-
pass
|
| 138 |
-
|
| 139 |
-
if report.get('document_url'):
|
| 140 |
-
st.markdown(f"[View on Companies House →]({report['document_url']})")
|
| 141 |
-
st.divider()
|
| 142 |
-
else:
|
| 143 |
-
st.caption("No annual report signals")
|
| 144 |
-
|
| 145 |
-
# CQC tab
|
| 146 |
-
with detail_tabs[3]:
|
| 147 |
-
if dossier.cqc_signals:
|
| 148 |
-
for cqc in dossier.cqc_signals:
|
| 149 |
-
rating = cqc.get('current_rating', 'Unknown')
|
| 150 |
-
if rating == "Inadequate":
|
| 151 |
-
st.error(f"CQC Rating: {rating} (Score: {cqc.get('cqc_score', 0)})")
|
| 152 |
-
elif rating == "Requires improvement":
|
| 153 |
-
st.warning(f"CQC Rating: {rating} (Score: {cqc.get('cqc_score', 0)})")
|
| 154 |
-
else:
|
| 155 |
-
st.info(f"CQC Rating: {rating} (Score: {cqc.get('cqc_score', 0)})")
|
| 156 |
-
|
| 157 |
-
if cqc.get('is_downgrade') == 1:
|
| 158 |
-
prev = cqc.get('previous_rating', 'Unknown')
|
| 159 |
-
severity = cqc.get('downgrade_severity', '')
|
| 160 |
-
st.error(f"DOWNGRADED from {prev} ({severity})")
|
| 161 |
-
|
| 162 |
-
st.caption(f"Type: {cqc.get('provider_type', 'Unknown')} | Region: {cqc.get('region', 'Unknown')}")
|
| 163 |
-
if cqc.get('inspection_date'):
|
| 164 |
-
st.caption(f"Inspection: {cqc['inspection_date'][:10]}")
|
| 165 |
-
|
| 166 |
-
activities = cqc.get('regulated_activities', '')
|
| 167 |
-
if activities:
|
| 168 |
-
try:
|
| 169 |
-
activity_list = _json.loads(activities) if isinstance(activities, str) else activities
|
| 170 |
-
if activity_list:
|
| 171 |
-
st.caption(f"Activities: {', '.join(activity_list[:3])}")
|
| 172 |
-
except Exception:
|
| 173 |
-
pass
|
| 174 |
-
|
| 175 |
-
if cqc.get('cqc_url'):
|
| 176 |
-
st.markdown(f"[View CQC Profile →]({cqc['cqc_url']})")
|
| 177 |
-
st.divider()
|
| 178 |
-
else:
|
| 179 |
-
st.caption("No CQC signals")
|
| 180 |
-
|
| 181 |
-
# Sentiment tab
|
| 182 |
-
with detail_tabs[4]:
|
| 183 |
-
if dossier.sentiment_signals:
|
| 184 |
-
for sent in dossier.sentiment_signals:
|
| 185 |
-
overall = sent.get('overall_rating', 0)
|
| 186 |
-
if overall and overall < 3.0:
|
| 187 |
-
rating_emoji = "🔴"
|
| 188 |
-
elif overall and overall < 3.5:
|
| 189 |
-
rating_emoji = "🟠"
|
| 190 |
-
elif overall and overall < 4.0:
|
| 191 |
-
rating_emoji = "🟡"
|
| 192 |
-
else:
|
| 193 |
-
rating_emoji = "🟢"
|
| 194 |
-
|
| 195 |
-
stars = "★" * int(overall) + "☆" * (5 - int(overall)) if overall else "N/A"
|
| 196 |
-
st.markdown(f"**{rating_emoji} Overall: {overall}/5** {stars} (Score: {sent.get('sentiment_score', 0)})")
|
| 197 |
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
if mgmt:
|
| 204 |
-
mgmt_emoji = "🔴" if mgmt < 2.5 else "🟠" if mgmt < 3.0 else "🟡"
|
| 205 |
-
st.caption(f"{mgmt_emoji} Management: {mgmt}/5")
|
| 206 |
-
else:
|
| 207 |
-
st.caption("Management: N/A")
|
| 208 |
-
with sub_cols[1]:
|
| 209 |
-
if culture:
|
| 210 |
-
cult_emoji = "🔴" if culture < 2.5 else "🟠" if culture < 3.0 else "🟡"
|
| 211 |
-
st.caption(f"{cult_emoji} Culture: {culture}/5")
|
| 212 |
-
else:
|
| 213 |
-
st.caption("Culture: N/A")
|
| 214 |
-
with sub_cols[2]:
|
| 215 |
-
if wl:
|
| 216 |
-
st.caption(f"Work/Life: {wl}/5")
|
| 217 |
-
else:
|
| 218 |
-
st.caption("Work/Life: N/A")
|
| 219 |
-
|
| 220 |
-
reviews = sent.get('review_count', 0)
|
| 221 |
-
if reviews:
|
| 222 |
-
st.caption(f"Based on {reviews} reviews")
|
| 223 |
-
if sent.get('signal_reason'):
|
| 224 |
-
st.info(sent['signal_reason'])
|
| 225 |
-
if sent.get('source_url'):
|
| 226 |
-
st.markdown(f"[View on Indeed →]({sent['source_url']})")
|
| 227 |
-
st.divider()
|
| 228 |
-
else:
|
| 229 |
-
st.caption("No sentiment data")
|
| 230 |
-
|
| 231 |
-
# M&A tab
|
| 232 |
-
with detail_tabs[5]:
|
| 233 |
-
if dossier.pe_deals:
|
| 234 |
-
for deal in dossier.pe_deals:
|
| 235 |
-
is_pe = deal.get('is_pe_deal', 0) == 1
|
| 236 |
-
if is_pe:
|
| 237 |
-
type_badge = "🟣 PE Buyout"
|
| 238 |
-
elif deal.get('deal_type') == 'mbo':
|
| 239 |
-
type_badge = "🔵 MBO"
|
| 240 |
-
elif deal.get('deal_type') == 'merger':
|
| 241 |
-
type_badge = "🟤 Merger"
|
| 242 |
-
else:
|
| 243 |
-
type_badge = "🟢 Trade Acquisition"
|
| 244 |
-
|
| 245 |
-
st.markdown(f"**{type_badge}** (Score: {deal.get('pe_score', 0)})")
|
| 246 |
-
st.markdown(f"Acquirer: **{deal.get('acquirer_name', 'Unknown')}**")
|
| 247 |
-
|
| 248 |
-
info_cols = st.columns(2)
|
| 249 |
-
with info_cols[0]:
|
| 250 |
-
if deal.get('deal_date'):
|
| 251 |
-
st.caption(f"Deal date: {deal['deal_date'][:10]}")
|
| 252 |
-
if deal.get('deal_value'):
|
| 253 |
-
st.caption(f"Value: {deal['deal_value']}")
|
| 254 |
-
with info_cols[1]:
|
| 255 |
-
st.caption(f"Source: {deal.get('source', 'Unknown')}")
|
| 256 |
-
|
| 257 |
-
if deal.get('signal_reason'):
|
| 258 |
-
st.info(deal['signal_reason'][:150])
|
| 259 |
-
if deal.get('source_url'):
|
| 260 |
-
st.markdown(f"[View Source →]({deal['source_url']})")
|
| 261 |
-
st.divider()
|
| 262 |
-
else:
|
| 263 |
-
st.caption("No M&A signals")
|
| 264 |
-
|
| 265 |
-
# LinkedIn Intelligence tab
|
| 266 |
-
with detail_tabs[6]:
|
| 267 |
-
li_intel = getattr(dossier, 'linkedin_intel', [])
|
| 268 |
-
if li_intel:
|
| 269 |
-
# Compute action score for each contact using company score
|
| 270 |
-
company_score = dossier.overall_score or 0
|
| 271 |
-
def _action_score(i):
|
| 272 |
-
return (company_score // 2
|
| 273 |
-
+ (20 if i.get('posts_about_transformation') else 0)
|
| 274 |
-
+ (10 if i.get('contact_active') else 0)
|
| 275 |
-
+ (10 if i.get('mutual_connections', 0) > 0 else 0))
|
| 276 |
-
|
| 277 |
-
sorted_intel = sorted(li_intel, key=_action_score, reverse=True)
|
| 278 |
-
best = sorted_intel[0]
|
| 279 |
-
best_via = best.get('colleague_name', '?')
|
| 280 |
-
|
| 281 |
-
# Summary banner
|
| 282 |
-
act_now = sum(1 for i in li_intel if _action_score(i) >= 70)
|
| 283 |
-
warm_count = sum(1 for i in li_intel if 50 <= _action_score(i) < 70)
|
| 284 |
-
posting_count = sum(1 for i in li_intel if i.get('posts_about_transformation'))
|
| 285 |
-
banner_parts = [f"**{len(li_intel)} contacts**"]
|
| 286 |
-
if act_now:
|
| 287 |
-
banner_parts.append(f"🔴 {act_now} Act Now")
|
| 288 |
-
if warm_count:
|
| 289 |
-
banner_parts.append(f"🟡 {warm_count} Warm")
|
| 290 |
-
if posting_count:
|
| 291 |
-
banner_parts.append(f"📢 {posting_count} posting about transformation")
|
| 292 |
-
banner_parts.append(f"Best route: via **{best_via}**")
|
| 293 |
-
st.markdown(" | ".join(banner_parts))
|
| 294 |
-
|
| 295 |
-
for intel in sorted_intel:
|
| 296 |
-
a_score = _action_score(intel)
|
| 297 |
-
contact_name = intel.get('contact_name', 'Unknown')
|
| 298 |
-
contact_title = intel.get('contact_title', 'Unknown')
|
| 299 |
-
colleague = intel.get('colleague_name', 'Unknown')
|
| 300 |
-
|
| 301 |
-
# Colour + urgency based on action score
|
| 302 |
-
if a_score >= 70:
|
| 303 |
-
border_color = "#d32f2f"
|
| 304 |
-
urgency = "🔴 ACT TODAY"
|
| 305 |
-
elif a_score >= 50:
|
| 306 |
-
border_color = "#f57c00"
|
| 307 |
-
urgency = "🟡 WARM — REACH OUT THIS WEEK"
|
| 308 |
-
elif a_score >= 30:
|
| 309 |
-
border_color = "#1976d2"
|
| 310 |
-
urgency = "🔵 WORTH A LOOK"
|
| 311 |
-
else:
|
| 312 |
-
border_color = "#9e9e9e"
|
| 313 |
-
urgency = "⚪ MONITOR"
|
| 314 |
-
|
| 315 |
-
# Signal badges
|
| 316 |
-
badges = []
|
| 317 |
-
if intel.get('posts_about_transformation'):
|
| 318 |
-
badges.append("📢 Posting about transformation")
|
| 319 |
-
if intel.get('contact_active'):
|
| 320 |
-
badges.append("✅ Active")
|
| 321 |
-
degree = intel.get('connection_degree', '?')
|
| 322 |
-
badges.append(f"🔗 {degree}° via {colleague}")
|
| 323 |
-
mutual = intel.get('mutual_connections', 0)
|
| 324 |
-
if mutual:
|
| 325 |
-
badges.append(f"👥 {mutual} mutual")
|
| 326 |
-
badge_str = " · ".join(badges)
|
| 327 |
-
|
| 328 |
-
# Smart route-in message
|
| 329 |
-
route_parts = []
|
| 330 |
-
route_parts.append(f"Ask <strong>{colleague}</strong> to introduce you to {contact_name.split()[0] if contact_name else 'them'}")
|
| 331 |
-
if intel.get('posts_about_transformation'):
|
| 332 |
-
route_parts.append("they're posting about transformation — perfect opener")
|
| 333 |
-
if intel.get('contact_active'):
|
| 334 |
-
route_parts.append("active on LinkedIn right now")
|
| 335 |
-
route_msg = " — ".join(route_parts)
|
| 336 |
-
|
| 337 |
-
route_html = f"""
|
| 338 |
-
<div style="background:#e3f2fd;border-left:4px solid #1565c0;padding:8px 12px;margin:8px 0;border-radius:4px;">
|
| 339 |
-
<strong>YOUR ROUTE IN:</strong> {route_msg}
|
| 340 |
-
</div>"""
|
| 341 |
-
|
| 342 |
-
card_html = f"""
|
| 343 |
-
<div style="border-left:5px solid {border_color};padding:10px 14px;margin:8px 0;background:#fafafa;border-radius:6px;">
|
| 344 |
-
<div style="display:flex;justify-content:space-between;align-items:center;">
|
| 345 |
-
<span style="font-weight:700;font-size:0.85em;">{urgency}</span>
|
| 346 |
-
<span style="font-size:0.85em;color:#555;">Action: {a_score}</span>
|
| 347 |
-
</div>
|
| 348 |
-
<div style="font-size:1.05em;margin:4px 0;"><strong>{contact_name}</strong> — {contact_title}</div>
|
| 349 |
-
<div style="font-size:0.85em;color:#666;">{badge_str}</div>
|
| 350 |
-
{route_html}
|
| 351 |
-
</div>"""
|
| 352 |
-
st.markdown(card_html, unsafe_allow_html=True)
|
| 353 |
-
|
| 354 |
-
# Transformation alert
|
| 355 |
-
if intel.get('posts_about_transformation'):
|
| 356 |
-
st.success("🚀 This contact is posting about transformation — perfect conversation opener!")
|
| 357 |
-
|
| 358 |
-
if intel.get('contact_url'):
|
| 359 |
-
st.markdown(f"[View LinkedIn Profile →]({intel['contact_url']})")
|
| 360 |
-
|
| 361 |
-
st.divider()
|
| 362 |
-
else:
|
| 363 |
-
st.caption("No LinkedIn intelligence — run a hunt with LinkedIn Deep enabled")
|
| 364 |
-
|
| 365 |
-
# Network tab (optional)
|
| 366 |
-
tab_idx = 7
|
| 367 |
-
if show_network:
|
| 368 |
-
with detail_tabs[tab_idx]:
|
| 369 |
-
if dossier.network:
|
| 370 |
-
for net in dossier.network:
|
| 371 |
-
tier = net.get('tier', '')
|
| 372 |
-
if tier == 'DIRECT HIT':
|
| 373 |
-
emoji = "🎯"
|
| 374 |
-
elif tier == 'SENIOR CONNECTION':
|
| 375 |
-
emoji = "⭐"
|
| 376 |
-
else:
|
| 377 |
-
emoji = "🔗"
|
| 378 |
-
col1, col2 = st.columns([3, 1])
|
| 379 |
-
with col1:
|
| 380 |
-
st.markdown(f"**{emoji} {net.get('contact', 'Unknown')}**")
|
| 381 |
-
st.caption(f"Position: {net.get('position', 'Unknown')} | Via: **{net.get('colleague', 'Unknown')}**")
|
| 382 |
-
with col2:
|
| 383 |
-
st.caption(f"Tier: {tier}")
|
| 384 |
-
st.divider()
|
| 385 |
-
else:
|
| 386 |
-
st.caption("No network connections")
|
| 387 |
-
tab_idx += 1
|
| 388 |
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
with detail_tabs[tab_idx]:
|
| 392 |
-
if dossier.network and dossier.network_status != "Cold":
|
| 393 |
-
draft_key = f"draft_{company_id_prefix}_{dossier.id}"
|
| 394 |
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
best_net = dossier.network[0] if dossier.network else {}
|
| 398 |
-
draft = draft_warm_intro_email(
|
| 399 |
-
colleague_name=best_net.get('colleague', 'Your colleague'),
|
| 400 |
-
contact_name=best_net.get('contact', 'Contact'),
|
| 401 |
-
contact_company=dossier.name,
|
| 402 |
-
contact_position=best_net.get('position', 'the team')
|
| 403 |
-
)
|
| 404 |
-
st.session_state[draft_key] = draft
|
| 405 |
-
st.rerun()
|
| 406 |
|
| 407 |
-
|
| 408 |
-
draft = st.session_state[draft_key]
|
| 409 |
-
st.markdown(f"**Subject:** {draft.subject}")
|
| 410 |
-
copyable = get_copyable_email(draft)
|
| 411 |
-
st.code(copyable['full_text'], language=None)
|
| 412 |
-
st.caption("👆 Copy this email")
|
| 413 |
-
if st.button("❌ Close", key=f"close_{draft_key}"):
|
| 414 |
-
del st.session_state[draft_key]
|
| 415 |
-
st.rerun()
|
| 416 |
-
else:
|
| 417 |
-
st.caption("No network connection - cold outreach required")
|
| 418 |
-
st.info("Consider finding a mutual connection before reaching out.")
|
| 419 |
|
|
|
|
|
|
|
|
|
|
| 420 |
|
| 421 |
-
|
| 422 |
-
st.
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
|
|
|
|
|
|
| 426 |
)
|
| 427 |
|
| 428 |
-
|
| 429 |
-
init_network_tables()
|
| 430 |
-
has_api_key = check_api_key()
|
| 431 |
-
|
| 432 |
-
# ============ SIDEBAR ============
|
| 433 |
-
with st.sidebar:
|
| 434 |
-
st.header("🎯 Sales Hunter")
|
| 435 |
-
st.caption("Company-Centric Intelligence")
|
| 436 |
-
|
| 437 |
-
st.divider()
|
| 438 |
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
|
|
|
| 443 |
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
if not has_api_key:
|
| 457 |
-
st.warning("⚠️ Add ANTHROPIC_API_KEY to .env")
|
| 458 |
|
| 459 |
-
|
| 460 |
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
council_status = st.empty()
|
| 464 |
-
council_progress = st.container()
|
| 465 |
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
|
|
|
|
|
|
|
|
|
| 469 |
|
| 470 |
-
|
| 471 |
-
from council_scanner import run_council_scan
|
| 472 |
|
| 473 |
-
|
| 474 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
|
| 476 |
-
|
| 477 |
-
summary = council_results.get('summary', {})
|
| 478 |
-
st.success(
|
| 479 |
-
f"✅ {council_results['network_hits']} connections, "
|
| 480 |
-
f"{council_results['tenders']} tenders, "
|
| 481 |
-
f"{council_results['jobs']} jobs, "
|
| 482 |
-
f"{council_results['news']} news, "
|
| 483 |
-
f"{council_results['people']} contacts"
|
| 484 |
-
)
|
| 485 |
-
time.sleep(1)
|
| 486 |
-
st.rerun()
|
| 487 |
-
except Exception as e:
|
| 488 |
-
st.error(f"Council scan failed: {e}")
|
| 489 |
|
| 490 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 491 |
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
stats = get_company_stats()
|
| 496 |
-
c1, c2 = st.columns(2)
|
| 497 |
-
c1.metric("Companies", stats['total_companies'])
|
| 498 |
-
c2.metric("🔥 Hot", stats['hot_companies'])
|
| 499 |
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
|
| 504 |
-
|
| 505 |
-
st.caption(f"{stats['total_news']} news | {stats['total_tenders']} tenders | {stats.get('total_reports', 0)} reports")
|
| 506 |
-
st.caption(f"{stats.get('total_cqc', 0)} CQC | {stats.get('total_sentiment', 0)} sentiment | {stats.get('total_pe_deals', 0)} M&A | {stats.get('total_linkedin_intel', 0)} LI intel")
|
| 507 |
-
except Exception as e:
|
| 508 |
-
st.caption(f"No data yet")
|
| 509 |
|
| 510 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
|
| 512 |
-
|
| 513 |
-
st.subheader("🔗 Network")
|
| 514 |
-
try:
|
| 515 |
-
net_stats = get_network_stats()
|
| 516 |
-
st.caption(f"{net_stats.get('total_connections', 0)} connections loaded")
|
| 517 |
-
except:
|
| 518 |
-
st.caption("No network data")
|
| 519 |
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
ext = uploaded_file.name.rsplit('.', 1)[-1].lower() if '.' in uploaded_file.name else 'csv'
|
| 532 |
-
file_path = f"data/my_team_connections.{ext}"
|
| 533 |
|
| 534 |
-
|
| 535 |
-
|
| 536 |
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
st.error(f"Import failed: {result.get('error', 'Unknown error')}")
|
| 544 |
|
| 545 |
-
|
| 546 |
|
| 547 |
-
|
| 548 |
-
|
|
|
|
| 549 |
try:
|
| 550 |
from linkedin_intel import get_linkedin_session_status
|
| 551 |
li_status = get_linkedin_session_status()
|
|
@@ -556,14 +203,14 @@ def main():
|
|
| 556 |
else:
|
| 557 |
st.caption("LinkedIn: Not configured")
|
| 558 |
|
| 559 |
-
if st.button("
|
| 560 |
st.session_state['linkedin_setup'] = True
|
| 561 |
st.rerun()
|
| 562 |
|
| 563 |
if st.session_state.get('linkedin_setup'):
|
| 564 |
st.info(
|
| 565 |
"A browser window will open. Please log in to LinkedIn "
|
| 566 |
-
"(including 2FA if needed). Do NOT close the browser
|
| 567 |
"it will close automatically once login is detected."
|
| 568 |
)
|
| 569 |
try:
|
|
@@ -582,7 +229,6 @@ def main():
|
|
| 582 |
finally:
|
| 583 |
st.session_state['linkedin_setup'] = False
|
| 584 |
|
| 585 |
-
# Show daily usage
|
| 586 |
try:
|
| 587 |
from linkedin_intel import check_daily_limits
|
| 588 |
limits = check_daily_limits()
|
|
@@ -596,760 +242,26 @@ def main():
|
|
| 596 |
except ImportError:
|
| 597 |
st.caption("LinkedIn module not available")
|
| 598 |
|
| 599 |
-
st.divider()
|
| 600 |
-
|
| 601 |
-
if st.button("🗑️ Clear All Data", type="secondary"):
|
| 602 |
-
clear_collator_data()
|
| 603 |
-
st.rerun()
|
| 604 |
-
|
| 605 |
-
# ============ MAIN AREA ============
|
| 606 |
-
|
| 607 |
-
# Get top companies first
|
| 608 |
-
companies = get_top_companies(limit=50, min_score=0)
|
| 609 |
-
stats = get_company_stats()
|
| 610 |
-
|
| 611 |
-
# ============ HERO BANNER ============
|
| 612 |
-
# Change 1: Removed unused CSS classes (.hero-card, .hot-lead-card, .action-btn)
|
| 613 |
-
st.markdown("""
|
| 614 |
-
<style>
|
| 615 |
-
.hero-stat {
|
| 616 |
-
text-align: center;
|
| 617 |
-
padding: 10px;
|
| 618 |
-
}
|
| 619 |
-
.hero-number {
|
| 620 |
-
font-size: 2.5em;
|
| 621 |
-
font-weight: bold;
|
| 622 |
-
color: #4CAF50;
|
| 623 |
-
}
|
| 624 |
-
</style>
|
| 625 |
-
""", unsafe_allow_html=True)
|
| 626 |
-
|
| 627 |
-
# Hero Stats Row 1: 4 primary metrics
|
| 628 |
-
hero_cols = st.columns(4)
|
| 629 |
-
with hero_cols[0]:
|
| 630 |
-
st.metric("🏢 Companies", stats['total_companies'], delta=f"{stats['hot_companies']} hot")
|
| 631 |
-
with hero_cols[1]:
|
| 632 |
-
st.metric("💼 Job Signals", stats['total_jobs'])
|
| 633 |
-
with hero_cols[2]:
|
| 634 |
-
st.metric("📰 News Signals", stats['total_news'])
|
| 635 |
-
with hero_cols[3]:
|
| 636 |
-
all_with_network = [c for c in companies if c.network_status and c.network_status != "Cold"]
|
| 637 |
-
st.metric("🔗 With Connections", len(all_with_network), delta="warm intros available")
|
| 638 |
-
|
| 639 |
-
# Change 1: Row 2 as compact caption instead of 6 cramped metric boxes
|
| 640 |
-
combo_companies = [c for c in companies if c.signal_summary and ("combo" in c.signal_summary.lower())]
|
| 641 |
-
combo_count = len(combo_companies)
|
| 642 |
-
li_tier_str = f"🔴{stats.get('li_act_now', 0)} Act Now · 🟡{stats.get('li_warm', 0)} Warm · 🔵{stats.get('li_nurture', 0)} Nurture" if stats.get('total_linkedin_intel', 0) > 0 else f"{stats.get('total_linkedin_intel', 0)}"
|
| 643 |
-
st.caption(f"📄 {stats.get('total_reports', 0)} Reports | 🏥 {stats.get('total_cqc', 0)} CQC | 🏛️ {stats.get('total_tenders', 0)} Tenders | 😐 {stats.get('total_sentiment', 0)} Sentiment | 🤝 {stats.get('total_pe_deals', 0)} M&A | 🔍 LI: {li_tier_str} | 🔥 {combo_count} Combos")
|
| 644 |
-
|
| 645 |
-
# ============ ALERTS STRIP (Change 3: Combined M&A + CQC + LinkedIn) ============
|
| 646 |
-
ma_companies = [c for c in companies if c.pe_deals][:5]
|
| 647 |
-
cqc_companies = [c for c in companies if c.cqc_signals][:5]
|
| 648 |
-
li_posting_companies = [c for c in companies if any(
|
| 649 |
-
intel.get('posts_about_transformation') for intel in getattr(c, 'linkedin_intel', [])
|
| 650 |
-
)][:5]
|
| 651 |
-
|
| 652 |
-
if ma_companies or cqc_companies or li_posting_companies:
|
| 653 |
-
st.divider()
|
| 654 |
-
st.subheader("⚡ Active Alerts")
|
| 655 |
-
|
| 656 |
-
alert_col1, alert_col2, alert_col3 = st.columns(3)
|
| 657 |
-
|
| 658 |
-
with alert_col1:
|
| 659 |
-
if ma_companies:
|
| 660 |
-
st.markdown("**🤝 M&A Activity**")
|
| 661 |
-
for company in ma_companies[:3]:
|
| 662 |
-
deal = company.pe_deals[0]
|
| 663 |
-
is_pe = deal.get('is_pe_deal', 0) == 1
|
| 664 |
-
if is_pe:
|
| 665 |
-
deal_badge = "🟣 PE"
|
| 666 |
-
elif deal.get('deal_type') == 'mbo':
|
| 667 |
-
deal_badge = "🔵 MBO"
|
| 668 |
-
else:
|
| 669 |
-
deal_badge = "🟢 Trade"
|
| 670 |
-
|
| 671 |
-
network_badge = f"🔗 {company.network_status}" if company.network_status and company.network_status != "Cold" else "⚪ No Connection"
|
| 672 |
-
st.markdown(f"**{company.name}** — {deal_badge} | Score: {company.overall_score} | {network_badge}")
|
| 673 |
-
if len(ma_companies) > 3:
|
| 674 |
-
st.caption(f"+ {len(ma_companies) - 3} more M&A alerts")
|
| 675 |
-
else:
|
| 676 |
-
st.caption("No M&A alerts")
|
| 677 |
-
|
| 678 |
-
with alert_col2:
|
| 679 |
-
if cqc_companies:
|
| 680 |
-
st.markdown("**🏥 CQC Concerns**")
|
| 681 |
-
for company in cqc_companies[:3]:
|
| 682 |
-
cqc = company.cqc_signals[0]
|
| 683 |
-
rating = cqc.get('current_rating', 'Unknown')
|
| 684 |
-
if rating == "Inadequate":
|
| 685 |
-
rating_badge = "🔴 Inadequate"
|
| 686 |
-
else:
|
| 687 |
-
rating_badge = "🟠 Requires Improvement"
|
| 688 |
-
|
| 689 |
-
network_badge = f"🔗 {company.network_status}" if company.network_status and company.network_status != "Cold" else "⚪ No Connection"
|
| 690 |
-
st.markdown(f"**{company.name}** — {rating_badge} | Score: {company.overall_score} | {network_badge}")
|
| 691 |
-
if len(cqc_companies) > 3:
|
| 692 |
-
st.caption(f"+ {len(cqc_companies) - 3} more CQC alerts")
|
| 693 |
-
else:
|
| 694 |
-
st.caption("No CQC alerts")
|
| 695 |
-
|
| 696 |
-
with alert_col3:
|
| 697 |
-
if li_posting_companies:
|
| 698 |
-
st.markdown("**🔗 LinkedIn: Posting About Transformation**")
|
| 699 |
-
for company in li_posting_companies[:3]:
|
| 700 |
-
posting_intels = [i for i in getattr(company, 'linkedin_intel', []) if i.get('posts_about_transformation')]
|
| 701 |
-
if posting_intels:
|
| 702 |
-
best = max(posting_intels, key=lambda x: x.get('relationship_score', 0))
|
| 703 |
-
score = best.get('relationship_score', 0)
|
| 704 |
-
if score >= 80:
|
| 705 |
-
tier_badge = "🟢 Strong"
|
| 706 |
-
elif score >= 60:
|
| 707 |
-
tier_badge = "🟡 Warm"
|
| 708 |
-
elif score >= 30:
|
| 709 |
-
tier_badge = "🔵 Lukewarm"
|
| 710 |
-
else:
|
| 711 |
-
tier_badge = "⚪ Cold"
|
| 712 |
-
colleague = best.get('colleague_name', '?')
|
| 713 |
-
st.markdown(f"**{company.name}** — {tier_badge} | via {colleague}")
|
| 714 |
-
if len(li_posting_companies) > 3:
|
| 715 |
-
st.caption(f"+ {len(li_posting_companies) - 3} more posting")
|
| 716 |
-
else:
|
| 717 |
-
st.caption("No LinkedIn transformation alerts")
|
| 718 |
-
|
| 719 |
-
# ============ LINKEDIN: YOUR ROUTES IN ============
|
| 720 |
-
li_actions = get_top_linkedin_actions(limit=5)
|
| 721 |
-
if li_actions:
|
| 722 |
-
st.divider()
|
| 723 |
-
st.subheader("🔗 LinkedIn: Your Routes In")
|
| 724 |
-
st.caption("WHO to call, WHY now, HOW to get in — ranked by opportunity value")
|
| 725 |
-
|
| 726 |
-
# --- "Email All Routes" button ---
|
| 727 |
-
if st.button("📨 Email All Routes", key="btn_email_all_routes"):
|
| 728 |
-
st.session_state["email_all_routes"] = True
|
| 729 |
-
st.rerun()
|
| 730 |
-
|
| 731 |
-
if st.session_state.get("email_all_routes"):
|
| 732 |
-
batch = draft_batch_colleague_summary(li_actions)
|
| 733 |
-
st.code(batch["full_text"], language=None)
|
| 734 |
-
recipients_str = ", ".join(sorted(batch["recipients"]))
|
| 735 |
-
mailto = (
|
| 736 |
-
f"mailto:?subject={url_quote(batch['subject'])}"
|
| 737 |
-
f"&body={url_quote(batch['body'])}"
|
| 738 |
-
)
|
| 739 |
-
st.markdown(
|
| 740 |
-
f"**To:** {recipients_str} \n"
|
| 741 |
-
f"[Open in email client]({mailto})"
|
| 742 |
-
)
|
| 743 |
-
if st.button("❌ Close", key="close_email_all_routes"):
|
| 744 |
-
del st.session_state["email_all_routes"]
|
| 745 |
-
st.rerun()
|
| 746 |
-
|
| 747 |
-
for idx, act in enumerate(li_actions):
|
| 748 |
-
action_score = act.get('action_score', 0)
|
| 749 |
-
company_score = act.get('company_score', 0)
|
| 750 |
-
contact = act.get('contact_name', 'Unknown')
|
| 751 |
-
title = act.get('contact_title', '')
|
| 752 |
-
company = act.get('company_name', 'Unknown')
|
| 753 |
-
colleague = act.get('colleague_name', '?')
|
| 754 |
-
active = act.get('contact_active', 0)
|
| 755 |
-
posting = act.get('posts_about_transformation', 0)
|
| 756 |
-
degree = act.get('connection_degree', '?')
|
| 757 |
-
mutual = act.get('mutual_connections', 0)
|
| 758 |
-
|
| 759 |
-
# Urgency based on composite action score
|
| 760 |
-
if action_score >= 70:
|
| 761 |
-
border_color = "#d32f2f"
|
| 762 |
-
urgency = "🔴 ACT TODAY"
|
| 763 |
-
elif action_score >= 50:
|
| 764 |
-
border_color = "#f57c00"
|
| 765 |
-
urgency = "🟡 WARM — REACH OUT THIS WEEK"
|
| 766 |
-
else:
|
| 767 |
-
border_color = "#1976d2"
|
| 768 |
-
urgency = "🔵 WORTH A LOOK"
|
| 769 |
-
|
| 770 |
-
# Signal badges
|
| 771 |
-
badges = []
|
| 772 |
-
if posting:
|
| 773 |
-
badges.append("📢 Posting about transformation")
|
| 774 |
-
if active:
|
| 775 |
-
badges.append("✅ Active on LinkedIn")
|
| 776 |
-
badges.append(f"🔗 {degree}° via {colleague}")
|
| 777 |
-
if mutual:
|
| 778 |
-
badges.append(f"👥 {mutual} mutual")
|
| 779 |
-
badge_str = " · ".join(badges)
|
| 780 |
-
|
| 781 |
-
# Build a smart route-in message
|
| 782 |
-
route_parts = []
|
| 783 |
-
route_parts.append(f"Ask <strong>{colleague}</strong> to introduce you to {contact.split()[0] if contact else 'them'}")
|
| 784 |
-
if posting:
|
| 785 |
-
route_parts.append(f"they're posting about transformation — perfect conversation opener")
|
| 786 |
-
if active:
|
| 787 |
-
route_parts.append(f"active on LinkedIn right now")
|
| 788 |
-
route_msg = " — ".join(route_parts)
|
| 789 |
-
|
| 790 |
-
route_html = f"""
|
| 791 |
-
<div style="background:#e3f2fd;border-left:4px solid #1565c0;padding:8px 12px;margin:8px 0;border-radius:4px;">
|
| 792 |
-
<strong>YOUR ROUTE IN:</strong> {route_msg}
|
| 793 |
-
</div>"""
|
| 794 |
-
|
| 795 |
-
card_html = f"""
|
| 796 |
-
<div style="border-left:5px solid {border_color};padding:12px 16px;margin:10px 0;background:#fafafa;border-radius:6px;">
|
| 797 |
-
<div style="display:flex;justify-content:space-between;align-items:center;">
|
| 798 |
-
<span style="font-weight:700;font-size:0.9em;">{urgency}</span>
|
| 799 |
-
<span style="font-size:0.9em;color:#555;">Company Score: {company_score} | Action: {action_score}</span>
|
| 800 |
-
</div>
|
| 801 |
-
<div style="font-size:1.1em;margin:6px 0;"><strong>{contact}</strong> — {title} at <strong>{company}</strong></div>
|
| 802 |
-
<div style="font-size:0.85em;color:#666;">{badge_str}</div>
|
| 803 |
-
{route_html}
|
| 804 |
-
</div>"""
|
| 805 |
-
st.markdown(card_html, unsafe_allow_html=True)
|
| 806 |
-
|
| 807 |
-
# --- Per-card "Email colleague" button ---
|
| 808 |
-
route_email_key = f"route_email_{idx}"
|
| 809 |
-
if st.button(f"📧 Email {colleague}", key=f"btn_{route_email_key}"):
|
| 810 |
-
st.session_state[route_email_key] = True
|
| 811 |
-
st.rerun()
|
| 812 |
-
|
| 813 |
-
if st.session_state.get(route_email_key):
|
| 814 |
-
draft = draft_colleague_intro_request(
|
| 815 |
-
colleague_name=colleague,
|
| 816 |
-
contact_name=contact,
|
| 817 |
-
contact_title=title,
|
| 818 |
-
company_name=company,
|
| 819 |
-
company_score=company_score,
|
| 820 |
-
posts_about_transformation=bool(posting),
|
| 821 |
-
contact_active=bool(active),
|
| 822 |
-
connection_degree=str(degree),
|
| 823 |
-
)
|
| 824 |
-
st.code(draft["full_text"], language=None)
|
| 825 |
-
mailto = (
|
| 826 |
-
f"mailto:?subject={url_quote(draft['subject'])}"
|
| 827 |
-
f"&body={url_quote(draft['body'])}"
|
| 828 |
-
)
|
| 829 |
-
st.markdown(f"[Open in email client]({mailto})")
|
| 830 |
-
if st.button("❌ Close", key=f"close_{route_email_key}"):
|
| 831 |
-
del st.session_state[route_email_key]
|
| 832 |
-
st.rerun()
|
| 833 |
-
|
| 834 |
-
# ============ HOT LEADS (Change 2: Moved up from below Network) ============
|
| 835 |
st.divider()
|
| 836 |
-
st.subheader("🔥 Hot Leads (Need Warm Intro)")
|
| 837 |
-
st.caption("High-scoring companies without team connections - find a way in!")
|
| 838 |
-
|
| 839 |
-
hot_without_network = [c for c in companies if c.overall_score >= 50 and (not c.network_status or c.network_status == "Cold")][:5]
|
| 840 |
-
|
| 841 |
-
if hot_without_network:
|
| 842 |
-
for company in hot_without_network:
|
| 843 |
-
li_intel = getattr(company, 'linkedin_intel', [])
|
| 844 |
-
# Any active/posting LI contact = a route in
|
| 845 |
-
has_li_route = any(
|
| 846 |
-
i.get('contact_active') or i.get('posts_about_transformation')
|
| 847 |
-
for i in li_intel
|
| 848 |
-
)
|
| 849 |
-
|
| 850 |
-
cols = st.columns([4, 1])
|
| 851 |
-
with cols[0]:
|
| 852 |
-
st.markdown(f"**🔥 {company.name}** (Score: {company.overall_score})")
|
| 853 |
-
# Signal summary as individual badges
|
| 854 |
-
if company.signal_summary:
|
| 855 |
-
signals = company.signal_summary.split(' | ')
|
| 856 |
-
sig_cols = st.columns(min(len(signals), 4))
|
| 857 |
-
for i, sig in enumerate(signals[:4]):
|
| 858 |
-
with sig_cols[i]:
|
| 859 |
-
st.caption(f"📌 {sig}")
|
| 860 |
-
with cols[1]:
|
| 861 |
-
if has_li_route:
|
| 862 |
-
# Pick best LI contact by signal quality
|
| 863 |
-
best_li = max(li_intel, key=lambda x: (x.get('posts_about_transformation', 0), x.get('contact_active', 0)))
|
| 864 |
-
li_colleague = best_li.get('colleague_name', '?')
|
| 865 |
-
li_contact = best_li.get('contact_name', '?').split()[0]
|
| 866 |
-
st.success(f"🔗 via {li_colleague} → {li_contact}")
|
| 867 |
-
else:
|
| 868 |
-
st.warning("⚪ No Connection")
|
| 869 |
-
else:
|
| 870 |
-
st.success("All hot leads have network connections! 🎉")
|
| 871 |
-
|
| 872 |
-
# ============ TEAM MEMBERS (Change 4: Collapsed in expander) ============
|
| 873 |
-
team_connections = {}
|
| 874 |
-
# Build a lookup of company objects by name for popover details
|
| 875 |
-
company_lookup = {c.name: c for c in companies}
|
| 876 |
-
for company in companies:
|
| 877 |
-
if company.best_colleague and company.network_status and company.network_status != "Cold":
|
| 878 |
-
colleague = company.best_colleague
|
| 879 |
-
if colleague not in team_connections:
|
| 880 |
-
team_connections[colleague] = []
|
| 881 |
-
team_connections[colleague].append({
|
| 882 |
-
'company': company.name,
|
| 883 |
-
'contact': company.best_contact,
|
| 884 |
-
'score': company.overall_score,
|
| 885 |
-
'source': 'csv',
|
| 886 |
-
})
|
| 887 |
-
# Also include LinkedIn contacts with score >= 20
|
| 888 |
-
for intel in getattr(company, 'linkedin_intel', []):
|
| 889 |
-
if intel.get('relationship_score', 0) >= 20:
|
| 890 |
-
li_colleague = intel.get('colleague_name', '')
|
| 891 |
-
if li_colleague:
|
| 892 |
-
if li_colleague not in team_connections:
|
| 893 |
-
team_connections[li_colleague] = []
|
| 894 |
-
# Avoid duplicates (same company already added via CSV)
|
| 895 |
-
existing_companies = {c['company'] for c in team_connections[li_colleague]}
|
| 896 |
-
if company.name not in existing_companies:
|
| 897 |
-
li_score = intel.get('relationship_score', 0)
|
| 898 |
-
if li_score >= 80:
|
| 899 |
-
li_badge = "🟢"
|
| 900 |
-
elif li_score >= 60:
|
| 901 |
-
li_badge = "🟡"
|
| 902 |
-
elif li_score >= 30:
|
| 903 |
-
li_badge = "🔵"
|
| 904 |
-
else:
|
| 905 |
-
li_badge = "⚪"
|
| 906 |
-
team_connections[li_colleague].append({
|
| 907 |
-
'company': company.name,
|
| 908 |
-
'contact': intel.get('contact_name', ''),
|
| 909 |
-
'score': company.overall_score,
|
| 910 |
-
'source': 'linkedin',
|
| 911 |
-
'li_badge': li_badge,
|
| 912 |
-
'li_action': intel.get('recommended_action', ''),
|
| 913 |
-
})
|
| 914 |
-
|
| 915 |
-
if team_connections:
|
| 916 |
-
st.divider()
|
| 917 |
-
with st.expander("👥 Team Members to Contact", expanded=False):
|
| 918 |
-
st.caption("These colleagues have connections at companies with active opportunities")
|
| 919 |
-
|
| 920 |
-
sorted_team = sorted(team_connections.items(), key=lambda x: len(x[1]), reverse=True)
|
| 921 |
-
|
| 922 |
-
team_cols = st.columns(min(len(sorted_team), 4))
|
| 923 |
-
for idx, (colleague, connections) in enumerate(sorted_team[:4]):
|
| 924 |
-
with team_cols[idx]:
|
| 925 |
-
hot_count = len([c for c in connections if c['score'] >= 50])
|
| 926 |
-
st.markdown(f"**👤 {colleague}**")
|
| 927 |
-
st.metric("Connections", len(connections), delta=f"{hot_count} hot" if hot_count else None)
|
| 928 |
-
|
| 929 |
-
for conn in sorted(connections, key=lambda x: x['score'], reverse=True)[:3]:
|
| 930 |
-
score_emoji = "🔥" if conn['score'] >= 50 else ""
|
| 931 |
-
contact_name = conn.get('contact', '')
|
| 932 |
-
company_short = conn['company'][:20] + ('...' if len(conn['company']) > 20 else '')
|
| 933 |
-
li_prefix = conn.get('li_badge', '') + " " if conn.get('source') == 'linkedin' else ""
|
| 934 |
-
|
| 935 |
-
# Clickable company name with popover showing why it's interesting
|
| 936 |
-
with st.popover(f"{li_prefix}{score_emoji} {company_short}"):
|
| 937 |
-
comp = company_lookup.get(conn['company'])
|
| 938 |
-
if comp:
|
| 939 |
-
st.markdown(f"### {comp.name}")
|
| 940 |
-
if comp.overall_score >= 70:
|
| 941 |
-
st.success(f"Score: {comp.overall_score}")
|
| 942 |
-
elif comp.overall_score >= 50:
|
| 943 |
-
st.warning(f"Score: {comp.overall_score}")
|
| 944 |
-
else:
|
| 945 |
-
st.info(f"Score: {comp.overall_score}")
|
| 946 |
-
|
| 947 |
-
if contact_name:
|
| 948 |
-
source_label = "LinkedIn" if conn.get('source') == 'linkedin' else "Network"
|
| 949 |
-
st.markdown(f"**{source_label}:** {colleague} → **{contact_name}**")
|
| 950 |
-
|
| 951 |
-
# Show LI action in popover
|
| 952 |
-
if conn.get('li_action'):
|
| 953 |
-
st.info(f"**Route in:** {conn['li_action']}")
|
| 954 |
-
|
| 955 |
-
if comp.signal_summary:
|
| 956 |
-
st.markdown("**Signals:**")
|
| 957 |
-
for sig in comp.signal_summary.split(' | ')[:4]:
|
| 958 |
-
st.caption(f"📌 {sig}")
|
| 959 |
-
|
| 960 |
-
if comp.jobs:
|
| 961 |
-
latest = comp.jobs[0]
|
| 962 |
-
st.markdown(f"**Latest Job:** {latest.get('title', 'Unknown')}")
|
| 963 |
-
if comp.news:
|
| 964 |
-
latest = comp.news[0]
|
| 965 |
-
st.markdown(f"**Latest News:** {latest.get('headline', 'Unknown')[:60]}")
|
| 966 |
-
if comp.pe_deals:
|
| 967 |
-
deal = comp.pe_deals[0]
|
| 968 |
-
st.markdown(f"**M&A:** {deal.get('acquirer_name', 'Unknown')} ({deal.get('deal_type', '')})")
|
| 969 |
-
if comp.cqc_signals:
|
| 970 |
-
cqc = comp.cqc_signals[0]
|
| 971 |
-
st.markdown(f"**CQC:** {cqc.get('current_rating', 'Unknown')}")
|
| 972 |
-
else:
|
| 973 |
-
st.markdown(f"**{conn['company']}** — Score: {conn['score']}")
|
| 974 |
-
|
| 975 |
-
st.divider()
|
| 976 |
-
|
| 977 |
-
# ============ MAIN TABS - Companies vs Tenders vs Council ============
|
| 978 |
-
main_tab1, main_tab2, main_tab3 = st.tabs(["🎯 Company Dossiers", "🏛️ Government Tenders", "🏛️ Council Opportunities"])
|
| 979 |
-
|
| 980 |
-
# ============ TAB 1: COMPANY DOSSIERS ============
|
| 981 |
-
with main_tab1:
|
| 982 |
-
# Recent Signals Feed
|
| 983 |
-
col_news, col_jobs = st.columns(2)
|
| 984 |
-
|
| 985 |
-
with col_news:
|
| 986 |
-
st.markdown("**📰 Latest News Signals**")
|
| 987 |
-
news_companies = [c for c in companies if c.news][:5]
|
| 988 |
-
if news_companies:
|
| 989 |
-
for company in news_companies:
|
| 990 |
-
if company.news:
|
| 991 |
-
latest_news = company.news[0]
|
| 992 |
-
urgency_emoji = "🔴" if latest_news.get('urgency') == 'high' else "🟡"
|
| 993 |
-
st.markdown(f"{urgency_emoji} **{company.name}**: {latest_news.get('headline', '')[:40]}...")
|
| 994 |
-
else:
|
| 995 |
-
st.caption("No recent news signals")
|
| 996 |
-
|
| 997 |
-
with col_jobs:
|
| 998 |
-
st.markdown("**💼 Latest Job Signals**")
|
| 999 |
-
job_companies = [c for c in companies if c.jobs][:5]
|
| 1000 |
-
if job_companies:
|
| 1001 |
-
for company in job_companies:
|
| 1002 |
-
if company.jobs:
|
| 1003 |
-
latest_job = company.jobs[0]
|
| 1004 |
-
score = latest_job.get('score', 0)
|
| 1005 |
-
score_emoji = "🔥" if score >= 80 else "✓"
|
| 1006 |
-
st.markdown(f"{score_emoji} **{company.name}**: {latest_job.get('title', '')[:35]}...")
|
| 1007 |
-
else:
|
| 1008 |
-
st.caption("No recent job signals")
|
| 1009 |
-
|
| 1010 |
-
st.divider()
|
| 1011 |
-
|
| 1012 |
-
if not companies:
|
| 1013 |
-
st.info("No companies found yet. Click **HUNT NOW** to start gathering intelligence.")
|
| 1014 |
-
else:
|
| 1015 |
-
# Change 5: Enhanced filter controls with search and Network Only
|
| 1016 |
-
filter_cols = st.columns([3, 1, 1, 1])
|
| 1017 |
-
with filter_cols[0]:
|
| 1018 |
-
search_term = st.text_input("🔍 Search companies", placeholder="Type company name...")
|
| 1019 |
-
with filter_cols[1]:
|
| 1020 |
-
network_filter = st.checkbox("🔗 Network Only")
|
| 1021 |
-
with filter_cols[2]:
|
| 1022 |
-
hot_only = st.checkbox("🔥 Hot Only (50+)")
|
| 1023 |
-
with filter_cols[3]:
|
| 1024 |
-
min_score_filter = st.slider("Min Score", 0, 100, 30, step=10)
|
| 1025 |
-
|
| 1026 |
-
# Apply filters
|
| 1027 |
-
filtered = companies
|
| 1028 |
-
if min_score_filter > 0:
|
| 1029 |
-
filtered = [c for c in filtered if c.overall_score >= min_score_filter]
|
| 1030 |
-
if network_filter:
|
| 1031 |
-
filtered = [c for c in filtered if c.network_status and c.network_status != "Cold"]
|
| 1032 |
-
if hot_only:
|
| 1033 |
-
filtered = [c for c in filtered if c.overall_score >= 50]
|
| 1034 |
-
if search_term:
|
| 1035 |
-
filtered = [c for c in filtered if search_term.lower() in c.name.lower()]
|
| 1036 |
-
|
| 1037 |
-
st.divider()
|
| 1038 |
-
|
| 1039 |
-
# Summary row
|
| 1040 |
-
summary_cols = st.columns(4)
|
| 1041 |
-
summary_cols[0].metric("Showing", f"{len(filtered)} companies")
|
| 1042 |
-
hot_count = len([c for c in filtered if c.overall_score >= 50])
|
| 1043 |
-
summary_cols[1].metric("🔥 Hot", hot_count)
|
| 1044 |
-
network_count = len([c for c in filtered if c.network_status and c.network_status != "Cold"])
|
| 1045 |
-
summary_cols[2].metric("🔗 With Network", network_count)
|
| 1046 |
-
combo_count_filtered = len([c for c in filtered if "job+news" in (c.signal_summary or "").lower()])
|
| 1047 |
-
summary_cols[3].metric("🔥 Combo", combo_count_filtered)
|
| 1048 |
-
|
| 1049 |
-
st.divider()
|
| 1050 |
-
|
| 1051 |
-
# Change 5: Pagination
|
| 1052 |
-
PAGE_SIZE = 10
|
| 1053 |
-
total_pages = max(1, (len(filtered) + PAGE_SIZE - 1) // PAGE_SIZE)
|
| 1054 |
-
page = st.number_input("Page", min_value=1, max_value=total_pages, value=1, key="dossier_page")
|
| 1055 |
-
start = (page - 1) * PAGE_SIZE
|
| 1056 |
-
page_companies = filtered[start:start + PAGE_SIZE]
|
| 1057 |
-
st.caption(f"Showing {start + 1}-{min(start + PAGE_SIZE, len(filtered))} of {len(filtered)} companies")
|
| 1058 |
-
|
| 1059 |
-
# Company Dossier Cards
|
| 1060 |
-
for dossier in page_companies:
|
| 1061 |
-
with st.container():
|
| 1062 |
-
# Header row
|
| 1063 |
-
header_cols = st.columns([3, 1, 2])
|
| 1064 |
-
|
| 1065 |
-
with header_cols[0]:
|
| 1066 |
-
score_emoji = "🔥" if dossier.overall_score >= 50 else ""
|
| 1067 |
-
st.markdown(f"### {score_emoji} {dossier.name}")
|
| 1068 |
|
| 1069 |
-
|
| 1070 |
-
|
| 1071 |
-
|
| 1072 |
-
|
| 1073 |
-
elif dossier.overall_score >= 50:
|
| 1074 |
-
st.warning(f"Score: {dossier.overall_score}")
|
| 1075 |
-
else:
|
| 1076 |
-
st.info(f"Score: {dossier.overall_score}")
|
| 1077 |
|
| 1078 |
-
with header_cols[2]:
|
| 1079 |
-
if dossier.network_status and dossier.network_status != "Cold":
|
| 1080 |
-
if dossier.best_colleague and dossier.best_contact:
|
| 1081 |
-
st.markdown(f"🔗 **{dossier.best_colleague}** knows **{dossier.best_contact}**")
|
| 1082 |
-
else:
|
| 1083 |
-
st.markdown(f"🔗 **{dossier.network_status}**")
|
| 1084 |
-
else:
|
| 1085 |
-
# Fallback: show LinkedIn route if available
|
| 1086 |
-
li_intel = getattr(dossier, 'linkedin_intel', [])
|
| 1087 |
-
li_routes = [i for i in li_intel if i.get('contact_active') or i.get('posts_about_transformation')]
|
| 1088 |
-
if li_routes:
|
| 1089 |
-
best_li = max(li_routes, key=lambda x: (x.get('posts_about_transformation', 0), x.get('contact_active', 0)))
|
| 1090 |
-
li_via = best_li.get('colleague_name', '?')
|
| 1091 |
-
li_contact = best_li.get('contact_name', '?').split()[0]
|
| 1092 |
-
posting_tag = " 📢" if best_li.get('posts_about_transformation') else ""
|
| 1093 |
-
st.markdown(f"🔗 **LI: {li_via}** → **{li_contact}**{posting_tag}")
|
| 1094 |
-
else:
|
| 1095 |
-
st.markdown("⚪ **No Connection**")
|
| 1096 |
-
|
| 1097 |
-
# Change 7: Signal summary as individual caption badges
|
| 1098 |
-
if dossier.signal_summary:
|
| 1099 |
-
signals = dossier.signal_summary.split(' | ')
|
| 1100 |
-
sig_cols = st.columns(min(len(signals), 4))
|
| 1101 |
-
for i, sig in enumerate(signals[:4]):
|
| 1102 |
-
with sig_cols[i]:
|
| 1103 |
-
st.caption(f"📌 {sig}")
|
| 1104 |
-
|
| 1105 |
-
# Expandable details using shared renderer (Change 10)
|
| 1106 |
-
with st.expander("📋 View Full Dossier"):
|
| 1107 |
-
render_dossier_tabs(dossier, "company", show_network=True, show_action=True)
|
| 1108 |
-
|
| 1109 |
-
st.divider()
|
| 1110 |
-
|
| 1111 |
-
# ============ TAB 2: GOVERNMENT TENDERS ============
|
| 1112 |
-
with main_tab2:
|
| 1113 |
-
st.subheader("🏛️ Government Tenders")
|
| 1114 |
-
st.caption("UK public sector opportunities from Contracts Finder")
|
| 1115 |
-
|
| 1116 |
-
# Get all tenders from companies
|
| 1117 |
-
all_tenders = []
|
| 1118 |
-
for company in companies:
|
| 1119 |
-
if company.tenders:
|
| 1120 |
-
for tender in company.tenders:
|
| 1121 |
-
tender['buyer'] = company.name
|
| 1122 |
-
tender['company_score'] = company.overall_score
|
| 1123 |
-
tender['network_status'] = company.network_status
|
| 1124 |
-
all_tenders.append(tender)
|
| 1125 |
-
|
| 1126 |
-
if not all_tenders:
|
| 1127 |
-
st.info("No tenders found yet. Click **HUNT NOW** to search for government opportunities.")
|
| 1128 |
-
else:
|
| 1129 |
-
# Tender filters
|
| 1130 |
-
tcol1, tcol2 = st.columns(2)
|
| 1131 |
-
with tcol1:
|
| 1132 |
-
show_urgent = st.checkbox("🔴 Urgent Only (< 14 days)", value=False)
|
| 1133 |
-
with tcol2:
|
| 1134 |
-
min_value = st.selectbox("Minimum Value", ["Any", "£100K+", "£500K+", "£1M+"])
|
| 1135 |
-
|
| 1136 |
-
# Apply filters
|
| 1137 |
-
filtered_tenders = all_tenders
|
| 1138 |
-
if show_urgent:
|
| 1139 |
-
filtered_tenders = [t for t in filtered_tenders if t.get('urgent')]
|
| 1140 |
-
if min_value == "£100K+":
|
| 1141 |
-
filtered_tenders = [t for t in filtered_tenders if (t.get('value') or 0) >= 100000]
|
| 1142 |
-
elif min_value == "£500K+":
|
| 1143 |
-
filtered_tenders = [t for t in filtered_tenders if (t.get('value') or 0) >= 500000]
|
| 1144 |
-
elif min_value == "£1M+":
|
| 1145 |
-
filtered_tenders = [t for t in filtered_tenders if (t.get('value') or 0) >= 1000000]
|
| 1146 |
-
|
| 1147 |
-
# Sort by urgency then value
|
| 1148 |
-
filtered_tenders.sort(key=lambda x: (not x.get('urgent'), -(x.get('value') or 0)))
|
| 1149 |
-
|
| 1150 |
-
st.divider()
|
| 1151 |
-
|
| 1152 |
-
# Stats
|
| 1153 |
-
tcols = st.columns(4)
|
| 1154 |
-
tcols[0].metric("Total Tenders", len(filtered_tenders))
|
| 1155 |
-
urgent_count = len([t for t in filtered_tenders if t.get('urgent')])
|
| 1156 |
-
tcols[1].metric("🔴 Urgent", urgent_count)
|
| 1157 |
-
total_value = sum(t.get('value') or 0 for t in filtered_tenders)
|
| 1158 |
-
tcols[2].metric("Total Value", format_value(total_value))
|
| 1159 |
-
with_network = len([t for t in filtered_tenders if t.get('network_status') and t.get('network_status') != "Cold"])
|
| 1160 |
-
tcols[3].metric("🔗 With Network", with_network)
|
| 1161 |
-
|
| 1162 |
-
st.divider()
|
| 1163 |
-
|
| 1164 |
-
# Tender cards
|
| 1165 |
-
for tender in filtered_tenders:
|
| 1166 |
-
urgent_emoji = "🔴" if tender.get('urgent') else "🟢"
|
| 1167 |
-
value_str = format_value(tender.get('value'))
|
| 1168 |
-
days = tender.get('days')
|
| 1169 |
-
days_str = f"{days} days left" if days else "No deadline"
|
| 1170 |
-
|
| 1171 |
-
with st.container():
|
| 1172 |
-
cols = st.columns([4, 1, 1])
|
| 1173 |
-
|
| 1174 |
-
with cols[0]:
|
| 1175 |
-
st.markdown(f"**{urgent_emoji} {tender.get('title', 'Unknown')[:80]}**")
|
| 1176 |
-
st.caption(f"Buyer: **{tender.get('buyer', 'Unknown')}** | Keywords: {tender.get('keywords', '')}")
|
| 1177 |
-
|
| 1178 |
-
with cols[1]:
|
| 1179 |
-
st.metric("Value", value_str)
|
| 1180 |
-
|
| 1181 |
-
with cols[2]:
|
| 1182 |
-
if tender.get('urgent'):
|
| 1183 |
-
st.error(days_str)
|
| 1184 |
-
else:
|
| 1185 |
-
st.info(days_str)
|
| 1186 |
-
|
| 1187 |
-
# Network connection info - show WHO
|
| 1188 |
-
if tender.get('network_status') and tender.get('network_status') != "Cold":
|
| 1189 |
-
# Try to get the actual contact details from the company
|
| 1190 |
-
buyer_company = next((c for c in companies if c.name == tender.get('buyer')), None)
|
| 1191 |
-
if buyer_company and buyer_company.best_colleague and buyer_company.best_contact:
|
| 1192 |
-
st.success(f"🔗 **{buyer_company.best_colleague}** knows **{buyer_company.best_contact}** at this org!")
|
| 1193 |
-
else:
|
| 1194 |
-
st.success(f"🔗 Team connection available!")
|
| 1195 |
-
|
| 1196 |
-
if tender.get('url'):
|
| 1197 |
-
st.markdown(f"[View Tender →]({tender['url']})")
|
| 1198 |
-
|
| 1199 |
-
st.divider()
|
| 1200 |
-
|
| 1201 |
-
|
| 1202 |
-
# ============ TAB 3: COUNCIL OPPORTUNITIES ============
|
| 1203 |
-
with main_tab3:
|
| 1204 |
-
st.subheader("🏛️ Council Opportunities")
|
| 1205 |
-
st.caption("UK councils with transformation, change, culture & L&D opportunities")
|
| 1206 |
-
|
| 1207 |
-
# Fetch ALL councils directly from DB (not limited to top-50 companies)
|
| 1208 |
-
council_terms = ["council", "borough", "authority", "city of edinburgh", "combined authority"]
|
| 1209 |
-
all_council_dossiers = get_top_companies(limit=500, min_score=0)
|
| 1210 |
-
council_companies = [
|
| 1211 |
-
c for c in all_council_dossiers
|
| 1212 |
-
if any(term in c.name.lower() for term in council_terms)
|
| 1213 |
-
]
|
| 1214 |
-
|
| 1215 |
-
if not council_companies:
|
| 1216 |
-
st.info("No council data yet. Click **🏛️ COUNCIL SCAN** in the sidebar to scan UK councils.")
|
| 1217 |
-
else:
|
| 1218 |
-
# Filter controls
|
| 1219 |
-
cc1, cc2, cc3 = st.columns([3, 1, 1])
|
| 1220 |
-
with cc1:
|
| 1221 |
-
council_search = st.text_input("🔍 Search councils", placeholder="Type council name...", key="council_search")
|
| 1222 |
-
with cc2:
|
| 1223 |
-
connected_only = st.checkbox("🔗 Connected Only", key="council_connected")
|
| 1224 |
-
with cc3:
|
| 1225 |
-
signals_only = st.checkbox("📊 With Signals Only", key="council_signals")
|
| 1226 |
-
|
| 1227 |
-
# Apply filters
|
| 1228 |
-
filtered_councils = council_companies
|
| 1229 |
-
if council_search:
|
| 1230 |
-
filtered_councils = [c for c in filtered_councils if council_search.lower() in c.name.lower()]
|
| 1231 |
-
if connected_only:
|
| 1232 |
-
filtered_councils = [c for c in filtered_councils if c.network_status and c.network_status != "Cold"]
|
| 1233 |
-
if signals_only:
|
| 1234 |
-
filtered_councils = [c for c in filtered_councils if c.overall_score > 0]
|
| 1235 |
-
|
| 1236 |
-
# Split into warm and cold
|
| 1237 |
-
warm_councils = [c for c in filtered_councils if c.network_status and c.network_status != "Cold"]
|
| 1238 |
-
cold_councils = [c for c in filtered_councils if not c.network_status or c.network_status == "Cold"]
|
| 1239 |
-
warm_councils.sort(key=lambda x: x.overall_score, reverse=True)
|
| 1240 |
-
cold_councils.sort(key=lambda x: x.overall_score, reverse=True)
|
| 1241 |
-
|
| 1242 |
-
# Stats row
|
| 1243 |
-
stat_cols = st.columns(4)
|
| 1244 |
-
stat_cols[0].metric("Councils Found", len(filtered_councils))
|
| 1245 |
-
hot_councils = len([c for c in filtered_councils if c.overall_score >= 50])
|
| 1246 |
-
stat_cols[1].metric("🔥 Hot", hot_councils)
|
| 1247 |
-
stat_cols[2].metric("🔗 With Connections", len(warm_councils))
|
| 1248 |
-
stat_cols[3].metric("⚪ Cold Outreach", len(cold_councils))
|
| 1249 |
-
|
| 1250 |
-
st.divider()
|
| 1251 |
-
|
| 1252 |
-
# Section 1: Warm Opportunities
|
| 1253 |
-
st.markdown("### 🔗 Warm Opportunities")
|
| 1254 |
-
st.caption("Councils WITH team connections — sorted by score")
|
| 1255 |
-
|
| 1256 |
-
if warm_councils:
|
| 1257 |
-
for council in warm_councils:
|
| 1258 |
-
with st.container():
|
| 1259 |
-
hcols = st.columns([3, 1, 2])
|
| 1260 |
-
|
| 1261 |
-
with hcols[0]:
|
| 1262 |
-
score_emoji = "🔥" if council.overall_score >= 50 else "📊" if council.overall_score > 0 else ""
|
| 1263 |
-
st.markdown(f"### {score_emoji} {council.name}")
|
| 1264 |
-
|
| 1265 |
-
with hcols[1]:
|
| 1266 |
-
if council.overall_score >= 70:
|
| 1267 |
-
st.success(f"Score: {council.overall_score}")
|
| 1268 |
-
elif council.overall_score >= 50:
|
| 1269 |
-
st.warning(f"Score: {council.overall_score}")
|
| 1270 |
-
else:
|
| 1271 |
-
st.info(f"Score: {council.overall_score}")
|
| 1272 |
-
|
| 1273 |
-
with hcols[2]:
|
| 1274 |
-
if council.best_colleague and council.best_contact:
|
| 1275 |
-
st.markdown(f"🔗 **{council.best_colleague}** → **{council.best_contact}**")
|
| 1276 |
-
else:
|
| 1277 |
-
st.markdown(f"🔗 **{council.network_status}**")
|
| 1278 |
-
|
| 1279 |
-
# Signal badges
|
| 1280 |
-
if council.signal_summary:
|
| 1281 |
-
signals = council.signal_summary.split(' | ')
|
| 1282 |
-
sig_cols = st.columns(min(len(signals), 4))
|
| 1283 |
-
for i, sig in enumerate(signals[:4]):
|
| 1284 |
-
with sig_cols[i]:
|
| 1285 |
-
st.caption(f"📌 {sig}")
|
| 1286 |
-
|
| 1287 |
-
# Expandable dossier
|
| 1288 |
-
with st.expander("📋 View Full Dossier"):
|
| 1289 |
-
render_dossier_tabs(council, "council_warm", show_network=True, show_action=True)
|
| 1290 |
-
|
| 1291 |
-
st.divider()
|
| 1292 |
-
else:
|
| 1293 |
-
st.caption("No councils with team connections found yet.")
|
| 1294 |
-
|
| 1295 |
-
st.markdown("---")
|
| 1296 |
-
|
| 1297 |
-
# Section 2: Cold Outreach Targets
|
| 1298 |
-
st.markdown("### ⚪ Cold Outreach Targets")
|
| 1299 |
-
st.caption("Councils WITHOUT connections but WITH signals — best cold outreach candidates")
|
| 1300 |
-
|
| 1301 |
-
cold_with_signals = [c for c in cold_councils if c.overall_score > 0]
|
| 1302 |
-
cold_no_signals = [c for c in cold_councils if c.overall_score == 0]
|
| 1303 |
-
|
| 1304 |
-
if cold_with_signals:
|
| 1305 |
-
for council in cold_with_signals:
|
| 1306 |
-
with st.container():
|
| 1307 |
-
hcols = st.columns([3, 1, 2])
|
| 1308 |
-
|
| 1309 |
-
with hcols[0]:
|
| 1310 |
-
score_emoji = "🔥" if council.overall_score >= 50 else "📊"
|
| 1311 |
-
st.markdown(f"### {score_emoji} {council.name}")
|
| 1312 |
-
|
| 1313 |
-
with hcols[1]:
|
| 1314 |
-
if council.overall_score >= 70:
|
| 1315 |
-
st.success(f"Score: {council.overall_score}")
|
| 1316 |
-
elif council.overall_score >= 50:
|
| 1317 |
-
st.warning(f"Score: {council.overall_score}")
|
| 1318 |
-
else:
|
| 1319 |
-
st.info(f"Score: {council.overall_score}")
|
| 1320 |
-
|
| 1321 |
-
with hcols[2]:
|
| 1322 |
-
# Show key contact from LinkedIn intel or job postings
|
| 1323 |
-
li_intel = getattr(council, 'linkedin_intel', [])
|
| 1324 |
-
if li_intel:
|
| 1325 |
-
best_li = li_intel[0]
|
| 1326 |
-
st.markdown(f"👤 **{best_li.get('contact_name', 'Unknown')}** — {best_li.get('contact_title', '')[:30]}")
|
| 1327 |
-
elif council.jobs:
|
| 1328 |
-
st.markdown(f"💼 {council.jobs[0].get('title', 'Unknown role')[:40]}")
|
| 1329 |
-
else:
|
| 1330 |
-
st.markdown("⚪ **No Connection**")
|
| 1331 |
-
|
| 1332 |
-
# Signal badges
|
| 1333 |
-
if council.signal_summary:
|
| 1334 |
-
signals = council.signal_summary.split(' | ')
|
| 1335 |
-
sig_cols = st.columns(min(len(signals), 4))
|
| 1336 |
-
for i, sig in enumerate(signals[:4]):
|
| 1337 |
-
with sig_cols[i]:
|
| 1338 |
-
st.caption(f"📌 {sig}")
|
| 1339 |
-
|
| 1340 |
-
with st.expander("📋 View Full Dossier"):
|
| 1341 |
-
render_dossier_tabs(council, "council_cold", show_network=False, show_action=False)
|
| 1342 |
-
|
| 1343 |
-
st.divider()
|
| 1344 |
-
else:
|
| 1345 |
-
st.caption("No councils with signals but without connections.")
|
| 1346 |
|
| 1347 |
-
|
| 1348 |
-
|
| 1349 |
-
|
| 1350 |
-
for council in cold_no_signals:
|
| 1351 |
-
st.caption(f"⚪ {council.name}")
|
| 1352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1353 |
|
| 1354 |
-
|
| 1355 |
-
main()
|
|
|
|
| 1 |
"""
|
| 2 |
+
Curium Lead Intelligence Platform - Main Entry Point
|
| 3 |
+
Multipage Streamlit app with shared sidebar.
|
| 4 |
"""
|
| 5 |
|
| 6 |
import streamlit as st
|
| 7 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
import os
|
| 9 |
from pathlib import Path
|
| 10 |
from dotenv import load_dotenv
|
|
|
|
| 15 |
|
| 16 |
# Import modules
|
| 17 |
from network_loader import init_network_tables, get_network_stats, load_master_csv
|
| 18 |
+
from collator import init_company_db, get_company_stats, get_all_source_health
|
| 19 |
+
from ui_components import inject_global_css, render_source_health_dots
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
def check_api_key():
|
|
|
|
| 34 |
return run_hunt(min_score=50, progress_callback=progress_callback)
|
| 35 |
|
| 36 |
|
| 37 |
+
# =============================================================================
|
| 38 |
+
# PAGE CONFIG & NAVIGATION
|
| 39 |
+
# =============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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================================================================
|
| 56 |
+
# SIDEBAR - Shared across all pages
|
| 57 |
+
# =============================================================================
|
| 58 |
|
| 59 |
+
with st.sidebar:
|
| 60 |
+
st.markdown(
|
| 61 |
+
'<div style="text-align:center;padding:8px 0;">'
|
| 62 |
+
'<span style="font-size:1.4em;font-weight:800;color:#1a237e;">CURIUM</span><br>'
|
| 63 |
+
'<span style="font-size:0.85em;color:#78909c;">Lead Intelligence Platform</span>'
|
| 64 |
+
'</div>',
|
| 65 |
+
unsafe_allow_html=True,
|
| 66 |
)
|
| 67 |
|
| 68 |
+
st.divider()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
+
# HUNT NOW
|
| 71 |
+
if st.button("\U0001f680 HUNT NOW", type="primary", use_container_width=True, disabled=not has_api_key,
|
| 72 |
+
help="Scan for new opportunities across all sources"):
|
| 73 |
+
status_box = st.empty()
|
| 74 |
+
progress_container = st.container()
|
| 75 |
|
| 76 |
+
with progress_container:
|
| 77 |
+
st.write("**Live Progress:**")
|
| 78 |
+
status_area = st.empty()
|
| 79 |
|
| 80 |
+
try:
|
| 81 |
+
results = run_autonomous_hunt(status_area)
|
| 82 |
+
st.session_state['last_hunt_results'] = results
|
| 83 |
+
time.sleep(1)
|
| 84 |
+
st.rerun()
|
| 85 |
+
except Exception as e:
|
| 86 |
+
st.error(f"Hunt failed: {e}")
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
+
st.caption("Scan all sources for new intelligence")
|
| 89 |
|
| 90 |
+
if not has_api_key:
|
| 91 |
+
st.warning("\u26a0\ufe0f Add ANTHROPIC_API_KEY to .env")
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
# Source health indicator dots
|
| 94 |
+
try:
|
| 95 |
+
source_health = get_all_source_health()
|
| 96 |
+
render_source_health_dots(source_health)
|
| 97 |
+
except Exception:
|
| 98 |
+
pass
|
| 99 |
|
| 100 |
+
st.divider()
|
|
|
|
| 101 |
|
| 102 |
+
# Service-line filter (shared across pages via session state)
|
| 103 |
+
service_filter = st.radio(
|
| 104 |
+
"Service Line",
|
| 105 |
+
["All", "Transformation Delivery", "Culture & Capability", "CODE 3i"],
|
| 106 |
+
key="service_filter",
|
| 107 |
+
horizontal=True,
|
| 108 |
+
)
|
| 109 |
|
| 110 |
+
st.divider()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
+
# Council Scan
|
| 113 |
+
if st.button("\U0001f3db\ufe0f COUNCIL SCAN", use_container_width=True, disabled=not has_api_key,
|
| 114 |
+
help="Scan UK councils for transformation opportunities"):
|
| 115 |
+
council_status = st.empty()
|
| 116 |
+
council_progress = st.container()
|
| 117 |
|
| 118 |
+
with council_progress:
|
| 119 |
+
st.write("**Council Scan Progress:**")
|
| 120 |
+
council_area = st.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
+
try:
|
| 123 |
+
from council_scanner import run_council_scan
|
| 124 |
+
|
| 125 |
+
def council_callback(msg):
|
| 126 |
+
council_area.write(msg)
|
| 127 |
+
|
| 128 |
+
council_results = run_council_scan(progress_callback=council_callback)
|
| 129 |
+
st.success(
|
| 130 |
+
f"\u2705 {council_results['network_hits']} connections, "
|
| 131 |
+
f"{council_results['tenders']} tenders, "
|
| 132 |
+
f"{council_results['jobs']} jobs, "
|
| 133 |
+
f"{council_results['news']} news, "
|
| 134 |
+
f"{council_results['people']} contacts"
|
| 135 |
+
)
|
| 136 |
+
time.sleep(1)
|
| 137 |
+
st.rerun()
|
| 138 |
+
except Exception as e:
|
| 139 |
+
st.error(f"Council scan failed: {e}")
|
| 140 |
|
| 141 |
+
st.divider()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
+
# Quick stats
|
| 144 |
+
try:
|
| 145 |
+
sidebar_stats = get_company_stats()
|
| 146 |
+
c1, c2, c3 = st.columns(3)
|
| 147 |
+
c1.metric("\U0001f3e2", sidebar_stats['total_companies'], help="Total companies tracked")
|
| 148 |
+
c2.metric("\U0001f525", sidebar_stats['hot_companies'], help="Companies scoring 50+")
|
| 149 |
+
c3.metric("\U0001f517", sidebar_stats['with_network'], help="Companies with team connections")
|
| 150 |
+
|
| 151 |
+
with st.expander("\U0001f4ca Detailed Stats"):
|
| 152 |
+
st.caption(f"\U0001f4bc {sidebar_stats['total_jobs']} Jobs | \U0001f4f0 {sidebar_stats['total_news']} News")
|
| 153 |
+
st.caption(f"\U0001f4c4 {sidebar_stats.get('total_reports', 0)} Reports | \U0001f3db\ufe0f {sidebar_stats.get('total_tenders', 0)} Tenders")
|
| 154 |
+
st.caption(f"\U0001f610 {sidebar_stats.get('total_sentiment', 0)} Sentiment")
|
| 155 |
+
st.caption(f"\U0001f91d {sidebar_stats.get('total_pe_deals', 0)} M&A | \U0001f50d {sidebar_stats.get('total_linkedin_intel', 0)} LI Intel")
|
| 156 |
+
st.caption(f"TD Pipeline: {sidebar_stats.get('td_hot', 0)} | CC Pipeline: {sidebar_stats.get('cc_hot', 0)}")
|
| 157 |
+
except Exception:
|
| 158 |
+
st.caption("No data yet \u2014 run a hunt to get started")
|
| 159 |
|
| 160 |
+
st.divider()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
+
# Network
|
| 163 |
+
st.subheader("\U0001f517 Network")
|
| 164 |
+
try:
|
| 165 |
+
net_stats = get_network_stats()
|
| 166 |
+
st.caption(f"{net_stats.get('total_connections', 0)} connections loaded")
|
| 167 |
+
except Exception:
|
| 168 |
+
st.caption("No network data")
|
| 169 |
+
|
| 170 |
+
uploaded_file = st.file_uploader(
|
| 171 |
+
"Upload Connections",
|
| 172 |
+
type=['csv', 'xlsx'],
|
| 173 |
+
help="Upload your team's LinkedIn connections export (CSV or Excel)"
|
| 174 |
+
)
|
| 175 |
|
| 176 |
+
if uploaded_file is not None:
|
| 177 |
+
os.makedirs("data", exist_ok=True)
|
| 178 |
+
ext = uploaded_file.name.rsplit('.', 1)[-1].lower() if '.' in uploaded_file.name else 'csv'
|
| 179 |
+
file_path = f"data/my_team_connections.{ext}"
|
|
|
|
|
|
|
| 180 |
|
| 181 |
+
with open(file_path, "wb") as f:
|
| 182 |
+
f.write(uploaded_file.getbuffer())
|
| 183 |
|
| 184 |
+
result = load_master_csv(file_path, clear_existing=True)
|
| 185 |
+
if result.get('success'):
|
| 186 |
+
st.success(f"\u2705 Loaded {result['imported']} connections from {len(result.get('colleagues', []))} team members")
|
| 187 |
+
st.rerun()
|
| 188 |
+
else:
|
| 189 |
+
st.error(f"Import failed: {result.get('error', 'Unknown error')}")
|
|
|
|
| 190 |
|
| 191 |
+
st.divider()
|
| 192 |
|
| 193 |
+
# LinkedIn Deep Intelligence
|
| 194 |
+
with st.expander("\U0001f50d LinkedIn Deep", expanded=False):
|
| 195 |
+
st.caption("Enrich companies with LinkedIn profile data, mutual connections, and activity signals")
|
| 196 |
try:
|
| 197 |
from linkedin_intel import get_linkedin_session_status
|
| 198 |
li_status = get_linkedin_session_status()
|
|
|
|
| 203 |
else:
|
| 204 |
st.caption("LinkedIn: Not configured")
|
| 205 |
|
| 206 |
+
if st.button("\U0001f510 Setup LinkedIn Login", use_container_width=True):
|
| 207 |
st.session_state['linkedin_setup'] = True
|
| 208 |
st.rerun()
|
| 209 |
|
| 210 |
if st.session_state.get('linkedin_setup'):
|
| 211 |
st.info(
|
| 212 |
"A browser window will open. Please log in to LinkedIn "
|
| 213 |
+
"(including 2FA if needed). Do NOT close the browser \u2014 "
|
| 214 |
"it will close automatically once login is detected."
|
| 215 |
)
|
| 216 |
try:
|
|
|
|
| 229 |
finally:
|
| 230 |
st.session_state['linkedin_setup'] = False
|
| 231 |
|
|
|
|
| 232 |
try:
|
| 233 |
from linkedin_intel import check_daily_limits
|
| 234 |
limits = check_daily_limits()
|
|
|
|
| 242 |
except ImportError:
|
| 243 |
st.caption("LinkedIn module not available")
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
+
# =============================================================================
|
| 254 |
+
# NAVIGATION
|
| 255 |
+
# =============================================================================
|
|
|
|
|
|
|
| 256 |
|
| 257 |
+
pages = st.navigation([
|
| 258 |
+
st.Page("pages/1_Dashboard.py", title="Dashboard", icon="\U0001f3af", default=True),
|
| 259 |
+
st.Page("pages/2_Approach_Brief.py", title="Approach Brief", icon="\U0001f4cb"),
|
| 260 |
+
st.Page("pages/3_Tenders.py", title="Government Tenders", icon="\U0001f3db\ufe0f"),
|
| 261 |
+
st.Page("pages/4_Councils.py", title="Council Opportunities", icon="\U0001f3db\ufe0f"),
|
| 262 |
+
st.Page("pages/5_LinkedIn_Hub.py", title="LinkedIn Hub", icon="\U0001f517"),
|
| 263 |
+
st.Page("pages/6_Intelligence.py", title="Intelligence Query", icon="\U0001f916"),
|
| 264 |
+
st.Page("pages/7_Source_Health.py", title="Source Health", icon="\U0001f6e0\ufe0f"),
|
| 265 |
+
])
|
| 266 |
|
| 267 |
+
pages.run()
|
|
|
collator.py
CHANGED
|
@@ -48,6 +48,20 @@ SIGNAL_SERVICE_MAP = {
|
|
| 48 |
'general': {'td': 0.5, 'cc': 0.5},
|
| 49 |
}
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
# =============================================================================
|
| 52 |
# SCORING WEIGHTS
|
| 53 |
# =============================================================================
|
|
@@ -102,6 +116,11 @@ SCORE_WEIGHTS = {
|
|
| 102 |
'linkedin_transformation_post': 15, # Contact posting about transformation
|
| 103 |
'linkedin_intel_plus_job': 25, # LinkedIn intel + job posting combo
|
| 104 |
'linkedin_multiple_contacts': 10, # 3+ contacts at same company
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
}
|
| 106 |
|
| 107 |
|
|
@@ -573,6 +592,10 @@ def add_tender_signal(company_name: str, title: str, value: float,
|
|
| 573 |
conn = get_connection()
|
| 574 |
cursor = conn.cursor()
|
| 575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 576 |
cursor.execute("""
|
| 577 |
INSERT INTO signals_tenders (company_id, title, value, deadline, days_to_deadline, is_urgent, matched_keywords, tender_url, date_found)
|
| 578 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
@@ -822,7 +845,10 @@ def _best_freshness(dates: list) -> float:
|
|
| 822 |
"""Return the best (highest) freshness multiplier from a list of date strings."""
|
| 823 |
if not dates:
|
| 824 |
return 1.0
|
| 825 |
-
|
|
|
|
|
|
|
|
|
|
| 826 |
|
| 827 |
|
| 828 |
def recalculate_company_score(company_id: int):
|
|
@@ -928,7 +954,8 @@ def recalculate_company_score(company_id: int):
|
|
| 928 |
|
| 929 |
if annual_reports:
|
| 930 |
ar_freshness = _best_freshness([r[1] for r in annual_reports])
|
| 931 |
-
|
|
|
|
| 932 |
if best_report_score >= 60:
|
| 933 |
score += int(SCORE_WEIGHTS['annual_report_strong'] * ar_freshness)
|
| 934 |
signals.append("strong annual report signal")
|
|
@@ -947,22 +974,24 @@ def recalculate_company_score(company_id: int):
|
|
| 947 |
|
| 948 |
if sentiment_signals:
|
| 949 |
sent_freshness = _best_freshness([s[2] for s in sentiment_signals])
|
| 950 |
-
|
| 951 |
-
|
|
|
|
|
|
|
| 952 |
|
| 953 |
-
if best_rating < 3.0:
|
| 954 |
score += int(SCORE_WEIGHTS['sentiment_poor'] * sent_freshness)
|
| 955 |
signals.append("poor sentiment")
|
| 956 |
-
elif best_rating < 3.5:
|
| 957 |
score += int(SCORE_WEIGHTS['sentiment_warning'] * sent_freshness)
|
| 958 |
signals.append("sentiment warning")
|
| 959 |
|
| 960 |
-
if best_mgmt and best_mgmt < 2.5:
|
| 961 |
score += int(SCORE_WEIGHTS['management_crisis'] * sent_freshness)
|
| 962 |
signals.append("management crisis")
|
| 963 |
|
| 964 |
# Combo: sentiment + jobs
|
| 965 |
-
if job_count > 0 and best_rating < 3.5:
|
| 966 |
score += int(SCORE_WEIGHTS['sentiment_plus_job'] * sent_freshness)
|
| 967 |
signals.append("sentiment+job combo")
|
| 968 |
|
|
@@ -1031,6 +1060,27 @@ def recalculate_company_score(company_id: int):
|
|
| 1031 |
score += SCORE_WEIGHTS['linkedin_intel_plus_job']
|
| 1032 |
signals.append("LI+job combo")
|
| 1033 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1034 |
# Get network signals
|
| 1035 |
cursor.execute("SELECT contact_name, colleague_name, connection_tier FROM signals_network WHERE company_id = ?", (company_id,))
|
| 1036 |
network = cursor.fetchall()
|
|
@@ -1056,11 +1106,54 @@ def recalculate_company_score(company_id: int):
|
|
| 1056 |
network_status = "🔗 Company"
|
| 1057 |
signals.append("🔗 company connection")
|
| 1058 |
|
| 1059 |
-
# Get best contact info
|
|
|
|
|
|
|
| 1060 |
for contact, colleague, tier in network:
|
| 1061 |
-
if tier == 'DIRECT HIT'
|
| 1062 |
-
|
| 1063 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1064 |
|
| 1065 |
# =================================================================
|
| 1066 |
# TEMPORAL URGENCY SCORING
|
|
@@ -1139,12 +1232,23 @@ def recalculate_company_score(company_id: int):
|
|
| 1139 |
all_recommended_services = set()
|
| 1140 |
|
| 1141 |
# Collect signal types from news
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1142 |
detected_signal_types = set()
|
| 1143 |
if news_count > 0:
|
| 1144 |
trigger_types = [n[2] for n in news if n[2]]
|
| 1145 |
for tt in trigger_types:
|
| 1146 |
if tt in SIGNAL_SERVICE_MAP:
|
| 1147 |
detected_signal_types.add(tt)
|
|
|
|
|
|
|
| 1148 |
|
| 1149 |
# Collect signal types from jobs (via job_analysis JSON)
|
| 1150 |
for job in jobs:
|
|
@@ -1168,12 +1272,13 @@ def recalculate_company_score(company_id: int):
|
|
| 1168 |
|
| 1169 |
# Sentiment signals boost CC strongly
|
| 1170 |
if sentiment_signals:
|
| 1171 |
-
|
| 1172 |
-
if
|
|
|
|
| 1173 |
w = SIGNAL_SERVICE_MAP.get('sentiment_poor', {'td': 0.3, 'cc': 1.0})
|
| 1174 |
td_score_val += int(20 * w['td'])
|
| 1175 |
cc_score_val += int(20 * w['cc'])
|
| 1176 |
-
elif
|
| 1177 |
w = SIGNAL_SERVICE_MAP.get('sentiment_poor', {'td': 0.3, 'cc': 1.0})
|
| 1178 |
td_score_val += int(10 * w['td'])
|
| 1179 |
cc_score_val += int(10 * w['cc'])
|
|
@@ -1192,7 +1297,73 @@ def recalculate_company_score(company_id: int):
|
|
| 1192 |
td_score_val += 5
|
| 1193 |
cc_score_val += 5
|
| 1194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1195 |
# Build recommended services list
|
|
|
|
|
|
|
|
|
|
| 1196 |
if td_score_val >= 20:
|
| 1197 |
if any('programme' in (j[0] or '').lower() or 'pmo' in (j[0] or '').lower() for j in jobs):
|
| 1198 |
all_recommended_services.add('project_programme_management')
|
|
@@ -1201,7 +1372,19 @@ def recalculate_company_score(company_id: int):
|
|
| 1201 |
all_recommended_services.add('change_management')
|
| 1202 |
if 'merger_acquisition' in detected_signal_types or pe_signals:
|
| 1203 |
all_recommended_services.add('ma_integration')
|
| 1204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1205 |
all_recommended_services.add('change_management')
|
| 1206 |
|
| 1207 |
if cc_score_val >= 20:
|
|
@@ -1211,12 +1394,36 @@ def recalculate_company_score(company_id: int):
|
|
| 1211 |
if 'culture_crisis' in detected_signal_types:
|
| 1212 |
all_recommended_services.add('culture_diagnostics')
|
| 1213 |
all_recommended_services.add('code_3i')
|
|
|
|
| 1214 |
if sentiment_signals:
|
| 1215 |
all_recommended_services.add('culture_diagnostics')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1216 |
if 'new_team' in detected_signal_types:
|
| 1217 |
all_recommended_services.add('team_profiling')
|
| 1218 |
all_recommended_services.add('code_3i')
|
| 1219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1220 |
all_recommended_services.add('leadership_strategy')
|
| 1221 |
|
| 1222 |
# Cap scores
|
|
@@ -1233,7 +1440,7 @@ def recalculate_company_score(company_id: int):
|
|
| 1233 |
best_contact = ?, best_colleague = ?, last_updated = ?,
|
| 1234 |
td_score = ?, cc_score = ?, recommended_services = ?
|
| 1235 |
WHERE id = ?
|
| 1236 |
-
""", (score, signal_summary, network_status, best_contact, best_colleague,
|
| 1237 |
datetime.now().isoformat(), td_score_val, cc_score_val,
|
| 1238 |
recommended_services_json, company_id))
|
| 1239 |
|
|
|
|
| 48 |
'general': {'td': 0.5, 'cc': 0.5},
|
| 49 |
}
|
| 50 |
|
| 51 |
+
# LinkedIn group → service line mapping (for group-specific scoring)
|
| 52 |
+
LINKEDIN_GROUP_SERVICE_MAP = {
|
| 53 |
+
'employee experience and engagement': {'td': 0.3, 'cc': 1.0, 'services': ['culture_diagnostics', 'mindset_behaviour']},
|
| 54 |
+
'hr circle': {'td': 0.3, 'cc': 1.0, 'services': ['culture_diagnostics', 'leadership_strategy']},
|
| 55 |
+
'cipd community': {'td': 0.2, 'cc': 1.0, 'services': ['mindset_behaviour', 'culture_diagnostics']},
|
| 56 |
+
'change management institute': {'td': 1.0, 'cc': 0.5, 'services': ['change_management', 'project_programme_management']},
|
| 57 |
+
'pmo professionals': {'td': 1.0, 'cc': 0.2, 'services': ['project_programme_management', 'tmo_pmo']},
|
| 58 |
+
'uk government digital': {'td': 0.8, 'cc': 0.4, 'services': ['agile_lean', 'change_management']},
|
| 59 |
+
'nhs leaders network': {'td': 0.6, 'cc': 0.8, 'services': ['leadership_strategy', 'change_management']},
|
| 60 |
+
'management consultants network': {'td': 0.7, 'cc': 0.5, 'services': ['change_management', 'operating_models']},
|
| 61 |
+
'leadership development network': {'td': 0.3, 'cc': 1.0, 'services': ['executive_coaching', 'leadership_strategy']},
|
| 62 |
+
'm&a integration professionals': {'td': 1.0, 'cc': 0.5, 'services': ['ma_integration', 'change_management']},
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
# =============================================================================
|
| 66 |
# SCORING WEIGHTS
|
| 67 |
# =============================================================================
|
|
|
|
| 116 |
'linkedin_transformation_post': 15, # Contact posting about transformation
|
| 117 |
'linkedin_intel_plus_job': 25, # LinkedIn intel + job posting combo
|
| 118 |
'linkedin_multiple_contacts': 10, # 3+ contacts at same company
|
| 119 |
+
|
| 120 |
+
# LinkedIn groups bonuses
|
| 121 |
+
'linkedin_group_signal': 15, # Active in a relevant LinkedIn group
|
| 122 |
+
'linkedin_group_multi': 10, # Appears in 2+ groups
|
| 123 |
+
'linkedin_group_plus_job': 20, # Group activity + job posting combo
|
| 124 |
}
|
| 125 |
|
| 126 |
|
|
|
|
| 592 |
conn = get_connection()
|
| 593 |
cursor = conn.cursor()
|
| 594 |
|
| 595 |
+
if _is_duplicate_signal(cursor, 'signals_tenders', company_id, 'title', title, days=14):
|
| 596 |
+
conn.close()
|
| 597 |
+
return company_id
|
| 598 |
+
|
| 599 |
cursor.execute("""
|
| 600 |
INSERT INTO signals_tenders (company_id, title, value, deadline, days_to_deadline, is_urgent, matched_keywords, tender_url, date_found)
|
| 601 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
|
|
| 845 |
"""Return the best (highest) freshness multiplier from a list of date strings."""
|
| 846 |
if not dates:
|
| 847 |
return 1.0
|
| 848 |
+
valid = [d for d in dates if d]
|
| 849 |
+
if not valid:
|
| 850 |
+
return 0.5
|
| 851 |
+
return max(_freshness_multiplier(d) for d in valid)
|
| 852 |
|
| 853 |
|
| 854 |
def recalculate_company_score(company_id: int):
|
|
|
|
| 954 |
|
| 955 |
if annual_reports:
|
| 956 |
ar_freshness = _best_freshness([r[1] for r in annual_reports])
|
| 957 |
+
report_scores = [r[0] for r in annual_reports if r[0] is not None and r[0] > 0]
|
| 958 |
+
best_report_score = max(report_scores) if report_scores else 0
|
| 959 |
if best_report_score >= 60:
|
| 960 |
score += int(SCORE_WEIGHTS['annual_report_strong'] * ar_freshness)
|
| 961 |
signals.append("strong annual report signal")
|
|
|
|
| 974 |
|
| 975 |
if sentiment_signals:
|
| 976 |
sent_freshness = _best_freshness([s[2] for s in sentiment_signals])
|
| 977 |
+
ratings = [s[0] for s in sentiment_signals if s[0] is not None and s[0] > 0]
|
| 978 |
+
best_rating = min(ratings) if ratings else None
|
| 979 |
+
mgmt_ratings = [s[1] for s in sentiment_signals if s[1] is not None and s[1] > 0]
|
| 980 |
+
best_mgmt = min(mgmt_ratings) if mgmt_ratings else None
|
| 981 |
|
| 982 |
+
if best_rating is not None and best_rating < 3.0:
|
| 983 |
score += int(SCORE_WEIGHTS['sentiment_poor'] * sent_freshness)
|
| 984 |
signals.append("poor sentiment")
|
| 985 |
+
elif best_rating is not None and best_rating < 3.5:
|
| 986 |
score += int(SCORE_WEIGHTS['sentiment_warning'] * sent_freshness)
|
| 987 |
signals.append("sentiment warning")
|
| 988 |
|
| 989 |
+
if best_mgmt is not None and best_mgmt < 2.5:
|
| 990 |
score += int(SCORE_WEIGHTS['management_crisis'] * sent_freshness)
|
| 991 |
signals.append("management crisis")
|
| 992 |
|
| 993 |
# Combo: sentiment + jobs
|
| 994 |
+
if job_count > 0 and best_rating is not None and best_rating < 3.5:
|
| 995 |
score += int(SCORE_WEIGHTS['sentiment_plus_job'] * sent_freshness)
|
| 996 |
signals.append("sentiment+job combo")
|
| 997 |
|
|
|
|
| 1060 |
score += SCORE_WEIGHTS['linkedin_intel_plus_job']
|
| 1061 |
signals.append("LI+job combo")
|
| 1062 |
|
| 1063 |
+
# Get LinkedIn group signals (stored as news with source='linkedin_groups')
|
| 1064 |
+
cursor.execute("""
|
| 1065 |
+
SELECT headline, reason, date_found FROM signals_news
|
| 1066 |
+
WHERE company_id = ? AND source = 'linkedin_groups'
|
| 1067 |
+
""", (company_id,))
|
| 1068 |
+
li_group_signals = cursor.fetchall()
|
| 1069 |
+
|
| 1070 |
+
if li_group_signals:
|
| 1071 |
+
lg_freshness = _best_freshness([g[2] for g in li_group_signals])
|
| 1072 |
+
score += int(SCORE_WEIGHTS['linkedin_group_signal'] * lg_freshness)
|
| 1073 |
+
signals.append(f"{len(li_group_signals)} LI group(s)")
|
| 1074 |
+
|
| 1075 |
+
# Multiple group appearances bonus
|
| 1076 |
+
if len(li_group_signals) >= 2:
|
| 1077 |
+
score += int(SCORE_WEIGHTS['linkedin_group_multi'] * lg_freshness)
|
| 1078 |
+
|
| 1079 |
+
# Group + job combo
|
| 1080 |
+
if job_count > 0:
|
| 1081 |
+
score += int(SCORE_WEIGHTS['linkedin_group_plus_job'] * lg_freshness)
|
| 1082 |
+
signals.append("LI group+job combo")
|
| 1083 |
+
|
| 1084 |
# Get network signals
|
| 1085 |
cursor.execute("SELECT contact_name, colleague_name, connection_tier FROM signals_network WHERE company_id = ?", (company_id,))
|
| 1086 |
network = cursor.fetchall()
|
|
|
|
| 1106 |
network_status = "🔗 Company"
|
| 1107 |
signals.append("🔗 company connection")
|
| 1108 |
|
| 1109 |
+
# Get best contact info (with service-affinity awareness)
|
| 1110 |
+
# Group connections by colleague to enable affinity-based routing
|
| 1111 |
+
colleague_connections = {}
|
| 1112 |
for contact, colleague, tier in network:
|
| 1113 |
+
if colleague not in colleague_connections or tier == 'DIRECT HIT':
|
| 1114 |
+
colleague_connections[colleague] = (contact, tier)
|
| 1115 |
+
|
| 1116 |
+
if len(colleague_connections) > 1:
|
| 1117 |
+
# Multiple colleagues have connections — route by service affinity
|
| 1118 |
+
try:
|
| 1119 |
+
from network_loader import _get_team_service_focus
|
| 1120 |
+
team_focus = _get_team_service_focus()
|
| 1121 |
+
except ImportError:
|
| 1122 |
+
team_focus = {}
|
| 1123 |
+
|
| 1124 |
+
# We'll use td_score_val and cc_score_val later, but they're not
|
| 1125 |
+
# computed yet. Use signal heuristics instead:
|
| 1126 |
+
td_signals = sum(1 for s in signals if any(kw in s for kw in ['restructuring', 'M&A', 'PE', 'programme', 'pmo', 'operating']))
|
| 1127 |
+
cc_signals = sum(1 for s in signals if any(kw in s for kw in ['leadership', 'sentiment', 'culture', 'coaching', 'wellbeing']))
|
| 1128 |
+
|
| 1129 |
+
dominant = None
|
| 1130 |
+
if td_signals > cc_signals + 1:
|
| 1131 |
+
dominant = 'transformation_delivery'
|
| 1132 |
+
elif cc_signals > td_signals + 1:
|
| 1133 |
+
dominant = 'culture_capability'
|
| 1134 |
+
|
| 1135 |
+
if dominant:
|
| 1136 |
+
# Prefer colleague whose focus matches the dominant need
|
| 1137 |
+
scored = []
|
| 1138 |
+
for coll, (cont, tier) in colleague_connections.items():
|
| 1139 |
+
focus = team_focus.get(coll.lower(), [])
|
| 1140 |
+
affinity = 1 if dominant in focus else 0
|
| 1141 |
+
tier_val = 0 if tier == 'DIRECT HIT' else (1 if tier == 'SENIOR CONNECTION' else 2)
|
| 1142 |
+
scored.append((tier_val, -affinity, coll, cont))
|
| 1143 |
+
scored.sort()
|
| 1144 |
+
best_colleague = scored[0][2]
|
| 1145 |
+
best_contact = scored[0][3]
|
| 1146 |
+
else:
|
| 1147 |
+
# No clear dominant — pick best tier
|
| 1148 |
+
for contact, colleague, tier in network:
|
| 1149 |
+
if tier == 'DIRECT HIT' or (not best_contact):
|
| 1150 |
+
best_contact = contact
|
| 1151 |
+
best_colleague = colleague
|
| 1152 |
+
else:
|
| 1153 |
+
for contact, colleague, tier in network:
|
| 1154 |
+
if tier == 'DIRECT HIT' or (not best_contact):
|
| 1155 |
+
best_contact = contact
|
| 1156 |
+
best_colleague = colleague
|
| 1157 |
|
| 1158 |
# =================================================================
|
| 1159 |
# TEMPORAL URGENCY SCORING
|
|
|
|
| 1232 |
all_recommended_services = set()
|
| 1233 |
|
| 1234 |
# Collect signal types from news
|
| 1235 |
+
# Map short trigger types (as stored in DB) to SIGNAL_SERVICE_MAP keys
|
| 1236 |
+
TRIGGER_TO_SIGNAL = {
|
| 1237 |
+
'leadership': 'leadership_change',
|
| 1238 |
+
'merger': 'merger_acquisition',
|
| 1239 |
+
'digital': 'digital_transformation',
|
| 1240 |
+
'ai_automation': 'digital_transformation',
|
| 1241 |
+
'appointment': 'leadership_change',
|
| 1242 |
+
'closure': 'restructuring',
|
| 1243 |
+
}
|
| 1244 |
detected_signal_types = set()
|
| 1245 |
if news_count > 0:
|
| 1246 |
trigger_types = [n[2] for n in news if n[2]]
|
| 1247 |
for tt in trigger_types:
|
| 1248 |
if tt in SIGNAL_SERVICE_MAP:
|
| 1249 |
detected_signal_types.add(tt)
|
| 1250 |
+
elif tt in TRIGGER_TO_SIGNAL:
|
| 1251 |
+
detected_signal_types.add(TRIGGER_TO_SIGNAL[tt])
|
| 1252 |
|
| 1253 |
# Collect signal types from jobs (via job_analysis JSON)
|
| 1254 |
for job in jobs:
|
|
|
|
| 1272 |
|
| 1273 |
# Sentiment signals boost CC strongly
|
| 1274 |
if sentiment_signals:
|
| 1275 |
+
_sl_ratings = [s[0] for s in sentiment_signals if s[0] is not None and s[0] > 0]
|
| 1276 |
+
_sl_best = min(_sl_ratings) if _sl_ratings else None
|
| 1277 |
+
if _sl_best is not None and _sl_best < 3.0:
|
| 1278 |
w = SIGNAL_SERVICE_MAP.get('sentiment_poor', {'td': 0.3, 'cc': 1.0})
|
| 1279 |
td_score_val += int(20 * w['td'])
|
| 1280 |
cc_score_val += int(20 * w['cc'])
|
| 1281 |
+
elif _sl_best is not None and _sl_best < 3.5:
|
| 1282 |
w = SIGNAL_SERVICE_MAP.get('sentiment_poor', {'td': 0.3, 'cc': 1.0})
|
| 1283 |
td_score_val += int(10 * w['td'])
|
| 1284 |
cc_score_val += int(10 * w['cc'])
|
|
|
|
| 1297 |
td_score_val += 5
|
| 1298 |
cc_score_val += 5
|
| 1299 |
|
| 1300 |
+
# LinkedIn group-specific TD/CC scoring and service recommendations
|
| 1301 |
+
if li_group_signals:
|
| 1302 |
+
for lg in li_group_signals:
|
| 1303 |
+
headline = (lg[0] or '').lower()
|
| 1304 |
+
for group_key, group_info in LINKEDIN_GROUP_SERVICE_MAP.items():
|
| 1305 |
+
if group_key in headline:
|
| 1306 |
+
td_score_val += int(10 * group_info['td'])
|
| 1307 |
+
cc_score_val += int(10 * group_info['cc'])
|
| 1308 |
+
for svc in group_info.get('services', []):
|
| 1309 |
+
all_recommended_services.add(svc)
|
| 1310 |
+
break
|
| 1311 |
+
|
| 1312 |
+
# =================================================================
|
| 1313 |
+
# CROSS-SIGNAL CONVERGENCE PATTERNS
|
| 1314 |
+
# Multi-signal combinations that indicate active transformation
|
| 1315 |
+
# =================================================================
|
| 1316 |
+
|
| 1317 |
+
# Collect raw trigger types for convergence checks (these use short names: 'leadership', 'merger', etc.)
|
| 1318 |
+
raw_trigger_types = set(n[2] for n in news if n[2]) if news_count > 0 else set()
|
| 1319 |
+
|
| 1320 |
+
# Pattern 1: "New leader reshaping culture"
|
| 1321 |
+
# Leadership change + poor sentiment = incoming culture transformation
|
| 1322 |
+
has_leadership = 'leadership' in raw_trigger_types or 'appointment' in raw_trigger_types or 'leadership_change' in detected_signal_types
|
| 1323 |
+
_conv_ratings = [s[0] for s in sentiment_signals if s[0] is not None and s[0] > 0] if sentiment_signals else []
|
| 1324 |
+
has_poor_sentiment = bool(_conv_ratings) and min(_conv_ratings) < 3.5
|
| 1325 |
+
if has_leadership and has_poor_sentiment:
|
| 1326 |
+
cc_score_val += 20
|
| 1327 |
+
td_score_val += 10
|
| 1328 |
+
signals.append("convergence: leader+sentiment")
|
| 1329 |
+
|
| 1330 |
+
# Pattern 2: "Restructuring under pressure"
|
| 1331 |
+
# Restructuring + hiring surge (multiple jobs) = active transformation
|
| 1332 |
+
has_restructuring = 'restructuring' in raw_trigger_types or 'restructuring' in detected_signal_types or 'operating_model_change' in detected_signal_types
|
| 1333 |
+
has_hiring_surge = job_count >= 3
|
| 1334 |
+
if has_restructuring and has_hiring_surge:
|
| 1335 |
+
td_score_val += 20
|
| 1336 |
+
cc_score_val += 10
|
| 1337 |
+
signals.append("convergence: restructure+hiring")
|
| 1338 |
+
|
| 1339 |
+
# Pattern 3: "Post-acquisition integration chaos"
|
| 1340 |
+
# M&A/PE + jobs + sentiment = full transformation opportunity
|
| 1341 |
+
has_ma = 'merger' in raw_trigger_types or 'merger_acquisition' in detected_signal_types or bool(pe_signals)
|
| 1342 |
+
if has_ma and job_count > 0 and has_poor_sentiment:
|
| 1343 |
+
td_score_val += 20
|
| 1344 |
+
cc_score_val += 20
|
| 1345 |
+
signals.append("convergence: M&A+jobs+sentiment")
|
| 1346 |
+
|
| 1347 |
+
# Pattern 4: "Culture crisis with no leadership"
|
| 1348 |
+
# Culture crisis + wellbeing issues + no leadership change = needs external help
|
| 1349 |
+
has_culture_crisis = 'culture_crisis' in detected_signal_types or 'wellbeing_crisis' in detected_signal_types or 'culture' in raw_trigger_types
|
| 1350 |
+
if has_culture_crisis and has_poor_sentiment and not has_leadership:
|
| 1351 |
+
cc_score_val += 25
|
| 1352 |
+
signals.append("convergence: culture crisis (no leader)")
|
| 1353 |
+
|
| 1354 |
+
# Pattern 5: "Digital transformation people gap"
|
| 1355 |
+
# Digital/AI signals + culture or team jobs = need people-side support
|
| 1356 |
+
has_digital = 'digital_transformation' in detected_signal_types or 'digital' in raw_trigger_types or 'ai_automation' in raw_trigger_types
|
| 1357 |
+
has_people_jobs = any(kw in (j[0] or '').lower() for j in jobs for kw in ['change', 'people', 'culture', 'engagement'])
|
| 1358 |
+
if has_digital and has_people_jobs:
|
| 1359 |
+
cc_score_val += 15
|
| 1360 |
+
td_score_val += 10
|
| 1361 |
+
signals.append("convergence: digital+people gap")
|
| 1362 |
+
|
| 1363 |
# Build recommended services list
|
| 1364 |
+
# Also scan job titles for keyword-based service matching
|
| 1365 |
+
all_job_titles_lower = ' '.join((j[0] or '').lower() for j in jobs)
|
| 1366 |
+
|
| 1367 |
if td_score_val >= 20:
|
| 1368 |
if any('programme' in (j[0] or '').lower() or 'pmo' in (j[0] or '').lower() for j in jobs):
|
| 1369 |
all_recommended_services.add('project_programme_management')
|
|
|
|
| 1372 |
all_recommended_services.add('change_management')
|
| 1373 |
if 'merger_acquisition' in detected_signal_types or pe_signals:
|
| 1374 |
all_recommended_services.add('ma_integration')
|
| 1375 |
+
# TMO/PMO: job titles or operating model change signals
|
| 1376 |
+
if any(kw in all_job_titles_lower for kw in ['tmo', 'pmo director', 'portfolio management', 'transformation office']):
|
| 1377 |
+
all_recommended_services.add('tmo_pmo')
|
| 1378 |
+
# Business Analysis: job titles mentioning BA/requirements/process
|
| 1379 |
+
if any(kw in all_job_titles_lower for kw in ['business analyst', 'business analysis', 'requirements', 'process improvement']):
|
| 1380 |
+
all_recommended_services.add('business_analysis')
|
| 1381 |
+
# Agile/Lean: digital transformation or agile job titles
|
| 1382 |
+
if 'digital_transformation' in detected_signal_types or any(kw in all_job_titles_lower for kw in ['agile', 'scrum', 'lean', 'ways of working']):
|
| 1383 |
+
all_recommended_services.add('agile_lean')
|
| 1384 |
+
# Service Desk: ITSM or service desk job titles
|
| 1385 |
+
if any(kw in all_job_titles_lower for kw in ['service desk', 'itsm', 'service management', 'it operations']):
|
| 1386 |
+
all_recommended_services.add('service_desk')
|
| 1387 |
+
if not all_recommended_services & {'project_programme_management', 'operating_models', 'ma_integration', 'tmo_pmo', 'business_analysis', 'agile_lean', 'service_desk'}:
|
| 1388 |
all_recommended_services.add('change_management')
|
| 1389 |
|
| 1390 |
if cc_score_val >= 20:
|
|
|
|
| 1394 |
if 'culture_crisis' in detected_signal_types:
|
| 1395 |
all_recommended_services.add('culture_diagnostics')
|
| 1396 |
all_recommended_services.add('code_3i')
|
| 1397 |
+
all_recommended_services.add('mindset_behaviour')
|
| 1398 |
if sentiment_signals:
|
| 1399 |
all_recommended_services.add('culture_diagnostics')
|
| 1400 |
+
# Poor management rating → dysfunctional teams / coaching
|
| 1401 |
+
if any(s[1] is not None and s[1] > 0 and s[1] < 2.5 for s in sentiment_signals):
|
| 1402 |
+
all_recommended_services.add('dysfunctional_teams')
|
| 1403 |
+
all_recommended_services.add('one_to_one_coaching')
|
| 1404 |
if 'new_team' in detected_signal_types:
|
| 1405 |
all_recommended_services.add('team_profiling')
|
| 1406 |
all_recommended_services.add('code_3i')
|
| 1407 |
+
all_recommended_services.add('facilitation')
|
| 1408 |
+
if 'wellbeing_crisis' in detected_signal_types:
|
| 1409 |
+
all_recommended_services.add('resilience')
|
| 1410 |
+
all_recommended_services.add('one_to_one_coaching')
|
| 1411 |
+
# Facilitation: strategy/offsite keywords in news
|
| 1412 |
+
if any(kw in all_job_titles_lower for kw in ['facilitation', 'workshop', 'offsite', 'strategy day']):
|
| 1413 |
+
all_recommended_services.add('facilitation')
|
| 1414 |
+
# Resilience: wellbeing/burnout keywords
|
| 1415 |
+
if any(kw in all_job_titles_lower for kw in ['wellbeing', 'resilience', 'mental health', 'burnout']):
|
| 1416 |
+
all_recommended_services.add('resilience')
|
| 1417 |
+
# Coaching: coaching/development keywords
|
| 1418 |
+
if any(kw in all_job_titles_lower for kw in ['coaching', 'personal development', 'performance coach', 'talent development']):
|
| 1419 |
+
all_recommended_services.add('one_to_one_coaching')
|
| 1420 |
+
# Dysfunctional teams: team conflict/dysfunction keywords
|
| 1421 |
+
if any(kw in all_job_titles_lower for kw in ['team conflict', 'team reset', 'team dysfunction']):
|
| 1422 |
+
all_recommended_services.add('dysfunctional_teams')
|
| 1423 |
+
# Mindset/behaviour: values/culture shift keywords
|
| 1424 |
+
if any(kw in all_job_titles_lower for kw in ['behavioural change', 'mindset', 'values programme', 'culture shift', 'psychological safety']):
|
| 1425 |
+
all_recommended_services.add('mindset_behaviour')
|
| 1426 |
+
if not all_recommended_services & {'executive_coaching', 'culture_diagnostics', 'team_profiling', 'facilitation', 'resilience', 'one_to_one_coaching', 'dysfunctional_teams', 'mindset_behaviour'}:
|
| 1427 |
all_recommended_services.add('leadership_strategy')
|
| 1428 |
|
| 1429 |
# Cap scores
|
|
|
|
| 1440 |
best_contact = ?, best_colleague = ?, last_updated = ?,
|
| 1441 |
td_score = ?, cc_score = ?, recommended_services = ?
|
| 1442 |
WHERE id = ?
|
| 1443 |
+
""", (min(score, 100), signal_summary, network_status, best_contact, best_colleague,
|
| 1444 |
datetime.now().isoformat(), td_score_val, cc_score_val,
|
| 1445 |
recommended_services_json, company_id))
|
| 1446 |
|
config.yaml
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
# =============================================================================
|
| 2 |
-
# CURIUM
|
| 3 |
# =============================================================================
|
| 4 |
-
#
|
| 5 |
-
#
|
| 6 |
# =============================================================================
|
| 7 |
|
| 8 |
# -----------------------------------------------------------------------------
|
|
@@ -11,61 +11,330 @@
|
|
| 11 |
company:
|
| 12 |
name: "Curium Solutions"
|
| 13 |
product: "CODE Ecosystem"
|
| 14 |
-
focus: "
|
| 15 |
target_turnover: "£500m - £5bn"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# -----------------------------------------------------------------------------
|
| 18 |
# TARGET SECTORS
|
| 19 |
-
# Define the industries and sectors to hunt in.
|
| 20 |
-
# The agent will rotate through these sectors.
|
| 21 |
# -----------------------------------------------------------------------------
|
| 22 |
target_sectors:
|
| 23 |
- name: "UK Retail"
|
| 24 |
keywords: ["retail", "supermarket", "grocery", "fashion retail", "ecommerce"]
|
| 25 |
-
companies: ["Tesco", "Sainsbury", "Marks & Spencer", "Next", "John Lewis"]
|
| 26 |
|
| 27 |
- name: "UK Financial Services"
|
| 28 |
keywords: ["banking", "insurance", "fintech", "asset management"]
|
| 29 |
-
companies: ["Barclays", "Lloyds", "HSBC", "Aviva", "Legal & General"]
|
| 30 |
|
| 31 |
-
- name: "UK Manufacturing"
|
| 32 |
keywords: ["manufacturing", "automotive", "aerospace", "engineering"]
|
| 33 |
-
companies: ["Rolls-Royce", "BAE Systems", "JCB", "Unilever"]
|
| 34 |
|
| 35 |
- name: "UK Healthcare"
|
| 36 |
keywords: ["NHS", "healthcare", "pharma", "life sciences"]
|
| 37 |
companies: ["GSK", "AstraZeneca", "Bupa"]
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
- name: "FTSE 250"
|
| 40 |
keywords: ["FTSE 250", "mid-cap", "UK listed"]
|
| 41 |
-
companies: []
|
| 42 |
|
| 43 |
- name: "Public Sector"
|
| 44 |
keywords: ["government", "council", "NHS trust", "public sector"]
|
| 45 |
-
companies: []
|
| 46 |
|
| 47 |
# -----------------------------------------------------------------------------
|
| 48 |
# JOB SEARCH KEYWORDS
|
| 49 |
-
#
|
| 50 |
# -----------------------------------------------------------------------------
|
| 51 |
job_keywords:
|
| 52 |
high_priority:
|
|
|
|
| 53 |
- "Head of Transformation"
|
| 54 |
- "Director of Change"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
- "Head of Leadership Development"
|
| 56 |
- "Chief People Officer"
|
| 57 |
- "Head of Organisational Development"
|
| 58 |
- "VP People & Culture"
|
| 59 |
- "Head of Culture"
|
| 60 |
-
- "Director of HR Transformation"
|
| 61 |
-
- "Head of Employee Experience"
|
| 62 |
- "Director of Culture"
|
| 63 |
- "Chief Culture Officer"
|
| 64 |
- "Head of Engagement"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
medium_priority:
|
|
|
|
| 67 |
- "Change Manager"
|
| 68 |
- "Transformation Lead"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
- "Leadership Development Manager"
|
| 70 |
- "OD Manager"
|
| 71 |
- "HR Business Partner"
|
|
@@ -77,6 +346,8 @@ job_keywords:
|
|
| 77 |
- "Behavioural Change Lead"
|
| 78 |
- "Organisation Design Manager"
|
| 79 |
- "Employee Engagement Specialist"
|
|
|
|
|
|
|
| 80 |
|
| 81 |
locations:
|
| 82 |
- "London"
|
|
@@ -87,42 +358,74 @@ job_keywords:
|
|
| 87 |
|
| 88 |
# -----------------------------------------------------------------------------
|
| 89 |
# NEWS TRIGGER KEYWORDS
|
| 90 |
-
#
|
|
|
|
| 91 |
# -----------------------------------------------------------------------------
|
| 92 |
news_triggers:
|
| 93 |
high_signal:
|
| 94 |
-
- "profit warning"
|
| 95 |
-
|
| 96 |
-
- "
|
| 97 |
-
|
| 98 |
-
- "
|
| 99 |
-
|
| 100 |
-
-
|
| 101 |
-
|
| 102 |
-
-
|
| 103 |
-
|
| 104 |
-
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
medium_signal:
|
| 108 |
-
- "strategic review"
|
| 109 |
-
|
| 110 |
-
- "
|
| 111 |
-
|
| 112 |
-
-
|
| 113 |
-
|
| 114 |
-
- "
|
| 115 |
-
|
| 116 |
-
- "
|
| 117 |
-
|
| 118 |
-
- "
|
| 119 |
-
|
| 120 |
-
- "
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
# -----------------------------------------------------------------------------
|
| 124 |
# TENDER KEYWORDS
|
| 125 |
-
# For UK Government tender searches.
|
| 126 |
# -----------------------------------------------------------------------------
|
| 127 |
tender_keywords:
|
| 128 |
- "transformation"
|
|
@@ -139,33 +442,53 @@ tender_keywords:
|
|
| 139 |
- "wellbeing"
|
| 140 |
- "psychological safety"
|
| 141 |
- "people strategy"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
# -----------------------------------------------------------------------------
|
| 144 |
# SCHEDULER SETTINGS
|
| 145 |
-
# Control when and how often the hunter runs.
|
| 146 |
# -----------------------------------------------------------------------------
|
| 147 |
scheduler:
|
| 148 |
-
# Daily run time (24-hour format)
|
| 149 |
daily_run_time: "09:00"
|
| 150 |
-
|
| 151 |
-
# Timezone
|
| 152 |
timezone: "Europe/London"
|
| 153 |
-
|
| 154 |
-
# How many searches per run (to avoid rate limits)
|
| 155 |
max_searches_per_run: 10
|
| 156 |
-
|
| 157 |
-
# Days to look back for news
|
| 158 |
news_lookback_days: 7
|
| 159 |
-
|
| 160 |
-
# Days to look back for tenders
|
| 161 |
tender_lookback_days: 14
|
| 162 |
-
|
| 163 |
-
# Minimum tender value (GBP)
|
| 164 |
min_tender_value: 100000
|
| 165 |
|
| 166 |
# -----------------------------------------------------------------------------
|
| 167 |
# HUNTING MODES
|
| 168 |
-
# Define different hunting strategies.
|
| 169 |
# -----------------------------------------------------------------------------
|
| 170 |
hunting_modes:
|
| 171 |
focused:
|
|
@@ -189,54 +512,35 @@ hunting_modes:
|
|
| 189 |
use_news: true
|
| 190 |
use_tenders: false
|
| 191 |
|
| 192 |
-
# Default hunting mode
|
| 193 |
default_mode: "focused"
|
| 194 |
|
| 195 |
# -----------------------------------------------------------------------------
|
| 196 |
# NOTIFICATION SETTINGS
|
| 197 |
-
# Configure how you receive the daily briefing.
|
| 198 |
# -----------------------------------------------------------------------------
|
| 199 |
notifications:
|
| 200 |
-
# Email settings (requires SMTP configuration)
|
| 201 |
email:
|
| 202 |
enabled: true
|
| 203 |
recipient: "piers@curium.co.uk"
|
| 204 |
smtp_server: "smtp.gmail.com"
|
| 205 |
smtp_port: 587
|
| 206 |
-
# Set these as environment variables:
|
| 207 |
-
# SMTP_USERNAME, SMTP_PASSWORD
|
| 208 |
|
| 209 |
-
# Slack settings (requires webhook URL)
|
| 210 |
slack:
|
| 211 |
enabled: false
|
| 212 |
-
# Set as environment variable: SLACK_WEBHOOK_URL
|
| 213 |
|
| 214 |
-
# Desktop notification (macOS)
|
| 215 |
desktop:
|
| 216 |
enabled: true
|
| 217 |
|
| 218 |
-
# Console output (always enabled)
|
| 219 |
console:
|
| 220 |
enabled: true
|
| 221 |
|
| 222 |
# -----------------------------------------------------------------------------
|
| 223 |
# FILTERING & SCORING
|
| 224 |
-
# Fine-tune lead qualification.
|
| 225 |
# -----------------------------------------------------------------------------
|
| 226 |
filtering:
|
| 227 |
-
# Minimum AI score to include in briefing
|
| 228 |
min_lead_score: 50
|
| 229 |
-
|
| 230 |
-
# Minimum news signal score
|
| 231 |
min_news_score: 60
|
| 232 |
-
|
| 233 |
-
# Maximum leads per briefing
|
| 234 |
max_leads_per_briefing: 10
|
| 235 |
-
|
| 236 |
-
# Require Companies House verification for UK companies
|
| 237 |
require_ch_verification: false
|
| 238 |
-
|
| 239 |
-
# Skip these company statuses
|
| 240 |
skip_company_statuses:
|
| 241 |
- "dissolved"
|
| 242 |
- "liquidation"
|
|
@@ -244,7 +548,6 @@ filtering:
|
|
| 244 |
|
| 245 |
# -----------------------------------------------------------------------------
|
| 246 |
# DATA SOURCES
|
| 247 |
-
# Enable/disable specific data sources.
|
| 248 |
# -----------------------------------------------------------------------------
|
| 249 |
data_sources:
|
| 250 |
remoteok:
|
|
@@ -252,29 +555,23 @@ data_sources:
|
|
| 252 |
base_url: "https://remoteok.com"
|
| 253 |
|
| 254 |
indeed:
|
| 255 |
-
enabled: false
|
| 256 |
base_url: "https://www.indeed.com"
|
| 257 |
|
| 258 |
newsapi:
|
| 259 |
enabled: true
|
| 260 |
-
# Requires NEWSAPI_KEY environment variable
|
| 261 |
|
| 262 |
gdelt:
|
| 263 |
-
enabled: true
|
| 264 |
|
| 265 |
uk_tenders:
|
| 266 |
enabled: true
|
| 267 |
-
# Free, no API key needed
|
| 268 |
|
| 269 |
companies_house_reports:
|
| 270 |
enabled: true
|
| 271 |
max_reports_per_hunt: 10
|
| 272 |
min_score_to_store: 30
|
| 273 |
|
| 274 |
-
cqc:
|
| 275 |
-
enabled: true
|
| 276 |
-
max_providers_per_hunt: 30
|
| 277 |
-
|
| 278 |
sentiment:
|
| 279 |
enabled: true
|
| 280 |
source: indeed_uk
|
|
@@ -286,28 +583,114 @@ data_sources:
|
|
| 286 |
days_back: 14
|
| 287 |
min_score_to_store: 40
|
| 288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
# -----------------------------------------------------------------------------
|
| 290 |
# RATE LIMITING
|
| 291 |
-
# Avoid being blocked by data sources.
|
| 292 |
# -----------------------------------------------------------------------------
|
| 293 |
rate_limits:
|
| 294 |
-
# Seconds between requests
|
| 295 |
request_delay: 2
|
| 296 |
-
|
| 297 |
-
# Max requests per minute
|
| 298 |
max_requests_per_minute: 20
|
| 299 |
-
|
| 300 |
-
# Randomize delays (helps avoid detection)
|
| 301 |
randomize_delays: true
|
| 302 |
|
| 303 |
# -----------------------------------------------------------------------------
|
| 304 |
# LINKEDIN GROUPS
|
| 305 |
-
# Scan LinkedIn groups for culture/engagement discussions via Google dorking.
|
| 306 |
-
# Groups are private, so we search for public posts shared from these groups.
|
| 307 |
# -----------------------------------------------------------------------------
|
| 308 |
linkedin_groups:
|
| 309 |
enabled: true
|
| 310 |
-
max_searches_per_run:
|
| 311 |
groups:
|
| 312 |
- name: "Employee Experience and Engagement"
|
| 313 |
keywords: ["employee experience", "engagement strategy", "culture transformation"]
|
|
@@ -315,19 +698,31 @@ linkedin_groups:
|
|
| 315 |
keywords: ["HR transformation", "people strategy", "culture change"]
|
| 316 |
- name: "CIPD Community"
|
| 317 |
keywords: ["organisational development", "employee engagement", "behavioural change"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
|
| 319 |
# -----------------------------------------------------------------------------
|
| 320 |
# LINKEDIN DEEP INTELLIGENCE
|
| 321 |
-
# Authenticated LinkedIn scraping via persistent browser profile.
|
| 322 |
-
# Requires one-time login setup via the dashboard sidebar.
|
| 323 |
# -----------------------------------------------------------------------------
|
| 324 |
linkedin_deep:
|
| 325 |
enabled: true
|
| 326 |
-
max_profiles_per_run:
|
| 327 |
max_companies_per_run: 10
|
| 328 |
-
daily_profile_limit:
|
| 329 |
-
daily_company_limit:
|
| 330 |
-
daily_search_limit:
|
| 331 |
min_company_score_for_scan: 50
|
| 332 |
scan_movers: true
|
| 333 |
scan_feed: true
|
|
@@ -347,3 +742,6 @@ linkedin_deep:
|
|
| 347 |
- "acquisition"
|
| 348 |
- "wellbeing"
|
| 349 |
- "behavioural change"
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# =============================================================================
|
| 2 |
+
# CURIUM LEAD INTELLIGENCE PLATFORM - CONFIGURATION
|
| 3 |
# =============================================================================
|
| 4 |
+
# Master configuration for the Curium Lead Intelligence Platform.
|
| 5 |
+
# All modules read from this file for service definitions, personas, and triggers.
|
| 6 |
# =============================================================================
|
| 7 |
|
| 8 |
# -----------------------------------------------------------------------------
|
|
|
|
| 11 |
company:
|
| 12 |
name: "Curium Solutions"
|
| 13 |
product: "CODE Ecosystem"
|
| 14 |
+
focus: "Transformation Delivery + Culture & Capability"
|
| 15 |
target_turnover: "£500m - £5bn"
|
| 16 |
+
values:
|
| 17 |
+
- "People First"
|
| 18 |
+
- "Keep It Simple"
|
| 19 |
+
- "Make It Real"
|
| 20 |
+
website: "https://www.curium.co.uk"
|
| 21 |
+
|
| 22 |
+
# -----------------------------------------------------------------------------
|
| 23 |
+
# CURIUM SERVICE CATALOG
|
| 24 |
+
# Two practice areas + one standalone digital product.
|
| 25 |
+
# Each service has keywords (for signal matching) and triggers (news/events).
|
| 26 |
+
# -----------------------------------------------------------------------------
|
| 27 |
+
services:
|
| 28 |
+
transformation_delivery:
|
| 29 |
+
label: "Transformation Delivery"
|
| 30 |
+
short: "TD"
|
| 31 |
+
description: "Helping organisations deliver complex change through expert programme management, operating model design, and M&A integration"
|
| 32 |
+
offerings:
|
| 33 |
+
project_programme_management:
|
| 34 |
+
label: "Project & Programme Management"
|
| 35 |
+
keywords: ["programme management", "project management", "PMO", "programme director", "delivery assurance"]
|
| 36 |
+
triggers: ["new programme", "programme failure", "delivery issues", "project overrun"]
|
| 37 |
+
change_management:
|
| 38 |
+
label: "Change Management"
|
| 39 |
+
keywords: ["change management", "change director", "change lead", "business change", "change adoption"]
|
| 40 |
+
triggers: ["restructuring", "transformation", "reorganisation", "new operating model"]
|
| 41 |
+
business_analysis:
|
| 42 |
+
label: "Business Analysis"
|
| 43 |
+
keywords: ["business analysis", "business analyst", "requirements", "process improvement", "BA lead"]
|
| 44 |
+
triggers: ["system implementation", "digital transformation", "process redesign"]
|
| 45 |
+
tmo_pmo:
|
| 46 |
+
label: "TMO/PMO Setup & Improvement"
|
| 47 |
+
keywords: ["TMO", "PMO", "transformation office", "portfolio management", "PMO director"]
|
| 48 |
+
triggers: ["new TMO", "PMO setup", "portfolio review", "governance overhaul"]
|
| 49 |
+
operating_models:
|
| 50 |
+
label: "Operating Model Design"
|
| 51 |
+
keywords: ["operating model", "target operating model", "TOM", "org design", "organisational design"]
|
| 52 |
+
triggers: ["restructuring", "operating model review", "org redesign", "post-merger integration"]
|
| 53 |
+
agile_lean:
|
| 54 |
+
label: "Agile & Lean Transformation"
|
| 55 |
+
keywords: ["agile transformation", "lean", "agile coach", "scrum", "agile ways of working"]
|
| 56 |
+
triggers: ["agile adoption", "ways of working", "delivery transformation"]
|
| 57 |
+
ma_integration:
|
| 58 |
+
label: "M&A Integration"
|
| 59 |
+
keywords: ["M&A integration", "post-merger", "acquisition integration", "merger integration", "carve-out"]
|
| 60 |
+
triggers: ["merger", "acquisition", "PE acquisition", "carve-out", "divestiture"]
|
| 61 |
+
service_desk:
|
| 62 |
+
label: "Service Desk Transformation"
|
| 63 |
+
keywords: ["service desk", "ITSM", "service management", "IT operations"]
|
| 64 |
+
triggers: ["service improvement", "outsourcing", "insourcing"]
|
| 65 |
+
|
| 66 |
+
culture_capability:
|
| 67 |
+
label: "Culture & Capability"
|
| 68 |
+
short: "CC"
|
| 69 |
+
description: "Building leadership capability, transforming culture, and developing high-performing teams through coaching, diagnostics, and behavioural change"
|
| 70 |
+
offerings:
|
| 71 |
+
executive_coaching:
|
| 72 |
+
label: "Executive Coaching"
|
| 73 |
+
keywords: ["executive coaching", "leadership coaching", "C-suite coaching", "board coaching"]
|
| 74 |
+
triggers: ["new CEO", "leadership change", "board effectiveness", "succession planning"]
|
| 75 |
+
leadership_strategy:
|
| 76 |
+
label: "Leadership Strategy"
|
| 77 |
+
keywords: ["leadership strategy", "leadership development", "leadership capability", "leadership pipeline"]
|
| 78 |
+
triggers: ["leadership gap", "succession crisis", "talent strategy", "leadership review"]
|
| 79 |
+
culture_diagnostics:
|
| 80 |
+
label: "Culture Diagnostics"
|
| 81 |
+
keywords: ["culture diagnostics", "culture assessment", "culture audit", "employee survey", "engagement survey"]
|
| 82 |
+
triggers: ["culture crisis", "toxic workplace", "employee exodus", "culture change programme"]
|
| 83 |
+
team_profiling:
|
| 84 |
+
label: "Team Profiling (TetraMap/CODE)"
|
| 85 |
+
keywords: ["team profiling", "TetraMap", "CODE assessment", "team diagnostics", "psychometric", "team effectiveness"]
|
| 86 |
+
triggers: ["new team", "team formation", "team dysfunction", "cross-functional team"]
|
| 87 |
+
facilitation:
|
| 88 |
+
label: "Facilitation"
|
| 89 |
+
keywords: ["facilitation", "workshop facilitation", "strategic facilitation", "offsite facilitation"]
|
| 90 |
+
triggers: ["strategy day", "leadership offsite", "board away day", "team building"]
|
| 91 |
+
resilience:
|
| 92 |
+
label: "Resilience & Wellbeing"
|
| 93 |
+
keywords: ["resilience", "wellbeing", "mental health", "stress management", "burnout"]
|
| 94 |
+
triggers: ["wellbeing programme", "mental health crisis", "burnout", "employee wellbeing"]
|
| 95 |
+
one_to_one_coaching:
|
| 96 |
+
label: "1-to-1 Coaching"
|
| 97 |
+
keywords: ["coaching", "personal development", "leadership coaching", "performance coaching"]
|
| 98 |
+
triggers: ["performance issues", "talent development", "high potential programme"]
|
| 99 |
+
dysfunctional_teams:
|
| 100 |
+
label: "Dysfunctional Team Intervention"
|
| 101 |
+
keywords: ["dysfunctional team", "team conflict", "team breakdown", "team reset"]
|
| 102 |
+
triggers: ["team conflict", "team failure", "team restructure", "senior team dysfunction"]
|
| 103 |
+
mindset_behaviour:
|
| 104 |
+
label: "Mindset & Behaviour Change"
|
| 105 |
+
keywords: ["mindset", "behavioural change", "behaviour change", "culture shift", "values programme"]
|
| 106 |
+
triggers: ["values launch", "behaviour framework", "culture transformation", "psychological safety"]
|
| 107 |
+
|
| 108 |
+
# -----------------------------------------------------------------------------
|
| 109 |
+
# CODE 3i - STANDALONE DIGITAL PRODUCT
|
| 110 |
+
# -----------------------------------------------------------------------------
|
| 111 |
+
code_3i:
|
| 112 |
+
label: "CODE 3i"
|
| 113 |
+
description: "Digital team and leadership assessment platform. Quick-deploy psychometric giving instant insight into team dynamics, communication styles, and leadership effectiveness."
|
| 114 |
+
triggers:
|
| 115 |
+
- "team formation"
|
| 116 |
+
- "new team"
|
| 117 |
+
- "team effectiveness"
|
| 118 |
+
- "team assessment"
|
| 119 |
+
- "team profiling"
|
| 120 |
+
- "onboarding teams"
|
| 121 |
+
- "cross-functional team"
|
| 122 |
+
- "hybrid working"
|
| 123 |
+
- "team building"
|
| 124 |
+
- "team culture"
|
| 125 |
+
- "psychometric"
|
| 126 |
+
- "leadership assessment"
|
| 127 |
+
- "360 feedback"
|
| 128 |
+
keywords:
|
| 129 |
+
- "team effectiveness"
|
| 130 |
+
- "team profiling"
|
| 131 |
+
- "team assessment"
|
| 132 |
+
- "psychometric"
|
| 133 |
+
- "360 feedback"
|
| 134 |
+
- "leadership assessment"
|
| 135 |
+
- "team dynamics"
|
| 136 |
+
- "communication styles"
|
| 137 |
+
value_prop: "Quick-deploy digital assessment that gives teams instant insight into how they work together. Used by DAC Beachcroft, Canada Life, and 100+ organisations."
|
| 138 |
+
|
| 139 |
+
# -----------------------------------------------------------------------------
|
| 140 |
+
# VALUE PROPOSITIONS (per service line, with case studies)
|
| 141 |
+
# -----------------------------------------------------------------------------
|
| 142 |
+
value_propositions:
|
| 143 |
+
transformation_delivery:
|
| 144 |
+
headline: "Expert delivery capability when you need it most"
|
| 145 |
+
pitch: "We embed senior transformation professionals who get things done. Not just strategy — actual delivery. Our programme managers, change leads, and BAs have delivered £bn+ programmes for FTSE 100 clients."
|
| 146 |
+
case_studies:
|
| 147 |
+
- client: "DAC Beachcroft"
|
| 148 |
+
summary: "Full transformation programme delivery including PMO setup, change management, and business analysis across a multi-year programme"
|
| 149 |
+
- client: "Canada Life"
|
| 150 |
+
summary: "Operating model redesign and implementation including organisational design, change management, and leadership alignment"
|
| 151 |
+
differentiators:
|
| 152 |
+
- "We stay until it's done — not just until the strategy deck is finished"
|
| 153 |
+
- "Our people integrate into your teams, not sit in ivory towers"
|
| 154 |
+
- "Practical, pragmatic delivery — not academic frameworks"
|
| 155 |
+
|
| 156 |
+
culture_capability:
|
| 157 |
+
headline: "Unlock the human side of transformation"
|
| 158 |
+
pitch: "Every transformation is really a people transformation. We help leaders build capability, shift culture, and develop high-performing teams. Our CODE assessment has been brilliant for teams going through change."
|
| 159 |
+
case_studies:
|
| 160 |
+
- client: "DAC Beachcroft"
|
| 161 |
+
summary: "Leadership development programme and team profiling using CODE across senior teams"
|
| 162 |
+
- client: "Canada Life"
|
| 163 |
+
summary: "Culture diagnostics and executive coaching programme supporting leadership through major transformation"
|
| 164 |
+
differentiators:
|
| 165 |
+
- "CODE 3i gives you instant, actionable team insight"
|
| 166 |
+
- "We combine coaching expertise with real transformation experience"
|
| 167 |
+
- "Our facilitators have actually led change, not just talked about it"
|
| 168 |
+
|
| 169 |
+
code_3i:
|
| 170 |
+
headline: "See your team clearly. In minutes."
|
| 171 |
+
pitch: "CODE 3i is a digital team assessment that takes 10 minutes per person and gives you instant insight into how your team communicates, makes decisions, and handles conflict. Perfect for new teams, teams under pressure, or any leader who wants to get the best from their people."
|
| 172 |
+
differentiators:
|
| 173 |
+
- "10-minute assessment, instant results"
|
| 174 |
+
- "Visual, intuitive output — no psychology degree needed"
|
| 175 |
+
- "Digital-first: runs at scale across global teams"
|
| 176 |
+
|
| 177 |
+
# -----------------------------------------------------------------------------
|
| 178 |
+
# TARGET PERSONAS
|
| 179 |
+
# Maps job titles to service affinities (TD, CC, CODE 3i).
|
| 180 |
+
# -----------------------------------------------------------------------------
|
| 181 |
+
target_personas:
|
| 182 |
+
# C-Suite
|
| 183 |
+
- title_pattern: "Chief People Officer"
|
| 184 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 185 |
+
priority: high
|
| 186 |
+
- title_pattern: "Chief Transformation Officer"
|
| 187 |
+
service_affinity: ["transformation_delivery", "culture_capability"]
|
| 188 |
+
priority: high
|
| 189 |
+
- title_pattern: "Chief Operating Officer"
|
| 190 |
+
service_affinity: ["transformation_delivery"]
|
| 191 |
+
priority: high
|
| 192 |
+
- title_pattern: "Chief HR Officer"
|
| 193 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 194 |
+
priority: high
|
| 195 |
+
|
| 196 |
+
# TD-leaning
|
| 197 |
+
- title_pattern: "Programme Director"
|
| 198 |
+
service_affinity: ["transformation_delivery"]
|
| 199 |
+
priority: high
|
| 200 |
+
- title_pattern: "Head of PMO"
|
| 201 |
+
service_affinity: ["transformation_delivery"]
|
| 202 |
+
priority: high
|
| 203 |
+
- title_pattern: "Head of Transformation"
|
| 204 |
+
service_affinity: ["transformation_delivery", "culture_capability"]
|
| 205 |
+
priority: high
|
| 206 |
+
- title_pattern: "M&A Integration Director"
|
| 207 |
+
service_affinity: ["transformation_delivery"]
|
| 208 |
+
priority: high
|
| 209 |
+
- title_pattern: "Director of Change"
|
| 210 |
+
service_affinity: ["transformation_delivery", "culture_capability"]
|
| 211 |
+
priority: high
|
| 212 |
+
- title_pattern: "Head of Business Change"
|
| 213 |
+
service_affinity: ["transformation_delivery"]
|
| 214 |
+
priority: medium
|
| 215 |
+
- title_pattern: "Portfolio Director"
|
| 216 |
+
service_affinity: ["transformation_delivery"]
|
| 217 |
+
priority: medium
|
| 218 |
+
|
| 219 |
+
# CC-leaning
|
| 220 |
+
- title_pattern: "Head of Leadership Development"
|
| 221 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 222 |
+
priority: high
|
| 223 |
+
- title_pattern: "Head of Coaching"
|
| 224 |
+
service_affinity: ["culture_capability"]
|
| 225 |
+
priority: high
|
| 226 |
+
- title_pattern: "Director of Wellbeing"
|
| 227 |
+
service_affinity: ["culture_capability"]
|
| 228 |
+
priority: high
|
| 229 |
+
- title_pattern: "Culture Programme Manager"
|
| 230 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 231 |
+
priority: high
|
| 232 |
+
- title_pattern: "Head of Culture"
|
| 233 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 234 |
+
priority: high
|
| 235 |
+
- title_pattern: "Head of Organisational Development"
|
| 236 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 237 |
+
priority: high
|
| 238 |
+
- title_pattern: "VP People & Culture"
|
| 239 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 240 |
+
priority: high
|
| 241 |
+
- title_pattern: "Director of Culture"
|
| 242 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 243 |
+
priority: high
|
| 244 |
+
- title_pattern: "Head of Employee Experience"
|
| 245 |
+
service_affinity: ["culture_capability"]
|
| 246 |
+
priority: medium
|
| 247 |
+
- title_pattern: "Head of Engagement"
|
| 248 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 249 |
+
priority: medium
|
| 250 |
+
|
| 251 |
+
# Mixed
|
| 252 |
+
- title_pattern: "Director of HR Transformation"
|
| 253 |
+
service_affinity: ["transformation_delivery", "culture_capability"]
|
| 254 |
+
priority: high
|
| 255 |
+
- title_pattern: "Chief Culture Officer"
|
| 256 |
+
service_affinity: ["culture_capability", "code_3i"]
|
| 257 |
+
priority: high
|
| 258 |
+
- title_pattern: "HR Business Partner"
|
| 259 |
+
service_affinity: ["culture_capability"]
|
| 260 |
+
priority: medium
|
| 261 |
|
| 262 |
# -----------------------------------------------------------------------------
|
| 263 |
# TARGET SECTORS
|
|
|
|
|
|
|
| 264 |
# -----------------------------------------------------------------------------
|
| 265 |
target_sectors:
|
| 266 |
- name: "UK Retail"
|
| 267 |
keywords: ["retail", "supermarket", "grocery", "fashion retail", "ecommerce"]
|
| 268 |
+
companies: ["Tesco", "Sainsbury", "Marks & Spencer", "Next", "John Lewis", "Weetabix", "LEGO"]
|
| 269 |
|
| 270 |
- name: "UK Financial Services"
|
| 271 |
keywords: ["banking", "insurance", "fintech", "asset management"]
|
| 272 |
+
companies: ["Barclays", "Lloyds", "HSBC", "Aviva", "Legal & General", "Allianz", "Santander", "Saga", "L&G"]
|
| 273 |
|
| 274 |
+
- name: "UK Manufacturing & Automotive"
|
| 275 |
keywords: ["manufacturing", "automotive", "aerospace", "engineering"]
|
| 276 |
+
companies: ["Rolls-Royce", "BAE Systems", "JCB", "Unilever", "Aston Martin", "BMW", "Volkswagen", "Jaguar Land Rover", "Skanska"]
|
| 277 |
|
| 278 |
- name: "UK Healthcare"
|
| 279 |
keywords: ["NHS", "healthcare", "pharma", "life sciences"]
|
| 280 |
companies: ["GSK", "AstraZeneca", "Bupa"]
|
| 281 |
|
| 282 |
+
- name: "UK Transport & Infrastructure"
|
| 283 |
+
keywords: ["transport", "rail", "aviation", "infrastructure", "logistics"]
|
| 284 |
+
companies: ["Birmingham Airport", "Heathrow", "Network Rail", "West Midlands Trains", "Walkers Transport"]
|
| 285 |
+
|
| 286 |
+
- name: "UK Consulting & Tech"
|
| 287 |
+
keywords: ["consulting", "technology", "professional services", "IT services"]
|
| 288 |
+
companies: ["Accenture", "McKinsey", "BCG", "Capgemini", "NTT DATA", "Ericsson", "Headlam"]
|
| 289 |
+
|
| 290 |
- name: "FTSE 250"
|
| 291 |
keywords: ["FTSE 250", "mid-cap", "UK listed"]
|
| 292 |
+
companies: []
|
| 293 |
|
| 294 |
- name: "Public Sector"
|
| 295 |
keywords: ["government", "council", "NHS trust", "public sector"]
|
| 296 |
+
companies: ["Swindon Borough Council"]
|
| 297 |
|
| 298 |
# -----------------------------------------------------------------------------
|
| 299 |
# JOB SEARCH KEYWORDS
|
| 300 |
+
# Enhanced with TD-specific and CC-specific roles.
|
| 301 |
# -----------------------------------------------------------------------------
|
| 302 |
job_keywords:
|
| 303 |
high_priority:
|
| 304 |
+
# TD roles
|
| 305 |
- "Head of Transformation"
|
| 306 |
- "Director of Change"
|
| 307 |
+
- "Programme Director"
|
| 308 |
+
- "Head of PMO"
|
| 309 |
+
- "M&A Integration Director"
|
| 310 |
+
- "Chief Transformation Officer"
|
| 311 |
+
- "Head of Business Change"
|
| 312 |
+
- "Portfolio Director"
|
| 313 |
+
# CC roles
|
| 314 |
- "Head of Leadership Development"
|
| 315 |
- "Chief People Officer"
|
| 316 |
- "Head of Organisational Development"
|
| 317 |
- "VP People & Culture"
|
| 318 |
- "Head of Culture"
|
|
|
|
|
|
|
| 319 |
- "Director of Culture"
|
| 320 |
- "Chief Culture Officer"
|
| 321 |
- "Head of Engagement"
|
| 322 |
+
- "Director of HR Transformation"
|
| 323 |
+
- "Head of Coaching"
|
| 324 |
+
- "Director of Wellbeing"
|
| 325 |
+
- "Culture Programme Manager"
|
| 326 |
+
- "Head of Employee Experience"
|
| 327 |
|
| 328 |
medium_priority:
|
| 329 |
+
# TD roles
|
| 330 |
- "Change Manager"
|
| 331 |
- "Transformation Lead"
|
| 332 |
+
- "Business Analyst Lead"
|
| 333 |
+
- "PMO Manager"
|
| 334 |
+
- "Integration Manager"
|
| 335 |
+
- "Agile Transformation Lead"
|
| 336 |
+
- "Operating Model Lead"
|
| 337 |
+
# CC roles
|
| 338 |
- "Leadership Development Manager"
|
| 339 |
- "OD Manager"
|
| 340 |
- "HR Business Partner"
|
|
|
|
| 346 |
- "Behavioural Change Lead"
|
| 347 |
- "Organisation Design Manager"
|
| 348 |
- "Employee Engagement Specialist"
|
| 349 |
+
- "Wellbeing Manager"
|
| 350 |
+
- "Coaching Programme Manager"
|
| 351 |
|
| 352 |
locations:
|
| 353 |
- "London"
|
|
|
|
| 358 |
|
| 359 |
# -----------------------------------------------------------------------------
|
| 360 |
# NEWS TRIGGER KEYWORDS
|
| 361 |
+
# Enhanced with service-line mapping.
|
| 362 |
+
# service_lines: which Curium practice areas are relevant for each trigger.
|
| 363 |
# -----------------------------------------------------------------------------
|
| 364 |
news_triggers:
|
| 365 |
high_signal:
|
| 366 |
+
- trigger: "profit warning"
|
| 367 |
+
service_lines: ["transformation_delivery"]
|
| 368 |
+
- trigger: "restructuring"
|
| 369 |
+
service_lines: ["transformation_delivery", "culture_capability"]
|
| 370 |
+
- trigger: "layoffs"
|
| 371 |
+
service_lines: ["transformation_delivery", "culture_capability"]
|
| 372 |
+
- trigger: "redundancies"
|
| 373 |
+
service_lines: ["transformation_delivery", "culture_capability"]
|
| 374 |
+
- trigger: "merger"
|
| 375 |
+
service_lines: ["transformation_delivery", "culture_capability"]
|
| 376 |
+
- trigger: "acquisition"
|
| 377 |
+
service_lines: ["transformation_delivery", "culture_capability"]
|
| 378 |
+
- trigger: "CEO steps down"
|
| 379 |
+
service_lines: ["culture_capability", "transformation_delivery"]
|
| 380 |
+
- trigger: "CEO resigns"
|
| 381 |
+
service_lines: ["culture_capability", "transformation_delivery"]
|
| 382 |
+
- trigger: "leadership change"
|
| 383 |
+
service_lines: ["culture_capability"]
|
| 384 |
+
- trigger: "culture crisis"
|
| 385 |
+
service_lines: ["culture_capability", "code_3i"]
|
| 386 |
+
- trigger: "toxic workplace"
|
| 387 |
+
service_lines: ["culture_capability", "code_3i"]
|
| 388 |
+
- trigger: "employee exodus"
|
| 389 |
+
service_lines: ["culture_capability"]
|
| 390 |
|
| 391 |
medium_signal:
|
| 392 |
+
- trigger: "strategic review"
|
| 393 |
+
service_lines: ["transformation_delivery"]
|
| 394 |
+
- trigger: "transformation"
|
| 395 |
+
service_lines: ["transformation_delivery", "culture_capability"]
|
| 396 |
+
- trigger: "turnaround"
|
| 397 |
+
service_lines: ["transformation_delivery"]
|
| 398 |
+
- trigger: "cost cutting"
|
| 399 |
+
service_lines: ["transformation_delivery"]
|
| 400 |
+
- trigger: "new CEO"
|
| 401 |
+
service_lines: ["transformation_delivery", "culture_capability"]
|
| 402 |
+
- trigger: "culture change"
|
| 403 |
+
service_lines: ["culture_capability", "code_3i"]
|
| 404 |
+
- trigger: "employee engagement"
|
| 405 |
+
service_lines: ["culture_capability", "code_3i"]
|
| 406 |
+
- trigger: "workforce"
|
| 407 |
+
service_lines: ["transformation_delivery", "culture_capability"]
|
| 408 |
+
- trigger: "employee experience"
|
| 409 |
+
service_lines: ["culture_capability"]
|
| 410 |
+
- trigger: "wellbeing programme"
|
| 411 |
+
service_lines: ["culture_capability"]
|
| 412 |
+
- trigger: "people strategy"
|
| 413 |
+
service_lines: ["culture_capability"]
|
| 414 |
+
- trigger: "behavioural change"
|
| 415 |
+
service_lines: ["culture_capability", "code_3i"]
|
| 416 |
+
- trigger: "psychological safety"
|
| 417 |
+
service_lines: ["culture_capability", "code_3i"]
|
| 418 |
+
- trigger: "team effectiveness"
|
| 419 |
+
service_lines: ["culture_capability", "code_3i"]
|
| 420 |
+
- trigger: "operating model"
|
| 421 |
+
service_lines: ["transformation_delivery"]
|
| 422 |
+
- trigger: "programme failure"
|
| 423 |
+
service_lines: ["transformation_delivery"]
|
| 424 |
+
- trigger: "integration"
|
| 425 |
+
service_lines: ["transformation_delivery", "culture_capability"]
|
| 426 |
|
| 427 |
# -----------------------------------------------------------------------------
|
| 428 |
# TENDER KEYWORDS
|
|
|
|
| 429 |
# -----------------------------------------------------------------------------
|
| 430 |
tender_keywords:
|
| 431 |
- "transformation"
|
|
|
|
| 442 |
- "wellbeing"
|
| 443 |
- "psychological safety"
|
| 444 |
- "people strategy"
|
| 445 |
+
- "programme management"
|
| 446 |
+
- "PMO"
|
| 447 |
+
- "M&A integration"
|
| 448 |
+
- "operating model"
|
| 449 |
+
|
| 450 |
+
# -----------------------------------------------------------------------------
|
| 451 |
+
# CURIUM TEAM (for LinkedIn activity generation)
|
| 452 |
+
# -----------------------------------------------------------------------------
|
| 453 |
+
team:
|
| 454 |
+
- name: "Piers Lyon"
|
| 455 |
+
role: "Managing Director"
|
| 456 |
+
service_focus: ["transformation_delivery", "culture_capability"]
|
| 457 |
+
- name: "Adam"
|
| 458 |
+
role: "Principal Consultant"
|
| 459 |
+
service_focus: ["transformation_delivery"]
|
| 460 |
+
- name: "Stuart"
|
| 461 |
+
role: "Principal Consultant"
|
| 462 |
+
service_focus: ["culture_capability"]
|
| 463 |
+
|
| 464 |
+
# -----------------------------------------------------------------------------
|
| 465 |
+
# LINKEDIN PREMIUM SETTINGS
|
| 466 |
+
# Upgrade enables: InMail, advanced search, who's viewed your profile.
|
| 467 |
+
# Sales Navigator adds: lead lists, saved searches, CRM integration.
|
| 468 |
+
# -----------------------------------------------------------------------------
|
| 469 |
+
linkedin:
|
| 470 |
+
membership: "premium" # options: free, premium, sales_navigator
|
| 471 |
+
features:
|
| 472 |
+
inmail_enabled: true
|
| 473 |
+
advanced_search: true
|
| 474 |
+
who_viewed: true
|
| 475 |
+
daily_actions_per_person: 5
|
| 476 |
+
content_posts_per_week: 3
|
| 477 |
+
max_connection_requests_per_day: 20
|
| 478 |
|
| 479 |
# -----------------------------------------------------------------------------
|
| 480 |
# SCHEDULER SETTINGS
|
|
|
|
| 481 |
# -----------------------------------------------------------------------------
|
| 482 |
scheduler:
|
|
|
|
| 483 |
daily_run_time: "09:00"
|
|
|
|
|
|
|
| 484 |
timezone: "Europe/London"
|
|
|
|
|
|
|
| 485 |
max_searches_per_run: 10
|
|
|
|
|
|
|
| 486 |
news_lookback_days: 7
|
|
|
|
|
|
|
| 487 |
tender_lookback_days: 14
|
|
|
|
|
|
|
| 488 |
min_tender_value: 100000
|
| 489 |
|
| 490 |
# -----------------------------------------------------------------------------
|
| 491 |
# HUNTING MODES
|
|
|
|
| 492 |
# -----------------------------------------------------------------------------
|
| 493 |
hunting_modes:
|
| 494 |
focused:
|
|
|
|
| 512 |
use_news: true
|
| 513 |
use_tenders: false
|
| 514 |
|
|
|
|
| 515 |
default_mode: "focused"
|
| 516 |
|
| 517 |
# -----------------------------------------------------------------------------
|
| 518 |
# NOTIFICATION SETTINGS
|
|
|
|
| 519 |
# -----------------------------------------------------------------------------
|
| 520 |
notifications:
|
|
|
|
| 521 |
email:
|
| 522 |
enabled: true
|
| 523 |
recipient: "piers@curium.co.uk"
|
| 524 |
smtp_server: "smtp.gmail.com"
|
| 525 |
smtp_port: 587
|
|
|
|
|
|
|
| 526 |
|
|
|
|
| 527 |
slack:
|
| 528 |
enabled: false
|
|
|
|
| 529 |
|
|
|
|
| 530 |
desktop:
|
| 531 |
enabled: true
|
| 532 |
|
|
|
|
| 533 |
console:
|
| 534 |
enabled: true
|
| 535 |
|
| 536 |
# -----------------------------------------------------------------------------
|
| 537 |
# FILTERING & SCORING
|
|
|
|
| 538 |
# -----------------------------------------------------------------------------
|
| 539 |
filtering:
|
|
|
|
| 540 |
min_lead_score: 50
|
|
|
|
|
|
|
| 541 |
min_news_score: 60
|
|
|
|
|
|
|
| 542 |
max_leads_per_briefing: 10
|
|
|
|
|
|
|
| 543 |
require_ch_verification: false
|
|
|
|
|
|
|
| 544 |
skip_company_statuses:
|
| 545 |
- "dissolved"
|
| 546 |
- "liquidation"
|
|
|
|
| 548 |
|
| 549 |
# -----------------------------------------------------------------------------
|
| 550 |
# DATA SOURCES
|
|
|
|
| 551 |
# -----------------------------------------------------------------------------
|
| 552 |
data_sources:
|
| 553 |
remoteok:
|
|
|
|
| 555 |
base_url: "https://remoteok.com"
|
| 556 |
|
| 557 |
indeed:
|
| 558 |
+
enabled: false
|
| 559 |
base_url: "https://www.indeed.com"
|
| 560 |
|
| 561 |
newsapi:
|
| 562 |
enabled: true
|
|
|
|
| 563 |
|
| 564 |
gdelt:
|
| 565 |
+
enabled: true
|
| 566 |
|
| 567 |
uk_tenders:
|
| 568 |
enabled: true
|
|
|
|
| 569 |
|
| 570 |
companies_house_reports:
|
| 571 |
enabled: true
|
| 572 |
max_reports_per_hunt: 10
|
| 573 |
min_score_to_store: 30
|
| 574 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
sentiment:
|
| 576 |
enabled: true
|
| 577 |
source: indeed_uk
|
|
|
|
| 583 |
days_back: 14
|
| 584 |
min_score_to_store: 40
|
| 585 |
|
| 586 |
+
rss_feeds:
|
| 587 |
+
enabled: true
|
| 588 |
+
feeds:
|
| 589 |
+
# Major UK business news
|
| 590 |
+
- name: "BBC Business"
|
| 591 |
+
url: "http://feeds.bbci.co.uk/news/business/rss.xml"
|
| 592 |
+
- name: "Sky News Business"
|
| 593 |
+
url: "https://feeds.skynews.com/feeds/rss/business.xml"
|
| 594 |
+
- name: "City A.M."
|
| 595 |
+
url: "https://www.cityam.com/feed/"
|
| 596 |
+
- name: "The Guardian Business"
|
| 597 |
+
url: "https://www.theguardian.com/uk/business/rss"
|
| 598 |
+
- name: "The Telegraph Business"
|
| 599 |
+
url: "https://www.telegraph.co.uk/business/rss.xml"
|
| 600 |
+
- name: "Reuters UK"
|
| 601 |
+
url: "https://www.reuters.com/rssFeed/UKBusinessNews/"
|
| 602 |
+
- name: "FT UK"
|
| 603 |
+
url: "https://www.ft.com/rss/home/uk"
|
| 604 |
+
# M&A / Private Equity / Deals
|
| 605 |
+
- name: "Private Equity News"
|
| 606 |
+
url: "https://www.penews.com/rss"
|
| 607 |
+
- name: "Mergermarket"
|
| 608 |
+
url: "https://www.mergermarket.com/rss/intelligence"
|
| 609 |
+
- name: "AltAssets PE News"
|
| 610 |
+
url: "https://www.altassets.net/feed"
|
| 611 |
+
- name: "The Deal (UK)"
|
| 612 |
+
url: "https://pipeline.thedeal.com/rss/pipeline"
|
| 613 |
+
# HR / People / Transformation
|
| 614 |
+
- name: "People Management (CIPD)"
|
| 615 |
+
url: "https://www.peoplemanagement.co.uk/rss"
|
| 616 |
+
- name: "HR Magazine"
|
| 617 |
+
url: "https://www.hrmagazine.co.uk/feed"
|
| 618 |
+
- name: "Personnel Today"
|
| 619 |
+
url: "https://www.personneltoday.com/feed/"
|
| 620 |
+
- name: "The HR Director"
|
| 621 |
+
url: "https://www.thehrdirector.com/feed/"
|
| 622 |
+
- name: "Raconteur"
|
| 623 |
+
url: "https://www.raconteur.net/feed/"
|
| 624 |
+
# Management Consulting / Strategy
|
| 625 |
+
- name: "Management Today"
|
| 626 |
+
url: "https://www.managementtoday.co.uk/feed/"
|
| 627 |
+
- name: "The Times Business"
|
| 628 |
+
url: "https://www.thetimes.com/rss/business"
|
| 629 |
+
- name: "Business Insider UK"
|
| 630 |
+
url: "https://www.businessinsider.com/sai/rss"
|
| 631 |
+
# Public Sector / NHS
|
| 632 |
+
- name: "HSJ (Health Service Journal)"
|
| 633 |
+
url: "https://www.hsj.co.uk/rss"
|
| 634 |
+
- name: "The MJ (Municipal Journal)"
|
| 635 |
+
url: "https://www.themj.co.uk/rss"
|
| 636 |
+
- name: "Public Finance"
|
| 637 |
+
url: "https://www.publicfinance.co.uk/rss"
|
| 638 |
+
- name: "Civil Service World"
|
| 639 |
+
url: "https://www.civilserviceworld.com/rss"
|
| 640 |
+
# Automotive / Manufacturing
|
| 641 |
+
- name: "Autocar UK"
|
| 642 |
+
url: "https://www.autocar.co.uk/rss"
|
| 643 |
+
- name: "Automotive News Europe"
|
| 644 |
+
url: "https://europe.autonews.com/rss.xml"
|
| 645 |
+
- name: "The Manufacturer"
|
| 646 |
+
url: "https://www.themanufacturer.com/feed/"
|
| 647 |
+
# Insurance
|
| 648 |
+
- name: "Insurance Times"
|
| 649 |
+
url: "https://www.insurancetimes.co.uk/rss"
|
| 650 |
+
- name: "Insurance Age"
|
| 651 |
+
url: "https://www.insuranceage.co.uk/rss"
|
| 652 |
+
# Construction / Infrastructure
|
| 653 |
+
- name: "Construction News"
|
| 654 |
+
url: "https://www.constructionnews.co.uk/feed/"
|
| 655 |
+
- name: "Building"
|
| 656 |
+
url: "https://www.building.co.uk/rss"
|
| 657 |
+
# Transport / Logistics
|
| 658 |
+
- name: "Transport Network"
|
| 659 |
+
url: "https://www.transport-network.co.uk/rss"
|
| 660 |
+
- name: "Rail Technology Magazine"
|
| 661 |
+
url: "https://www.railtechnologymagazine.com/feed/"
|
| 662 |
+
# Tech / AI / Digital
|
| 663 |
+
- name: "Tech Monitor"
|
| 664 |
+
url: "https://techmonitor.ai/feed"
|
| 665 |
+
- name: "Computer Weekly"
|
| 666 |
+
url: "https://www.computerweekly.com/rss/IT-management.xml"
|
| 667 |
+
- name: "The Register"
|
| 668 |
+
url: "https://www.theregister.com/headlines.atom"
|
| 669 |
+
# Sustainability / ESG
|
| 670 |
+
- name: "edie"
|
| 671 |
+
url: "https://www.edie.net/feed/"
|
| 672 |
+
- name: "BusinessGreen"
|
| 673 |
+
url: "https://www.businessgreen.com/rss"
|
| 674 |
+
# Retail
|
| 675 |
+
- name: "Retail Gazette"
|
| 676 |
+
url: "https://www.retailgazette.co.uk/feed/"
|
| 677 |
+
- name: "Retail Week"
|
| 678 |
+
url: "https://www.retail-week.com/rss"
|
| 679 |
+
|
| 680 |
# -----------------------------------------------------------------------------
|
| 681 |
# RATE LIMITING
|
|
|
|
| 682 |
# -----------------------------------------------------------------------------
|
| 683 |
rate_limits:
|
|
|
|
| 684 |
request_delay: 2
|
|
|
|
|
|
|
| 685 |
max_requests_per_minute: 20
|
|
|
|
|
|
|
| 686 |
randomize_delays: true
|
| 687 |
|
| 688 |
# -----------------------------------------------------------------------------
|
| 689 |
# LINKEDIN GROUPS
|
|
|
|
|
|
|
| 690 |
# -----------------------------------------------------------------------------
|
| 691 |
linkedin_groups:
|
| 692 |
enabled: true
|
| 693 |
+
max_searches_per_run: 12
|
| 694 |
groups:
|
| 695 |
- name: "Employee Experience and Engagement"
|
| 696 |
keywords: ["employee experience", "engagement strategy", "culture transformation"]
|
|
|
|
| 698 |
keywords: ["HR transformation", "people strategy", "culture change"]
|
| 699 |
- name: "CIPD Community"
|
| 700 |
keywords: ["organisational development", "employee engagement", "behavioural change"]
|
| 701 |
+
- name: "Change Management Institute"
|
| 702 |
+
keywords: ["change management", "change leadership", "transformation delivery"]
|
| 703 |
+
- name: "PMO Professionals"
|
| 704 |
+
keywords: ["programme management", "PMO", "project delivery", "portfolio management"]
|
| 705 |
+
- name: "UK Government Digital and Technology"
|
| 706 |
+
keywords: ["public sector transformation", "digital government", "GDS"]
|
| 707 |
+
- name: "NHS Leaders Network"
|
| 708 |
+
keywords: ["NHS transformation", "healthcare leadership", "NHS change"]
|
| 709 |
+
- name: "Management Consultants Network"
|
| 710 |
+
keywords: ["management consulting", "strategy consulting", "transformation consulting"]
|
| 711 |
+
- name: "Leadership Development Network"
|
| 712 |
+
keywords: ["leadership development", "executive coaching", "leadership pipeline"]
|
| 713 |
+
- name: "M&A Integration Professionals"
|
| 714 |
+
keywords: ["M&A integration", "post-merger", "acquisition integration"]
|
| 715 |
|
| 716 |
# -----------------------------------------------------------------------------
|
| 717 |
# LINKEDIN DEEP INTELLIGENCE
|
|
|
|
|
|
|
| 718 |
# -----------------------------------------------------------------------------
|
| 719 |
linkedin_deep:
|
| 720 |
enabled: true
|
| 721 |
+
max_profiles_per_run: 100
|
| 722 |
max_companies_per_run: 10
|
| 723 |
+
daily_profile_limit: 200
|
| 724 |
+
daily_company_limit: 40
|
| 725 |
+
daily_search_limit: 30
|
| 726 |
min_company_score_for_scan: 50
|
| 727 |
scan_movers: true
|
| 728 |
scan_feed: true
|
|
|
|
| 742 |
- "acquisition"
|
| 743 |
- "wellbeing"
|
| 744 |
- "behavioural change"
|
| 745 |
+
- "team effectiveness"
|
| 746 |
+
- "operating model"
|
| 747 |
+
- "programme management"
|
cqc_radar.py
DELETED
|
@@ -1,350 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
CQC Inspection Radar Module (cqc_radar.py)
|
| 3 |
-
Monitors Care Quality Commission ratings for healthcare organisations
|
| 4 |
-
rated "Requires Improvement" or "Inadequate" - these almost always trigger
|
| 5 |
-
transformation programmes.
|
| 6 |
-
|
| 7 |
-
Requires free subscription key from https://api-portal.service.cqc.org.uk/
|
| 8 |
-
Set CQC_SUBSCRIPTION_KEY environment variable.
|
| 9 |
-
"""
|
| 10 |
-
|
| 11 |
-
import os
|
| 12 |
-
import requests
|
| 13 |
-
import time
|
| 14 |
-
from datetime import datetime
|
| 15 |
-
|
| 16 |
-
# CQC API - requires free subscription key from https://api-portal.service.cqc.org.uk/
|
| 17 |
-
# Set CQC_SUBSCRIPTION_KEY environment variable
|
| 18 |
-
CQC_API_BASE = "https://api.service.cqc.org.uk/public/v1"
|
| 19 |
-
|
| 20 |
-
# Ratings that trigger transformation opportunities
|
| 21 |
-
TRIGGER_RATINGS = ["Requires improvement", "Inadequate"]
|
| 22 |
-
|
| 23 |
-
# Rating hierarchy (best to worst)
|
| 24 |
-
RATING_HIERARCHY = ["Outstanding", "Good", "Requires improvement", "Inadequate"]
|
| 25 |
-
|
| 26 |
-
# Rate limit: CQC allows ~100/min, we'll be polite
|
| 27 |
-
REQUEST_DELAY = 0.7
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
def get_subscription_key() -> str:
|
| 31 |
-
"""Get CQC subscription key from environment."""
|
| 32 |
-
key = os.environ.get("CQC_SUBSCRIPTION_KEY")
|
| 33 |
-
if not key:
|
| 34 |
-
raise ValueError(
|
| 35 |
-
"CQC_SUBSCRIPTION_KEY environment variable is not set. "
|
| 36 |
-
"Get your free key at: https://api-portal.service.cqc.org.uk/"
|
| 37 |
-
)
|
| 38 |
-
return key
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
def _cqc_headers() -> dict:
|
| 42 |
-
"""Build headers for CQC API requests."""
|
| 43 |
-
return {
|
| 44 |
-
"Ocp-Apim-Subscription-Key": get_subscription_key(),
|
| 45 |
-
"Accept": "application/json"
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
def search_providers_by_rating(rating: str, page: int = 1, per_page: int = 20,
|
| 50 |
-
region: str = None) -> dict:
|
| 51 |
-
"""
|
| 52 |
-
Search CQC providers filtered by overall rating.
|
| 53 |
-
|
| 54 |
-
Args:
|
| 55 |
-
rating: Overall rating to filter by (e.g. "Requires improvement")
|
| 56 |
-
page: Page number
|
| 57 |
-
per_page: Results per page
|
| 58 |
-
region: Optional region filter
|
| 59 |
-
|
| 60 |
-
Returns:
|
| 61 |
-
API response dict with providers list
|
| 62 |
-
"""
|
| 63 |
-
params = {
|
| 64 |
-
"overallRating": rating,
|
| 65 |
-
"page": page,
|
| 66 |
-
"perPage": per_page,
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
if region:
|
| 70 |
-
params["region"] = region
|
| 71 |
-
|
| 72 |
-
try:
|
| 73 |
-
response = requests.get(
|
| 74 |
-
f"{CQC_API_BASE}/providers",
|
| 75 |
-
params=params,
|
| 76 |
-
headers=_cqc_headers(),
|
| 77 |
-
timeout=15
|
| 78 |
-
)
|
| 79 |
-
|
| 80 |
-
if response.status_code != 200:
|
| 81 |
-
print(f"CQC API error: {response.status_code}")
|
| 82 |
-
return {"providers": [], "total": 0}
|
| 83 |
-
|
| 84 |
-
return response.json()
|
| 85 |
-
|
| 86 |
-
except Exception as e:
|
| 87 |
-
print(f"CQC API request error: {e}")
|
| 88 |
-
return {"providers": [], "total": 0}
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
def get_provider_details(provider_id: str) -> dict:
|
| 92 |
-
"""
|
| 93 |
-
Get detailed provider information including rating history.
|
| 94 |
-
|
| 95 |
-
Args:
|
| 96 |
-
provider_id: CQC provider ID
|
| 97 |
-
|
| 98 |
-
Returns:
|
| 99 |
-
Provider details dict
|
| 100 |
-
"""
|
| 101 |
-
try:
|
| 102 |
-
response = requests.get(
|
| 103 |
-
f"{CQC_API_BASE}/providers/{provider_id}",
|
| 104 |
-
headers=_cqc_headers(),
|
| 105 |
-
timeout=15
|
| 106 |
-
)
|
| 107 |
-
|
| 108 |
-
if response.status_code != 200:
|
| 109 |
-
return {}
|
| 110 |
-
|
| 111 |
-
return response.json()
|
| 112 |
-
|
| 113 |
-
except Exception as e:
|
| 114 |
-
print(f"CQC provider details error: {e}")
|
| 115 |
-
return {}
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
def detect_rating_downgrade(provider_details: dict) -> dict:
|
| 119 |
-
"""
|
| 120 |
-
Detect if a provider has been downgraded by comparing current vs historical ratings.
|
| 121 |
-
|
| 122 |
-
Args:
|
| 123 |
-
provider_details: Full provider details from API
|
| 124 |
-
|
| 125 |
-
Returns:
|
| 126 |
-
Dict with downgrade info: {downgraded, previous_rating, current_rating, severity}
|
| 127 |
-
"""
|
| 128 |
-
result = {
|
| 129 |
-
"downgraded": False,
|
| 130 |
-
"previous_rating": None,
|
| 131 |
-
"current_rating": None,
|
| 132 |
-
"severity": None
|
| 133 |
-
}
|
| 134 |
-
|
| 135 |
-
# Get current overall rating
|
| 136 |
-
current_ratings = provider_details.get("currentRatings", {})
|
| 137 |
-
overall = current_ratings.get("overall", {})
|
| 138 |
-
current_rating = overall.get("rating")
|
| 139 |
-
|
| 140 |
-
if not current_rating:
|
| 141 |
-
return result
|
| 142 |
-
|
| 143 |
-
result["current_rating"] = current_rating
|
| 144 |
-
|
| 145 |
-
# Check historic ratings
|
| 146 |
-
historic_ratings = provider_details.get("historicRatings", [])
|
| 147 |
-
|
| 148 |
-
if not historic_ratings:
|
| 149 |
-
return result
|
| 150 |
-
|
| 151 |
-
# Find the most recent previous overall rating
|
| 152 |
-
for historic in historic_ratings:
|
| 153 |
-
historic_overall = historic.get("overall", {})
|
| 154 |
-
previous_rating = historic_overall.get("rating")
|
| 155 |
-
|
| 156 |
-
if previous_rating and previous_rating != current_rating:
|
| 157 |
-
result["previous_rating"] = previous_rating
|
| 158 |
-
|
| 159 |
-
# Check if it's a downgrade
|
| 160 |
-
try:
|
| 161 |
-
current_idx = RATING_HIERARCHY.index(current_rating)
|
| 162 |
-
previous_idx = RATING_HIERARCHY.index(previous_rating)
|
| 163 |
-
|
| 164 |
-
if current_idx > previous_idx: # Higher index = worse rating
|
| 165 |
-
result["downgraded"] = True
|
| 166 |
-
steps = current_idx - previous_idx
|
| 167 |
-
if steps >= 2:
|
| 168 |
-
result["severity"] = "major"
|
| 169 |
-
else:
|
| 170 |
-
result["severity"] = "minor"
|
| 171 |
-
except ValueError:
|
| 172 |
-
pass
|
| 173 |
-
|
| 174 |
-
break
|
| 175 |
-
|
| 176 |
-
return result
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
def score_cqc_signal(current_rating: str, downgrade_info: dict,
|
| 180 |
-
inspection_date: str = None) -> int:
|
| 181 |
-
"""
|
| 182 |
-
Score a CQC signal based on rating, downgrade, and recency.
|
| 183 |
-
|
| 184 |
-
Args:
|
| 185 |
-
current_rating: Current overall CQC rating
|
| 186 |
-
downgrade_info: Downgrade detection result
|
| 187 |
-
inspection_date: Date of most recent inspection
|
| 188 |
-
|
| 189 |
-
Returns:
|
| 190 |
-
Score 0-100
|
| 191 |
-
"""
|
| 192 |
-
score = 0
|
| 193 |
-
|
| 194 |
-
# Base score from rating
|
| 195 |
-
if current_rating == "Inadequate":
|
| 196 |
-
score = 85
|
| 197 |
-
elif current_rating == "Requires improvement":
|
| 198 |
-
score = 65
|
| 199 |
-
|
| 200 |
-
# Downgrade bonus
|
| 201 |
-
if downgrade_info.get("downgraded"):
|
| 202 |
-
score += 15
|
| 203 |
-
if downgrade_info.get("severity") == "major":
|
| 204 |
-
score += 10
|
| 205 |
-
|
| 206 |
-
# Recency bonus - recent inspections are more actionable
|
| 207 |
-
if inspection_date:
|
| 208 |
-
try:
|
| 209 |
-
inspection_dt = datetime.strptime(inspection_date[:10], "%Y-%m-%d")
|
| 210 |
-
days_ago = (datetime.now() - inspection_dt).days
|
| 211 |
-
if days_ago <= 90:
|
| 212 |
-
score += 5
|
| 213 |
-
except (ValueError, TypeError):
|
| 214 |
-
pass
|
| 215 |
-
|
| 216 |
-
return min(100, score)
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
def scan_cqc_triggers(max_providers: int = 50) -> list:
|
| 220 |
-
"""
|
| 221 |
-
Main entry point: scan CQC for providers with trigger ratings.
|
| 222 |
-
|
| 223 |
-
Args:
|
| 224 |
-
max_providers: Maximum providers to process
|
| 225 |
-
|
| 226 |
-
Returns:
|
| 227 |
-
Sorted list of signal dicts with provider info and scores
|
| 228 |
-
"""
|
| 229 |
-
# Check for subscription key upfront
|
| 230 |
-
try:
|
| 231 |
-
get_subscription_key()
|
| 232 |
-
except ValueError as e:
|
| 233 |
-
print(f" CQC: {e}")
|
| 234 |
-
return []
|
| 235 |
-
|
| 236 |
-
signals = []
|
| 237 |
-
processed = 0
|
| 238 |
-
|
| 239 |
-
for rating in TRIGGER_RATINGS:
|
| 240 |
-
if processed >= max_providers:
|
| 241 |
-
break
|
| 242 |
-
|
| 243 |
-
print(f" CQC: Scanning '{rating}' providers...")
|
| 244 |
-
|
| 245 |
-
try:
|
| 246 |
-
result = search_providers_by_rating(
|
| 247 |
-
rating=rating,
|
| 248 |
-
per_page=min(max_providers - processed, 25)
|
| 249 |
-
)
|
| 250 |
-
except Exception as e:
|
| 251 |
-
print(f" CQC search error: {e}")
|
| 252 |
-
continue
|
| 253 |
-
|
| 254 |
-
providers = result.get("providers", [])
|
| 255 |
-
|
| 256 |
-
for provider_summary in providers:
|
| 257 |
-
if processed >= max_providers:
|
| 258 |
-
break
|
| 259 |
-
|
| 260 |
-
provider_id = provider_summary.get("providerId")
|
| 261 |
-
if not provider_id:
|
| 262 |
-
continue
|
| 263 |
-
|
| 264 |
-
time.sleep(REQUEST_DELAY)
|
| 265 |
-
|
| 266 |
-
try:
|
| 267 |
-
details = get_provider_details(provider_id)
|
| 268 |
-
if not details:
|
| 269 |
-
continue
|
| 270 |
-
|
| 271 |
-
# Detect downgrade
|
| 272 |
-
downgrade_info = detect_rating_downgrade(details)
|
| 273 |
-
|
| 274 |
-
# Get inspection date
|
| 275 |
-
inspection_date = None
|
| 276 |
-
current_ratings = details.get("currentRatings", {})
|
| 277 |
-
overall = current_ratings.get("overall", {})
|
| 278 |
-
inspection_date = overall.get("reportDate")
|
| 279 |
-
|
| 280 |
-
# Score the signal
|
| 281 |
-
cqc_score = score_cqc_signal(
|
| 282 |
-
current_rating=rating,
|
| 283 |
-
downgrade_info=downgrade_info,
|
| 284 |
-
inspection_date=inspection_date
|
| 285 |
-
)
|
| 286 |
-
|
| 287 |
-
# Get provider name and details
|
| 288 |
-
provider_name = details.get("name", provider_summary.get("providerName", "Unknown"))
|
| 289 |
-
provider_type = details.get("type", "Unknown")
|
| 290 |
-
region = details.get("region", "Unknown")
|
| 291 |
-
|
| 292 |
-
# Get regulated activities
|
| 293 |
-
regulated_activities = []
|
| 294 |
-
for activity in details.get("regulatedActivities", []):
|
| 295 |
-
name = activity.get("name")
|
| 296 |
-
if name:
|
| 297 |
-
regulated_activities.append(name)
|
| 298 |
-
|
| 299 |
-
# Build CQC profile URL
|
| 300 |
-
cqc_url = f"https://www.cqc.org.uk/provider/{provider_id}"
|
| 301 |
-
|
| 302 |
-
signals.append({
|
| 303 |
-
"provider_name": provider_name,
|
| 304 |
-
"provider_id": provider_id,
|
| 305 |
-
"provider_type": provider_type,
|
| 306 |
-
"region": region,
|
| 307 |
-
"current_rating": rating,
|
| 308 |
-
"previous_rating": downgrade_info.get("previous_rating"),
|
| 309 |
-
"is_downgrade": downgrade_info.get("downgraded", False),
|
| 310 |
-
"downgrade_severity": downgrade_info.get("severity"),
|
| 311 |
-
"inspection_date": inspection_date,
|
| 312 |
-
"regulated_activities": regulated_activities,
|
| 313 |
-
"cqc_score": cqc_score,
|
| 314 |
-
"cqc_url": cqc_url
|
| 315 |
-
})
|
| 316 |
-
|
| 317 |
-
processed += 1
|
| 318 |
-
|
| 319 |
-
except Exception as e:
|
| 320 |
-
print(f" CQC provider {provider_id} error: {e}")
|
| 321 |
-
continue
|
| 322 |
-
|
| 323 |
-
# Sort by score descending
|
| 324 |
-
signals.sort(key=lambda x: x.get("cqc_score", 0), reverse=True)
|
| 325 |
-
|
| 326 |
-
return signals
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
# For testing
|
| 330 |
-
if __name__ == "__main__":
|
| 331 |
-
print("=" * 60)
|
| 332 |
-
print("CQC Inspection Radar")
|
| 333 |
-
print("=" * 60)
|
| 334 |
-
|
| 335 |
-
print("\nScanning for CQC triggers...")
|
| 336 |
-
triggers = scan_cqc_triggers(max_providers=10)
|
| 337 |
-
|
| 338 |
-
if triggers:
|
| 339 |
-
print(f"\nFound {len(triggers)} triggers:\n")
|
| 340 |
-
for t in triggers:
|
| 341 |
-
downgrade_str = ""
|
| 342 |
-
if t["is_downgrade"]:
|
| 343 |
-
downgrade_str = f" (DOWNGRADED from {t['previous_rating']}, {t['downgrade_severity']})"
|
| 344 |
-
print(f" [{t['cqc_score']}] {t['provider_name']}")
|
| 345 |
-
print(f" Rating: {t['current_rating']}{downgrade_str}")
|
| 346 |
-
print(f" Type: {t['provider_type']} | Region: {t['region']}")
|
| 347 |
-
print(f" URL: {t['cqc_url']}")
|
| 348 |
-
print()
|
| 349 |
-
else:
|
| 350 |
-
print("No CQC triggers found.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
def draft_warm_intro_email(
|
| 105 |
colleague_name: str,
|
| 106 |
contact_name: str,
|
|
@@ -149,6 +215,11 @@ Goal:
|
|
| 149 |
if additional_context:
|
| 150 |
scenario += f"\nAdditional context: {additional_context}"
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
try:
|
| 153 |
client = get_client()
|
| 154 |
|
|
@@ -259,6 +330,11 @@ Goal:
|
|
| 259 |
- Keep it under 4 paragraphs
|
| 260 |
"""
|
| 261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
try:
|
| 263 |
client = get_client()
|
| 264 |
|
|
@@ -340,9 +416,12 @@ def draft_linkedin_message(
|
|
| 340 |
}
|
| 341 |
limit = char_limits.get(message_type, 300)
|
| 342 |
|
|
|
|
|
|
|
| 343 |
prompt = f"""Write a {message_type} LinkedIn message to {contact_name} ({contact_position} at {contact_company}).
|
| 344 |
|
| 345 |
Context: {context if context else 'General professional outreach'}
|
|
|
|
| 346 |
|
| 347 |
Rules:
|
| 348 |
- Maximum {limit} characters
|
|
@@ -359,6 +438,7 @@ Return ONLY the message text, no JSON, no quotes."""
|
|
| 359 |
response = client.messages.create(
|
| 360 |
model="claude-sonnet-4-20250514",
|
| 361 |
max_tokens=256,
|
|
|
|
| 362 |
messages=[{"role": "user", "content": prompt}]
|
| 363 |
)
|
| 364 |
text = response.content[0].text.strip()
|
|
@@ -398,6 +478,11 @@ Goal:
|
|
| 398 |
- Under 4 paragraphs
|
| 399 |
"""
|
| 400 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
try:
|
| 402 |
client = get_client()
|
| 403 |
response = client.messages.create(
|
|
|
|
| 101 |
}"""
|
| 102 |
|
| 103 |
|
| 104 |
+
def _match_persona(contact_position: str) -> Optional[dict]:
|
| 105 |
+
"""Match a contact's position to a buyer persona from config.yaml.
|
| 106 |
+
|
| 107 |
+
Returns persona dict with title_pattern, service_affinity, priority,
|
| 108 |
+
or None if no match found.
|
| 109 |
+
"""
|
| 110 |
+
if not contact_position:
|
| 111 |
+
return None
|
| 112 |
+
try:
|
| 113 |
+
import yaml
|
| 114 |
+
with open('config.yaml', 'r') as f:
|
| 115 |
+
config = yaml.safe_load(f)
|
| 116 |
+
personas = config.get('target_personas', [])
|
| 117 |
+
except Exception:
|
| 118 |
+
return None
|
| 119 |
+
|
| 120 |
+
pos_lower = contact_position.lower()
|
| 121 |
+
best_match = None
|
| 122 |
+
best_score = 0
|
| 123 |
+
|
| 124 |
+
for persona in personas:
|
| 125 |
+
pattern = persona.get('title_pattern', '').lower()
|
| 126 |
+
if not pattern:
|
| 127 |
+
continue
|
| 128 |
+
# Check for substring match or keyword overlap
|
| 129 |
+
if pattern in pos_lower or pos_lower in pattern:
|
| 130 |
+
score = 100
|
| 131 |
+
else:
|
| 132 |
+
# Word overlap scoring
|
| 133 |
+
pattern_words = set(pattern.split())
|
| 134 |
+
pos_words = set(pos_lower.split())
|
| 135 |
+
overlap = pattern_words & pos_words
|
| 136 |
+
score = (len(overlap) / max(len(pattern_words), 1)) * 80
|
| 137 |
+
|
| 138 |
+
if score > best_score and score >= 40:
|
| 139 |
+
best_score = score
|
| 140 |
+
best_match = persona
|
| 141 |
+
|
| 142 |
+
return best_match
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def _build_persona_context(contact_position: str) -> str:
|
| 146 |
+
"""Build persona-aware context string for email prompts."""
|
| 147 |
+
persona = _match_persona(contact_position)
|
| 148 |
+
if not persona:
|
| 149 |
+
return ""
|
| 150 |
+
|
| 151 |
+
affinities = persona.get('service_affinity', [])
|
| 152 |
+
priority = persona.get('priority', 'medium')
|
| 153 |
+
|
| 154 |
+
service_labels = {
|
| 155 |
+
'transformation_delivery': 'Transformation Delivery (programme management, change, M&A)',
|
| 156 |
+
'culture_capability': 'Culture & Capability (coaching, leadership, team development)',
|
| 157 |
+
'code_3i': 'CODE 3i (digital team assessment)',
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
affinity_str = ', '.join(service_labels.get(a, a) for a in affinities)
|
| 161 |
+
|
| 162 |
+
return (
|
| 163 |
+
f"\n**Buyer Persona Insight ({priority} priority):**\n"
|
| 164 |
+
f"- This persona ({persona['title_pattern']}) typically buys: {affinity_str}\n"
|
| 165 |
+
f"- Tailor the message to their likely pain points and decision-making authority\n"
|
| 166 |
+
f"- {'This is a high-priority persona — be specific about relevant services' if priority == 'high' else 'Position services naturally without being pushy'}\n"
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
def draft_warm_intro_email(
|
| 171 |
colleague_name: str,
|
| 172 |
contact_name: str,
|
|
|
|
| 215 |
if additional_context:
|
| 216 |
scenario += f"\nAdditional context: {additional_context}"
|
| 217 |
|
| 218 |
+
# Inject buyer persona insight if available
|
| 219 |
+
persona_ctx = _build_persona_context(contact_position)
|
| 220 |
+
if persona_ctx:
|
| 221 |
+
scenario += persona_ctx
|
| 222 |
+
|
| 223 |
try:
|
| 224 |
client = get_client()
|
| 225 |
|
|
|
|
| 330 |
- Keep it under 4 paragraphs
|
| 331 |
"""
|
| 332 |
|
| 333 |
+
# Inject buyer persona insight if available
|
| 334 |
+
persona_ctx = _build_persona_context(contact_position)
|
| 335 |
+
if persona_ctx:
|
| 336 |
+
scenario += persona_ctx
|
| 337 |
+
|
| 338 |
try:
|
| 339 |
client = get_client()
|
| 340 |
|
|
|
|
| 416 |
}
|
| 417 |
limit = char_limits.get(message_type, 300)
|
| 418 |
|
| 419 |
+
persona_ctx = _build_persona_context(contact_position)
|
| 420 |
+
|
| 421 |
prompt = f"""Write a {message_type} LinkedIn message to {contact_name} ({contact_position} at {contact_company}).
|
| 422 |
|
| 423 |
Context: {context if context else 'General professional outreach'}
|
| 424 |
+
{persona_ctx}
|
| 425 |
|
| 426 |
Rules:
|
| 427 |
- Maximum {limit} characters
|
|
|
|
| 438 |
response = client.messages.create(
|
| 439 |
model="claude-sonnet-4-20250514",
|
| 440 |
max_tokens=256,
|
| 441 |
+
system=GHOSTWRITER_SYSTEM_PROMPT,
|
| 442 |
messages=[{"role": "user", "content": prompt}]
|
| 443 |
)
|
| 444 |
text = response.content[0].text.strip()
|
|
|
|
| 478 |
- Under 4 paragraphs
|
| 479 |
"""
|
| 480 |
|
| 481 |
+
# Inject buyer persona insight if available
|
| 482 |
+
persona_ctx = _build_persona_context(contact_position)
|
| 483 |
+
if persona_ctx:
|
| 484 |
+
scenario += persona_ctx
|
| 485 |
+
|
| 486 |
try:
|
| 487 |
client = get_client()
|
| 488 |
response = client.messages.create(
|
financials.py
CHANGED
|
@@ -8,6 +8,10 @@ import json
|
|
| 8 |
import requests
|
| 9 |
from typing import Optional
|
| 10 |
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# Companies House API base URL
|
| 13 |
COMPANIES_HOUSE_API = "https://api.company-information.service.gov.uk"
|
|
|
|
| 8 |
import requests
|
| 9 |
from typing import Optional
|
| 10 |
from pathlib import Path
|
| 11 |
+
from dotenv import load_dotenv
|
| 12 |
+
|
| 13 |
+
env_path = Path(__file__).parent / '.env'
|
| 14 |
+
load_dotenv(dotenv_path=env_path, override=True)
|
| 15 |
|
| 16 |
# Companies House API base URL
|
| 17 |
COMPANIES_HOUSE_API = "https://api.company-information.service.gov.uk"
|
hunter.py
CHANGED
|
@@ -21,7 +21,7 @@ load_dotenv(dotenv_path=env_path, override=True)
|
|
| 21 |
|
| 22 |
# Import our modules
|
| 23 |
from brain import analyze_opportunity
|
| 24 |
-
from network_loader import find_network_hit
|
| 25 |
from collator import (
|
| 26 |
add_job_signal, add_news_signal, add_tender_signal, add_network_signal,
|
| 27 |
add_annual_report_signal, add_sentiment_signal, add_pe_deal_signal,
|
|
@@ -349,7 +349,7 @@ class AutonomousHunter:
|
|
| 349 |
add_network_signal(
|
| 350 |
company_name=company,
|
| 351 |
contact_name=hit.best_match.name,
|
| 352 |
-
contact_position=hit.best_match.
|
| 353 |
colleague_name=hit.best_match.colleague,
|
| 354 |
connection_tier=hit.best_match.tier_label,
|
| 355 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
@@ -531,7 +531,7 @@ class AutonomousHunter:
|
|
| 531 |
add_network_signal(
|
| 532 |
company_name=company,
|
| 533 |
contact_name=hit.best_match.name,
|
| 534 |
-
contact_position=hit.best_match.
|
| 535 |
colleague_name=hit.best_match.colleague,
|
| 536 |
connection_tier=hit.best_match.tier_label,
|
| 537 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
@@ -580,7 +580,7 @@ class AutonomousHunter:
|
|
| 580 |
add_network_signal(
|
| 581 |
company_name=company,
|
| 582 |
contact_name=hit.best_match.name,
|
| 583 |
-
contact_position=hit.best_match.
|
| 584 |
colleague_name=hit.best_match.colleague,
|
| 585 |
connection_tier=hit.best_match.tier_label,
|
| 586 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
@@ -698,7 +698,7 @@ class AutonomousHunter:
|
|
| 698 |
add_network_signal(
|
| 699 |
company_name=buyer,
|
| 700 |
contact_name=hit.best_match.name,
|
| 701 |
-
contact_position=hit.best_match.
|
| 702 |
colleague_name=hit.best_match.colleague,
|
| 703 |
connection_tier=hit.best_match.tier_label,
|
| 704 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
@@ -901,7 +901,7 @@ class AutonomousHunter:
|
|
| 901 |
add_network_signal(
|
| 902 |
company_name=signal['company_name'],
|
| 903 |
contact_name=hit.best_match.name,
|
| 904 |
-
contact_position=hit.best_match.
|
| 905 |
colleague_name=hit.best_match.colleague,
|
| 906 |
connection_tier=hit.best_match.tier_label,
|
| 907 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
@@ -974,7 +974,7 @@ class AutonomousHunter:
|
|
| 974 |
add_network_signal(
|
| 975 |
company_name=deal['company_name'],
|
| 976 |
contact_name=hit.best_match.name,
|
| 977 |
-
contact_position=hit.best_match.
|
| 978 |
colleague_name=hit.best_match.colleague,
|
| 979 |
connection_tier=hit.best_match.tier_label,
|
| 980 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
@@ -1051,7 +1051,7 @@ class AutonomousHunter:
|
|
| 1051 |
add_network_signal(
|
| 1052 |
company_name=company,
|
| 1053 |
contact_name=hit.best_match.name,
|
| 1054 |
-
contact_position=hit.best_match.
|
| 1055 |
colleague_name=hit.best_match.colleague,
|
| 1056 |
connection_tier=hit.best_match.tier_label,
|
| 1057 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
|
|
| 21 |
|
| 22 |
# Import our modules
|
| 23 |
from brain import analyze_opportunity
|
| 24 |
+
from network_loader import find_network_hit, find_network_hit_with_affinity
|
| 25 |
from collator import (
|
| 26 |
add_job_signal, add_news_signal, add_tender_signal, add_network_signal,
|
| 27 |
add_annual_report_signal, add_sentiment_signal, add_pe_deal_signal,
|
|
|
|
| 349 |
add_network_signal(
|
| 350 |
company_name=company,
|
| 351 |
contact_name=hit.best_match.name,
|
| 352 |
+
contact_position=hit.best_match.position,
|
| 353 |
colleague_name=hit.best_match.colleague,
|
| 354 |
connection_tier=hit.best_match.tier_label,
|
| 355 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
|
|
| 531 |
add_network_signal(
|
| 532 |
company_name=company,
|
| 533 |
contact_name=hit.best_match.name,
|
| 534 |
+
contact_position=hit.best_match.position,
|
| 535 |
colleague_name=hit.best_match.colleague,
|
| 536 |
connection_tier=hit.best_match.tier_label,
|
| 537 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
|
|
| 580 |
add_network_signal(
|
| 581 |
company_name=company,
|
| 582 |
contact_name=hit.best_match.name,
|
| 583 |
+
contact_position=hit.best_match.position,
|
| 584 |
colleague_name=hit.best_match.colleague,
|
| 585 |
connection_tier=hit.best_match.tier_label,
|
| 586 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
|
|
| 698 |
add_network_signal(
|
| 699 |
company_name=buyer,
|
| 700 |
contact_name=hit.best_match.name,
|
| 701 |
+
contact_position=hit.best_match.position,
|
| 702 |
colleague_name=hit.best_match.colleague,
|
| 703 |
connection_tier=hit.best_match.tier_label,
|
| 704 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
|
|
| 901 |
add_network_signal(
|
| 902 |
company_name=signal['company_name'],
|
| 903 |
contact_name=hit.best_match.name,
|
| 904 |
+
contact_position=hit.best_match.position,
|
| 905 |
colleague_name=hit.best_match.colleague,
|
| 906 |
connection_tier=hit.best_match.tier_label,
|
| 907 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
|
|
| 974 |
add_network_signal(
|
| 975 |
company_name=deal['company_name'],
|
| 976 |
contact_name=hit.best_match.name,
|
| 977 |
+
contact_position=hit.best_match.position,
|
| 978 |
colleague_name=hit.best_match.colleague,
|
| 979 |
connection_tier=hit.best_match.tier_label,
|
| 980 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
|
|
|
| 1051 |
add_network_signal(
|
| 1052 |
company_name=company,
|
| 1053 |
contact_name=hit.best_match.name,
|
| 1054 |
+
contact_position=hit.best_match.position,
|
| 1055 |
colleague_name=hit.best_match.colleague,
|
| 1056 |
connection_tier=hit.best_match.tier_label,
|
| 1057 |
match_score=hit.best_match.score if hasattr(hit.best_match, 'score') else 80.0
|
linkedin_activity.py
ADD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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
LinkedIn Activity Generator (linkedin_activity.py)
|
| 3 |
+
Creates daily engagement playbooks for the Curium team.
|
| 4 |
+
|
| 5 |
+
Generates:
|
| 6 |
+
- Daily prioritised actions per team member (comment, connect, share, message, endorse)
|
| 7 |
+
- Personalised connection request messages (< 300 chars)
|
| 8 |
+
- Content calendar based on market signals
|
| 9 |
+
- Comment drafts positioning Curium expertise
|
| 10 |
+
- Team-wide advocacy playbooks
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import os
|
| 14 |
+
import json
|
| 15 |
+
import sqlite3
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
from datetime import datetime, timedelta
|
| 18 |
+
from dataclasses import dataclass, field
|
| 19 |
+
from typing import Optional
|
| 20 |
+
from dotenv import load_dotenv
|
| 21 |
+
from anthropic import Anthropic
|
| 22 |
+
|
| 23 |
+
# Load environment variables
|
| 24 |
+
env_path = Path(__file__).parent / '.env'
|
| 25 |
+
load_dotenv(dotenv_path=env_path, override=True)
|
| 26 |
+
|
| 27 |
+
DATABASE = "leads.db"
|
| 28 |
+
|
| 29 |
+
# Anthropic client singleton
|
| 30 |
+
_client = None
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def get_client():
|
| 34 |
+
"""Get or create the Anthropic client."""
|
| 35 |
+
global _client
|
| 36 |
+
if _client is None:
|
| 37 |
+
api_key = os.environ.get("ANTHROPIC_API_KEY")
|
| 38 |
+
if not api_key:
|
| 39 |
+
raise ValueError("ANTHROPIC_API_KEY not set")
|
| 40 |
+
_client = Anthropic(api_key=api_key)
|
| 41 |
+
return _client
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def get_connection():
|
| 45 |
+
return sqlite3.connect(DATABASE)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
# =============================================================================
|
| 49 |
+
# DATA MODELS
|
| 50 |
+
# =============================================================================
|
| 51 |
+
|
| 52 |
+
@dataclass
|
| 53 |
+
class LinkedInAction:
|
| 54 |
+
"""A single LinkedIn action for a team member."""
|
| 55 |
+
colleague: str # Team member name
|
| 56 |
+
action_type: str # connect, comment, share, message, endorse, inmail
|
| 57 |
+
target: str # Contact name or post topic
|
| 58 |
+
target_company: str # Target's company
|
| 59 |
+
target_position: str # Target's position
|
| 60 |
+
suggested_text: str # Draft message/comment text
|
| 61 |
+
priority: int # 1=urgent, 2=important, 3=nice-to-do
|
| 62 |
+
service_line: Optional[str] = None # TD, CC, or CODE
|
| 63 |
+
reason: str = "" # Why this action matters
|
| 64 |
+
status: str = "pending" # pending, done, skipped
|
| 65 |
+
created_at: str = ""
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
@dataclass
|
| 69 |
+
class ContentSuggestion:
|
| 70 |
+
"""A content piece suggestion for LinkedIn posting."""
|
| 71 |
+
topic: str
|
| 72 |
+
hook: str # Opening line / attention grabber
|
| 73 |
+
key_points: list # 3-5 bullet points
|
| 74 |
+
service_line: str # TD, CC, or CODE
|
| 75 |
+
suggested_author: str # Which team member should post
|
| 76 |
+
post_type: str = "thought_leadership" # thought_leadership, case_study, market_commentary, tip
|
| 77 |
+
hashtags: list = field(default_factory=list)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
# =============================================================================
|
| 81 |
+
# DATABASE TABLES
|
| 82 |
+
# =============================================================================
|
| 83 |
+
|
| 84 |
+
def init_linkedin_actions_table():
|
| 85 |
+
"""Create linkedin_actions tracking table."""
|
| 86 |
+
conn = get_connection()
|
| 87 |
+
cursor = conn.cursor()
|
| 88 |
+
|
| 89 |
+
cursor.execute("""
|
| 90 |
+
CREATE TABLE IF NOT EXISTS linkedin_actions (
|
| 91 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 92 |
+
colleague TEXT NOT NULL,
|
| 93 |
+
action_type TEXT NOT NULL,
|
| 94 |
+
target_name TEXT,
|
| 95 |
+
target_company TEXT,
|
| 96 |
+
target_position TEXT,
|
| 97 |
+
suggested_text TEXT,
|
| 98 |
+
priority INTEGER DEFAULT 2,
|
| 99 |
+
service_line TEXT,
|
| 100 |
+
reason TEXT,
|
| 101 |
+
status TEXT DEFAULT 'pending',
|
| 102 |
+
created_at TEXT NOT NULL,
|
| 103 |
+
completed_at TEXT
|
| 104 |
+
)
|
| 105 |
+
""")
|
| 106 |
+
|
| 107 |
+
cursor.execute("CREATE INDEX IF NOT EXISTS idx_actions_colleague ON linkedin_actions(colleague)")
|
| 108 |
+
cursor.execute("CREATE INDEX IF NOT EXISTS idx_actions_status ON linkedin_actions(status)")
|
| 109 |
+
cursor.execute("CREATE INDEX IF NOT EXISTS idx_actions_date ON linkedin_actions(created_at)")
|
| 110 |
+
|
| 111 |
+
conn.commit()
|
| 112 |
+
conn.close()
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
# Initialize on import
|
| 116 |
+
init_linkedin_actions_table()
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
# =============================================================================
|
| 120 |
+
# ACTION GENERATION
|
| 121 |
+
# =============================================================================
|
| 122 |
+
|
| 123 |
+
def generate_daily_actions(colleague_name: str, companies: list, max_actions: int = 5) -> list[LinkedInAction]:
|
| 124 |
+
"""Generate prioritised daily LinkedIn actions for a team member.
|
| 125 |
+
|
| 126 |
+
Args:
|
| 127 |
+
colleague_name: Team member name
|
| 128 |
+
companies: List of CompanyDossier objects (top companies)
|
| 129 |
+
max_actions: Maximum actions to generate (default 5)
|
| 130 |
+
|
| 131 |
+
Returns:
|
| 132 |
+
List of LinkedInAction objects, sorted by priority
|
| 133 |
+
"""
|
| 134 |
+
actions = []
|
| 135 |
+
today = datetime.now().isoformat()[:10]
|
| 136 |
+
|
| 137 |
+
for company in companies:
|
| 138 |
+
# Skip low-scoring companies
|
| 139 |
+
if company.overall_score < 20:
|
| 140 |
+
continue
|
| 141 |
+
|
| 142 |
+
td = getattr(company, 'td_score', 0) or 0
|
| 143 |
+
cc = getattr(company, 'cc_score', 0) or 0
|
| 144 |
+
primary_line = "TD" if td > cc else "CC" if cc > td else "Both"
|
| 145 |
+
|
| 146 |
+
# Priority 1: Companies with LinkedIn intel showing active contacts
|
| 147 |
+
for intel in getattr(company, 'linkedin_intel', []):
|
| 148 |
+
if intel.get('colleague_name', '') == colleague_name:
|
| 149 |
+
if intel.get('posts_about_transformation'):
|
| 150 |
+
actions.append(LinkedInAction(
|
| 151 |
+
colleague=colleague_name,
|
| 152 |
+
action_type="comment",
|
| 153 |
+
target=intel.get('contact_name', 'Unknown'),
|
| 154 |
+
target_company=company.name,
|
| 155 |
+
target_position=intel.get('contact_title', ''),
|
| 156 |
+
suggested_text=f"Comment on their transformation post — position Curium's {primary_line} expertise",
|
| 157 |
+
priority=1,
|
| 158 |
+
service_line=primary_line,
|
| 159 |
+
reason=f"Score {company.overall_score}. Contact posting about transformation.",
|
| 160 |
+
created_at=today,
|
| 161 |
+
))
|
| 162 |
+
elif intel.get('contact_active'):
|
| 163 |
+
actions.append(LinkedInAction(
|
| 164 |
+
colleague=colleague_name,
|
| 165 |
+
action_type="message",
|
| 166 |
+
target=intel.get('contact_name', 'Unknown'),
|
| 167 |
+
target_company=company.name,
|
| 168 |
+
target_position=intel.get('contact_title', ''),
|
| 169 |
+
suggested_text=f"Warm message referencing their recent activity and Curium's work in their sector",
|
| 170 |
+
priority=2,
|
| 171 |
+
service_line=primary_line,
|
| 172 |
+
reason=f"Score {company.overall_score}. Active contact at hot company.",
|
| 173 |
+
created_at=today,
|
| 174 |
+
))
|
| 175 |
+
|
| 176 |
+
# Priority 1: Companies with network connections via this colleague
|
| 177 |
+
for net in getattr(company, 'network', []):
|
| 178 |
+
if net.get('colleague', '') == colleague_name and company.overall_score >= 50:
|
| 179 |
+
actions.append(LinkedInAction(
|
| 180 |
+
colleague=colleague_name,
|
| 181 |
+
action_type="message",
|
| 182 |
+
target=net.get('contact', 'Unknown'),
|
| 183 |
+
target_company=company.name,
|
| 184 |
+
target_position=net.get('position', ''),
|
| 185 |
+
suggested_text=f"Reconnect with {net.get('contact', 'them')} — mention relevant work at Curium",
|
| 186 |
+
priority=1,
|
| 187 |
+
service_line=primary_line,
|
| 188 |
+
reason=f"Score {company.overall_score}. Direct connection at hot company.",
|
| 189 |
+
created_at=today,
|
| 190 |
+
))
|
| 191 |
+
|
| 192 |
+
# Priority 2: Hot companies without connections — connect
|
| 193 |
+
if company.overall_score >= 50 and (not company.network_status or company.network_status == "Cold"):
|
| 194 |
+
# Find a relevant contact from jobs or LinkedIn intel
|
| 195 |
+
target_name = ""
|
| 196 |
+
target_position = ""
|
| 197 |
+
|
| 198 |
+
for intel in getattr(company, 'linkedin_intel', []):
|
| 199 |
+
target_name = intel.get('contact_name', '')
|
| 200 |
+
target_position = intel.get('contact_title', '')
|
| 201 |
+
break
|
| 202 |
+
|
| 203 |
+
if target_name:
|
| 204 |
+
actions.append(LinkedInAction(
|
| 205 |
+
colleague=colleague_name,
|
| 206 |
+
action_type="connect",
|
| 207 |
+
target=target_name,
|
| 208 |
+
target_company=company.name,
|
| 209 |
+
target_position=target_position,
|
| 210 |
+
suggested_text=f"Connect with {target_name} — reference their company's transformation signals",
|
| 211 |
+
priority=2,
|
| 212 |
+
service_line=primary_line,
|
| 213 |
+
reason=f"Score {company.overall_score}. No connection yet — need a way in.",
|
| 214 |
+
created_at=today,
|
| 215 |
+
))
|
| 216 |
+
|
| 217 |
+
# Priority 3: Companies with news — share/comment opportunity
|
| 218 |
+
if company.news and company.overall_score >= 30:
|
| 219 |
+
latest_news = company.news[0]
|
| 220 |
+
actions.append(LinkedInAction(
|
| 221 |
+
colleague=colleague_name,
|
| 222 |
+
action_type="share",
|
| 223 |
+
target=latest_news.get('headline', 'News article'),
|
| 224 |
+
target_company=company.name,
|
| 225 |
+
target_position="",
|
| 226 |
+
suggested_text=f"Share with Curium perspective on {latest_news.get('trigger', 'transformation')}",
|
| 227 |
+
priority=3,
|
| 228 |
+
service_line=primary_line,
|
| 229 |
+
reason=f"Score {company.overall_score}. News: {latest_news.get('headline', '')[:50]}",
|
| 230 |
+
created_at=today,
|
| 231 |
+
))
|
| 232 |
+
|
| 233 |
+
# Sort by priority, deduplicate by target, limit to max_actions
|
| 234 |
+
actions.sort(key=lambda a: a.priority)
|
| 235 |
+
seen_targets = set()
|
| 236 |
+
unique_actions = []
|
| 237 |
+
for action in actions:
|
| 238 |
+
key = f"{action.target}_{action.action_type}"
|
| 239 |
+
if key not in seen_targets:
|
| 240 |
+
seen_targets.add(key)
|
| 241 |
+
unique_actions.append(action)
|
| 242 |
+
if len(unique_actions) >= max_actions:
|
| 243 |
+
break
|
| 244 |
+
|
| 245 |
+
# Save to database
|
| 246 |
+
_save_actions(unique_actions)
|
| 247 |
+
|
| 248 |
+
return unique_actions
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
def _save_actions(actions: list[LinkedInAction]):
|
| 252 |
+
"""Persist actions to database for tracking."""
|
| 253 |
+
conn = get_connection()
|
| 254 |
+
cursor = conn.cursor()
|
| 255 |
+
|
| 256 |
+
for action in actions:
|
| 257 |
+
cursor.execute("""
|
| 258 |
+
INSERT INTO linkedin_actions
|
| 259 |
+
(colleague, action_type, target_name, target_company, target_position,
|
| 260 |
+
suggested_text, priority, service_line, reason, status, created_at)
|
| 261 |
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
| 262 |
+
""", (action.colleague, action.action_type, action.target,
|
| 263 |
+
action.target_company, action.target_position,
|
| 264 |
+
action.suggested_text, action.priority, action.service_line,
|
| 265 |
+
action.reason, action.status, action.created_at))
|
| 266 |
+
|
| 267 |
+
conn.commit()
|
| 268 |
+
conn.close()
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
def update_action_status(action_id: int, status: str):
|
| 272 |
+
"""Update action status (pending -> done/skipped)."""
|
| 273 |
+
conn = get_connection()
|
| 274 |
+
cursor = conn.cursor()
|
| 275 |
+
completed = datetime.now().isoformat() if status == "done" else None
|
| 276 |
+
cursor.execute(
|
| 277 |
+
"UPDATE linkedin_actions SET status = ?, completed_at = ? WHERE id = ?",
|
| 278 |
+
(status, completed, action_id)
|
| 279 |
+
)
|
| 280 |
+
conn.commit()
|
| 281 |
+
conn.close()
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
def get_pending_actions(colleague_name: str = None) -> list[dict]:
|
| 285 |
+
"""Get pending actions, optionally filtered by colleague."""
|
| 286 |
+
conn = get_connection()
|
| 287 |
+
cursor = conn.cursor()
|
| 288 |
+
|
| 289 |
+
if colleague_name:
|
| 290 |
+
cursor.execute("""
|
| 291 |
+
SELECT id, colleague, action_type, target_name, target_company,
|
| 292 |
+
target_position, suggested_text, priority, service_line,
|
| 293 |
+
reason, status, created_at
|
| 294 |
+
FROM linkedin_actions
|
| 295 |
+
WHERE colleague = ? AND status = 'pending'
|
| 296 |
+
ORDER BY priority, created_at DESC
|
| 297 |
+
""", (colleague_name,))
|
| 298 |
+
else:
|
| 299 |
+
cursor.execute("""
|
| 300 |
+
SELECT id, colleague, action_type, target_name, target_company,
|
| 301 |
+
target_position, suggested_text, priority, service_line,
|
| 302 |
+
reason, status, created_at
|
| 303 |
+
FROM linkedin_actions
|
| 304 |
+
WHERE status = 'pending'
|
| 305 |
+
ORDER BY priority, created_at DESC
|
| 306 |
+
""")
|
| 307 |
+
|
| 308 |
+
columns = ['id', 'colleague', 'action_type', 'target_name', 'target_company',
|
| 309 |
+
'target_position', 'suggested_text', 'priority', 'service_line',
|
| 310 |
+
'reason', 'status', 'created_at']
|
| 311 |
+
results = [dict(zip(columns, row)) for row in cursor.fetchall()]
|
| 312 |
+
conn.close()
|
| 313 |
+
return results
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
# =============================================================================
|
| 317 |
+
# CONNECTION REQUEST GENERATION
|
| 318 |
+
# =============================================================================
|
| 319 |
+
|
| 320 |
+
def generate_connection_request(
|
| 321 |
+
contact_name: str,
|
| 322 |
+
contact_company: str,
|
| 323 |
+
contact_position: str,
|
| 324 |
+
context: str = "",
|
| 325 |
+
) -> str:
|
| 326 |
+
"""Generate a personalised LinkedIn connection request (< 300 chars).
|
| 327 |
+
|
| 328 |
+
Args:
|
| 329 |
+
contact_name: Target person
|
| 330 |
+
contact_company: Their company
|
| 331 |
+
contact_position: Their role
|
| 332 |
+
context: Why we're connecting (signal, news, etc.)
|
| 333 |
+
|
| 334 |
+
Returns:
|
| 335 |
+
String message under 300 characters
|
| 336 |
+
"""
|
| 337 |
+
prompt = f"""Write a LinkedIn connection request to {contact_name} ({contact_position} at {contact_company}).
|
| 338 |
+
|
| 339 |
+
Context: {context if context else 'Professional networking in transformation space'}
|
| 340 |
+
|
| 341 |
+
Rules:
|
| 342 |
+
- MAXIMUM 290 characters (hard limit)
|
| 343 |
+
- Warm, British English, professional
|
| 344 |
+
- Reference something specific about them
|
| 345 |
+
- Mention you're at Curium Solutions only if natural
|
| 346 |
+
- No buzzwords, no "synergy", no "leverage"
|
| 347 |
+
- Start with their name or a specific reference
|
| 348 |
+
|
| 349 |
+
Return ONLY the message text."""
|
| 350 |
+
|
| 351 |
+
try:
|
| 352 |
+
client = get_client()
|
| 353 |
+
response = client.messages.create(
|
| 354 |
+
model="claude-sonnet-4-20250514",
|
| 355 |
+
max_tokens=128,
|
| 356 |
+
messages=[{"role": "user", "content": prompt}]
|
| 357 |
+
)
|
| 358 |
+
text = response.content[0].text.strip().strip('"')
|
| 359 |
+
return text[:300]
|
| 360 |
+
except Exception:
|
| 361 |
+
first_name = contact_name.split()[0] if contact_name else "Hi"
|
| 362 |
+
return f"Hi {first_name}, I work in the transformation space at Curium and noticed your role at {contact_company}. Would be great to connect."[:300]
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
# =============================================================================
|
| 366 |
+
# CONTENT CALENDAR GENERATION
|
| 367 |
+
# =============================================================================
|
| 368 |
+
|
| 369 |
+
def generate_content_calendar(signals: list, weeks: int = 2) -> list[ContentSuggestion]:
|
| 370 |
+
"""Generate a content calendar based on current market signals.
|
| 371 |
+
|
| 372 |
+
Args:
|
| 373 |
+
signals: List of dicts with 'trigger', 'company', 'headline' keys
|
| 374 |
+
weeks: Number of weeks to plan
|
| 375 |
+
|
| 376 |
+
Returns:
|
| 377 |
+
List of ContentSuggestion objects
|
| 378 |
+
"""
|
| 379 |
+
# Build signal summary for AI
|
| 380 |
+
signal_summary = "\n".join([
|
| 381 |
+
f"- {s.get('trigger', 'general')}: {s.get('headline', s.get('company', 'Unknown'))}"
|
| 382 |
+
for s in signals[:10]
|
| 383 |
+
])
|
| 384 |
+
|
| 385 |
+
prompt = f"""Based on these current market signals, create a {weeks}-week LinkedIn content calendar for Curium Solutions.
|
| 386 |
+
|
| 387 |
+
Signals:
|
| 388 |
+
{signal_summary}
|
| 389 |
+
|
| 390 |
+
About Curium:
|
| 391 |
+
- Two practices: Transformation Delivery (programme management, change, M&A) and Culture & Capability (coaching, leadership, team development)
|
| 392 |
+
- Product: CODE 3i digital team assessment
|
| 393 |
+
- Values: People First, Keep It Simple, Make It Real
|
| 394 |
+
- Tone: Practical, insightful, no jargon
|
| 395 |
+
|
| 396 |
+
Generate {weeks * 3} content suggestions as JSON array. Each entry:
|
| 397 |
+
{{
|
| 398 |
+
"topic": "Post topic",
|
| 399 |
+
"hook": "Opening line that grabs attention (1 sentence)",
|
| 400 |
+
"key_points": ["point 1", "point 2", "point 3"],
|
| 401 |
+
"service_line": "TD or CC or CODE",
|
| 402 |
+
"post_type": "thought_leadership or case_study or market_commentary or tip",
|
| 403 |
+
"suggested_author": "Piers or Adam or Stuart",
|
| 404 |
+
"hashtags": ["#hashtag1", "#hashtag2"]
|
| 405 |
+
}}
|
| 406 |
+
|
| 407 |
+
Return ONLY the JSON array."""
|
| 408 |
+
|
| 409 |
+
try:
|
| 410 |
+
client = get_client()
|
| 411 |
+
response = client.messages.create(
|
| 412 |
+
model="claude-sonnet-4-20250514",
|
| 413 |
+
max_tokens=2048,
|
| 414 |
+
messages=[{"role": "user", "content": prompt}]
|
| 415 |
+
)
|
| 416 |
+
|
| 417 |
+
text = response.content[0].text.strip()
|
| 418 |
+
if text.startswith("```"):
|
| 419 |
+
lines = text.split('\n')
|
| 420 |
+
if lines[0].startswith("```"):
|
| 421 |
+
lines = lines[1:]
|
| 422 |
+
if lines and lines[-1].strip() == "```":
|
| 423 |
+
lines = lines[:-1]
|
| 424 |
+
text = '\n'.join(lines).strip()
|
| 425 |
+
|
| 426 |
+
items = json.loads(text)
|
| 427 |
+
suggestions = []
|
| 428 |
+
for item in items:
|
| 429 |
+
suggestions.append(ContentSuggestion(
|
| 430 |
+
topic=item.get('topic', ''),
|
| 431 |
+
hook=item.get('hook', ''),
|
| 432 |
+
key_points=item.get('key_points', []),
|
| 433 |
+
service_line=item.get('service_line', 'Both'),
|
| 434 |
+
suggested_author=item.get('suggested_author', 'Piers'),
|
| 435 |
+
post_type=item.get('post_type', 'thought_leadership'),
|
| 436 |
+
hashtags=item.get('hashtags', []),
|
| 437 |
+
))
|
| 438 |
+
return suggestions
|
| 439 |
+
|
| 440 |
+
except Exception as e:
|
| 441 |
+
# Return a default suggestion
|
| 442 |
+
return [ContentSuggestion(
|
| 443 |
+
topic="The human side of transformation",
|
| 444 |
+
hook="Every transformation is really a people transformation.",
|
| 445 |
+
key_points=[
|
| 446 |
+
"Technical delivery matters, but culture eats strategy for breakfast",
|
| 447 |
+
"CODE 3i helps teams understand how they work together",
|
| 448 |
+
"The best transformations invest in both delivery and people"
|
| 449 |
+
],
|
| 450 |
+
service_line="Both",
|
| 451 |
+
suggested_author="Piers",
|
| 452 |
+
post_type="thought_leadership",
|
| 453 |
+
hashtags=["#Transformation", "#Leadership", "#TeamEffectiveness"],
|
| 454 |
+
)]
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
# =============================================================================
|
| 458 |
+
# COMMENT DRAFTING
|
| 459 |
+
# =============================================================================
|
| 460 |
+
|
| 461 |
+
def generate_comment_draft(post_topic: str, curium_angle: str, service_line: str = "Both") -> str:
|
| 462 |
+
"""Generate a thoughtful LinkedIn comment positioning Curium expertise.
|
| 463 |
+
|
| 464 |
+
Args:
|
| 465 |
+
post_topic: What the post is about
|
| 466 |
+
curium_angle: How Curium's expertise relates
|
| 467 |
+
service_line: TD, CC, or Both
|
| 468 |
+
|
| 469 |
+
Returns:
|
| 470 |
+
Comment text (< 1250 chars)
|
| 471 |
+
"""
|
| 472 |
+
prompt = f"""Write a LinkedIn comment on a post about: {post_topic}
|
| 473 |
+
|
| 474 |
+
Curium angle: {curium_angle}
|
| 475 |
+
Service focus: {service_line}
|
| 476 |
+
|
| 477 |
+
Rules:
|
| 478 |
+
- Under 1250 characters
|
| 479 |
+
- Add genuine value — don't just agree
|
| 480 |
+
- Share a specific insight or experience
|
| 481 |
+
- If CODE 3i is relevant, mention naturally ("We've been using our CODE assessment and finding...")
|
| 482 |
+
- British English, professional but conversational
|
| 483 |
+
- Don't start with "Great post!" — be more original
|
| 484 |
+
- End with a question or invitation to discuss
|
| 485 |
+
|
| 486 |
+
Return ONLY the comment text."""
|
| 487 |
+
|
| 488 |
+
try:
|
| 489 |
+
client = get_client()
|
| 490 |
+
response = client.messages.create(
|
| 491 |
+
model="claude-sonnet-4-20250514",
|
| 492 |
+
max_tokens=512,
|
| 493 |
+
messages=[{"role": "user", "content": prompt}]
|
| 494 |
+
)
|
| 495 |
+
return response.content[0].text.strip()[:1250]
|
| 496 |
+
except Exception:
|
| 497 |
+
return f"Really interesting perspective on {post_topic}. We've been seeing similar patterns in our work. Happy to share some thoughts if useful."
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
# =============================================================================
|
| 501 |
+
# ADVOCACY PLAYBOOK
|
| 502 |
+
# =============================================================================
|
| 503 |
+
|
| 504 |
+
def generate_advocacy_playbook(team: list[dict], top_companies: list) -> dict:
|
| 505 |
+
"""Generate a weekly team-wide advocacy plan.
|
| 506 |
+
|
| 507 |
+
Args:
|
| 508 |
+
team: List of team member dicts with 'name', 'service_focus' keys
|
| 509 |
+
top_companies: List of CompanyDossier objects
|
| 510 |
+
|
| 511 |
+
Returns:
|
| 512 |
+
Dict with team_actions (by member), content_plan, and summary
|
| 513 |
+
"""
|
| 514 |
+
team_actions = {}
|
| 515 |
+
|
| 516 |
+
for member in team:
|
| 517 |
+
name = member.get('name', 'Unknown')
|
| 518 |
+
focus = member.get('service_focus', [])
|
| 519 |
+
|
| 520 |
+
# Generate actions for this member
|
| 521 |
+
member_actions = generate_daily_actions(
|
| 522 |
+
colleague_name=name,
|
| 523 |
+
companies=top_companies,
|
| 524 |
+
max_actions=5
|
| 525 |
+
)
|
| 526 |
+
|
| 527 |
+
team_actions[name] = {
|
| 528 |
+
'actions': member_actions,
|
| 529 |
+
'focus': focus,
|
| 530 |
+
'action_count': len(member_actions),
|
| 531 |
+
'priority_1_count': len([a for a in member_actions if a.priority == 1]),
|
| 532 |
+
}
|
| 533 |
+
|
| 534 |
+
# Build signals from top companies for content calendar
|
| 535 |
+
signals = []
|
| 536 |
+
for company in top_companies[:10]:
|
| 537 |
+
for news in getattr(company, 'news', [])[:2]:
|
| 538 |
+
signals.append({
|
| 539 |
+
'trigger': news.get('trigger', 'general'),
|
| 540 |
+
'company': company.name,
|
| 541 |
+
'headline': news.get('headline', ''),
|
| 542 |
+
})
|
| 543 |
+
|
| 544 |
+
content_plan = generate_content_calendar(signals, weeks=1)
|
| 545 |
+
|
| 546 |
+
total_actions = sum(v['action_count'] for v in team_actions.values())
|
| 547 |
+
priority_1_total = sum(v['priority_1_count'] for v in team_actions.values())
|
| 548 |
+
|
| 549 |
+
return {
|
| 550 |
+
'team_actions': team_actions,
|
| 551 |
+
'content_plan': content_plan,
|
| 552 |
+
'summary': {
|
| 553 |
+
'total_actions': total_actions,
|
| 554 |
+
'priority_1_actions': priority_1_total,
|
| 555 |
+
'team_members': len(team),
|
| 556 |
+
'content_pieces': len(content_plan),
|
| 557 |
+
'generated_at': datetime.now().isoformat(),
|
| 558 |
+
}
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
# =============================================================================
|
| 563 |
+
# STATS
|
| 564 |
+
# =============================================================================
|
| 565 |
+
|
| 566 |
+
def get_action_stats(colleague_name: str = None) -> dict:
|
| 567 |
+
"""Get action completion stats."""
|
| 568 |
+
conn = get_connection()
|
| 569 |
+
cursor = conn.cursor()
|
| 570 |
+
|
| 571 |
+
where = "WHERE colleague = ?" if colleague_name else ""
|
| 572 |
+
params = (colleague_name,) if colleague_name else ()
|
| 573 |
+
|
| 574 |
+
cursor.execute(f"SELECT COUNT(*) FROM linkedin_actions {where}", params)
|
| 575 |
+
total = cursor.fetchone()[0]
|
| 576 |
+
|
| 577 |
+
where_done = f"{where} {'AND' if where else 'WHERE'} status = 'done'"
|
| 578 |
+
cursor.execute(f"SELECT COUNT(*) FROM linkedin_actions {where_done}", params)
|
| 579 |
+
done = cursor.fetchone()[0]
|
| 580 |
+
|
| 581 |
+
where_pending = f"{where} {'AND' if where else 'WHERE'} status = 'pending'"
|
| 582 |
+
cursor.execute(f"SELECT COUNT(*) FROM linkedin_actions {where_pending}", params)
|
| 583 |
+
pending = cursor.fetchone()[0]
|
| 584 |
+
|
| 585 |
+
where_skipped = f"{where} {'AND' if where else 'WHERE'} status = 'skipped'"
|
| 586 |
+
cursor.execute(f"SELECT COUNT(*) FROM linkedin_actions {where_skipped}", params)
|
| 587 |
+
skipped = cursor.fetchone()[0]
|
| 588 |
+
|
| 589 |
+
conn.close()
|
| 590 |
+
|
| 591 |
+
return {
|
| 592 |
+
'total': total,
|
| 593 |
+
'done': done,
|
| 594 |
+
'pending': pending,
|
| 595 |
+
'skipped': skipped,
|
| 596 |
+
'completion_rate': round(done / total * 100, 1) if total > 0 else 0,
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
|
| 600 |
+
# =============================================================================
|
| 601 |
+
# TEST HARNESS
|
| 602 |
+
# =============================================================================
|
| 603 |
+
|
| 604 |
+
if __name__ == "__main__":
|
| 605 |
+
print("Testing LinkedIn Activity Generator")
|
| 606 |
+
print("=" * 60)
|
| 607 |
+
|
| 608 |
+
# Test connection request
|
| 609 |
+
print("\nTest 1: Connection Request")
|
| 610 |
+
print("-" * 40)
|
| 611 |
+
msg = generate_connection_request(
|
| 612 |
+
contact_name="Sarah Thompson",
|
| 613 |
+
contact_company="Unilever",
|
| 614 |
+
contact_position="Head of OD",
|
| 615 |
+
context="Unilever restructuring their UK operations"
|
| 616 |
+
)
|
| 617 |
+
print(f"Message ({len(msg)} chars): {msg}")
|
| 618 |
+
|
| 619 |
+
# Test comment draft
|
| 620 |
+
print("\nTest 2: Comment Draft")
|
| 621 |
+
print("-" * 40)
|
| 622 |
+
comment = generate_comment_draft(
|
| 623 |
+
post_topic="Why transformation programmes fail",
|
| 624 |
+
curium_angle="Our experience delivering programmes and the people/culture gap",
|
| 625 |
+
service_line="Both"
|
| 626 |
+
)
|
| 627 |
+
print(f"Comment ({len(comment)} chars):\n{comment}")
|
| 628 |
+
|
| 629 |
+
# Test action stats
|
| 630 |
+
print("\nTest 3: Action Stats")
|
| 631 |
+
print("-" * 40)
|
| 632 |
+
stats = get_action_stats()
|
| 633 |
+
print(f"Stats: {stats}")
|
| 634 |
+
|
| 635 |
+
print("\nAll tests complete.")
|
linkedin_intel.py
CHANGED
|
@@ -34,9 +34,9 @@ PROFILE_DIR = os.path.expanduser("~/.curium-linkedin-profile")
|
|
| 34 |
DATABASE = "leads.db"
|
| 35 |
|
| 36 |
DAILY_LIMITS = {
|
| 37 |
-
"profile_views":
|
| 38 |
-
"company_views":
|
| 39 |
-
"searches":
|
| 40 |
}
|
| 41 |
|
| 42 |
# Delay settings (overridable from config)
|
|
@@ -1171,6 +1171,12 @@ def get_senior_target_contacts(limit: int = 30) -> list:
|
|
| 1171 |
'%head of talent%', '%director of talent%',
|
| 1172 |
'%head of change%', '%director of change%',
|
| 1173 |
'%chief culture%', '%chief transformation%',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1174 |
]
|
| 1175 |
|
| 1176 |
# Build a big OR query for all target roles
|
|
|
|
| 34 |
DATABASE = "leads.db"
|
| 35 |
|
| 36 |
DAILY_LIMITS = {
|
| 37 |
+
"profile_views": 200,
|
| 38 |
+
"company_views": 40,
|
| 39 |
+
"searches": 30,
|
| 40 |
}
|
| 41 |
|
| 42 |
# Delay settings (overridable from config)
|
|
|
|
| 1171 |
'%head of talent%', '%director of talent%',
|
| 1172 |
'%head of change%', '%director of change%',
|
| 1173 |
'%chief culture%', '%chief transformation%',
|
| 1174 |
+
'%programme director%', '%program director%',
|
| 1175 |
+
'%head of pmo%', '%pmo director%',
|
| 1176 |
+
'%chief operating%', '%coo %',
|
| 1177 |
+
'%head of strategy%', '%director of strategy%',
|
| 1178 |
+
'%head of digital%', '%director of digital%',
|
| 1179 |
+
'%head of wellbeing%', '%director of wellbeing%',
|
| 1180 |
]
|
| 1181 |
|
| 1182 |
# Build a big OR query for all target roles
|
linkedin_relationship.py
CHANGED
|
@@ -115,8 +115,13 @@ def _compute_score(rs: RelationshipStrength) -> tuple:
|
|
| 115 |
|
| 116 |
# ----- RECENCY MULTIPLIER -----
|
| 117 |
if rs.last_interaction_days < 0:
|
| 118 |
-
#
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
elif rs.last_interaction_days <= 30:
|
| 121 |
recency = 1.0
|
| 122 |
elif rs.last_interaction_days <= 90:
|
|
@@ -126,12 +131,6 @@ def _compute_score(rs: RelationshipStrength) -> tuple:
|
|
| 126 |
else:
|
| 127 |
recency = 0.3
|
| 128 |
|
| 129 |
-
# If we have no interaction data at all, use a neutral multiplier
|
| 130 |
-
if (rs.contact_liked_colleague == 0 and rs.contact_commented_colleague == 0
|
| 131 |
-
and rs.colleague_liked_contact == 0 and rs.colleague_commented_contact == 0
|
| 132 |
-
and rs.last_interaction_days < 0):
|
| 133 |
-
recency = 0.2
|
| 134 |
-
|
| 135 |
# ----- TENURE BONUS -----
|
| 136 |
tenure = 0
|
| 137 |
if rs.years_connected >= 5:
|
|
|
|
| 115 |
|
| 116 |
# ----- RECENCY MULTIPLIER -----
|
| 117 |
if rs.last_interaction_days < 0:
|
| 118 |
+
# No interaction data — use connection degree as proxy instead of penalising
|
| 119 |
+
if rs.connection_degree == 1:
|
| 120 |
+
recency = 0.7 # 1st degree = likely real relationship
|
| 121 |
+
elif rs.connection_degree == 2:
|
| 122 |
+
recency = 0.5 # 2nd degree = some connection
|
| 123 |
+
else:
|
| 124 |
+
recency = 0.3 # 3rd degree = weak link
|
| 125 |
elif rs.last_interaction_days <= 30:
|
| 126 |
recency = 1.0
|
| 127 |
elif rs.last_interaction_days <= 90:
|
|
|
|
| 131 |
else:
|
| 132 |
recency = 0.3
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
# ----- TENURE BONUS -----
|
| 135 |
tenure = 0
|
| 136 |
if rs.years_connected >= 5:
|
network_loader.py
CHANGED
|
@@ -682,6 +682,95 @@ def find_network_hit(
|
|
| 682 |
)
|
| 683 |
|
| 684 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 685 |
# =============================================================================
|
| 686 |
# MOVERS ALERT
|
| 687 |
# =============================================================================
|
|
|
|
| 682 |
)
|
| 683 |
|
| 684 |
|
| 685 |
+
# =============================================================================
|
| 686 |
+
# SERVICE-AFFINITY ROUTING
|
| 687 |
+
# =============================================================================
|
| 688 |
+
|
| 689 |
+
# Team member specialisations (loaded from config at runtime, with fallback)
|
| 690 |
+
_TEAM_SERVICE_FOCUS = None
|
| 691 |
+
|
| 692 |
+
def _get_team_service_focus() -> dict:
|
| 693 |
+
"""Load team member service focus from config.yaml (cached)."""
|
| 694 |
+
global _TEAM_SERVICE_FOCUS
|
| 695 |
+
if _TEAM_SERVICE_FOCUS is not None:
|
| 696 |
+
return _TEAM_SERVICE_FOCUS
|
| 697 |
+
|
| 698 |
+
try:
|
| 699 |
+
import yaml
|
| 700 |
+
with open('config.yaml', 'r') as f:
|
| 701 |
+
config = yaml.safe_load(f)
|
| 702 |
+
team = config.get('team', [])
|
| 703 |
+
_TEAM_SERVICE_FOCUS = {
|
| 704 |
+
m['name'].lower(): m.get('service_focus', [])
|
| 705 |
+
for m in team
|
| 706 |
+
}
|
| 707 |
+
except Exception:
|
| 708 |
+
_TEAM_SERVICE_FOCUS = {
|
| 709 |
+
'piers lyon': ['transformation_delivery', 'culture_capability'],
|
| 710 |
+
'adam': ['transformation_delivery'],
|
| 711 |
+
'stuart': ['culture_capability'],
|
| 712 |
+
}
|
| 713 |
+
return _TEAM_SERVICE_FOCUS
|
| 714 |
+
|
| 715 |
+
|
| 716 |
+
def find_network_hit_with_affinity(
|
| 717 |
+
company: str,
|
| 718 |
+
target_role: str = None,
|
| 719 |
+
dominant_service: str = None,
|
| 720 |
+
td_score: int = 0,
|
| 721 |
+
cc_score: int = 0,
|
| 722 |
+
min_company_score: int = 75,
|
| 723 |
+
min_role_score: int = 60,
|
| 724 |
+
) -> 'NetworkHit':
|
| 725 |
+
"""Enhanced network routing that considers colleague service specialisation.
|
| 726 |
+
|
| 727 |
+
When multiple colleagues have connections at the same company, prefer
|
| 728 |
+
the colleague whose service_focus matches the company's dominant need.
|
| 729 |
+
|
| 730 |
+
Args:
|
| 731 |
+
company: Target company name
|
| 732 |
+
target_role: Optional target role/position
|
| 733 |
+
dominant_service: 'transformation_delivery' or 'culture_capability' (explicit)
|
| 734 |
+
td_score: Company's TD score (used to infer dominant service if not explicit)
|
| 735 |
+
cc_score: Company's CC score (used to infer dominant service if not explicit)
|
| 736 |
+
"""
|
| 737 |
+
# Get base matches
|
| 738 |
+
hit = find_network_hit(company, target_role, min_company_score, min_role_score)
|
| 739 |
+
|
| 740 |
+
if not hit.has_connection or len(hit.matches) <= 1:
|
| 741 |
+
return hit # No routing decision needed
|
| 742 |
+
|
| 743 |
+
# Determine dominant service need
|
| 744 |
+
if not dominant_service:
|
| 745 |
+
if td_score > cc_score + 10:
|
| 746 |
+
dominant_service = 'transformation_delivery'
|
| 747 |
+
elif cc_score > td_score + 10:
|
| 748 |
+
dominant_service = 'culture_capability'
|
| 749 |
+
else:
|
| 750 |
+
return hit # Scores are close, no strong affinity preference
|
| 751 |
+
|
| 752 |
+
team_focus = _get_team_service_focus()
|
| 753 |
+
|
| 754 |
+
# Re-sort matches: prefer colleagues whose service_focus includes the dominant service
|
| 755 |
+
def affinity_sort_key(m: ConnectionMatch):
|
| 756 |
+
colleague_lower = (m.colleague or '').lower()
|
| 757 |
+
focus = team_focus.get(colleague_lower, [])
|
| 758 |
+
has_affinity = 1 if dominant_service in focus else 0
|
| 759 |
+
# Primary: tier (lower = better), Secondary: affinity (1 = better), Tertiary: match_score
|
| 760 |
+
return (m.tier.value, -has_affinity, -m.match_score, -m.role_match_score)
|
| 761 |
+
|
| 762 |
+
sorted_matches = sorted(hit.matches, key=affinity_sort_key)
|
| 763 |
+
|
| 764 |
+
return NetworkHit(
|
| 765 |
+
company=company,
|
| 766 |
+
target_role=target_role,
|
| 767 |
+
matches=sorted_matches,
|
| 768 |
+
best_match=sorted_matches[0],
|
| 769 |
+
tier=sorted_matches[0].tier,
|
| 770 |
+
total_connections=len(sorted_matches),
|
| 771 |
+
)
|
| 772 |
+
|
| 773 |
+
|
| 774 |
# =============================================================================
|
| 775 |
# MOVERS ALERT
|
| 776 |
# =============================================================================
|
pages/2_Approach_Brief.py
ADDED
|
@@ -0,0 +1,502 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Curium Lead Intelligence Platform - Approach Brief Page
|
| 3 |
+
Consolidated one-pager for approaching a company or contact.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import streamlit as st
|
| 7 |
+
from datetime import datetime
|
| 8 |
+
from html import escape
|
| 9 |
+
|
| 10 |
+
from collator import (
|
| 11 |
+
get_top_companies, get_company_dossier,
|
| 12 |
+
get_signal_completeness, calculate_confidence,
|
| 13 |
+
)
|
| 14 |
+
from ui_components import (
|
| 15 |
+
section_header, freshness_badge, render_service_badges, page_guide,
|
| 16 |
+
synthesize_why_now, recommend_pitch, get_best_route,
|
| 17 |
+
SERVICE_LABELS, TD_SERVICES, CC_SERVICES, SOURCE_LABELS,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def _format_date_ago(date_str):
|
| 22 |
+
"""Format a date string as 'Xd ago' or the date itself."""
|
| 23 |
+
if not date_str:
|
| 24 |
+
return ""
|
| 25 |
+
try:
|
| 26 |
+
dt = datetime.fromisoformat(date_str.replace('Z', '+00:00'))
|
| 27 |
+
if dt.tzinfo:
|
| 28 |
+
dt = dt.replace(tzinfo=None)
|
| 29 |
+
days = (datetime.now() - dt).days
|
| 30 |
+
if days == 0:
|
| 31 |
+
return "today"
|
| 32 |
+
elif days == 1:
|
| 33 |
+
return "1d ago"
|
| 34 |
+
else:
|
| 35 |
+
return f"{days}d ago"
|
| 36 |
+
except (ValueError, TypeError):
|
| 37 |
+
return date_str[:10] if date_str else ""
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def _build_why_now_signals(dossier):
|
| 41 |
+
"""Build structured WHY NOW signals list with source tags and dates."""
|
| 42 |
+
signals = []
|
| 43 |
+
|
| 44 |
+
# News signals
|
| 45 |
+
for news in (dossier.news or [])[:3]:
|
| 46 |
+
headline = news.get('headline', '')
|
| 47 |
+
source = news.get('source', '')
|
| 48 |
+
date = news.get('date', '')
|
| 49 |
+
age = _format_date_ago(date)
|
| 50 |
+
trigger = news.get('trigger', 'news')
|
| 51 |
+
if headline:
|
| 52 |
+
signals.append({
|
| 53 |
+
'tag': 'NEWS',
|
| 54 |
+
'color': '#1565c0',
|
| 55 |
+
'text': f'"{escape(headline[:80])}"',
|
| 56 |
+
'detail': f"{source}, {age}" if source else age,
|
| 57 |
+
'date': date,
|
| 58 |
+
})
|
| 59 |
+
|
| 60 |
+
# Job signals
|
| 61 |
+
for job in (dossier.jobs or [])[:3]:
|
| 62 |
+
title = job.get('title', '')
|
| 63 |
+
source = job.get('source', '')
|
| 64 |
+
date = job.get('date', '')
|
| 65 |
+
age = _format_date_ago(date)
|
| 66 |
+
score = job.get('score', 0)
|
| 67 |
+
if title:
|
| 68 |
+
signals.append({
|
| 69 |
+
'tag': 'JOBS',
|
| 70 |
+
'color': '#2e7d32',
|
| 71 |
+
'text': f'Hiring "{escape(title[:60])}" (score {score})',
|
| 72 |
+
'detail': f"{source}, {age}" if source else age,
|
| 73 |
+
'date': date,
|
| 74 |
+
})
|
| 75 |
+
|
| 76 |
+
# M&A signals
|
| 77 |
+
for deal in (dossier.pe_deals or [])[:2]:
|
| 78 |
+
acquirer = deal.get('acquirer_name', '')
|
| 79 |
+
deal_type = deal.get('deal_type', '')
|
| 80 |
+
is_pe = deal.get('is_pe_deal', 0) == 1
|
| 81 |
+
date = deal.get('date', '')
|
| 82 |
+
age = _format_date_ago(date)
|
| 83 |
+
label = "PE buyout" if is_pe else (deal_type or "acquisition")
|
| 84 |
+
if acquirer:
|
| 85 |
+
signals.append({
|
| 86 |
+
'tag': 'M&A',
|
| 87 |
+
'color': '#7b1fa2',
|
| 88 |
+
'text': f'{escape(label)} by {escape(acquirer[:40])}',
|
| 89 |
+
'detail': age,
|
| 90 |
+
'date': date,
|
| 91 |
+
})
|
| 92 |
+
|
| 93 |
+
# Sentiment signals
|
| 94 |
+
for sent in (dossier.sentiment_signals or [])[:1]:
|
| 95 |
+
overall = sent.get('overall_rating', 0)
|
| 96 |
+
mgmt = sent.get('management_rating', 0)
|
| 97 |
+
reviews = sent.get('review_count', 0)
|
| 98 |
+
date = sent.get('date', '')
|
| 99 |
+
age = _format_date_ago(date)
|
| 100 |
+
if overall:
|
| 101 |
+
mgmt_note = f" \u2014 mgmt rated {mgmt:.1f}" if mgmt else ""
|
| 102 |
+
signals.append({
|
| 103 |
+
'tag': 'SENTIMENT',
|
| 104 |
+
'color': '#e65100',
|
| 105 |
+
'text': f'Glassdoor {overall:.1f}/5 ({reviews} reviews){mgmt_note}',
|
| 106 |
+
'detail': age,
|
| 107 |
+
'date': date,
|
| 108 |
+
})
|
| 109 |
+
|
| 110 |
+
# Annual reports
|
| 111 |
+
for report in (dossier.annual_reports or [])[:1]:
|
| 112 |
+
score = report.get('score', 0)
|
| 113 |
+
date = report.get('date', '')
|
| 114 |
+
age = _format_date_ago(date)
|
| 115 |
+
if score >= 40:
|
| 116 |
+
signals.append({
|
| 117 |
+
'tag': 'REPORT',
|
| 118 |
+
'color': '#546e7a',
|
| 119 |
+
'text': f'Annual report flags restructuring signals (score {score})',
|
| 120 |
+
'detail': age,
|
| 121 |
+
'date': date,
|
| 122 |
+
})
|
| 123 |
+
|
| 124 |
+
# Sort by date (newest first)
|
| 125 |
+
signals.sort(key=lambda x: x.get('date', '') or '', reverse=True)
|
| 126 |
+
return signals
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def _build_route_section(dossier):
|
| 130 |
+
"""Build structured route information."""
|
| 131 |
+
routes = []
|
| 132 |
+
|
| 133 |
+
# CSV network route
|
| 134 |
+
if dossier.network_status and dossier.network_status != "Cold":
|
| 135 |
+
if dossier.best_colleague and dossier.best_contact:
|
| 136 |
+
routes.append({
|
| 137 |
+
'type': 'Best',
|
| 138 |
+
'text': f'Ask {dossier.best_colleague} to intro you to {dossier.best_contact}',
|
| 139 |
+
'source': 'Team network (CSV)',
|
| 140 |
+
})
|
| 141 |
+
# Look for backup routes from network
|
| 142 |
+
if len(dossier.network or []) > 1:
|
| 143 |
+
backup = dossier.network[1]
|
| 144 |
+
routes.append({
|
| 145 |
+
'type': 'Backup',
|
| 146 |
+
'text': f'{backup.get("colleague", "?")} connected to {backup.get("contact", "?")} ({backup.get("position", "")})',
|
| 147 |
+
'source': 'Team network',
|
| 148 |
+
})
|
| 149 |
+
|
| 150 |
+
# LinkedIn intel routes
|
| 151 |
+
li_intel = getattr(dossier, 'linkedin_intel', [])
|
| 152 |
+
for intel in li_intel[:3]:
|
| 153 |
+
colleague = intel.get('colleague_name', '?')
|
| 154 |
+
contact = intel.get('contact_name', '?')
|
| 155 |
+
title = intel.get('contact_title', '')
|
| 156 |
+
posting = intel.get('posts_about_transformation', 0)
|
| 157 |
+
active = intel.get('contact_active', 0)
|
| 158 |
+
|
| 159 |
+
suffix = ""
|
| 160 |
+
if posting:
|
| 161 |
+
suffix = " \u2014 posting about transformation"
|
| 162 |
+
elif active:
|
| 163 |
+
suffix = " \u2014 active on LinkedIn"
|
| 164 |
+
|
| 165 |
+
route_type = 'LinkedIn' if not routes else 'Alt'
|
| 166 |
+
routes.append({
|
| 167 |
+
'type': route_type,
|
| 168 |
+
'text': f'{colleague} \u2192 {contact} ({title[:30]}){suffix}',
|
| 169 |
+
'source': 'LinkedIn Intel',
|
| 170 |
+
})
|
| 171 |
+
|
| 172 |
+
if not routes:
|
| 173 |
+
routes.append({
|
| 174 |
+
'type': 'Cold',
|
| 175 |
+
'text': 'No warm route found \u2014 consider LinkedIn search or InMail',
|
| 176 |
+
'source': '',
|
| 177 |
+
})
|
| 178 |
+
|
| 179 |
+
return routes
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def _build_pitch_section(dossier):
|
| 183 |
+
"""Build structured pitch recommendations."""
|
| 184 |
+
td = getattr(dossier, 'td_score', 0) or 0
|
| 185 |
+
cc = getattr(dossier, 'cc_score', 0) or 0
|
| 186 |
+
services = getattr(dossier, 'recommended_services', []) or []
|
| 187 |
+
|
| 188 |
+
pitches = []
|
| 189 |
+
if td >= cc and td >= 20:
|
| 190 |
+
td_services = [SERVICE_LABELS.get(s, s) for s in services if s in TD_SERVICES]
|
| 191 |
+
pitches.append({
|
| 192 |
+
'type': 'Primary',
|
| 193 |
+
'text': ' + '.join(td_services[:3]) if td_services else 'Programme & Change Mgmt',
|
| 194 |
+
'score': f'TD: {td}/100',
|
| 195 |
+
})
|
| 196 |
+
if cc >= 20:
|
| 197 |
+
cc_services = [SERVICE_LABELS.get(s, s) for s in services if s in CC_SERVICES]
|
| 198 |
+
pitch_type = 'Primary' if cc > td else 'Secondary'
|
| 199 |
+
pitches.append({
|
| 200 |
+
'type': pitch_type,
|
| 201 |
+
'text': ' + '.join(cc_services[:3]) if cc_services else 'Culture diagnostics + Coaching',
|
| 202 |
+
'score': f'CC: {cc}/100',
|
| 203 |
+
})
|
| 204 |
+
if 'code_3i' in services:
|
| 205 |
+
pitches.append({
|
| 206 |
+
'type': 'CODE',
|
| 207 |
+
'text': 'CODE 3i diagnostic \u2014 maps culture in 10 mins per person',
|
| 208 |
+
'score': '',
|
| 209 |
+
})
|
| 210 |
+
|
| 211 |
+
if not pitches:
|
| 212 |
+
pitches.append({
|
| 213 |
+
'type': 'Explore',
|
| 214 |
+
'text': 'Initial conversation about their change agenda',
|
| 215 |
+
'score': '',
|
| 216 |
+
})
|
| 217 |
+
|
| 218 |
+
return pitches
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
def _build_talking_points(dossier):
|
| 222 |
+
"""Build evidence-based talking points (no generic lines)."""
|
| 223 |
+
signals = (getattr(dossier, 'signal_summary', '') or '').lower()
|
| 224 |
+
points = []
|
| 225 |
+
|
| 226 |
+
if 'restructuring' in signals or 'operating model' in signals:
|
| 227 |
+
points.append(
|
| 228 |
+
"\"I saw your restructuring announcement \u2014 we helped [similar co] "
|
| 229 |
+
"through the same and embedded senior PMs to keep delivery on track.\""
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
+
for sent in (dossier.sentiment_signals or [])[:1]:
|
| 233 |
+
overall = sent.get('overall_rating', 0)
|
| 234 |
+
if overall and overall < 3.5:
|
| 235 |
+
points.append(
|
| 236 |
+
"\"Your Glassdoor reviews flag culture alignment during change \u2014 "
|
| 237 |
+
"our CODE 3i maps that in 10 mins per person.\""
|
| 238 |
+
)
|
| 239 |
+
|
| 240 |
+
for deal in (dossier.pe_deals or [])[:1]:
|
| 241 |
+
acquirer = deal.get('acquirer_name', '')
|
| 242 |
+
if acquirer:
|
| 243 |
+
points.append(
|
| 244 |
+
f"\"With the {escape(acquirer[:30])} acquisition, integration support is critical \u2014 "
|
| 245 |
+
"we specialise in post-merger programme management.\""
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
if 'leadership' in signals or 'culture' in signals:
|
| 249 |
+
points.append(
|
| 250 |
+
"\"Leadership transitions are when culture gaps slow delivery most \u2014 "
|
| 251 |
+
"our diagnostic identifies exactly where to focus.\""
|
| 252 |
+
)
|
| 253 |
+
|
| 254 |
+
for job in (dossier.jobs or [])[:1]:
|
| 255 |
+
title = job.get('title', '')
|
| 256 |
+
if title:
|
| 257 |
+
points.append(
|
| 258 |
+
f"\"I noticed you're hiring for {escape(title[:40])} \u2014 we can augment "
|
| 259 |
+
"that with senior programme and change managers while you build internal capacity.\""
|
| 260 |
+
)
|
| 261 |
+
|
| 262 |
+
if 'news' in signals and not points:
|
| 263 |
+
for news in (dossier.news or [])[:1]:
|
| 264 |
+
headline = news.get('headline', '')
|
| 265 |
+
if headline:
|
| 266 |
+
points.append(
|
| 267 |
+
f"\"I saw \'{escape(headline[:50])}\' \u2014 we help organisations "
|
| 268 |
+
"going through exactly this kind of change.\""
|
| 269 |
+
)
|
| 270 |
+
|
| 271 |
+
if not points:
|
| 272 |
+
points.append(
|
| 273 |
+
"\"We help organisations going through change \u2014 combining programme "
|
| 274 |
+
"delivery with people and culture expertise for faster results.\""
|
| 275 |
+
)
|
| 276 |
+
|
| 277 |
+
return points[:3]
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
def _generate_plaintext_brief(dossier, confidence, signals, routes, pitches, talking_points, completeness):
|
| 281 |
+
"""Generate a clean plaintext version of the brief for copying."""
|
| 282 |
+
lines = []
|
| 283 |
+
lines.append(f"APPROACH BRIEF: {dossier.name}")
|
| 284 |
+
lines.append(f"Confidence: {completeness['checked']}/{completeness['total']} sources | Data quality: {confidence['level']}")
|
| 285 |
+
lines.append(f"Generated: {datetime.now().strftime('%d %b %Y')}")
|
| 286 |
+
lines.append("-" * 50)
|
| 287 |
+
lines.append("")
|
| 288 |
+
lines.append("WHY NOW (verified signals, newest first)")
|
| 289 |
+
for sig in signals:
|
| 290 |
+
lines.append(f" [{sig['tag']}] {sig['text']} - {sig['detail']}")
|
| 291 |
+
lines.append("")
|
| 292 |
+
lines.append("SIGNAL COVERAGE")
|
| 293 |
+
source_parts = []
|
| 294 |
+
for src_name, has_data in completeness['sources'].items():
|
| 295 |
+
label = SOURCE_LABELS.get(src_name, (src_name,))[0]
|
| 296 |
+
mark = "\u2713" if has_data else "\u2014"
|
| 297 |
+
source_parts.append(f"{label}: {mark}")
|
| 298 |
+
lines.append(" " + " | ".join(source_parts))
|
| 299 |
+
lines.append("")
|
| 300 |
+
lines.append("YOUR ROUTE IN")
|
| 301 |
+
for route in routes:
|
| 302 |
+
lines.append(f" {route['type']}: {route['text']}")
|
| 303 |
+
lines.append("")
|
| 304 |
+
lines.append("WHAT TO PITCH")
|
| 305 |
+
for pitch in pitches:
|
| 306 |
+
lines.append(f" {pitch['type']}: {pitch['text']} ({pitch['score']})")
|
| 307 |
+
lines.append("")
|
| 308 |
+
lines.append("TALKING POINTS (evidence-based)")
|
| 309 |
+
for i, point in enumerate(talking_points, 1):
|
| 310 |
+
lines.append(f" {i}. {point}")
|
| 311 |
+
lines.append("")
|
| 312 |
+
lines.append("CONFIDENCE ASSESSMENT")
|
| 313 |
+
lines.append(f" {confidence['explanation']}")
|
| 314 |
+
lines.append(f" Network confidence: {'HIGH (direct connection via colleague)' if confidence['details'].get('network', '').startswith('Warm') else 'LOW (no warm route)'}")
|
| 315 |
+
return "\n".join(lines)
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
def run():
|
| 319 |
+
section_header("Approach Brief", "Everything you need to know before approaching a company \u2014 one page, all facts")
|
| 320 |
+
|
| 321 |
+
page_guide([
|
| 322 |
+
"Select a company from the dropdown \u2014 or click a company name on the Dashboard to jump here.",
|
| 323 |
+
"Review <b>Why Now</b> signals to understand what's triggering the opportunity.",
|
| 324 |
+
"Check <b>Routes In</b> to find the warmest colleague introduction.",
|
| 325 |
+
"Use the <b>Confidence Score</b> to judge how solid the evidence is before reaching out.",
|
| 326 |
+
"Share the brief with colleagues as a one-page prep before calls or meetings.",
|
| 327 |
+
])
|
| 328 |
+
|
| 329 |
+
# Company selector
|
| 330 |
+
companies = get_top_companies(limit=100, min_score=0)
|
| 331 |
+
if not companies:
|
| 332 |
+
st.info("No companies tracked yet. Run HUNT NOW from the sidebar first.")
|
| 333 |
+
return
|
| 334 |
+
|
| 335 |
+
# Check for pre-selected company from dashboard
|
| 336 |
+
preselected_id = st.session_state.get('approach_brief_company_id')
|
| 337 |
+
preselected_idx = 0
|
| 338 |
+
company_options = {c.name: c.id for c in companies}
|
| 339 |
+
company_names = list(company_options.keys())
|
| 340 |
+
|
| 341 |
+
if preselected_id:
|
| 342 |
+
for i, c in enumerate(companies):
|
| 343 |
+
if c.id == preselected_id:
|
| 344 |
+
preselected_idx = i
|
| 345 |
+
break
|
| 346 |
+
# Clear after use
|
| 347 |
+
del st.session_state['approach_brief_company_id']
|
| 348 |
+
|
| 349 |
+
selected_name = st.selectbox(
|
| 350 |
+
"Select company to brief",
|
| 351 |
+
company_names,
|
| 352 |
+
index=preselected_idx,
|
| 353 |
+
key="approach_brief_company",
|
| 354 |
+
)
|
| 355 |
+
|
| 356 |
+
if not selected_name:
|
| 357 |
+
return
|
| 358 |
+
|
| 359 |
+
company_id = company_options[selected_name]
|
| 360 |
+
dossier = get_company_dossier(company_id)
|
| 361 |
+
if not dossier:
|
| 362 |
+
st.error("Company not found")
|
| 363 |
+
return
|
| 364 |
+
|
| 365 |
+
# Calculate all brief components
|
| 366 |
+
confidence = calculate_confidence(company_id)
|
| 367 |
+
completeness = get_signal_completeness(company_id)
|
| 368 |
+
signals = _build_why_now_signals(dossier)
|
| 369 |
+
routes = _build_route_section(dossier)
|
| 370 |
+
pitches = _build_pitch_section(dossier)
|
| 371 |
+
talking_points = _build_talking_points(dossier)
|
| 372 |
+
|
| 373 |
+
# Confidence level colour
|
| 374 |
+
conf_colors = {
|
| 375 |
+
'HIGH': '#2e7d32', 'MEDIUM-HIGH': '#1976d2',
|
| 376 |
+
'MEDIUM': '#f57c00', 'LOW': '#d32f2f'
|
| 377 |
+
}
|
| 378 |
+
conf_color = conf_colors.get(confidence['level'], '#9e9e9e')
|
| 379 |
+
|
| 380 |
+
# BRIEF HEADER
|
| 381 |
+
badges_html = render_service_badges(dossier)
|
| 382 |
+
st.markdown(
|
| 383 |
+
f'<div style="background:linear-gradient(135deg,#1a237e 0%,#283593 100%);padding:20px 24px;border-radius:10px;margin-bottom:16px;">'
|
| 384 |
+
f'<div style="color:white;font-size:1.4em;font-weight:800;">APPROACH BRIEF: {escape(dossier.name)}</div>'
|
| 385 |
+
f'<div style="color:#90caf9;margin-top:6px;">'
|
| 386 |
+
f'<span style="background:{conf_color};color:white;padding:3px 10px;border-radius:12px;font-size:0.8em;font-weight:700;">'
|
| 387 |
+
f'{confidence["level"]}</span> '
|
| 388 |
+
f'<span style="margin-left:8px;">{completeness["checked"]}/{completeness["total"]} sources checked</span> '
|
| 389 |
+
f'<span style="margin-left:8px;">Score: {dossier.overall_score}</span> '
|
| 390 |
+
f'<span style="margin-left:8px;">Generated: {datetime.now().strftime("%d %b %Y")}</span>'
|
| 391 |
+
f'</div>'
|
| 392 |
+
f'<div style="color:#90caf9;margin-top:4px;">{badges_html}</div>'
|
| 393 |
+
f'</div>',
|
| 394 |
+
unsafe_allow_html=True,
|
| 395 |
+
)
|
| 396 |
+
|
| 397 |
+
# WHY NOW section
|
| 398 |
+
st.markdown('<div class="brief-section"><div class="brief-section-title">WHY NOW (verified signals, newest first)</div>', unsafe_allow_html=True)
|
| 399 |
+
if signals:
|
| 400 |
+
for sig in signals:
|
| 401 |
+
sig_badge = freshness_badge(sig.get('date'))
|
| 402 |
+
st.markdown(
|
| 403 |
+
f'<div style="margin:4px 0;padding:4px 0;border-bottom:1px solid #eee;">'
|
| 404 |
+
f'<span style="background:{sig["color"]};color:white;padding:1px 6px;border-radius:6px;font-size:0.75em;font-weight:600;">{sig["tag"]}</span> '
|
| 405 |
+
f'{sig["text"]} '
|
| 406 |
+
f'<span style="color:#999;font-size:0.85em;">\u2014 {sig["detail"]}</span> '
|
| 407 |
+
f'{sig_badge}'
|
| 408 |
+
f'</div>',
|
| 409 |
+
unsafe_allow_html=True,
|
| 410 |
+
)
|
| 411 |
+
else:
|
| 412 |
+
st.caption("No verified signals found")
|
| 413 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 414 |
+
|
| 415 |
+
# Two-column layout for SIGNAL COVERAGE and YOUR ROUTE IN
|
| 416 |
+
col1, col2 = st.columns(2)
|
| 417 |
+
|
| 418 |
+
with col1:
|
| 419 |
+
st.markdown('<div class="brief-section"><div class="brief-section-title">SIGNAL COVERAGE</div>', unsafe_allow_html=True)
|
| 420 |
+
for src_name, has_data in completeness['sources'].items():
|
| 421 |
+
label = SOURCE_LABELS.get(src_name, (src_name,))[0]
|
| 422 |
+
icon = '\u2705' if has_data else '\u2014'
|
| 423 |
+
color = '#2e7d32' if has_data else '#bdbdbd'
|
| 424 |
+
st.markdown(
|
| 425 |
+
f'<span style="color:{color};font-size:0.9em;">{icon} {label}</span><br>',
|
| 426 |
+
unsafe_allow_html=True,
|
| 427 |
+
)
|
| 428 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 429 |
+
|
| 430 |
+
with col2:
|
| 431 |
+
st.markdown('<div class="brief-section"><div class="brief-section-title">YOUR ROUTE IN</div>', unsafe_allow_html=True)
|
| 432 |
+
for route in routes:
|
| 433 |
+
route_color = '#2e7d32' if route['type'] == 'Best' else '#1976d2' if route['type'] == 'LinkedIn' else '#f57c00' if route['type'] == 'Backup' else '#9e9e9e'
|
| 434 |
+
st.markdown(
|
| 435 |
+
f'<div style="margin:4px 0;">'
|
| 436 |
+
f'<span style="font-weight:700;color:{route_color};font-size:0.85em;">{route["type"]}:</span> '
|
| 437 |
+
f'{escape(route["text"])}'
|
| 438 |
+
f'</div>',
|
| 439 |
+
unsafe_allow_html=True,
|
| 440 |
+
)
|
| 441 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 442 |
+
|
| 443 |
+
# WHAT TO PITCH
|
| 444 |
+
st.markdown('<div class="brief-section"><div class="brief-section-title">WHAT TO PITCH</div>', unsafe_allow_html=True)
|
| 445 |
+
for pitch in pitches:
|
| 446 |
+
pitch_color = '#1976d2' if 'Primary' in pitch['type'] else '#2e7d32' if 'Secondary' in pitch['type'] else '#e65100'
|
| 447 |
+
st.markdown(
|
| 448 |
+
f'<div style="margin:4px 0;">'
|
| 449 |
+
f'<span style="font-weight:700;color:{pitch_color};font-size:0.85em;">{pitch["type"]}:</span> '
|
| 450 |
+
f'{escape(pitch["text"])} '
|
| 451 |
+
f'<span style="color:#999;font-size:0.85em;">{pitch["score"]}</span>'
|
| 452 |
+
f'</div>',
|
| 453 |
+
unsafe_allow_html=True,
|
| 454 |
+
)
|
| 455 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 456 |
+
|
| 457 |
+
# TALKING POINTS
|
| 458 |
+
st.markdown('<div class="brief-section"><div class="brief-section-title">TALKING POINTS (evidence-based, no generic lines)</div>', unsafe_allow_html=True)
|
| 459 |
+
for i, point in enumerate(talking_points, 1):
|
| 460 |
+
st.markdown(
|
| 461 |
+
f'<div style="background:#f5f5f5;padding:8px 12px;border-radius:6px;margin:6px 0;'
|
| 462 |
+
f'font-size:0.92em;color:#333;border-left:3px solid #1a237e;">'
|
| 463 |
+
f'{i}. {point}'
|
| 464 |
+
f'</div>',
|
| 465 |
+
unsafe_allow_html=True,
|
| 466 |
+
)
|
| 467 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 468 |
+
|
| 469 |
+
# CONFIDENCE ASSESSMENT
|
| 470 |
+
st.markdown(
|
| 471 |
+
f'<div class="brief-section">'
|
| 472 |
+
f'<div class="brief-section-title">CONFIDENCE ASSESSMENT</div>'
|
| 473 |
+
f'<div style="margin:4px 0;">'
|
| 474 |
+
f'<span style="background:{conf_color};color:white;padding:3px 10px;border-radius:12px;font-size:0.85em;font-weight:700;">'
|
| 475 |
+
f'{confidence["level"]} ({confidence["score"]}/100)</span>'
|
| 476 |
+
f'</div>'
|
| 477 |
+
f'<div style="font-size:0.9em;color:#546e7a;margin-top:6px;">{confidence["explanation"]}</div>'
|
| 478 |
+
f'</div>',
|
| 479 |
+
unsafe_allow_html=True,
|
| 480 |
+
)
|
| 481 |
+
|
| 482 |
+
# ACTION BUTTONS
|
| 483 |
+
st.divider()
|
| 484 |
+
btn_cols = st.columns([1, 1, 2])
|
| 485 |
+
|
| 486 |
+
with btn_cols[0]:
|
| 487 |
+
plaintext = _generate_plaintext_brief(dossier, confidence, signals, routes, pitches, talking_points, completeness)
|
| 488 |
+
if st.button("\U0001f4cb Copy as Text", key="copy_brief", use_container_width=True):
|
| 489 |
+
st.session_state['brief_plaintext'] = plaintext
|
| 490 |
+
|
| 491 |
+
with btn_cols[1]:
|
| 492 |
+
if st.button("\U0001f5a8\ufe0f Print Brief", key="print_brief", use_container_width=True):
|
| 493 |
+
st.markdown('<script>window.print()</script>', unsafe_allow_html=True)
|
| 494 |
+
|
| 495 |
+
if 'brief_plaintext' in st.session_state:
|
| 496 |
+
st.code(st.session_state['brief_plaintext'], language=None)
|
| 497 |
+
if st.button("\u274c Close", key="close_brief_text"):
|
| 498 |
+
del st.session_state['brief_plaintext']
|
| 499 |
+
st.rerun()
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
run()
|
pages/3_Tenders.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Curium Lead Intelligence Platform - Government Tenders Page
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import streamlit as st
|
| 6 |
+
from collator import get_top_companies
|
| 7 |
+
from ui_components import (
|
| 8 |
+
section_header, next_step_box, empty_state, format_value,
|
| 9 |
+
get_best_route, freshness_badge, page_guide,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def run():
|
| 14 |
+
section_header("Government Tenders", "UK public sector opportunities from Contracts Finder \u2014 sorted by urgency")
|
| 15 |
+
|
| 16 |
+
page_guide([
|
| 17 |
+
"Tenders are pulled automatically from Contracts Finder during each hunt.",
|
| 18 |
+
"Use <b>Urgent Only</b> to focus on deadlines within 14 days.",
|
| 19 |
+
"Filter by <b>Minimum Value</b> to skip small contracts.",
|
| 20 |
+
"Tenders marked <b>With Network</b> mean your team already has connections at the buyer \u2014 prioritise these.",
|
| 21 |
+
])
|
| 22 |
+
|
| 23 |
+
companies = get_top_companies(limit=50, min_score=0)
|
| 24 |
+
|
| 25 |
+
all_tenders = []
|
| 26 |
+
for company in companies:
|
| 27 |
+
if company.tenders:
|
| 28 |
+
for tender in company.tenders:
|
| 29 |
+
tender['buyer'] = company.name
|
| 30 |
+
tender['company_score'] = company.overall_score
|
| 31 |
+
tender['network_status'] = company.network_status
|
| 32 |
+
all_tenders.append(tender)
|
| 33 |
+
|
| 34 |
+
if not all_tenders:
|
| 35 |
+
empty_state("\U0001f3db\ufe0f", "No tenders found yet. Click HUNT NOW to search for government opportunities.")
|
| 36 |
+
return
|
| 37 |
+
|
| 38 |
+
tcol1, tcol2 = st.columns(2)
|
| 39 |
+
with tcol1:
|
| 40 |
+
show_urgent = st.checkbox("\U0001f534 Urgent Only (< 14 days)", value=False)
|
| 41 |
+
with tcol2:
|
| 42 |
+
min_value = st.selectbox("Minimum Value", ["Any", "\u00a3100K+", "\u00a3500K+", "\u00a31M+"])
|
| 43 |
+
|
| 44 |
+
filtered_tenders = all_tenders
|
| 45 |
+
if show_urgent:
|
| 46 |
+
filtered_tenders = [t for t in filtered_tenders if t.get('urgent')]
|
| 47 |
+
if min_value == "\u00a3100K+":
|
| 48 |
+
filtered_tenders = [t for t in filtered_tenders if (t.get('value') or 0) >= 100000]
|
| 49 |
+
elif min_value == "\u00a3500K+":
|
| 50 |
+
filtered_tenders = [t for t in filtered_tenders if (t.get('value') or 0) >= 500000]
|
| 51 |
+
elif min_value == "\u00a31M+":
|
| 52 |
+
filtered_tenders = [t for t in filtered_tenders if (t.get('value') or 0) >= 1000000]
|
| 53 |
+
|
| 54 |
+
filtered_tenders.sort(key=lambda x: (not x.get('urgent'), -(x.get('value') or 0)))
|
| 55 |
+
|
| 56 |
+
st.divider()
|
| 57 |
+
|
| 58 |
+
tcols = st.columns(4)
|
| 59 |
+
tcols[0].metric("Total Tenders", len(filtered_tenders))
|
| 60 |
+
urgent_count = len([t for t in filtered_tenders if t.get('urgent')])
|
| 61 |
+
tcols[1].metric("\U0001f534 Urgent", urgent_count)
|
| 62 |
+
total_value = sum(t.get('value') or 0 for t in filtered_tenders)
|
| 63 |
+
tcols[2].metric("Total Value", format_value(total_value))
|
| 64 |
+
with_network_t = len([t for t in filtered_tenders if t.get('network_status') and t.get('network_status') != "Cold"])
|
| 65 |
+
tcols[3].metric("\U0001f517 With Network", with_network_t)
|
| 66 |
+
|
| 67 |
+
urgent_tenders = [t for t in filtered_tenders if t.get('urgent')]
|
| 68 |
+
if urgent_tenders:
|
| 69 |
+
next_step_box(f"{len(urgent_tenders)} tender{'s' if len(urgent_tenders) != 1 else ''} closing within 14 days \u2014 review and decide which to bid on")
|
| 70 |
+
|
| 71 |
+
st.divider()
|
| 72 |
+
|
| 73 |
+
urgent_list = [t for t in filtered_tenders if t.get('urgent')]
|
| 74 |
+
upcoming_list = [t for t in filtered_tenders if not t.get('urgent')]
|
| 75 |
+
|
| 76 |
+
def _render_tender(tender):
|
| 77 |
+
urgent_emoji = "\U0001f534" if tender.get('urgent') else "\U0001f7e2"
|
| 78 |
+
value_str = format_value(tender.get('value'))
|
| 79 |
+
days = tender.get('days')
|
| 80 |
+
days_str = f"{days} days left" if days else "No deadline"
|
| 81 |
+
keywords = tender.get('keywords', '')
|
| 82 |
+
date_badge = freshness_badge(tender.get('date'))
|
| 83 |
+
|
| 84 |
+
buyer_company = next((c for c in companies if c.name == tender.get('buyer')), None)
|
| 85 |
+
route_text = ""
|
| 86 |
+
if buyer_company:
|
| 87 |
+
route = get_best_route(buyer_company)
|
| 88 |
+
if route['type'] != 'cold':
|
| 89 |
+
route_text = f"<div class='route-in'><strong>Your route:</strong> via {route.get('colleague', 'team contact')}</div>"
|
| 90 |
+
else:
|
| 91 |
+
route_text = "<div style='font-size:0.85em;color:#f57c00;margin:4px 0;'>No warm route \u2014 cold outreach needed</div>"
|
| 92 |
+
|
| 93 |
+
card_html = f"""
|
| 94 |
+
<div class="action-card urgency-{'red' if tender.get('urgent') else 'green'}">
|
| 95 |
+
<div class="action-card-header">
|
| 96 |
+
<span>{urgent_emoji} <strong>{value_str}</strong> \u00b7 {days_str} {date_badge}</span>
|
| 97 |
+
</div>
|
| 98 |
+
<div class="action-card-body">
|
| 99 |
+
<div class="company-name">{tender.get('title', 'Unknown')[:80]}</div>
|
| 100 |
+
<div style="font-size:0.88em;color:#546e7a;margin:4px 0;">
|
| 101 |
+
Buyer: <strong>{tender.get('buyer', 'Unknown')}</strong> | Why bid: {keywords}
|
| 102 |
+
</div>
|
| 103 |
+
{route_text}
|
| 104 |
+
</div>
|
| 105 |
+
</div>"""
|
| 106 |
+
st.markdown(card_html, unsafe_allow_html=True)
|
| 107 |
+
|
| 108 |
+
if tender.get('url'):
|
| 109 |
+
st.markdown(f"[View Tender \u2192]({tender['url']})")
|
| 110 |
+
|
| 111 |
+
if urgent_list:
|
| 112 |
+
st.markdown(
|
| 113 |
+
f'<div style="font-weight:700;color:#d32f2f;font-size:0.95em;margin:8px 0;">'
|
| 114 |
+
f'\U0001f534 URGENT \u2014 Closing Soon ({len(urgent_list)} tenders)</div>',
|
| 115 |
+
unsafe_allow_html=True,
|
| 116 |
+
)
|
| 117 |
+
for tender in urgent_list:
|
| 118 |
+
_render_tender(tender)
|
| 119 |
+
|
| 120 |
+
if upcoming_list:
|
| 121 |
+
st.markdown(
|
| 122 |
+
f'<div style="font-weight:700;color:#388e3c;font-size:0.95em;margin:12px 0 4px 0;">'
|
| 123 |
+
f'\U0001f7e2 UPCOMING ({len(upcoming_list)} tenders)</div>',
|
| 124 |
+
unsafe_allow_html=True,
|
| 125 |
+
)
|
| 126 |
+
for tender in upcoming_list:
|
| 127 |
+
_render_tender(tender)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
run()
|
pages/4_Councils.py
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
| 5 |
+
import streamlit as st
|
| 6 |
+
from urllib.parse import quote as url_quote
|
| 7 |
+
from collator import get_top_companies
|
| 8 |
+
from ui_components import (
|
| 9 |
+
section_header, next_step_box, empty_state, page_guide,
|
| 10 |
+
urgency_badge_html, urgency_for_score,
|
| 11 |
+
render_service_badges, render_dossier_tabs,
|
| 12 |
+
synthesize_why_now, build_evidence_snippets, evidence_html,
|
| 13 |
+
get_best_route, freshness_badge,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def run():
|
| 18 |
+
section_header("Council Opportunities", "UK councils with transformation, change, culture & L&D opportunities")
|
| 19 |
+
|
| 20 |
+
page_guide([
|
| 21 |
+
"Click <b>COUNCIL SCAN</b> in the sidebar to discover UK council opportunities.",
|
| 22 |
+
"Search by name or filter to <b>Connected Only</b> to find councils your team already knows.",
|
| 23 |
+
"Warm councils (you have connections) appear first \u2014 approach these before cold outreach.",
|
| 24 |
+
"Expand a council card to see signals, routes in, and evidence \u2014 same detail as the Dashboard.",
|
| 25 |
+
])
|
| 26 |
+
|
| 27 |
+
council_terms = ["council", "borough", "authority", "city of edinburgh", "combined authority"]
|
| 28 |
+
all_council_dossiers = get_top_companies(limit=500, min_score=0)
|
| 29 |
+
council_companies = [
|
| 30 |
+
c for c in all_council_dossiers
|
| 31 |
+
if any(term in c.name.lower() for term in council_terms)
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
if not council_companies:
|
| 35 |
+
empty_state("\U0001f3db\ufe0f", "No council data yet. Click COUNCIL SCAN in the sidebar to scan UK councils.")
|
| 36 |
+
return
|
| 37 |
+
|
| 38 |
+
cc1, cc2, cc3 = st.columns([3, 1, 1])
|
| 39 |
+
with cc1:
|
| 40 |
+
council_search = st.text_input("\U0001f50d Search councils", placeholder="Type council name...", key="council_search")
|
| 41 |
+
with cc2:
|
| 42 |
+
connected_only = st.checkbox("\U0001f517 Connected Only", key="council_connected")
|
| 43 |
+
with cc3:
|
| 44 |
+
signals_only = st.checkbox("\U0001f4ca With Signals Only", key="council_signals")
|
| 45 |
+
|
| 46 |
+
filtered_councils = council_companies
|
| 47 |
+
if council_search:
|
| 48 |
+
filtered_councils = [c for c in filtered_councils if council_search.lower() in c.name.lower()]
|
| 49 |
+
if connected_only:
|
| 50 |
+
filtered_councils = [c for c in filtered_councils if c.network_status and c.network_status != "Cold"]
|
| 51 |
+
if signals_only:
|
| 52 |
+
filtered_councils = [c for c in filtered_councils if c.overall_score > 0]
|
| 53 |
+
|
| 54 |
+
warm_councils = [c for c in filtered_councils if c.network_status and c.network_status != "Cold"]
|
| 55 |
+
cold_councils = [c for c in filtered_councils if not c.network_status or c.network_status == "Cold"]
|
| 56 |
+
warm_councils.sort(key=lambda x: x.overall_score, reverse=True)
|
| 57 |
+
cold_councils.sort(key=lambda x: x.overall_score, reverse=True)
|
| 58 |
+
|
| 59 |
+
stat_cols = st.columns(4)
|
| 60 |
+
stat_cols[0].metric("Councils Found", len(filtered_councils))
|
| 61 |
+
stat_cols[1].metric("\U0001f525 Hot", len([c for c in filtered_councils if c.overall_score >= 50]))
|
| 62 |
+
stat_cols[2].metric("\U0001f517 With Connections", len(warm_councils))
|
| 63 |
+
stat_cols[3].metric("\u26aa Cold Outreach", len(cold_councils))
|
| 64 |
+
|
| 65 |
+
if warm_councils:
|
| 66 |
+
next_step_box(f"You have connections at {len(warm_councils)} councils \u2014 reach out to these first")
|
| 67 |
+
|
| 68 |
+
st.divider()
|
| 69 |
+
|
| 70 |
+
# WARM OPPORTUNITIES
|
| 71 |
+
st.markdown(
|
| 72 |
+
'<div class="section-hdr">\U0001f517 Warm Opportunities</div>'
|
| 73 |
+
'<div class="section-sub">Councils where your team has connections \u2014 reach out first</div>',
|
| 74 |
+
unsafe_allow_html=True,
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
if warm_councils:
|
| 78 |
+
for council in warm_councils:
|
| 79 |
+
urgency = urgency_for_score(council.overall_score)
|
| 80 |
+
badge = urgency_badge_html(urgency)
|
| 81 |
+
badges_html = render_service_badges(council)
|
| 82 |
+
route = get_best_route(council)
|
| 83 |
+
why = synthesize_why_now(council) if council.overall_score > 0 else "No strong signals yet \u2014 monitor"
|
| 84 |
+
evidence = evidence_html(build_evidence_snippets(council))
|
| 85 |
+
|
| 86 |
+
card_html = f"""
|
| 87 |
+
<div class="action-card urgency-{urgency}">
|
| 88 |
+
<div class="action-card-header">
|
| 89 |
+
{badge} {badges_html}
|
| 90 |
+
<span style="font-size:0.9em;color:#333;">Score: {council.overall_score}</span>
|
| 91 |
+
</div>
|
| 92 |
+
<div class="action-card-body">
|
| 93 |
+
<div class="company-name">{council.name}</div>
|
| 94 |
+
<div class="why-now"><strong>WHY NOW:</strong> {why}</div>
|
| 95 |
+
{evidence}
|
| 96 |
+
<div class="route-in"><strong>YOUR ROUTE IN:</strong> {route['msg']}</div>
|
| 97 |
+
</div>
|
| 98 |
+
</div>"""
|
| 99 |
+
st.markdown(card_html, unsafe_allow_html=True)
|
| 100 |
+
|
| 101 |
+
with st.expander("\U0001f4cb View Full Dossier"):
|
| 102 |
+
render_dossier_tabs(council, "council_warm", show_network=True, show_action=True)
|
| 103 |
+
st.divider()
|
| 104 |
+
else:
|
| 105 |
+
st.caption("No councils with team connections found yet.")
|
| 106 |
+
|
| 107 |
+
st.markdown("---")
|
| 108 |
+
|
| 109 |
+
# COLD OUTREACH
|
| 110 |
+
st.markdown(
|
| 111 |
+
'<div class="section-hdr">\u26aa Cold Outreach Targets</div>'
|
| 112 |
+
'<div class="section-sub">Councils with signals but no connections \u2014 consider LinkedIn outreach</div>',
|
| 113 |
+
unsafe_allow_html=True,
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
cold_with_signals = [c for c in cold_councils if c.overall_score > 0]
|
| 117 |
+
cold_no_signals = [c for c in cold_councils if c.overall_score == 0]
|
| 118 |
+
|
| 119 |
+
if cold_with_signals:
|
| 120 |
+
for council in cold_with_signals:
|
| 121 |
+
urgency = urgency_for_score(council.overall_score)
|
| 122 |
+
badge = urgency_badge_html(urgency)
|
| 123 |
+
badges_html = render_service_badges(council)
|
| 124 |
+
why = synthesize_why_now(council)
|
| 125 |
+
evidence = evidence_html(build_evidence_snippets(council))
|
| 126 |
+
|
| 127 |
+
contact_info = ""
|
| 128 |
+
li_intel = getattr(council, 'linkedin_intel', [])
|
| 129 |
+
if li_intel:
|
| 130 |
+
best_li = li_intel[0]
|
| 131 |
+
contact_info = f"<div style='font-size:0.88em;color:#546e7a;margin:4px 0;'>\U0001f464 {best_li.get('contact_name', 'Unknown')} \u2014 {best_li.get('contact_title', '')[:30]}</div>"
|
| 132 |
+
elif council.jobs:
|
| 133 |
+
contact_info = f"<div style='font-size:0.88em;color:#546e7a;margin:4px 0;'>\U0001f4bc Hiring: {council.jobs[0].get('title', 'Unknown role')[:40]}</div>"
|
| 134 |
+
|
| 135 |
+
card_html = f"""
|
| 136 |
+
<div class="action-card urgency-{urgency}">
|
| 137 |
+
<div class="action-card-header">
|
| 138 |
+
{badge} {badges_html}
|
| 139 |
+
<span style="font-size:0.9em;color:#333;">Score: {council.overall_score}</span>
|
| 140 |
+
</div>
|
| 141 |
+
<div class="action-card-body">
|
| 142 |
+
<div class="company-name">{council.name}</div>
|
| 143 |
+
<div class="why-now"><strong>WHY NOW:</strong> {why}</div>
|
| 144 |
+
{evidence}
|
| 145 |
+
{contact_info}
|
| 146 |
+
</div>
|
| 147 |
+
</div>"""
|
| 148 |
+
st.markdown(card_html, unsafe_allow_html=True)
|
| 149 |
+
|
| 150 |
+
li_search = f"https://www.linkedin.com/search/results/people/?keywords={url_quote(council.name)}"
|
| 151 |
+
st.markdown(f"[\U0001f50d Search LinkedIn]({li_search})")
|
| 152 |
+
|
| 153 |
+
with st.expander("\U0001f4cb View Full Dossier"):
|
| 154 |
+
render_dossier_tabs(council, "council_cold", show_network=False, show_action=False)
|
| 155 |
+
st.divider()
|
| 156 |
+
else:
|
| 157 |
+
st.caption("No councils with signals but without connections.")
|
| 158 |
+
|
| 159 |
+
if cold_no_signals:
|
| 160 |
+
with st.expander(f"\U0001f4cb {len(cold_no_signals)} councils with no signals yet"):
|
| 161 |
+
for council in cold_no_signals:
|
| 162 |
+
st.caption(f"\u26aa {council.name}")
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
run()
|
pages/6_Intelligence.py
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Curium Lead Intelligence Platform - Intelligence Query Page
|
| 3 |
+
Proactive intelligence briefing + natural-language query engine.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import streamlit as st
|
| 7 |
+
from collator import get_top_companies
|
| 8 |
+
from query_engine import build_context_summary, run_query, generate_proactive_briefing
|
| 9 |
+
from ui_components import section_header, page_guide
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def run():
|
| 13 |
+
section_header("Intelligence Query", "Proactive intelligence briefing + natural-language query engine")
|
| 14 |
+
|
| 15 |
+
page_guide([
|
| 16 |
+
"The <b>Strategic Briefing</b> below is auto-generated from your data \u2014 review it for quick wins.",
|
| 17 |
+
"Click any insight (Sleeping Giants, Ready to Approach, Signal Storms) to expand the detail.",
|
| 18 |
+
"Use the <b>chat box</b> at the bottom to ask questions in plain English, e.g. \"Which companies have both job signals and news?\"",
|
| 19 |
+
"Re-visit after each hunt \u2014 the briefing updates automatically with fresh intelligence.",
|
| 20 |
+
])
|
| 21 |
+
|
| 22 |
+
if "query_messages" not in st.session_state:
|
| 23 |
+
st.session_state.query_messages = []
|
| 24 |
+
if "query_display" not in st.session_state:
|
| 25 |
+
st.session_state.query_display = []
|
| 26 |
+
if "query_context" not in st.session_state:
|
| 27 |
+
st.session_state.query_context = None
|
| 28 |
+
if "query_briefing" not in st.session_state:
|
| 29 |
+
st.session_state.query_briefing = None
|
| 30 |
+
if "query_prefill" not in st.session_state:
|
| 31 |
+
st.session_state.query_prefill = None
|
| 32 |
+
|
| 33 |
+
if st.session_state.query_context is None or st.session_state.query_briefing is None:
|
| 34 |
+
with st.spinner("Loading intelligence data and generating strategic briefing..."):
|
| 35 |
+
st.session_state.query_context = build_context_summary()
|
| 36 |
+
st.session_state.query_briefing = generate_proactive_briefing()
|
| 37 |
+
|
| 38 |
+
briefing = st.session_state.query_briefing
|
| 39 |
+
|
| 40 |
+
# PROACTIVE INTELLIGENCE BRIEFING
|
| 41 |
+
has_any_briefing = (
|
| 42 |
+
briefing.get('sleeping_giants') or briefing.get('ready_to_approach')
|
| 43 |
+
or briefing.get('signal_storms') or briefing.get('pe_plays')
|
| 44 |
+
or briefing.get('personal')
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
if has_any_briefing:
|
| 48 |
+
st.markdown(
|
| 49 |
+
'<div style="background:linear-gradient(135deg,#1a237e 0%,#283593 100%);padding:12px 18px;border-radius:8px;margin-bottom:12px;">'
|
| 50 |
+
'<span style="color:#fff;font-size:1.1em;font-weight:700;">Strategic Intelligence Briefing</span>'
|
| 51 |
+
'<span style="color:#90caf9;font-size:0.85em;margin-left:12px;">Auto-generated from your data \u2014 click any insight to explore</span>'
|
| 52 |
+
'</div>',
|
| 53 |
+
unsafe_allow_html=True,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# Personal LinkedIn Priorities
|
| 57 |
+
personal = briefing.get('personal', {})
|
| 58 |
+
if personal and personal.get('name'):
|
| 59 |
+
p = personal
|
| 60 |
+
gap = p.get('hot_companies_team_has', 0) - p.get('hot_companies_connected', 0)
|
| 61 |
+
with st.expander(f"\U0001f464 Your LinkedIn Priorities \u2014 {p['name']}", expanded=True):
|
| 62 |
+
st.markdown(
|
| 63 |
+
f"**Rank:** {p.get('rank', '?')}th of {p.get('total_team', '?')} | "
|
| 64 |
+
f"**{p.get('connections', 0):,}** connections | "
|
| 65 |
+
f"**{p.get('recent_connections', 0)}** new in 6 months | "
|
| 66 |
+
f"**{p.get('hot_companies_connected', 0)}** hot companies (vs {p.get('hot_companies_team_has', 0)} team total, gap: {gap})"
|
| 67 |
+
)
|
| 68 |
+
top_actions = p.get('top_actions_preview', [])
|
| 69 |
+
if top_actions:
|
| 70 |
+
st.markdown("**Top actions today:**")
|
| 71 |
+
action_icons = ['\U0001f91d', '\U0001f4ac', '\U0001f517']
|
| 72 |
+
for i, action_text in enumerate(top_actions):
|
| 73 |
+
icon = action_icons[i] if i < len(action_icons) else '\U0001f4cc'
|
| 74 |
+
st.markdown(f"{i+1}. {icon} {action_text}")
|
| 75 |
+
if st.button("Generate full action plan \u2192", key="personal_action_plan_btn", type="primary"):
|
| 76 |
+
st.session_state.query_prefill = f"Generate my personal LinkedIn action plan for {p['name']}"
|
| 77 |
+
|
| 78 |
+
briefing_cols = st.columns(2)
|
| 79 |
+
|
| 80 |
+
with briefing_cols[0]:
|
| 81 |
+
conviction = briefing.get('highest_conviction', [])
|
| 82 |
+
if conviction:
|
| 83 |
+
with st.expander(f"\U0001f525 Highest Conviction \u2014 {len(conviction)} multi-signal leads", expanded=True):
|
| 84 |
+
st.caption("3+ independent signals corroborate each opportunity \u2014 highest confidence")
|
| 85 |
+
for c_lead in conviction:
|
| 86 |
+
col_a, col_b = st.columns([4, 1])
|
| 87 |
+
with col_a:
|
| 88 |
+
st.markdown(
|
| 89 |
+
f"**{c_lead['company']}** (score: {c_lead['score']}, {c_lead['conviction']}/8 signals)"
|
| 90 |
+
f" \nEvidence: {', '.join(c_lead['signals'])}"
|
| 91 |
+
)
|
| 92 |
+
with col_b:
|
| 93 |
+
if st.button("Ask \u2192", key=f"top_conv_{c_lead['company']}", use_container_width=True):
|
| 94 |
+
st.session_state.query_prefill = f"Full conviction analysis on {c_lead['company']}: all evidence, routes in with evidence quality, and recommended approach"
|
| 95 |
+
|
| 96 |
+
with briefing_cols[1]:
|
| 97 |
+
ready = briefing.get('ready_to_approach', [])
|
| 98 |
+
if ready:
|
| 99 |
+
with st.expander(f"\U0001f3af Ready to Approach \u2014 {len(ready)} high-scoring leads with connections", expanded=True):
|
| 100 |
+
st.caption("Score 50+ with network connections \u2014 ranked by engagement evidence quality")
|
| 101 |
+
for r in ready:
|
| 102 |
+
col_a, col_b = st.columns([4, 1])
|
| 103 |
+
with col_a:
|
| 104 |
+
evidence = r.get('evidence', 'unverified')
|
| 105 |
+
st.markdown(
|
| 106 |
+
f"**{r['company']}** (score: {r['score']}, {r['network_status']})"
|
| 107 |
+
f" \nRoute: {r['best_contact']} via {r['best_colleague']} | {evidence}"
|
| 108 |
+
)
|
| 109 |
+
with col_b:
|
| 110 |
+
if st.button("Ask \u2192", key=f"ready_{r['company']}", use_container_width=True):
|
| 111 |
+
st.session_state.query_prefill = f"Find routes into {r['company']} with evidence quality \u2014 show me engagement data, signals, and recommended approach"
|
| 112 |
+
|
| 113 |
+
briefing_cols2 = st.columns(2)
|
| 114 |
+
|
| 115 |
+
with briefing_cols2[0]:
|
| 116 |
+
velocity = briefing.get('hiring_velocity', [])
|
| 117 |
+
if velocity:
|
| 118 |
+
with st.expander(f"\U0001f4bc Programmes in Flight \u2014 {len(velocity)} companies hiring heavily", expanded=True):
|
| 119 |
+
st.caption("3+ transformation roles = active programme, budget confirmed")
|
| 120 |
+
for v in velocity:
|
| 121 |
+
col_a, col_b = st.columns([4, 1])
|
| 122 |
+
with col_a:
|
| 123 |
+
st.markdown(
|
| 124 |
+
f"**{v['company']}** ({v['role_count']} roles, score: {v['score']}, {v['network']})"
|
| 125 |
+
f" \nRoles: {v['titles'][:100]}"
|
| 126 |
+
)
|
| 127 |
+
with col_b:
|
| 128 |
+
if st.button("Ask \u2192", key=f"vel_{v['company']}", use_container_width=True):
|
| 129 |
+
st.session_state.query_prefill = f"Competitor intelligence on {v['company']}: who's hiring, do we know the buyers, and how do we get in?"
|
| 130 |
+
|
| 131 |
+
with briefing_cols2[1]:
|
| 132 |
+
pe = briefing.get('pe_plays', [])
|
| 133 |
+
if pe:
|
| 134 |
+
with st.expander(f"\U0001f4b0 PE Integration Plays \u2014 {len(pe)} PE-backed with connections", expanded=False):
|
| 135 |
+
st.caption("Post-acquisition = Transformation Delivery goldmine")
|
| 136 |
+
for p in pe:
|
| 137 |
+
col_a, col_b = st.columns([4, 1])
|
| 138 |
+
with col_a:
|
| 139 |
+
st.markdown(
|
| 140 |
+
f"**{p['company']}** (score: {p['score']})"
|
| 141 |
+
f" \n{p['deal_type']} by {p['acquirer']} \u2014 route: {p['best_contact']} via {p['best_colleague']}"
|
| 142 |
+
)
|
| 143 |
+
with col_b:
|
| 144 |
+
if st.button("Ask \u2192", key=f"pe_{p['company']}", use_container_width=True):
|
| 145 |
+
st.session_state.query_prefill = f"PE integration play for {p['company']}: deal context, route in, and what TD services to pitch?"
|
| 146 |
+
|
| 147 |
+
briefing_cols3 = st.columns(2)
|
| 148 |
+
with briefing_cols3[0]:
|
| 149 |
+
giants = briefing.get('sleeping_giants', [])
|
| 150 |
+
if giants:
|
| 151 |
+
with st.expander(f"\U0001f48e Untapped Gold \u2014 {len(giants)} companies with active signals", expanded=False):
|
| 152 |
+
st.caption("Untracked companies showing recent activity")
|
| 153 |
+
for g in giants:
|
| 154 |
+
col_a, col_b = st.columns([4, 1])
|
| 155 |
+
with col_a:
|
| 156 |
+
signals_list = []
|
| 157 |
+
if g.get('recent'):
|
| 158 |
+
signals_list.append(f"{g['recent']} new connections (6mo)")
|
| 159 |
+
if g['seniors']:
|
| 160 |
+
signals_list.append(f"{g['seniors']} senior contacts")
|
| 161 |
+
st.markdown(f"**{g['company']}** \u2014 {' | '.join(signals_list)} \nTeam: {g['team']}")
|
| 162 |
+
with col_b:
|
| 163 |
+
if st.button("Ask \u2192", key=f"giant_{g['company']}", use_container_width=True):
|
| 164 |
+
st.session_state.query_prefill = f"Find all warm routes into {g['company']} and tell me if we should be tracking them"
|
| 165 |
+
|
| 166 |
+
st.divider()
|
| 167 |
+
|
| 168 |
+
# CHAT INTERFACE
|
| 169 |
+
st.markdown("**Try asking:**")
|
| 170 |
+
chip_cols = st.columns(5)
|
| 171 |
+
example_queries = [
|
| 172 |
+
"Which leads have the highest conviction \u2014 multiple independent signals?",
|
| 173 |
+
"Where are competitors active? Which companies are hiring for transformation?",
|
| 174 |
+
"Who has the best network into healthcare and what's the evidence quality?",
|
| 175 |
+
"PE-backed companies where we have verified engagement contacts",
|
| 176 |
+
"Strategic brief: where should the team focus this week and why?",
|
| 177 |
+
]
|
| 178 |
+
selected_example = None
|
| 179 |
+
for i, q in enumerate(example_queries):
|
| 180 |
+
with chip_cols[i]:
|
| 181 |
+
if st.button(q, key=f"example_q_{i}", use_container_width=True):
|
| 182 |
+
selected_example = q
|
| 183 |
+
|
| 184 |
+
st.divider()
|
| 185 |
+
|
| 186 |
+
for msg in st.session_state.query_display:
|
| 187 |
+
with st.chat_message(msg["role"]):
|
| 188 |
+
st.markdown(msg["text"])
|
| 189 |
+
|
| 190 |
+
if st.session_state.query_display:
|
| 191 |
+
if st.button("Clear conversation", key="clear_query"):
|
| 192 |
+
st.session_state.query_messages = []
|
| 193 |
+
st.session_state.query_display = []
|
| 194 |
+
st.rerun()
|
| 195 |
+
|
| 196 |
+
user_input = st.chat_input("Ask anything about your intelligence data...", key="query_chat_input")
|
| 197 |
+
|
| 198 |
+
if st.session_state.query_prefill:
|
| 199 |
+
user_input = st.session_state.query_prefill
|
| 200 |
+
st.session_state.query_prefill = None
|
| 201 |
+
|
| 202 |
+
if selected_example:
|
| 203 |
+
user_input = selected_example
|
| 204 |
+
|
| 205 |
+
if user_input:
|
| 206 |
+
st.session_state.query_display.append({"role": "user", "text": user_input})
|
| 207 |
+
with st.chat_message("user"):
|
| 208 |
+
st.markdown(user_input)
|
| 209 |
+
|
| 210 |
+
with st.chat_message("assistant"):
|
| 211 |
+
with st.spinner("Analysing your intelligence data..."):
|
| 212 |
+
try:
|
| 213 |
+
response_text, updated_history = run_query(
|
| 214 |
+
user_input,
|
| 215 |
+
st.session_state.query_messages,
|
| 216 |
+
st.session_state.query_context,
|
| 217 |
+
)
|
| 218 |
+
st.session_state.query_messages = updated_history
|
| 219 |
+
st.session_state.query_display.append({"role": "assistant", "text": response_text})
|
| 220 |
+
st.markdown(response_text)
|
| 221 |
+
except Exception as e:
|
| 222 |
+
error_msg = f"Query failed: {str(e)}"
|
| 223 |
+
st.session_state.query_display.append({"role": "assistant", "text": error_msg})
|
| 224 |
+
st.error(error_msg)
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
run()
|
pages/7_Source_Health.py
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Curium Lead Intelligence Platform - Source Health Dashboard
|
| 3 |
+
Shows status of all 9 data sources with traffic-light indicators.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import streamlit as st
|
| 7 |
+
from datetime import datetime
|
| 8 |
+
from collator import get_all_source_health, get_company_stats
|
| 9 |
+
from ui_components import section_header, SOURCE_LABELS, freshness_badge, page_guide
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def run():
|
| 13 |
+
section_header("Source Health Dashboard", "Monitor all 8 data sources \u2014 fix issues before they compromise your intelligence")
|
| 14 |
+
|
| 15 |
+
page_guide([
|
| 16 |
+
"Green = healthy, Red = error, Grey = never scanned. Aim for all green.",
|
| 17 |
+
"Fix <b>Missing API Keys</b> first \u2014 each card shows exactly what to set and where.",
|
| 18 |
+
"If a source shows errors, read the error message and follow the setup instructions on the card.",
|
| 19 |
+
"Run <b>HUNT NOW</b> from the sidebar after fixing issues to re-scan all sources.",
|
| 20 |
+
])
|
| 21 |
+
|
| 22 |
+
source_health = get_all_source_health()
|
| 23 |
+
stats = get_company_stats()
|
| 24 |
+
|
| 25 |
+
# Summary KPIs
|
| 26 |
+
healthy = sum(1 for s in source_health if s['status'] == 'success')
|
| 27 |
+
errors = sum(1 for s in source_health if s['status'] == 'error')
|
| 28 |
+
never_run = sum(1 for s in source_health if s['status'] == 'never_run')
|
| 29 |
+
missing_keys = sum(1 for s in source_health if not s.get('api_key_set'))
|
| 30 |
+
|
| 31 |
+
kpi_cols = st.columns(4)
|
| 32 |
+
with kpi_cols[0]:
|
| 33 |
+
st.metric("\u2705 Healthy Sources", f"{healthy}/8")
|
| 34 |
+
with kpi_cols[1]:
|
| 35 |
+
st.metric("\u274c Errors", errors)
|
| 36 |
+
with kpi_cols[2]:
|
| 37 |
+
st.metric("\u26aa Never Scanned", never_run)
|
| 38 |
+
with kpi_cols[3]:
|
| 39 |
+
st.metric("\U0001f511 Missing API Keys", missing_keys)
|
| 40 |
+
|
| 41 |
+
if errors > 0 or missing_keys > 0:
|
| 42 |
+
st.markdown(
|
| 43 |
+
f'<div style="background:#ffebee;border-left:4px solid #d32f2f;padding:10px 14px;'
|
| 44 |
+
f'border-radius:4px;margin:10px 0;font-size:0.95em;">'
|
| 45 |
+
f'<strong>Action needed:</strong> {errors} source(s) with errors, '
|
| 46 |
+
f'{missing_keys} missing API key(s). Fix these to get complete intelligence.</div>',
|
| 47 |
+
unsafe_allow_html=True,
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
if never_run >= 5:
|
| 51 |
+
st.info("Run HUNT NOW from the sidebar to scan all sources for the first time.")
|
| 52 |
+
|
| 53 |
+
st.divider()
|
| 54 |
+
|
| 55 |
+
# Source detail cards
|
| 56 |
+
for src in source_health:
|
| 57 |
+
name = src['source_name']
|
| 58 |
+
label, emoji = SOURCE_LABELS.get(name, (name, '\U0001f50d'))
|
| 59 |
+
status = src['status']
|
| 60 |
+
last_scan = src.get('last_scan_at')
|
| 61 |
+
error = src.get('last_error')
|
| 62 |
+
records_found = src.get('records_found', 0)
|
| 63 |
+
total_records = src.get('total_records', 0)
|
| 64 |
+
api_key_set = src.get('api_key_set', 1)
|
| 65 |
+
api_key_name = src.get('api_key_name')
|
| 66 |
+
instructions = src.get('setup_instructions', '')
|
| 67 |
+
|
| 68 |
+
# Status indicator
|
| 69 |
+
if status == 'success':
|
| 70 |
+
status_color = '#2e7d32'
|
| 71 |
+
status_icon = '\u2705'
|
| 72 |
+
status_label = 'HEALTHY'
|
| 73 |
+
border_color = '#2e7d32'
|
| 74 |
+
elif status == 'error':
|
| 75 |
+
status_color = '#d32f2f'
|
| 76 |
+
status_icon = '\u274c'
|
| 77 |
+
status_label = 'ERROR'
|
| 78 |
+
border_color = '#d32f2f'
|
| 79 |
+
elif status == 'disabled':
|
| 80 |
+
status_color = '#f57c00'
|
| 81 |
+
status_icon = '\u23f8\ufe0f'
|
| 82 |
+
status_label = 'DISABLED'
|
| 83 |
+
border_color = '#f57c00'
|
| 84 |
+
else:
|
| 85 |
+
status_color = '#9e9e9e'
|
| 86 |
+
status_icon = '\u26aa'
|
| 87 |
+
status_label = 'NEVER RUN'
|
| 88 |
+
border_color = '#bdbdbd'
|
| 89 |
+
|
| 90 |
+
# Last scan freshness
|
| 91 |
+
scan_badge = freshness_badge(last_scan) if last_scan else '<span class="freshness-grey">Never scanned</span>'
|
| 92 |
+
|
| 93 |
+
# API key status
|
| 94 |
+
key_html = ""
|
| 95 |
+
if api_key_name:
|
| 96 |
+
if api_key_set:
|
| 97 |
+
key_html = f'<span style="color:#2e7d32;font-size:0.85em;">\U0001f511 {api_key_name}: Set</span>'
|
| 98 |
+
else:
|
| 99 |
+
key_html = f'<span style="color:#d32f2f;font-size:0.85em;">\U0001f511 {api_key_name}: <strong>MISSING</strong></span>'
|
| 100 |
+
|
| 101 |
+
# Record counts
|
| 102 |
+
db_count = 0
|
| 103 |
+
count_table = {
|
| 104 |
+
'jobs': 'total_jobs',
|
| 105 |
+
'news': 'total_news',
|
| 106 |
+
'tenders': 'total_tenders',
|
| 107 |
+
'annual_reports': 'total_reports',
|
| 108 |
+
|
| 109 |
+
'sentiment': 'total_sentiment',
|
| 110 |
+
'pe_deals': 'total_pe_deals',
|
| 111 |
+
'linkedin_intel': 'total_linkedin_intel',
|
| 112 |
+
}.get(name)
|
| 113 |
+
if count_table:
|
| 114 |
+
db_count = stats.get(count_table, 0)
|
| 115 |
+
|
| 116 |
+
card_html = f"""
|
| 117 |
+
<div style="border-left:5px solid {border_color};padding:12px 16px;margin:8px 0;background:#fafafa;border-radius:6px;">
|
| 118 |
+
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;">
|
| 119 |
+
<div>
|
| 120 |
+
<span style="font-size:1.1em;font-weight:700;">{emoji} {label}</span>
|
| 121 |
+
<span style="background:{status_color};color:white;padding:2px 8px;border-radius:10px;font-size:0.75em;font-weight:600;margin-left:8px;">{status_label}</span>
|
| 122 |
+
</div>
|
| 123 |
+
<div style="font-size:0.85em;color:#666;">
|
| 124 |
+
Last scan: {scan_badge} | Records in DB: <strong>{db_count}</strong> | Last run found: {records_found}
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
<div style="font-size:0.85em;color:#546e7a;margin:4px 0;">
|
| 128 |
+
{key_html}
|
| 129 |
+
</div>"""
|
| 130 |
+
|
| 131 |
+
if status == 'error' and error:
|
| 132 |
+
card_html += f"""
|
| 133 |
+
<div style="background:#ffebee;border-left:3px solid #d32f2f;padding:6px 10px;margin:6px 0;border-radius:3px;font-size:0.85em;color:#c62828;">
|
| 134 |
+
<strong>Error:</strong> {error}
|
| 135 |
+
</div>"""
|
| 136 |
+
|
| 137 |
+
if not api_key_set or status == 'never_run' or status == 'error':
|
| 138 |
+
card_html += f"""
|
| 139 |
+
<div style="background:#e3f2fd;border-left:3px solid #1565c0;padding:6px 10px;margin:6px 0;border-radius:3px;font-size:0.85em;">
|
| 140 |
+
<strong>Setup:</strong> {instructions}
|
| 141 |
+
</div>"""
|
| 142 |
+
|
| 143 |
+
card_html += "</div>"
|
| 144 |
+
st.markdown(card_html, unsafe_allow_html=True)
|
| 145 |
+
|
| 146 |
+
st.divider()
|
| 147 |
+
|
| 148 |
+
# Data coverage summary
|
| 149 |
+
st.markdown("### Data Coverage Summary")
|
| 150 |
+
coverage_cols = st.columns(3)
|
| 151 |
+
with coverage_cols[0]:
|
| 152 |
+
st.markdown("**Signal Counts**")
|
| 153 |
+
st.caption(f"\U0001f4bc Jobs: {stats.get('total_jobs', 0)}")
|
| 154 |
+
st.caption(f"\U0001f4f0 News: {stats.get('total_news', 0)}")
|
| 155 |
+
st.caption(f"\U0001f3db\ufe0f Tenders: {stats.get('total_tenders', 0)}")
|
| 156 |
+
with coverage_cols[1]:
|
| 157 |
+
st.caption(f"\U0001f4c4 Reports: {stats.get('total_reports', 0)}")
|
| 158 |
+
|
| 159 |
+
st.caption(f"\U0001f610 Sentiment: {stats.get('total_sentiment', 0)}")
|
| 160 |
+
with coverage_cols[2]:
|
| 161 |
+
st.caption(f"\U0001f91d M&A: {stats.get('total_pe_deals', 0)}")
|
| 162 |
+
st.caption(f"\U0001f50d LinkedIn Intel: {stats.get('total_linkedin_intel', 0)}")
|
| 163 |
+
st.caption(f"\U0001f3e2 Companies: {stats.get('total_companies', 0)}")
|
| 164 |
+
|
| 165 |
+
# Recommendations
|
| 166 |
+
issues = []
|
| 167 |
+
for src in source_health:
|
| 168 |
+
if not src.get('api_key_set') and src.get('api_key_name'):
|
| 169 |
+
issues.append(f"Set **{src['api_key_name']}** in `.env` to enable {SOURCE_LABELS.get(src['source_name'], (src['source_name'],))[0]}")
|
| 170 |
+
elif src['status'] == 'error':
|
| 171 |
+
issues.append(f"Fix **{SOURCE_LABELS.get(src['source_name'], (src['source_name'],))[0]}** \u2014 {src.get('last_error', 'unknown error')[:60]}")
|
| 172 |
+
elif src['status'] == 'never_run':
|
| 173 |
+
issues.append(f"Run HUNT NOW to scan **{SOURCE_LABELS.get(src['source_name'], (src['source_name'],))[0]}** for the first time")
|
| 174 |
+
|
| 175 |
+
if issues:
|
| 176 |
+
st.markdown("### Recommended Actions")
|
| 177 |
+
for i, issue in enumerate(issues, 1):
|
| 178 |
+
st.markdown(f"{i}. {issue}")
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
run()
|
query_engine.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
CHANGED
|
@@ -9,3 +9,4 @@ python-dotenv
|
|
| 9 |
rapidfuzz
|
| 10 |
pdfplumber
|
| 11 |
beautifulsoup4
|
|
|
|
|
|
| 9 |
rapidfuzz
|
| 10 |
pdfplumber
|
| 11 |
beautifulsoup4
|
| 12 |
+
feedparser
|
ui_components.py
ADDED
|
@@ -0,0 +1,1157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Curium Lead Intelligence Platform - Shared UI Components
|
| 3 |
+
Extracted from app.py: design constants, CSS, badge renderers, card helpers.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import streamlit as st
|
| 7 |
+
import json as _json
|
| 8 |
+
from datetime import datetime, timedelta
|
| 9 |
+
from html import escape
|
| 10 |
+
from urllib.parse import quote as url_quote
|
| 11 |
+
|
| 12 |
+
# =============================================================================
|
| 13 |
+
# SERVICE LINE LABELS & SETS
|
| 14 |
+
# =============================================================================
|
| 15 |
+
|
| 16 |
+
SERVICE_LABELS = {
|
| 17 |
+
'project_programme_management': 'Programme Mgmt',
|
| 18 |
+
'change_management': 'Change Mgmt',
|
| 19 |
+
'business_analysis': 'Business Analysis',
|
| 20 |
+
'tmo_pmo': 'TMO/PMO',
|
| 21 |
+
'operating_models': 'Operating Models',
|
| 22 |
+
'agile_lean': 'Agile & Lean',
|
| 23 |
+
'ma_integration': 'M&A Integration',
|
| 24 |
+
'service_desk': 'Service Desk',
|
| 25 |
+
'executive_coaching': 'Executive Coaching',
|
| 26 |
+
'leadership_strategy': 'Leadership Strategy',
|
| 27 |
+
'culture_diagnostics': 'Culture Diagnostics',
|
| 28 |
+
'team_profiling': 'Team Profiling',
|
| 29 |
+
'facilitation': 'Facilitation',
|
| 30 |
+
'resilience': 'Resilience',
|
| 31 |
+
'one_to_one_coaching': '1-to-1 Coaching',
|
| 32 |
+
'dysfunctional_teams': 'Team Intervention',
|
| 33 |
+
'mindset_behaviour': 'Mindset & Behaviour',
|
| 34 |
+
'code_3i': 'CODE 3i',
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
TD_SERVICES = {'project_programme_management', 'change_management', 'business_analysis',
|
| 38 |
+
'tmo_pmo', 'operating_models', 'agile_lean', 'ma_integration', 'service_desk'}
|
| 39 |
+
CC_SERVICES = {'executive_coaching', 'leadership_strategy', 'culture_diagnostics',
|
| 40 |
+
'team_profiling', 'facilitation', 'resilience', 'one_to_one_coaching',
|
| 41 |
+
'dysfunctional_teams', 'mindset_behaviour', 'code_3i'}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
# =============================================================================
|
| 45 |
+
# DESIGN SYSTEM — CONSTANTS
|
| 46 |
+
# =============================================================================
|
| 47 |
+
|
| 48 |
+
COLORS = {
|
| 49 |
+
'primary': '#1a237e',
|
| 50 |
+
'td': '#1976d2',
|
| 51 |
+
'cc': '#2e7d32',
|
| 52 |
+
'code': '#e65100',
|
| 53 |
+
'urgent_red': '#d32f2f',
|
| 54 |
+
'warm_amber': '#f57c00',
|
| 55 |
+
'monitor_green': '#388e3c',
|
| 56 |
+
'neutral': '#546e7a',
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
URGENCY_CONFIG = {
|
| 60 |
+
'red': {'color': '#d32f2f', 'bg': '#ffebee', 'label': 'ACT TODAY', 'border': '#d32f2f'},
|
| 61 |
+
'amber': {'color': '#e65100', 'bg': '#fff3e0', 'label': 'THIS WEEK', 'border': '#f57c00'},
|
| 62 |
+
'green': {'color': '#2e7d32', 'bg': '#e8f5e9', 'label': 'MONITOR', 'border': '#388e3c'},
|
| 63 |
+
'blue': {'color': '#1565c0', 'bg': '#e3f2fd', 'label': 'INFO', 'border': '#1976d2'},
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
SOURCE_LABELS = {
|
| 67 |
+
'jobs': ('Jobs', '\U0001f4bc'),
|
| 68 |
+
'news': ('News', '\U0001f4f0'),
|
| 69 |
+
'tenders': ('Tenders', '\U0001f3db\ufe0f'),
|
| 70 |
+
'annual_reports': ('Reports', '\U0001f4c4'),
|
| 71 |
+
'sentiment': ('Sentiment', '\U0001f610'),
|
| 72 |
+
'pe_deals': ('M&A', '\U0001f91d'),
|
| 73 |
+
'linkedin_groups': ('LI Groups', '\U0001f517'),
|
| 74 |
+
'linkedin_intel': ('LI Intel', '\U0001f50d'),
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
# =============================================================================
|
| 79 |
+
# GLOBAL CSS
|
| 80 |
+
# =============================================================================
|
| 81 |
+
|
| 82 |
+
def inject_global_css():
|
| 83 |
+
"""Inject the design system CSS into the page."""
|
| 84 |
+
st.markdown("""
|
| 85 |
+
<style>
|
| 86 |
+
/* ---- Brand Palette ---- */
|
| 87 |
+
:root {
|
| 88 |
+
--curium-primary: #1a237e;
|
| 89 |
+
--curium-td: #1976d2;
|
| 90 |
+
--curium-cc: #2e7d32;
|
| 91 |
+
--curium-code: #e65100;
|
| 92 |
+
--urgent-red: #d32f2f;
|
| 93 |
+
--warm-amber: #f57c00;
|
| 94 |
+
--monitor-green: #388e3c;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/* ---- Action Card ---- */
|
| 98 |
+
.action-card {
|
| 99 |
+
border-radius: 8px;
|
| 100 |
+
padding: 16px 18px;
|
| 101 |
+
margin: 8px 0;
|
| 102 |
+
background: #fafafa;
|
| 103 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.08);
|
| 104 |
+
transition: box-shadow 0.2s;
|
| 105 |
+
}
|
| 106 |
+
.action-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.13); }
|
| 107 |
+
.action-card.urgency-red { border-left: 5px solid var(--urgent-red); }
|
| 108 |
+
.action-card.urgency-amber { border-left: 5px solid var(--warm-amber); }
|
| 109 |
+
.action-card.urgency-green { border-left: 5px solid var(--monitor-green); }
|
| 110 |
+
.action-card.urgency-blue { border-left: 5px solid var(--curium-td); }
|
| 111 |
+
|
| 112 |
+
.action-card-header {
|
| 113 |
+
display: flex;
|
| 114 |
+
justify-content: space-between;
|
| 115 |
+
align-items: center;
|
| 116 |
+
margin-bottom: 6px;
|
| 117 |
+
}
|
| 118 |
+
.action-card-body { margin: 6px 0; }
|
| 119 |
+
.action-card-body .company-name {
|
| 120 |
+
font-size: 1.1em; font-weight: 700; color: #212121;
|
| 121 |
+
}
|
| 122 |
+
.action-card-body .why-now {
|
| 123 |
+
font-size: 0.9em; color: #546e7a; margin-top: 4px;
|
| 124 |
+
}
|
| 125 |
+
.action-card-body .route-in {
|
| 126 |
+
background: #e3f2fd; border-left: 3px solid #1565c0;
|
| 127 |
+
padding: 6px 10px; margin: 6px 0; border-radius: 3px; font-size: 0.9em;
|
| 128 |
+
}
|
| 129 |
+
.action-card-body .pitch {
|
| 130 |
+
background: #f3e5f5; border-left: 3px solid #7b1fa2;
|
| 131 |
+
padding: 6px 10px; margin: 6px 0; border-radius: 3px; font-size: 0.9em;
|
| 132 |
+
}
|
| 133 |
+
.evidence {
|
| 134 |
+
background: #e8f5e9; border-left: 3px solid #2e7d32;
|
| 135 |
+
padding: 6px 10px; margin: 6px 0; border-radius: 3px;
|
| 136 |
+
font-size: 0.85em; color: #1b5e20;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/* ---- Urgency Badges ---- */
|
| 140 |
+
.badge-red {
|
| 141 |
+
background: #d32f2f; color: white; padding: 3px 10px;
|
| 142 |
+
border-radius: 12px; font-size: 0.75em; font-weight: 700; letter-spacing: 0.5px;
|
| 143 |
+
}
|
| 144 |
+
.badge-amber {
|
| 145 |
+
background: #f57c00; color: white; padding: 3px 10px;
|
| 146 |
+
border-radius: 12px; font-size: 0.75em; font-weight: 700; letter-spacing: 0.5px;
|
| 147 |
+
}
|
| 148 |
+
.badge-green {
|
| 149 |
+
background: #388e3c; color: white; padding: 3px 10px;
|
| 150 |
+
border-radius: 12px; font-size: 0.75em; font-weight: 700; letter-spacing: 0.5px;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/* ---- Next Step Banner ---- */
|
| 154 |
+
.next-step-banner {
|
| 155 |
+
background: #e3f2fd; border-left: 4px solid #1565c0;
|
| 156 |
+
padding: 10px 14px; margin: 10px 0; border-radius: 4px; font-size: 0.95em;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/* ---- KPI Card ---- */
|
| 160 |
+
.kpi-card {
|
| 161 |
+
text-align: center; padding: 12px 8px;
|
| 162 |
+
background: #fafafa; border-radius: 8px; border: 1px solid #e0e0e0;
|
| 163 |
+
}
|
| 164 |
+
.kpi-card .kpi-number { font-size: 1.8em; font-weight: 800; color: #1a237e; }
|
| 165 |
+
.kpi-card .kpi-label { font-size: 0.85em; color: #546e7a; margin-top: 2px; }
|
| 166 |
+
.kpi-card .kpi-context { font-size: 0.78em; color: #90a4ae; margin-top: 4px; }
|
| 167 |
+
|
| 168 |
+
/* ---- Empty State ---- */
|
| 169 |
+
.empty-state { text-align: center; padding: 40px 20px; color: #90a4ae; }
|
| 170 |
+
.empty-state .icon { font-size: 3em; }
|
| 171 |
+
.empty-state .message { font-size: 1.1em; margin-top: 8px; }
|
| 172 |
+
|
| 173 |
+
/* ---- Section Header ---- */
|
| 174 |
+
.section-hdr { font-size: 1.3em; font-weight: 700; color: #1a237e; margin-bottom: 2px; }
|
| 175 |
+
.section-sub { font-size: 0.9em; color: #78909c; margin-bottom: 12px; }
|
| 176 |
+
|
| 177 |
+
/* ---- Priority Banner ---- */
|
| 178 |
+
.priority-banner {
|
| 179 |
+
background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
|
| 180 |
+
color: white; padding: 20px 24px; border-radius: 10px; margin-bottom: 16px;
|
| 181 |
+
}
|
| 182 |
+
.priority-banner h3 {
|
| 183 |
+
color: white !important; margin-bottom: 12px;
|
| 184 |
+
font-size: 1.1em; letter-spacing: 1px;
|
| 185 |
+
}
|
| 186 |
+
.priority-item { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.15); }
|
| 187 |
+
.priority-item:last-child { border-bottom: none; }
|
| 188 |
+
.priority-item .rank { font-size: 1.3em; font-weight: 800; margin-right: 10px; }
|
| 189 |
+
.priority-item .detail { font-size: 0.92em; color: rgba(255,255,255,0.85); margin-top: 2px; }
|
| 190 |
+
|
| 191 |
+
/* ---- Alert Card ---- */
|
| 192 |
+
.alert-card {
|
| 193 |
+
border-radius: 6px; padding: 10px 14px; margin: 6px 0;
|
| 194 |
+
background: #fff; border: 1px solid #e0e0e0;
|
| 195 |
+
}
|
| 196 |
+
.alert-card .what { font-weight: 600; }
|
| 197 |
+
.alert-card .why { font-size: 0.88em; color: #546e7a; margin: 4px 0; }
|
| 198 |
+
.alert-card .action-cta { font-size: 0.85em; font-weight: 600; color: #1565c0; margin-top: 4px; }
|
| 199 |
+
|
| 200 |
+
/* ---- Service Tags ---- */
|
| 201 |
+
.service-tag-td { background: #1976d2; color: white; padding: 2px 8px; border-radius: 12px; font-size: 0.75em; font-weight: 600; }
|
| 202 |
+
.service-tag-cc { background: #2e7d32; color: white; padding: 2px 8px; border-radius: 12px; font-size: 0.75em; font-weight: 600; }
|
| 203 |
+
.service-tag-code { background: #e65100; color: white; padding: 2px 8px; border-radius: 12px; font-size: 0.75em; font-weight: 600; }
|
| 204 |
+
|
| 205 |
+
/* ---- Welcome / Onboarding ---- */
|
| 206 |
+
.welcome-box {
|
| 207 |
+
background: linear-gradient(135deg, #e8eaf6 0%, #c5cae9 100%);
|
| 208 |
+
padding: 30px; border-radius: 12px; text-align: center; margin: 20px 0;
|
| 209 |
+
}
|
| 210 |
+
.welcome-box h2 { color: #1a237e !important; }
|
| 211 |
+
.welcome-step {
|
| 212 |
+
display: flex; align-items: center; padding: 12px 0;
|
| 213 |
+
text-align: left; max-width: 500px; margin: 0 auto;
|
| 214 |
+
}
|
| 215 |
+
.welcome-step .step-num {
|
| 216 |
+
background: #1a237e; color: white; border-radius: 50%;
|
| 217 |
+
width: 32px; height: 32px; display: flex; align-items: center;
|
| 218 |
+
justify-content: center; font-weight: 700; margin-right: 14px; flex-shrink: 0;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
/* ---- Freshness Badges ---- */
|
| 222 |
+
.freshness-green {
|
| 223 |
+
display: inline-block; background: #2e7d32; color: white; padding: 1px 6px;
|
| 224 |
+
border-radius: 8px; font-size: 0.7em; font-weight: 600;
|
| 225 |
+
}
|
| 226 |
+
.freshness-amber {
|
| 227 |
+
display: inline-block; background: #f57c00; color: white; padding: 1px 6px;
|
| 228 |
+
border-radius: 8px; font-size: 0.7em; font-weight: 600;
|
| 229 |
+
}
|
| 230 |
+
.freshness-red {
|
| 231 |
+
display: inline-block; background: #d32f2f; color: white; padding: 1px 6px;
|
| 232 |
+
border-radius: 8px; font-size: 0.7em; font-weight: 600;
|
| 233 |
+
}
|
| 234 |
+
.freshness-grey {
|
| 235 |
+
display: inline-block; background: #9e9e9e; color: white; padding: 1px 6px;
|
| 236 |
+
border-radius: 8px; font-size: 0.7em; font-weight: 600;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
/* ---- Source Health Dots ---- */
|
| 240 |
+
.source-dot {
|
| 241 |
+
display: inline-block; width: 10px; height: 10px;
|
| 242 |
+
border-radius: 50%; margin: 0 3px;
|
| 243 |
+
}
|
| 244 |
+
.source-dot.green { background: #2e7d32; }
|
| 245 |
+
.source-dot.amber { background: #f57c00; }
|
| 246 |
+
.source-dot.red { background: #d32f2f; }
|
| 247 |
+
.source-dot.grey { background: #bdbdbd; }
|
| 248 |
+
|
| 249 |
+
/* ---- Signal Completeness ---- */
|
| 250 |
+
.completeness-badge {
|
| 251 |
+
display: inline-block; background: #e3f2fd; color: #1565c0;
|
| 252 |
+
padding: 2px 8px; border-radius: 8px; font-size: 0.72em; font-weight: 600;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
/* ---- Approach Brief ---- */
|
| 256 |
+
.brief-section {
|
| 257 |
+
margin: 12px 0; padding: 12px 16px;
|
| 258 |
+
background: #fafafa; border-radius: 6px; border: 1px solid #e0e0e0;
|
| 259 |
+
}
|
| 260 |
+
.brief-section-title {
|
| 261 |
+
font-weight: 700; font-size: 0.9em; color: #1a237e;
|
| 262 |
+
text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
/* ---- Print-Friendly ---- */
|
| 266 |
+
@media print {
|
| 267 |
+
[data-testid="stSidebar"], [data-testid="stHeader"],
|
| 268 |
+
[data-testid="stToolbar"], .stDeployButton,
|
| 269 |
+
button, .stButton { display: none !important; }
|
| 270 |
+
.main .block-container { padding-top: 0 !important; max-width: 100% !important; }
|
| 271 |
+
}
|
| 272 |
+
</style>
|
| 273 |
+
""", unsafe_allow_html=True)
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
# =============================================================================
|
| 277 |
+
# BADGE & LABEL HELPERS
|
| 278 |
+
# =============================================================================
|
| 279 |
+
|
| 280 |
+
def urgency_badge_html(level):
|
| 281 |
+
"""Return styled HTML span for urgency level."""
|
| 282 |
+
cfg = URGENCY_CONFIG.get(level, URGENCY_CONFIG['blue'])
|
| 283 |
+
return (
|
| 284 |
+
f'<span style="background:{cfg["color"]};color:white;padding:3px 10px;'
|
| 285 |
+
f'border-radius:12px;font-size:0.75em;font-weight:700;letter-spacing:0.5px;">'
|
| 286 |
+
f'{cfg["label"]}</span>'
|
| 287 |
+
)
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
def urgency_for_score(score):
|
| 291 |
+
"""Map a numeric score to an urgency level."""
|
| 292 |
+
if score >= 70:
|
| 293 |
+
return 'red'
|
| 294 |
+
elif score >= 50:
|
| 295 |
+
return 'amber'
|
| 296 |
+
return 'green'
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
def freshness_badge(date_str):
|
| 300 |
+
"""Return HTML badge showing data age: green (<7d), amber (7-30d), red (>30d).
|
| 301 |
+
|
| 302 |
+
Args:
|
| 303 |
+
date_str: ISO date string or None
|
| 304 |
+
Returns:
|
| 305 |
+
HTML string with coloured badge showing age
|
| 306 |
+
"""
|
| 307 |
+
if not date_str:
|
| 308 |
+
return '<span class="freshness-grey">No date</span>'
|
| 309 |
+
|
| 310 |
+
try:
|
| 311 |
+
dt = datetime.fromisoformat(date_str.replace('Z', '+00:00'))
|
| 312 |
+
if dt.tzinfo:
|
| 313 |
+
dt = dt.replace(tzinfo=None)
|
| 314 |
+
days_ago = (datetime.now() - dt).days
|
| 315 |
+
except (ValueError, TypeError):
|
| 316 |
+
return '<span class="freshness-grey">Unknown</span>'
|
| 317 |
+
|
| 318 |
+
if days_ago < 0:
|
| 319 |
+
days_ago = 0
|
| 320 |
+
|
| 321 |
+
if days_ago <= 7:
|
| 322 |
+
css_class = "freshness-green"
|
| 323 |
+
label = f"{days_ago}d ago" if days_ago > 0 else "Today"
|
| 324 |
+
elif days_ago <= 30:
|
| 325 |
+
css_class = "freshness-amber"
|
| 326 |
+
label = f"{days_ago}d ago"
|
| 327 |
+
else:
|
| 328 |
+
css_class = "freshness-red"
|
| 329 |
+
if days_ago > 365:
|
| 330 |
+
label = f"{days_ago // 365}y ago"
|
| 331 |
+
else:
|
| 332 |
+
label = f"{days_ago}d ago"
|
| 333 |
+
|
| 334 |
+
return f'<span class="{css_class}">{label}</span>'
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
def signal_completeness_badge(completeness):
|
| 338 |
+
"""Render '5/9 sources checked' badge.
|
| 339 |
+
|
| 340 |
+
Args:
|
| 341 |
+
completeness: dict from get_signal_completeness() with 'checked' and 'total' keys
|
| 342 |
+
"""
|
| 343 |
+
checked = completeness.get('checked', 0)
|
| 344 |
+
total = completeness.get('total', 9)
|
| 345 |
+
return f'<span class="completeness-badge">{checked}/{total} sources</span>'
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
def render_service_badges(dossier):
|
| 349 |
+
"""Render TD/CC/CODE service-line badges for a company."""
|
| 350 |
+
td = getattr(dossier, 'td_score', 0) or 0
|
| 351 |
+
cc = getattr(dossier, 'cc_score', 0) or 0
|
| 352 |
+
services = getattr(dossier, 'recommended_services', []) or []
|
| 353 |
+
|
| 354 |
+
badges = []
|
| 355 |
+
if td > 0:
|
| 356 |
+
color = "#d32f2f" if td >= 50 else "#1976d2" if td >= 20 else "#9e9e9e"
|
| 357 |
+
badges.append(f'<span style="background:{color};color:white;padding:2px 8px;border-radius:12px;font-size:0.75em;font-weight:600;">TD: {td}</span>')
|
| 358 |
+
if cc > 0:
|
| 359 |
+
color = "#d32f2f" if cc >= 50 else "#2e7d32" if cc >= 20 else "#9e9e9e"
|
| 360 |
+
badges.append(f'<span style="background:{color};color:white;padding:2px 8px;border-radius:12px;font-size:0.75em;font-weight:600;">CC: {cc}</span>')
|
| 361 |
+
if 'code_3i' in services:
|
| 362 |
+
badges.append(f'<span style="background:#e65100;color:white;padding:2px 8px;border-radius:12px;font-size:0.75em;font-weight:600;">CODE 3i</span>')
|
| 363 |
+
|
| 364 |
+
return " ".join(badges) if badges else ""
|
| 365 |
+
|
| 366 |
+
|
| 367 |
+
def render_source_health_dots(source_health):
|
| 368 |
+
"""Render row of 9 coloured dots for sidebar source health.
|
| 369 |
+
|
| 370 |
+
Args:
|
| 371 |
+
source_health: list of dicts from get_all_source_health()
|
| 372 |
+
"""
|
| 373 |
+
dots = []
|
| 374 |
+
for src in source_health:
|
| 375 |
+
status = src.get('status', 'never_run')
|
| 376 |
+
name = src.get('source_name', '?')
|
| 377 |
+
label, emoji = SOURCE_LABELS.get(name, (name, '?'))
|
| 378 |
+
|
| 379 |
+
if status == 'success':
|
| 380 |
+
css = 'green'
|
| 381 |
+
title = f'{label}: OK'
|
| 382 |
+
elif status == 'error':
|
| 383 |
+
css = 'red'
|
| 384 |
+
err = src.get('last_error', 'Unknown error')
|
| 385 |
+
title = f'{label}: ERROR - {err[:60]}'
|
| 386 |
+
elif status == 'disabled':
|
| 387 |
+
css = 'amber'
|
| 388 |
+
title = f'{label}: Disabled'
|
| 389 |
+
else:
|
| 390 |
+
css = 'grey'
|
| 391 |
+
title = f'{label}: Never scanned'
|
| 392 |
+
|
| 393 |
+
dots.append(f'<span class="source-dot {css}" title="{title}"></span>')
|
| 394 |
+
|
| 395 |
+
if dots:
|
| 396 |
+
html = '<div style="text-align:center;margin:4px 0;">' + ''.join(dots) + '</div>'
|
| 397 |
+
st.markdown(html, unsafe_allow_html=True)
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
# =============================================================================
|
| 401 |
+
# LAYOUT HELPERS
|
| 402 |
+
# =============================================================================
|
| 403 |
+
|
| 404 |
+
def section_header(title, subtitle):
|
| 405 |
+
"""Render a section title with grey subtitle explaining purpose."""
|
| 406 |
+
st.markdown(
|
| 407 |
+
f'<div style="margin-bottom:4px;">'
|
| 408 |
+
f'<span style="font-size:1.3em;font-weight:700;color:#1a237e;">{title}</span>'
|
| 409 |
+
f'</div>'
|
| 410 |
+
f'<div style="font-size:0.9em;color:#78909c;margin-bottom:12px;">{subtitle}</div>',
|
| 411 |
+
unsafe_allow_html=True,
|
| 412 |
+
)
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
def next_step_box(text):
|
| 416 |
+
"""Blue callout box for next-step guidance."""
|
| 417 |
+
st.markdown(
|
| 418 |
+
f'<div style="background:#e3f2fd;border-left:4px solid #1565c0;padding:10px 14px;'
|
| 419 |
+
f'margin:10px 0;border-radius:4px;font-size:0.95em;">'
|
| 420 |
+
f'<strong>Next step:</strong> {text}</div>',
|
| 421 |
+
unsafe_allow_html=True,
|
| 422 |
+
)
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
def page_guide(tips: list[str], collapsed: bool = True):
|
| 426 |
+
"""Render inline how-to guidance as a collapsible tip box.
|
| 427 |
+
|
| 428 |
+
Args:
|
| 429 |
+
tips: list of short, action-oriented tip strings.
|
| 430 |
+
collapsed: if True the guide starts collapsed (default).
|
| 431 |
+
"""
|
| 432 |
+
bullets = "".join(f"<li style='margin-bottom:4px;'>{t}</li>" for t in tips)
|
| 433 |
+
html = (
|
| 434 |
+
f'<ul style="margin:4px 0 0 8px;padding-left:16px;color:#455a64;'
|
| 435 |
+
f'font-size:0.9em;line-height:1.5;">{bullets}</ul>'
|
| 436 |
+
)
|
| 437 |
+
with st.expander("How to use this page", expanded=not collapsed):
|
| 438 |
+
st.markdown(html, unsafe_allow_html=True)
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
def empty_state(icon, message, button_label=None, button_key=None):
|
| 442 |
+
"""Centered empty state with guidance."""
|
| 443 |
+
st.markdown(
|
| 444 |
+
f'<div style="text-align:center;padding:40px 20px;color:#90a4ae;">'
|
| 445 |
+
f'<div style="font-size:3em;">{icon}</div>'
|
| 446 |
+
f'<div style="font-size:1.1em;margin-top:8px;">{message}</div>'
|
| 447 |
+
f'</div>',
|
| 448 |
+
unsafe_allow_html=True,
|
| 449 |
+
)
|
| 450 |
+
if button_label and button_key:
|
| 451 |
+
col1, col2, col3 = st.columns([1, 2, 1])
|
| 452 |
+
with col2:
|
| 453 |
+
return st.button(button_label, key=button_key, type="primary", use_container_width=True)
|
| 454 |
+
return False
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
def kpi_with_context(label, value, context, delta=None):
|
| 458 |
+
"""Metric card with a one-line explanation beneath the number."""
|
| 459 |
+
st.metric(label, value, delta=delta)
|
| 460 |
+
st.caption(context)
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
def format_value(value, currency="GBP"):
|
| 464 |
+
"""Format monetary value with appropriate suffix."""
|
| 465 |
+
import pandas as pd
|
| 466 |
+
if pd.isna(value) or value == 0 or value is None:
|
| 467 |
+
return "\u2014"
|
| 468 |
+
if value >= 1_000_000:
|
| 469 |
+
return f"\u00a3{value/1_000_000:.1f}M"
|
| 470 |
+
elif value >= 1_000:
|
| 471 |
+
return f"\u00a3{value/1_000:.0f}K"
|
| 472 |
+
return f"\u00a3{value:.0f}"
|
| 473 |
+
|
| 474 |
+
|
| 475 |
+
# =============================================================================
|
| 476 |
+
# HUNT STATUS RENDERER
|
| 477 |
+
# =============================================================================
|
| 478 |
+
|
| 479 |
+
def render_hunt_source_status():
|
| 480 |
+
"""Render a compact row of coloured badges showing per-source hunt results."""
|
| 481 |
+
results = st.session_state.get('last_hunt_results')
|
| 482 |
+
if not results:
|
| 483 |
+
return
|
| 484 |
+
source_status = results.get('source_status')
|
| 485 |
+
if not source_status:
|
| 486 |
+
return
|
| 487 |
+
|
| 488 |
+
pills = []
|
| 489 |
+
for key, (label, emoji) in SOURCE_LABELS.items():
|
| 490 |
+
info = source_status.get(key, {})
|
| 491 |
+
status = info.get('status', 'pending')
|
| 492 |
+
count = info.get('count', 0)
|
| 493 |
+
error = info.get('error')
|
| 494 |
+
|
| 495 |
+
if status == 'success' and count > 0:
|
| 496 |
+
bg = '#2e7d32'
|
| 497 |
+
text = f'{emoji} {label} ✓ {count}'
|
| 498 |
+
title = f'{label}: {count} found'
|
| 499 |
+
elif status == 'success':
|
| 500 |
+
bg = '#757575'
|
| 501 |
+
text = f'{emoji} {label} ✓ 0'
|
| 502 |
+
title = f'{label}: ran OK, 0 results'
|
| 503 |
+
elif status == 'error':
|
| 504 |
+
bg = '#c62828'
|
| 505 |
+
text = f'{emoji} {label} ✗'
|
| 506 |
+
title = f'{label} error: {error or "unknown"}'
|
| 507 |
+
elif status == 'disabled':
|
| 508 |
+
bg = '#9e9e9e'
|
| 509 |
+
text = f'{emoji} {label} — off'
|
| 510 |
+
title = f'{label}: disabled'
|
| 511 |
+
else:
|
| 512 |
+
bg = '#bdbdbd'
|
| 513 |
+
text = f'{emoji} {label} ...'
|
| 514 |
+
title = f'{label}: pending'
|
| 515 |
+
|
| 516 |
+
pills.append(
|
| 517 |
+
f'<span title="{title}" style="display:inline-block;background:{bg};color:white;'
|
| 518 |
+
f'padding:3px 10px;border-radius:12px;font-size:0.75em;font-weight:600;'
|
| 519 |
+
f'margin:2px 3px;white-space:nowrap;">{text}</span>'
|
| 520 |
+
)
|
| 521 |
+
|
| 522 |
+
html = (
|
| 523 |
+
'<div style="display:flex;flex-wrap:wrap;align-items:center;gap:2px;margin-bottom:8px;">'
|
| 524 |
+
+ ''.join(pills)
|
| 525 |
+
+ '</div>'
|
| 526 |
+
)
|
| 527 |
+
st.markdown(html, unsafe_allow_html=True)
|
| 528 |
+
|
| 529 |
+
if st.button("Dismiss", key="dismiss_hunt_status", type="secondary"):
|
| 530 |
+
del st.session_state['last_hunt_results']
|
| 531 |
+
st.rerun()
|
| 532 |
+
|
| 533 |
+
|
| 534 |
+
# =============================================================================
|
| 535 |
+
# SIGNAL ANALYSIS HELPERS
|
| 536 |
+
# =============================================================================
|
| 537 |
+
|
| 538 |
+
def synthesize_why_now(dossier):
|
| 539 |
+
"""Build a 'WHY NOW' sentence from all signals."""
|
| 540 |
+
signals = (getattr(dossier, 'signal_summary', '') or '').lower()
|
| 541 |
+
parts = []
|
| 542 |
+
if 'restructuring' in signals or 'operating model' in signals:
|
| 543 |
+
parts.append('Active restructuring')
|
| 544 |
+
if 'leadership' in signals or 'new ceo' in signals or 'new cto' in signals:
|
| 545 |
+
parts.append('Leadership change')
|
| 546 |
+
if 'm&a' in signals or 'acquisition' in signals or 'pe' in signals:
|
| 547 |
+
parts.append('M&A activity')
|
| 548 |
+
if 'sentiment' in signals or 'glassdoor' in signals:
|
| 549 |
+
sent_signals = getattr(dossier, 'sentiment_signals', [])
|
| 550 |
+
if sent_signals:
|
| 551 |
+
rating = sent_signals[0].get('overall_rating', 0)
|
| 552 |
+
parts.append(f'Poor employee sentiment ({rating:.1f}\u2605)' if rating else 'Employee sentiment concerns')
|
| 553 |
+
else:
|
| 554 |
+
parts.append('Employee sentiment concerns')
|
| 555 |
+
if 'job' in signals:
|
| 556 |
+
parts.append('Hiring for transformation roles')
|
| 557 |
+
if 'news' in signals:
|
| 558 |
+
parts.append('Recent news activity')
|
| 559 |
+
if not parts:
|
| 560 |
+
parts.append('Multiple change signals detected')
|
| 561 |
+
return ' + '.join(parts)
|
| 562 |
+
|
| 563 |
+
|
| 564 |
+
def build_evidence_snippets(dossier):
|
| 565 |
+
"""Extract top 2 factual evidence snippets from dossier signal data.
|
| 566 |
+
|
| 567 |
+
Returns real data citations - no LLM calls, no AI-generated text.
|
| 568 |
+
"""
|
| 569 |
+
snippets = []
|
| 570 |
+
|
| 571 |
+
for job in (dossier.jobs or []):
|
| 572 |
+
title = job.get('title', '')
|
| 573 |
+
score = job.get('score', 0)
|
| 574 |
+
if title:
|
| 575 |
+
snippets.append(f"Hiring: {escape(title[:60])} (score {score})")
|
| 576 |
+
break
|
| 577 |
+
|
| 578 |
+
for news in (dossier.news or []):
|
| 579 |
+
headline = news.get('headline', '')
|
| 580 |
+
if headline:
|
| 581 |
+
snippets.append(f"News: '{escape(headline[:70])}'")
|
| 582 |
+
break
|
| 583 |
+
|
| 584 |
+
for sent in (dossier.sentiment_signals or []):
|
| 585 |
+
overall = sent.get('overall_rating', 0)
|
| 586 |
+
reviews = sent.get('review_count', 0)
|
| 587 |
+
if overall:
|
| 588 |
+
review_str = f" ({reviews} reviews)" if reviews else ""
|
| 589 |
+
snippets.append(f"Glassdoor: {overall:.1f}\u2605 overall{review_str}")
|
| 590 |
+
break
|
| 591 |
+
|
| 592 |
+
for deal in (dossier.pe_deals or []):
|
| 593 |
+
acquirer = deal.get('acquirer_name', '')
|
| 594 |
+
deal_type = deal.get('deal_type', '')
|
| 595 |
+
is_pe = deal.get('is_pe_deal', 0) == 1
|
| 596 |
+
if acquirer:
|
| 597 |
+
label = "PE buyout" if is_pe else (deal_type or "acquisition")
|
| 598 |
+
snippets.append(f"M&A: {escape(acquirer[:40])} \u2014 {escape(label)}")
|
| 599 |
+
break
|
| 600 |
+
|
| 601 |
+
for report in (dossier.annual_reports or []):
|
| 602 |
+
score = report.get('score', 0)
|
| 603 |
+
if score >= 40:
|
| 604 |
+
snippets.append("Annual report flags restructuring signals")
|
| 605 |
+
break
|
| 606 |
+
|
| 607 |
+
return snippets[:2]
|
| 608 |
+
|
| 609 |
+
|
| 610 |
+
def evidence_html(snippets):
|
| 611 |
+
"""Render evidence snippets as a compact green HTML block."""
|
| 612 |
+
if not snippets:
|
| 613 |
+
return ""
|
| 614 |
+
lines = "".join(f"<div>{s}</div>" for s in snippets)
|
| 615 |
+
return f'<div class="evidence"><strong>EVIDENCE:</strong> {lines}</div>'
|
| 616 |
+
|
| 617 |
+
|
| 618 |
+
def recommend_pitch(dossier):
|
| 619 |
+
"""Recommend which Curium service to pitch first based on primary signals."""
|
| 620 |
+
signals = (getattr(dossier, 'signal_summary', '') or '').lower()
|
| 621 |
+
td = getattr(dossier, 'td_score', 0) or 0
|
| 622 |
+
cc = getattr(dossier, 'cc_score', 0) or 0
|
| 623 |
+
services = getattr(dossier, 'recommended_services', []) or []
|
| 624 |
+
|
| 625 |
+
if 'code_3i' in services and ('leadership' in signals or 'culture' in signals):
|
| 626 |
+
return 'Culture diagnostics + CODE 3i (leadership change is the primary signal)'
|
| 627 |
+
if cc > td and cc >= 30:
|
| 628 |
+
if 'culture' in signals or 'sentiment' in signals:
|
| 629 |
+
return 'Culture diagnostics and executive coaching (people signals are strongest)'
|
| 630 |
+
return 'Executive coaching and leadership strategy'
|
| 631 |
+
if td > cc and td >= 30:
|
| 632 |
+
if 'restructuring' in signals or 'operating model' in signals:
|
| 633 |
+
return 'Programme management + change management (delivery signals are strongest)'
|
| 634 |
+
if 'm&a' in signals:
|
| 635 |
+
return 'M&A integration + programme management'
|
| 636 |
+
return 'Transformation delivery \u2014 programme and change management'
|
| 637 |
+
if td >= 20 and cc >= 20:
|
| 638 |
+
return 'Blended TD + CC approach \u2014 start with a discovery conversation'
|
| 639 |
+
return 'Explore fit via an initial conversation about their change agenda'
|
| 640 |
+
|
| 641 |
+
|
| 642 |
+
def get_best_route(dossier):
|
| 643 |
+
"""Find the best route into a company from network + LinkedIn intel."""
|
| 644 |
+
if dossier.network_status and dossier.network_status != "Cold":
|
| 645 |
+
if dossier.best_colleague and dossier.best_contact:
|
| 646 |
+
return {
|
| 647 |
+
'type': 'warm',
|
| 648 |
+
'colleague': dossier.best_colleague,
|
| 649 |
+
'contact': dossier.best_contact,
|
| 650 |
+
'msg': f'Ask {dossier.best_colleague} to intro you to {dossier.best_contact}',
|
| 651 |
+
}
|
| 652 |
+
li_intel = getattr(dossier, 'linkedin_intel', [])
|
| 653 |
+
if li_intel:
|
| 654 |
+
best = max(li_intel, key=lambda x: (
|
| 655 |
+
x.get('posts_about_transformation', 0) * 20 +
|
| 656 |
+
x.get('contact_active', 0) * 10 +
|
| 657 |
+
min(x.get('mutual_connections', 0), 5) * 2
|
| 658 |
+
))
|
| 659 |
+
colleague = best.get('colleague_name', '?')
|
| 660 |
+
contact = best.get('contact_name', '?')
|
| 661 |
+
posting = best.get('posts_about_transformation')
|
| 662 |
+
suffix = " \u2014 they're posting about transformation" if posting else ""
|
| 663 |
+
return {
|
| 664 |
+
'type': 'linkedin',
|
| 665 |
+
'colleague': colleague,
|
| 666 |
+
'contact': contact,
|
| 667 |
+
'posting': posting,
|
| 668 |
+
'msg': f'Ask {colleague} to intro you to {contact}{suffix}',
|
| 669 |
+
}
|
| 670 |
+
return {'type': 'cold', 'msg': 'No connection found \u2014 consider LinkedIn outreach'}
|
| 671 |
+
|
| 672 |
+
|
| 673 |
+
def compute_priority_actions(companies, limit=3):
|
| 674 |
+
"""Scan all companies and return top priority actions."""
|
| 675 |
+
actions = []
|
| 676 |
+
for c in companies:
|
| 677 |
+
score = c.overall_score or 0
|
| 678 |
+
if score < 20:
|
| 679 |
+
continue
|
| 680 |
+
|
| 681 |
+
route = get_best_route(c)
|
| 682 |
+
why = synthesize_why_now(c)
|
| 683 |
+
pitch = recommend_pitch(c)
|
| 684 |
+
urgency = urgency_for_score(score)
|
| 685 |
+
|
| 686 |
+
priority = score
|
| 687 |
+
if c.pe_deals:
|
| 688 |
+
priority += 15
|
| 689 |
+
|
| 690 |
+
li_intel = getattr(c, 'linkedin_intel', [])
|
| 691 |
+
if any(i.get('posts_about_transformation') for i in li_intel):
|
| 692 |
+
priority += 12
|
| 693 |
+
if c.tenders:
|
| 694 |
+
for t in c.tenders:
|
| 695 |
+
if t.get('urgent'):
|
| 696 |
+
priority += 20
|
| 697 |
+
|
| 698 |
+
actions.append({
|
| 699 |
+
'company': c,
|
| 700 |
+
'score': score,
|
| 701 |
+
'priority': priority,
|
| 702 |
+
'urgency': urgency,
|
| 703 |
+
'route': route,
|
| 704 |
+
'why': why,
|
| 705 |
+
'pitch': pitch,
|
| 706 |
+
})
|
| 707 |
+
|
| 708 |
+
actions.sort(key=lambda x: x['priority'], reverse=True)
|
| 709 |
+
return actions[:limit]
|
| 710 |
+
|
| 711 |
+
|
| 712 |
+
# =============================================================================
|
| 713 |
+
# DOSSIER TAB RENDERERS
|
| 714 |
+
# =============================================================================
|
| 715 |
+
|
| 716 |
+
def render_curium_fit_tab(dossier):
|
| 717 |
+
"""Render the Curium Fit tab - verdict first, then details."""
|
| 718 |
+
td = getattr(dossier, 'td_score', 0) or 0
|
| 719 |
+
cc = getattr(dossier, 'cc_score', 0) or 0
|
| 720 |
+
services = getattr(dossier, 'recommended_services', []) or []
|
| 721 |
+
|
| 722 |
+
max_score = max(td, cc)
|
| 723 |
+
if max_score >= 50:
|
| 724 |
+
if cc > td:
|
| 725 |
+
verdict = f"Strong CC fit ({cc}/100) \u2014 lead with coaching and culture diagnostics"
|
| 726 |
+
elif td > cc:
|
| 727 |
+
verdict = f"Strong TD fit ({td}/100) \u2014 lead with programme and change management"
|
| 728 |
+
else:
|
| 729 |
+
verdict = f"Strong dual fit (TD: {td}, CC: {cc}) \u2014 position blended offering"
|
| 730 |
+
st.markdown(
|
| 731 |
+
f'<div style="background:#e8f5e9;border-left:4px solid #2e7d32;padding:12px 16px;'
|
| 732 |
+
f'border-radius:4px;margin-bottom:12px;font-size:1.05em;">'
|
| 733 |
+
f'<strong>VERDICT:</strong> {verdict}</div>',
|
| 734 |
+
unsafe_allow_html=True,
|
| 735 |
+
)
|
| 736 |
+
elif max_score >= 20:
|
| 737 |
+
if cc > td:
|
| 738 |
+
verdict = f"Moderate CC fit ({cc}/100) \u2014 explore coaching and leadership needs"
|
| 739 |
+
elif td > cc:
|
| 740 |
+
verdict = f"Moderate TD fit ({td}/100) \u2014 explore programme management needs"
|
| 741 |
+
else:
|
| 742 |
+
verdict = f"Moderate dual fit (TD: {td}, CC: {cc}) \u2014 worth a discovery call"
|
| 743 |
+
st.markdown(
|
| 744 |
+
f'<div style="background:#fff3e0;border-left:4px solid #f57c00;padding:12px 16px;'
|
| 745 |
+
f'border-radius:4px;margin-bottom:12px;font-size:1.05em;">'
|
| 746 |
+
f'<strong>VERDICT:</strong> {verdict}</div>',
|
| 747 |
+
unsafe_allow_html=True,
|
| 748 |
+
)
|
| 749 |
+
else:
|
| 750 |
+
st.markdown(
|
| 751 |
+
f'<div style="background:#fafafa;border-left:4px solid #9e9e9e;padding:12px 16px;'
|
| 752 |
+
f'border-radius:4px;margin-bottom:12px;font-size:1.05em;">'
|
| 753 |
+
f'<strong>VERDICT:</strong> Low fit (TD: {td}, CC: {cc}) \u2014 monitor for now</div>',
|
| 754 |
+
unsafe_allow_html=True,
|
| 755 |
+
)
|
| 756 |
+
|
| 757 |
+
pitch = recommend_pitch(dossier)
|
| 758 |
+
st.markdown(
|
| 759 |
+
f'<div style="background:#e3f2fd;border-left:4px solid #1565c0;padding:10px 14px;'
|
| 760 |
+
f'border-radius:4px;margin:8px 0;">'
|
| 761 |
+
f'<strong>PITCH THIS FIRST:</strong> {pitch}</div>',
|
| 762 |
+
unsafe_allow_html=True,
|
| 763 |
+
)
|
| 764 |
+
|
| 765 |
+
col1, col2 = st.columns(2)
|
| 766 |
+
with col1:
|
| 767 |
+
st.markdown("**Transformation Delivery**")
|
| 768 |
+
st.progress(min(td, 100) / 100)
|
| 769 |
+
st.caption(f"TD Score: {td}/100")
|
| 770 |
+
with col2:
|
| 771 |
+
st.markdown("**Culture & Capability**")
|
| 772 |
+
st.progress(min(cc, 100) / 100)
|
| 773 |
+
st.caption(f"CC Score: {cc}/100")
|
| 774 |
+
|
| 775 |
+
if services:
|
| 776 |
+
st.markdown("**Recommended Services:**")
|
| 777 |
+
td_svc = [s for s in services if s in TD_SERVICES]
|
| 778 |
+
cc_svc = [s for s in services if s in CC_SERVICES]
|
| 779 |
+
if td_svc:
|
| 780 |
+
labels = [SERVICE_LABELS.get(s, s) for s in td_svc]
|
| 781 |
+
st.markdown("TD: " + " | ".join([f"**{l}**" for l in labels]))
|
| 782 |
+
if cc_svc:
|
| 783 |
+
labels = [SERVICE_LABELS.get(s, s) for s in cc_svc]
|
| 784 |
+
st.markdown("CC: " + " | ".join([f"**{l}**" for l in labels]))
|
| 785 |
+
else:
|
| 786 |
+
st.caption("No specific services recommended yet \u2014 run a hunt to populate")
|
| 787 |
+
|
| 788 |
+
# Conversation starters
|
| 789 |
+
st.divider()
|
| 790 |
+
st.markdown("**Conversation Starters**")
|
| 791 |
+
st.caption("Use these as openers when reaching out")
|
| 792 |
+
|
| 793 |
+
signals = (dossier.signal_summary or "").lower()
|
| 794 |
+
starters = []
|
| 795 |
+
|
| 796 |
+
if "restructuring" in signals or "operating model" in signals:
|
| 797 |
+
starters.append("\"I noticed you're going through a restructure \u2014 we've helped similar orgs embed senior programme managers to accelerate delivery.\"")
|
| 798 |
+
if "leadership" in signals or "culture" in signals:
|
| 799 |
+
starters.append("\"With the leadership changes happening, our CODE 3i diagnostic can quickly map where culture gaps might slow things down.\"")
|
| 800 |
+
if "m&a" in signals or "pe" in signals or "acquisition" in signals:
|
| 801 |
+
starters.append("\"Post-merger integration is where we see most value \u2014 we combine delivery expertise with culture alignment to land the change.\"")
|
| 802 |
+
if "sentiment" in signals:
|
| 803 |
+
starters.append("\"Employee sentiment data suggests there's room to improve engagement \u2014 our culture diagnostics can pinpoint exactly where to focus.\"")
|
| 804 |
+
if not starters:
|
| 805 |
+
starters.append("\"We help organisations going through change \u2014 combining programme delivery with people and culture expertise for faster results.\"")
|
| 806 |
+
|
| 807 |
+
for starter in starters:
|
| 808 |
+
st.markdown(
|
| 809 |
+
f'<div style="background:#f5f5f5;padding:8px 12px;border-radius:6px;margin:4px 0;'
|
| 810 |
+
f'font-size:0.92em;color:#333;border-left:3px solid #1a237e;">{starter}</div>',
|
| 811 |
+
unsafe_allow_html=True,
|
| 812 |
+
)
|
| 813 |
+
|
| 814 |
+
competitor_signals = []
|
| 815 |
+
if "restructuring" in signals or "operating model" in signals:
|
| 816 |
+
competitor_signals.append("Moorhouse, PA Consulting")
|
| 817 |
+
if "culture" in signals or "leadership" in signals:
|
| 818 |
+
competitor_signals.append("YSC, Clarasys")
|
| 819 |
+
if competitor_signals:
|
| 820 |
+
st.caption(f"Competitors to watch: {', '.join(competitor_signals)}")
|
| 821 |
+
|
| 822 |
+
|
| 823 |
+
def render_dossier_tabs(dossier, company_id_prefix, show_network=True, show_action=True):
|
| 824 |
+
"""Shared tab renderer for company dossiers. Curium Fit tab first."""
|
| 825 |
+
from email_engine import (
|
| 826 |
+
draft_warm_intro_email, get_copyable_email,
|
| 827 |
+
)
|
| 828 |
+
|
| 829 |
+
tab_labels = ["\U0001f3af Curium Fit", "\U0001f4bc Jobs", "\U0001f4f0 News",
|
| 830 |
+
"\U0001f4c4 Reports", "\U0001f610 Sentiment",
|
| 831 |
+
"\U0001f91d M&A", "\U0001f50d LI Intel"]
|
| 832 |
+
if show_network:
|
| 833 |
+
tab_labels.append("\U0001f517 Network")
|
| 834 |
+
if show_action:
|
| 835 |
+
tab_labels.append("\u2709\ufe0f Action")
|
| 836 |
+
|
| 837 |
+
detail_tabs = st.tabs(tab_labels)
|
| 838 |
+
|
| 839 |
+
with detail_tabs[0]:
|
| 840 |
+
render_curium_fit_tab(dossier)
|
| 841 |
+
|
| 842 |
+
# Jobs tab
|
| 843 |
+
with detail_tabs[1]:
|
| 844 |
+
if dossier.jobs:
|
| 845 |
+
for job in dossier.jobs:
|
| 846 |
+
job_score = job.get('score', 0)
|
| 847 |
+
job_emoji = "\U0001f525" if job_score >= 80 else "\u2705" if job_score >= 60 else "\U0001f4cb"
|
| 848 |
+
date_badge = freshness_badge(job.get('date'))
|
| 849 |
+
st.markdown(f"**{job_emoji} {job.get('title', 'Unknown Role')}** (Score: {job_score}) {date_badge}", unsafe_allow_html=True)
|
| 850 |
+
if job.get('analysis'):
|
| 851 |
+
analysis = job['analysis']
|
| 852 |
+
st.caption(analysis[:200] + "..." if len(analysis) > 200 else analysis)
|
| 853 |
+
if job.get('url'):
|
| 854 |
+
st.markdown(f"[View Job \u2192]({job['url']})")
|
| 855 |
+
st.divider()
|
| 856 |
+
else:
|
| 857 |
+
st.caption("No job signals")
|
| 858 |
+
|
| 859 |
+
# News tab
|
| 860 |
+
with detail_tabs[2]:
|
| 861 |
+
if dossier.news:
|
| 862 |
+
for news in dossier.news:
|
| 863 |
+
urgency = news.get('urgency', 'low')
|
| 864 |
+
urgency_emoji = "\U0001f534" if urgency == 'high' else "\U0001f7e1" if urgency == 'medium' else "\U0001f7e2"
|
| 865 |
+
date_badge = freshness_badge(news.get('date'))
|
| 866 |
+
st.markdown(f"**{urgency_emoji} {news.get('headline', 'Unknown')}** {date_badge}", unsafe_allow_html=True)
|
| 867 |
+
if news.get('trigger'):
|
| 868 |
+
reason = news.get('reason', '')
|
| 869 |
+
st.caption(f"**Trigger:** {news['trigger']} | {reason[:100]}" if reason else f"**Trigger:** {news['trigger']}")
|
| 870 |
+
if news.get('url'):
|
| 871 |
+
st.markdown(f"[Read Article \u2192]({news['url']})")
|
| 872 |
+
st.divider()
|
| 873 |
+
else:
|
| 874 |
+
st.caption("No news signals")
|
| 875 |
+
|
| 876 |
+
# Annual Reports tab
|
| 877 |
+
with detail_tabs[3]:
|
| 878 |
+
if dossier.annual_reports:
|
| 879 |
+
for report in dossier.annual_reports:
|
| 880 |
+
report_score = report.get('score', 0)
|
| 881 |
+
score_emoji = "\U0001f525" if report_score >= 60 else "\U0001f4c4"
|
| 882 |
+
urgency = report.get('urgency', 'low')
|
| 883 |
+
urgency_emoji = "\U0001f534" if urgency == 'high' else "\U0001f7e1" if urgency == 'medium' else "\U0001f7e2"
|
| 884 |
+
date_badge = freshness_badge(report.get('date'))
|
| 885 |
+
|
| 886 |
+
st.markdown(f"**{score_emoji} Annual Report** (Score: {report_score}) {urgency_emoji} {date_badge}", unsafe_allow_html=True)
|
| 887 |
+
st.caption(f"Filing date: {report.get('filing_date', 'Unknown')}")
|
| 888 |
+
|
| 889 |
+
if report.get('summary'):
|
| 890 |
+
st.markdown(report['summary'])
|
| 891 |
+
|
| 892 |
+
signals = report.get('signals_found', '')
|
| 893 |
+
if signals:
|
| 894 |
+
try:
|
| 895 |
+
signal_list = _json.loads(signals) if isinstance(signals, str) else signals
|
| 896 |
+
if signal_list:
|
| 897 |
+
st.markdown("**Signals:** " + ", ".join(signal_list))
|
| 898 |
+
except Exception:
|
| 899 |
+
st.markdown(f"**Signals:** {signals}")
|
| 900 |
+
|
| 901 |
+
quotes = report.get('key_quotes', '')
|
| 902 |
+
if quotes:
|
| 903 |
+
try:
|
| 904 |
+
quote_list = _json.loads(quotes) if isinstance(quotes, str) else quotes
|
| 905 |
+
if quote_list:
|
| 906 |
+
st.markdown("**Key Quotes:**")
|
| 907 |
+
for q in quote_list[:3]:
|
| 908 |
+
st.caption(f'> "{q}"')
|
| 909 |
+
except Exception:
|
| 910 |
+
pass
|
| 911 |
+
|
| 912 |
+
if report.get('document_url'):
|
| 913 |
+
st.markdown(f"[View on Companies House \u2192]({report['document_url']})")
|
| 914 |
+
st.divider()
|
| 915 |
+
else:
|
| 916 |
+
st.caption("No annual report signals")
|
| 917 |
+
|
| 918 |
+
# Sentiment tab
|
| 919 |
+
with detail_tabs[4]:
|
| 920 |
+
if dossier.sentiment_signals:
|
| 921 |
+
for sent in dossier.sentiment_signals:
|
| 922 |
+
overall = sent.get('overall_rating', 0)
|
| 923 |
+
date_badge = freshness_badge(sent.get('date'))
|
| 924 |
+
if overall and overall < 3.0:
|
| 925 |
+
rating_emoji = "\U0001f534"
|
| 926 |
+
elif overall and overall < 3.5:
|
| 927 |
+
rating_emoji = "\U0001f7e0"
|
| 928 |
+
elif overall and overall < 4.0:
|
| 929 |
+
rating_emoji = "\U0001f7e1"
|
| 930 |
+
else:
|
| 931 |
+
rating_emoji = "\U0001f7e2"
|
| 932 |
+
|
| 933 |
+
stars = "\u2605" * int(overall) + "\u2606" * (5 - int(overall)) if overall else "N/A"
|
| 934 |
+
st.markdown(f"**{rating_emoji} Overall: {overall}/5** {stars} (Score: {sent.get('sentiment_score', 0)}) {date_badge}", unsafe_allow_html=True)
|
| 935 |
+
|
| 936 |
+
sub_cols = st.columns(3)
|
| 937 |
+
mgmt = sent.get('management_rating')
|
| 938 |
+
culture = sent.get('culture_rating')
|
| 939 |
+
wl = sent.get('work_life_rating')
|
| 940 |
+
with sub_cols[0]:
|
| 941 |
+
if mgmt:
|
| 942 |
+
mgmt_emoji = "\U0001f534" if mgmt < 2.5 else "\U0001f7e0" if mgmt < 3.0 else "\U0001f7e1"
|
| 943 |
+
st.caption(f"{mgmt_emoji} Management: {mgmt}/5")
|
| 944 |
+
else:
|
| 945 |
+
st.caption("Management: N/A")
|
| 946 |
+
with sub_cols[1]:
|
| 947 |
+
if culture:
|
| 948 |
+
cult_emoji = "\U0001f534" if culture < 2.5 else "\U0001f7e0" if culture < 3.0 else "\U0001f7e1"
|
| 949 |
+
st.caption(f"{cult_emoji} Culture: {culture}/5")
|
| 950 |
+
else:
|
| 951 |
+
st.caption("Culture: N/A")
|
| 952 |
+
with sub_cols[2]:
|
| 953 |
+
if wl:
|
| 954 |
+
st.caption(f"Work/Life: {wl}/5")
|
| 955 |
+
else:
|
| 956 |
+
st.caption("Work/Life: N/A")
|
| 957 |
+
|
| 958 |
+
reviews = sent.get('review_count', 0)
|
| 959 |
+
if reviews:
|
| 960 |
+
st.caption(f"Based on {reviews} reviews")
|
| 961 |
+
if sent.get('signal_reason'):
|
| 962 |
+
st.info(sent['signal_reason'])
|
| 963 |
+
if sent.get('source_url'):
|
| 964 |
+
st.markdown(f"[View on Indeed \u2192]({sent['source_url']})")
|
| 965 |
+
st.divider()
|
| 966 |
+
else:
|
| 967 |
+
st.caption("No sentiment data")
|
| 968 |
+
|
| 969 |
+
# M&A tab
|
| 970 |
+
with detail_tabs[5]:
|
| 971 |
+
if dossier.pe_deals:
|
| 972 |
+
for deal in dossier.pe_deals:
|
| 973 |
+
is_pe = deal.get('is_pe_deal', 0) == 1
|
| 974 |
+
date_badge = freshness_badge(deal.get('date'))
|
| 975 |
+
if is_pe:
|
| 976 |
+
type_badge = "\U0001f7e3 PE Buyout"
|
| 977 |
+
elif deal.get('deal_type') == 'mbo':
|
| 978 |
+
type_badge = "\U0001f535 MBO"
|
| 979 |
+
elif deal.get('deal_type') == 'merger':
|
| 980 |
+
type_badge = "\U0001f7e4 Merger"
|
| 981 |
+
else:
|
| 982 |
+
type_badge = "\U0001f7e2 Trade Acquisition"
|
| 983 |
+
|
| 984 |
+
st.markdown(f"**{type_badge}** (Score: {deal.get('pe_score', 0)}) {date_badge}", unsafe_allow_html=True)
|
| 985 |
+
st.markdown(f"Acquirer: **{deal.get('acquirer_name', 'Unknown')}**")
|
| 986 |
+
|
| 987 |
+
info_cols = st.columns(2)
|
| 988 |
+
with info_cols[0]:
|
| 989 |
+
if deal.get('deal_date'):
|
| 990 |
+
st.caption(f"Deal date: {deal['deal_date'][:10]}")
|
| 991 |
+
if deal.get('deal_value'):
|
| 992 |
+
st.caption(f"Value: {deal['deal_value']}")
|
| 993 |
+
with info_cols[1]:
|
| 994 |
+
st.caption(f"Source: {deal.get('source', 'Unknown')}")
|
| 995 |
+
|
| 996 |
+
if deal.get('signal_reason'):
|
| 997 |
+
st.info(deal['signal_reason'][:150])
|
| 998 |
+
if deal.get('source_url'):
|
| 999 |
+
st.markdown(f"[View Source \u2192]({deal['source_url']})")
|
| 1000 |
+
st.divider()
|
| 1001 |
+
else:
|
| 1002 |
+
st.caption("No M&A signals")
|
| 1003 |
+
|
| 1004 |
+
# LinkedIn Intelligence tab
|
| 1005 |
+
with detail_tabs[6]:
|
| 1006 |
+
li_intel = getattr(dossier, 'linkedin_intel', [])
|
| 1007 |
+
if li_intel:
|
| 1008 |
+
company_score = dossier.overall_score or 0
|
| 1009 |
+
def _action_score(i):
|
| 1010 |
+
return (company_score // 2
|
| 1011 |
+
+ (20 if i.get('posts_about_transformation') else 0)
|
| 1012 |
+
+ (10 if i.get('contact_active') else 0)
|
| 1013 |
+
+ (10 if i.get('mutual_connections', 0) > 0 else 0))
|
| 1014 |
+
|
| 1015 |
+
sorted_intel = sorted(li_intel, key=_action_score, reverse=True)
|
| 1016 |
+
best = sorted_intel[0]
|
| 1017 |
+
best_via = best.get('colleague_name', '?')
|
| 1018 |
+
|
| 1019 |
+
act_now = sum(1 for i in li_intel if _action_score(i) >= 70)
|
| 1020 |
+
warm_count = sum(1 for i in li_intel if 50 <= _action_score(i) < 70)
|
| 1021 |
+
posting_count = sum(1 for i in li_intel if i.get('posts_about_transformation'))
|
| 1022 |
+
banner_parts = [f"**{len(li_intel)} contacts**"]
|
| 1023 |
+
if act_now:
|
| 1024 |
+
banner_parts.append(f"\U0001f534 {act_now} Act Now")
|
| 1025 |
+
if warm_count:
|
| 1026 |
+
banner_parts.append(f"\U0001f7e1 {warm_count} Warm")
|
| 1027 |
+
if posting_count:
|
| 1028 |
+
banner_parts.append(f"\U0001f4e2 {posting_count} posting about transformation")
|
| 1029 |
+
banner_parts.append(f"Best route: via **{best_via}**")
|
| 1030 |
+
st.markdown(" | ".join(banner_parts))
|
| 1031 |
+
|
| 1032 |
+
for intel in sorted_intel:
|
| 1033 |
+
a_score = _action_score(intel)
|
| 1034 |
+
contact_name = intel.get('contact_name', 'Unknown')
|
| 1035 |
+
contact_title = intel.get('contact_title', 'Unknown')
|
| 1036 |
+
colleague = intel.get('colleague_name', 'Unknown')
|
| 1037 |
+
date_badge = freshness_badge(intel.get('date'))
|
| 1038 |
+
|
| 1039 |
+
if a_score >= 70:
|
| 1040 |
+
border_color = "#d32f2f"
|
| 1041 |
+
urgency = "\U0001f534 ACT TODAY"
|
| 1042 |
+
elif a_score >= 50:
|
| 1043 |
+
border_color = "#f57c00"
|
| 1044 |
+
urgency = "\U0001f7e1 THIS WEEK"
|
| 1045 |
+
elif a_score >= 30:
|
| 1046 |
+
border_color = "#1976d2"
|
| 1047 |
+
urgency = "\U0001f535 WORTH A LOOK"
|
| 1048 |
+
else:
|
| 1049 |
+
border_color = "#9e9e9e"
|
| 1050 |
+
urgency = "\u26aa MONITOR"
|
| 1051 |
+
|
| 1052 |
+
badges = []
|
| 1053 |
+
if intel.get('posts_about_transformation'):
|
| 1054 |
+
badges.append("\U0001f4e2 Posting about transformation")
|
| 1055 |
+
if intel.get('contact_active'):
|
| 1056 |
+
badges.append("\u2705 Active")
|
| 1057 |
+
degree = intel.get('connection_degree', '?')
|
| 1058 |
+
badges.append(f"\U0001f517 {degree}\u00b0 via {colleague}")
|
| 1059 |
+
mutual = intel.get('mutual_connections', 0)
|
| 1060 |
+
if mutual:
|
| 1061 |
+
badges.append(f"\U0001f465 {mutual} mutual")
|
| 1062 |
+
badge_str = " \u00b7 ".join(badges)
|
| 1063 |
+
|
| 1064 |
+
route_parts = []
|
| 1065 |
+
route_parts.append(f"Ask <strong>{colleague}</strong> to introduce you to {contact_name.split()[0] if contact_name else 'them'}")
|
| 1066 |
+
if intel.get('posts_about_transformation'):
|
| 1067 |
+
route_parts.append("they're posting about transformation \u2014 perfect opener")
|
| 1068 |
+
if intel.get('contact_active'):
|
| 1069 |
+
route_parts.append("active on LinkedIn right now")
|
| 1070 |
+
route_msg = " \u2014 ".join(route_parts)
|
| 1071 |
+
|
| 1072 |
+
route_html = f"""
|
| 1073 |
+
<div style="background:#e3f2fd;border-left:4px solid #1565c0;padding:8px 12px;margin:8px 0;border-radius:4px;">
|
| 1074 |
+
<strong>YOUR ROUTE IN:</strong> {route_msg}
|
| 1075 |
+
</div>"""
|
| 1076 |
+
|
| 1077 |
+
card_html = f"""
|
| 1078 |
+
<div style="border-left:5px solid {border_color};padding:10px 14px;margin:8px 0;background:#fafafa;border-radius:6px;">
|
| 1079 |
+
<div style="display:flex;justify-content:space-between;align-items:center;">
|
| 1080 |
+
<span style="font-weight:700;font-size:0.85em;">{urgency}</span>
|
| 1081 |
+
<span style="font-size:0.85em;color:#555;">Action: {a_score} {date_badge}</span>
|
| 1082 |
+
</div>
|
| 1083 |
+
<div style="font-size:1.05em;margin:4px 0;"><strong>{contact_name}</strong> \u2014 {contact_title}</div>
|
| 1084 |
+
<div style="font-size:0.85em;color:#666;">{badge_str}</div>
|
| 1085 |
+
{route_html}
|
| 1086 |
+
</div>"""
|
| 1087 |
+
st.markdown(card_html, unsafe_allow_html=True)
|
| 1088 |
+
|
| 1089 |
+
if intel.get('posts_about_transformation'):
|
| 1090 |
+
st.success("This contact is posting about transformation \u2014 perfect conversation opener!")
|
| 1091 |
+
|
| 1092 |
+
btn_cols = st.columns([1, 1, 3])
|
| 1093 |
+
with btn_cols[0]:
|
| 1094 |
+
if intel.get('contact_url'):
|
| 1095 |
+
st.markdown(f"[View LinkedIn \u2192]({intel['contact_url']})")
|
| 1096 |
+
|
| 1097 |
+
st.divider()
|
| 1098 |
+
else:
|
| 1099 |
+
st.caption("No LinkedIn intelligence \u2014 run a hunt with LinkedIn Deep enabled")
|
| 1100 |
+
|
| 1101 |
+
# Network tab (optional)
|
| 1102 |
+
tab_idx = 7
|
| 1103 |
+
if show_network:
|
| 1104 |
+
with detail_tabs[tab_idx]:
|
| 1105 |
+
if dossier.network:
|
| 1106 |
+
for net in dossier.network:
|
| 1107 |
+
tier = net.get('tier', '')
|
| 1108 |
+
if tier == 'DIRECT HIT':
|
| 1109 |
+
emoji = "\U0001f3af"
|
| 1110 |
+
elif tier == 'SENIOR CONNECTION':
|
| 1111 |
+
emoji = "\u2b50"
|
| 1112 |
+
else:
|
| 1113 |
+
emoji = "\U0001f517"
|
| 1114 |
+
col1, col2 = st.columns([3, 1])
|
| 1115 |
+
with col1:
|
| 1116 |
+
st.markdown(f"**{emoji} {net.get('contact', 'Unknown')}**")
|
| 1117 |
+
st.caption(f"Position: {net.get('position', 'Unknown')} | Via: **{net.get('colleague', 'Unknown')}**")
|
| 1118 |
+
with col2:
|
| 1119 |
+
st.caption(f"Tier: {tier}")
|
| 1120 |
+
st.divider()
|
| 1121 |
+
else:
|
| 1122 |
+
st.caption("No network connections")
|
| 1123 |
+
tab_idx += 1
|
| 1124 |
+
|
| 1125 |
+
# Action tab (optional)
|
| 1126 |
+
if show_action:
|
| 1127 |
+
with detail_tabs[tab_idx]:
|
| 1128 |
+
if dossier.network and dossier.network_status != "Cold":
|
| 1129 |
+
draft_key = f"draft_{company_id_prefix}_{dossier.id}"
|
| 1130 |
+
|
| 1131 |
+
if st.button("\U0001f4e7 Draft Intro Email", key=f"btn_{draft_key}"):
|
| 1132 |
+
with st.spinner("Writing personalized email..."):
|
| 1133 |
+
best_net = dossier.network[0] if dossier.network else {}
|
| 1134 |
+
draft = draft_warm_intro_email(
|
| 1135 |
+
colleague_name=best_net.get('colleague', 'Your colleague'),
|
| 1136 |
+
contact_name=best_net.get('contact', 'Contact'),
|
| 1137 |
+
contact_company=dossier.name,
|
| 1138 |
+
contact_position=best_net.get('position', 'the team')
|
| 1139 |
+
)
|
| 1140 |
+
st.session_state[draft_key] = draft
|
| 1141 |
+
st.rerun()
|
| 1142 |
+
|
| 1143 |
+
if draft_key in st.session_state:
|
| 1144 |
+
draft = st.session_state[draft_key]
|
| 1145 |
+
st.markdown(f"**Subject:** {draft.subject}")
|
| 1146 |
+
copyable = get_copyable_email(draft)
|
| 1147 |
+
st.code(copyable['full_text'], language=None)
|
| 1148 |
+
if draft.linkedin_version:
|
| 1149 |
+
st.markdown("**LinkedIn Version:**")
|
| 1150 |
+
st.code(draft.linkedin_version, language=None)
|
| 1151 |
+
st.caption("Copy the above for email or LinkedIn")
|
| 1152 |
+
if st.button("\u274c Close", key=f"close_{draft_key}"):
|
| 1153 |
+
del st.session_state[draft_key]
|
| 1154 |
+
st.rerun()
|
| 1155 |
+
else:
|
| 1156 |
+
st.caption("No network connection \u2014 cold outreach required")
|
| 1157 |
+
st.info("Consider finding a mutual connection before reaching out.")
|