The safety scoring algorithm has been enhanced with a new AI-powered context analysis service that integrates real-time geopolitical data for more accurate risk assessments.
> impact
We've shipped a new backend service that uses an LLM to provide real-time context to our safety scoring algorithm. This service periodically ingests data from news APIs and official RSS feeds, feeding headlines and summaries to an LLM. The model classifies the current geopolitical situation as 'escalating', 'de-escalating', or 'stable'. The main scoring function now fetches this classification and uses it as a significant modifier, ensuring the final safety score reflects the most current external events.
The previous scoring model was purely reactive, relying solely on historical alert data like timing, frequency, and density. This approach had a critical blind spot: it lacked real-world context. It could not differentiate between a temporary lull during a major conflict and a genuine de-escalation following a ceasefire. This limitation could result in a safety score that was slow to react to rapidly changing conditions, potentially providing a false sense of security or undue alarm.
This enhancement makes our safety score significantly more robust and predictive. By integrating AI-driven analysis of the current geopolitical climate, the score is no longer just a lagging indicator of past events. It is now a context-aware assessment that adjusts the risk level based on developing situations. For users, this means a more nuanced and reliable safety indicator that empowers them to make better-informed decisions based on a holistic view of the situation.
> Try this now
try this
# Navigate to `src/lib/scoring.ts` to see how AI context modifies the safety score.
# The `calculateSafetyScore` function now integrates real-time geopolitical analysis.
// 1. We start by fetching the original score based on historical alert data.
const historicalScore = calculateHistoricalScore(alertData);
// 2. We then call our new AI service to get the current geopolitical context.
// This service continuously analyzes news feeds and official statements.
const geopoliticalContext = await getGeopoliticalContext(); // Returns 'escalating', 'de-escalating', or 'stable'
// 3. Finally, we apply a modifier based on the AI-derived context.
let finalScore = historicalScore;
switch (geopoliticalContext) {
case 'escalating':
// If the situation is escalating, we significantly increase the risk (lower the safety score).
finalScore *= 0.7;
break;
case 'de-escalating':
// If things are calming down, we cautiously improve the safety score.
finalScore *= 1.15;
break;
case 'stable':
// If stable, the historical score is considered a reliable indicator.
finalScore *= 1.0;
break;
}
// 4. The function returns the context-aware final score.
return Math.max(0, Math.min(100, finalScore)); // Clamp score between 0 and 100