File size: 1,166 Bytes
4dd34e4
 
7abb8fd
 
 
4dd34e4
 
 
 
 
7abb8fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os

import httpx
import json

from dotenv import load_dotenv
load_dotenv()

API_KEY = os.getenv("API_KEY")

URL = "http://localhost:8000/v1/discover"

payload = {
    "topic": "deepseek-v3 optimization",
    "difficulty": 4,
    "max_results": 5
}

headers = {
    "X-API-Key": API_KEY,
    "Content-Type": "application/json"
}

print(f"🚀 Sending request for: {payload['topic']}...")

with httpx.Client(timeout=60.0) as client:
    response = client.post(URL, json=payload, headers=headers)
    
    if response.status_code == 200:
        data = response.json()
        print(f"\n✅ Success! Latency: {data.get('processing_time_ms')}ms | Cache: {data.get('cache_hit')}")
        print("-" * 50)
        
        for i, src in enumerate(data.get("sources", []), 1):
            decay = src.get("decay_report", {})
            print(f"[{i}] {src['title'][:60]}")
            print(f"    Platform: {src['source_platform']} | Quality: {src['quality_score']}")
            print(f"    Freshness: {decay.get('label')} ({decay.get('decay_score')} decay)")
            print("-" * 50)
    else:
        print(f"❌ Error {response.status_code}: {response.text}")