| """Test script for the running FastAPI server — NOT run directly. |
| |
| This does not start the server itself. Run the server first, in one terminal: |
| |
| uvicorn app.api.main:app --reload --port 8000 |
| |
| Then, in a SECOND terminal (same environment, same GROQ_API_KEY/S2_API_KEY), |
| run this script: |
| |
| python -m tests.test_api_live |
| """ |
|
|
| import httpx |
|
|
| SAMPLE_TEXT = """ |
| Body: |
| Attention mechanisms allow transformer models to capture long-range |
| dependencies in sequential data without relying on recurrence [1]. |
| |
| References: |
| [1] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, |
| A. N., Kaiser, L., & Polosukhin, I. (2017). Attention is all you need. |
| In Advances in Neural Information Processing Systems (NeurIPS 2017). |
| """ |
|
|
|
|
| def main(): |
| print("Checking /health ...") |
| health = httpx.get("http://localhost:8000/health", timeout=10.0) |
| print(" ", health.status_code, health.json()) |
| print() |
|
|
| print("Calling /audit (this takes a while — real LLM + retrieval + NLI calls) ...") |
| resp = httpx.post( |
| "http://localhost:8000/audit", |
| json={"text": SAMPLE_TEXT}, |
| timeout=120.0, |
| ) |
| print(" status:", resp.status_code) |
| report = resp.json() |
| print(" n_claims:", report.get("n_claims")) |
| print(" initial_agreement_rate:", report.get("initial_agreement_rate")) |
| print(" n_escalated:", report.get("n_escalated")) |
| for i, c in enumerate(report.get("claims", []), 1): |
| print(f" claim {i} final_verdict:", c.get("final_verdict")) |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|