File size: 1,121 Bytes
6438a35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Run the self-contained local folder; optional repo ID after publication."""
import argparse
import json
from pathlib import Path
from transformers import AutoModel

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--model', default=str(Path(__file__).resolve().parent))
    parser.add_argument('--device', default='cuda:0')
    args = parser.parse_args()
    model = AutoModel.from_pretrained(args.model, trust_remote_code=True, device=args.device)
    result = model.decide('The ticket category is security. Routing rule: security goes to Sentinel.', {
        'route': {'type': 'choice', 'instructions': 'Choose the required tool.',
                  'criteria': {'ledger': 'Ledger', 'sentinel': 'Sentinel'}},
        'security': {'type': 'noul', 'instructions': 'Is this a security ticket?',
                     'criteria': {'false': 'No', 'true': 'Yes'}},
        'grade': {'type': 'score', 'instructions': 'Security tickets have high priority.',
                  'criteria': ['Low', 'Medium', 'High']}
    })
    print(json.dumps(result, ensure_ascii=False, indent=2))