from typing import Dict, Any, List
def format_verification_blocks(verification_result: Dict[str, Any]) -> List[Dict[str, Any]]:
"""Format verification result as Slack blocks."""
verdict = verification_result.get('verdict', 'UNKNOWN')
confidence = verification_result.get('confidence', 0)
summary = verification_result.get('summary', 'No summary available')
# Color based on verdict
color_map = {
'TRUE': '#36a64f', # Green
'FALSE': '#ff0000', # Red
'PARTIALLY_TRUE': '#ff9900', # Orange
'INCONCLUSIVE': '#808080' # Gray
}
color = color_map.get(verdict, '#808080')
# Emoji based on verdict
emoji_map = {
'TRUE': '✅',
'FALSE': '❌',
'PARTIALLY_TRUE': '⚠️',
'INCONCLUSIVE': '❓'
}
emoji = emoji_map.get(verdict, '❓')
blocks = [
{
"type": "header",
"text": {
"type": "plain_text",
"text": f"{emoji} Verification Result: {verdict}"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": f"*Confidence:*\n{confidence:.1f}%"
},
{
"type": "mrkdwn",
"text": f"*Verdict:*\n{verdict}"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": f"*Summary:*\n{summary}"
}
}
]
# Add evidence if available
evidence = verification_result.get('evidence', [])
if evidence:
evidence_text = "\n".join([
f"• {e.get('message', 'No details')}"
for e in evidence[:5] # Limit to 5 items
])
blocks.append({
"type": "section",
"text": {
"type": "mrkdwn",
"text": f"*Evidence:*\n{evidence_text}"
}
})
# Add context
blocks.append({
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": f"Verification ID: `{verification_result.get('verification_id', 'N/A')}`"
}
]
})
return blocks