File size: 1,088 Bytes
417cf26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Run one request through Sarvam-Prism. Downloads the model (~106 GB) on first use when given the repo id.
    python example.py                      # from the Hugging Face Hub
    python example.py /path/to/sarvam-prism  # from a local copy
"""
import json, sys
from prism import Prism

model = Prism.from_pretrained(sys.argv[1] if len(sys.argv) > 1 else "sarvamai/prism")
answers = model.decide(
    state={"ticket": "My card was charged twice for the same order and I still haven't got a refund."},
    questions={
        "team": {"type": "choice", "instructions": "Which team should handle this ticket?",
                 "criteria": {"billing": "payments, charges and refunds", "tech": "app or website problems",
                              "delivery": "shipping and order status"}},
        "urgent": {"type": "yes_no", "instructions": "Does this need a reply within the hour?"},
        "anger": {"type": "score", "instructions": "How upset is the customer?",
                  "criteria": ["calm", "annoyed", "angry", "furious"]},
    })
print(json.dumps(answers, indent=2))