""" 🔍 SentrySearch - Threat Intelligence Profile Generator """ import gradio as gr from src.core.threat_intel_tool_cached import ThreatIntelToolCached from src.core.markdown_generator import generate_markdown def generate_threat_profile(api_key, tool_name, enable_quality_control, progress=gr.Progress()): """Generate threat intelligence profile using original implementation""" if not api_key.strip(): return "❌ Please enter your Anthropic API key", None if not tool_name.strip(): return "❌ Please enter a tool name", None try: # Initialize the threat intelligence tool with the API key and tracing enabled import os trace_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data", "traces") os.makedirs(trace_dir, exist_ok=True) tool = ThreatIntelToolCached(api_key, enable_tracing=True, trace_export_dir=trace_dir) tool.enable_quality_control = enable_quality_control # Generate threat intelligence progress(0.1, "🔄 Initializing threat intelligence generation...") threat_data = tool.get_threat_intelligence( tool_name, progress_callback=lambda p, msg: progress(p, msg) ) # Generate markdown progress(0.98, "📝 Generating markdown report...") markdown_content = generate_markdown(threat_data) # Extract quality assessment for display quality_data = None if '_quality_assessment' in threat_data: quality_data = threat_data['_quality_assessment'] progress(1.0, "✅ Threat intelligence profile generated successfully!") return markdown_content, quality_data except Exception as e: error_msg = f"Error generating profile: {str(e)}" progress(1.0, f"❌ {error_msg}") return error_msg, None def create_ui(): """Main function to launch the application""" print("🚀 Starting SentrySearch - Threat Intelligence Profile Generator...") print("📌 Make sure you have your Anthropic API key ready!") print("🌐 Opening web interface...") with gr.Blocks(title="SentrySearch: AI-Powered Threat Intelligence", theme=gr.themes.Soft()) as interface: # Header section gr.HTML("""
Comprehensive threat analysis and intelligence gathering with quality validation