File size: 1,543 Bytes
5db2259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""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()