import os
from openai import OpenAI
client = OpenAI(base_url="https://api.levanto.ai/v1", api_key=os.environ["LEVANTO_API_KEY"])
decision = client.decisions.create(
model="sage-latest",
input="I was charged twice for my order. Please refund the duplicate today.",
questions=[
{"type": "predicate", "name": "refund", "instructions": "The customer asks for money back."},
{
"type": "choice",
"name": "team",
"instructions": "Which team should handle this?",
"choices": [{"value": "billing"}, {"value": "technical"}, {"value": "shipping"}],
},
{
"type": "score",
"name": "urgency",
"instructions": "How urgent is it?",
"levels": [{"label": "Can wait"}, {"label": "This week"}, {"label": "Today"}],
},
],
)
refund, team, urgency = decision.answers
refund.probability # 0.95
team.choice # "billing"
urgency.score # 1.99, from 0 to 2