import os
import requests
response = requests.post(
"https://api.swarms.world/v1/decision/completions",
headers={"x-api-key": os.environ["SWARMS_API_KEY"]},
json={
"model_name": "jev-latest",
"state": "Checkout has been failing for every customer since 9am. We are losing orders.",
"questions": {
"is_urgent": {"type": "noul", "instructions": "Is this urgent?"},
"team": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"payments": "Checkout, billing, refunds",
"infra": "Outages, latency, servers",
"support": None,
},
},
"severity": {
"type": "score",
"instructions": "How severe is the impact?",
"criteria": ["No impact", "Minor", "Major", "Critical"],
},
},
},
timeout=60,
)
response.raise_for_status()
result = response.json()
answers = result["answers"]
print("Urgent:", answers["is_urgent"]["noul"])
print("Team:", answers["team"]["choice"], "confidence", answers["team"]["confidence"])
print("Severity:", answers["severity"]["legend"][str(round(answers["severity"]["score"]))])
print("Answered by:", result["model"])
print("Cost:", result["usage"]["total_cost"])