import json
import os
from pathlib import Path
import httpx

request = {
    "input": {
        "question": "A recipe needs 250 g of flour per loaf. How much flour is needed for 3 loaves?",
        "responses": {
            "A": "750 g, because 3 × 250 g = 750 g.",
            "B": "500 g, because 250 g + 250 g = 500 g.",
            "C": "0.75 kg, because 3 × 0.25 kg = 0.75 kg.",
        },
    },
    "schema": json.loads(Path("probabilities.schema.json").read_text(encoding="utf-8")),
}
with httpx.Client(
    base_url="https://api.blatent.ai",
    headers={"Authorization": f"Bearer {os.environ['BLATENT_API_KEY']}"},
    timeout=195,
) as client:
    response = client.post("/v1/resolve", json=request)
    response.raise_for_status()
    print(json.dumps(response.json()["probabilities"]))
