Spaces:
Running
Running
| 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}") |