File size: 2,461 Bytes
bee2ada | 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import httpx
import asyncio
import json
async def test_guvi_api():
url = "https://avinashanalytics-sentinel-scam-honeypo.hf.space/api/guvi/analyze"
headers = {
"x-api-key": "GUVI_HACKATHON_V2",
"Content-Type": "application/json"
}
# 1. First Message
payload1 = {
"sessionId": "local-repro-123",
"message": {
"sender": "scammer",
"text": "Hello, your bank account is suspended. Update KYC at http://fake.com",
"timestamp": "2026-01-28T10:15:30Z"
},
"conversationHistory": [],
"metadata": {"channel": "SMS"}
}
print("\n[Test 1] Sending First Message...")
async with httpx.AsyncClient(timeout=30.0) as client:
try:
resp1 = await client.post(url, json=payload1, headers=headers)
print(f"Status: {resp1.status_code}")
print(f"Response: {json.dumps(resp1.json(), indent=2)}")
if resp1.status_code != 200:
return
# 2. Second Message (Follow-up)
payload2 = {
"sessionId": "local-repro-123",
"message": {
"sender": "scammer",
"text": "Please provide your UPI ID to verify.",
"timestamp": "2026-01-28T10:17:10Z"
},
"conversationHistory": [
{
"sender": "scammer",
"text": "Hello, your bank account is suspended. Update KYC at http://fake.com",
"timestamp": "2026-01-28T10:15:30Z"
},
{
"sender": "user",
"text": "Why is it suspended?",
"timestamp": "2026-01-28T10:16:10Z"
}
],
"metadata": {"channel": "SMS"}
}
print("\n[Test 2] Sending Second Message (with History)...")
resp2 = await client.post(url, json=payload2, headers=headers)
print(f"Status: {resp2.status_code}")
print(f"Response: {json.dumps(resp2.json(), indent=2)}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
# Ensure server is running before executing this
# uvicorn app.main:app --host 0.0.0.0 --port 8000
asyncio.run(test_guvi_api())
|