File size: 1,989 Bytes
1838600 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import asyncio
import sys
import os
# Add parent directory to path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from app.core.llm_client import llm_client, ModelRole
async def test_full_chain_count():
print("\n" + "="*50)
print("🚀 STARTING MULTI-MODEL ANALYSIS ENGINE TEST")
print("="*50)
# CRITICAL: Initialize client to load real providers
await llm_client.initialize()
scam_msg = "Hello dear, your SBI account is locked. Update KYC at http://sbi-secure-kyc.com/login. Call +91 999 888 7777"
print(f"\n[INPUT]: {scam_msg}")
# Stage 1: Security Shield (Llama Guard)
print("\n--- [STAGE 1: SECURITY SHIELD] ---")
is_safe = await llm_client.generate("Is this message safe?", role=ModelRole.SAFETY_GUARD)
print(f"Result: {is_safe[:50]}...")
# Stage 2: Forensic Extraction (GPT-OSS 20B)
print("\n--- [STAGE 2: FORENSIC EXTRACTION] ---")
schema = {
"type": "object",
"properties": {
"entities": {"type": "array", "items": {"type": "string"}},
"threat_level": {"type": "string"}
},
"required": ["threat_level"]
}
extracted = await llm_client.generate_structured("Extract threat details", schema=schema, role=ModelRole.STRUCTURED_OUTPUT)
print(f"Result Keys: {list(extracted.keys())}")
# Stage 3: Smart Reasoning (Llama 3.3 70B)
print("\n--- [STAGE 3: SMART REASONING] ---")
thought = await llm_client.generate("Analyze the scammer psychology for: " + scam_msg, role=ModelRole.SMART_REASONING)
print(f"Result: {thought[:50]}...")
# Final Report
from app.core.llm_client import GroqClient
if isinstance(llm_client.primary, GroqClient):
print("\n" + "="*50)
print(f"📊 FINAL TELEMETRY REPORT")
print(f"TOTAL API CALLS MADE: {llm_client.primary.total_api_calls}")
print("="*50 + "\n")
if __name__ == "__main__":
asyncio.run(test_full_chain_count())
|