File size: 1,204 Bytes
8ae71a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | """Run from any directory after installing the downloaded model's runtime."""
import argparse
import json
from pathlib import Path
from jevlike import SystemOne, Choice, Score, Noul
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--model-dir', type=Path, default=Path(__file__).resolve().parents[1])
parser.add_argument('--device', default='cuda', choices=['cuda', 'cpu'])
args = parser.parse_args()
model = SystemOne.load(str(args.model_dir), device=args.device, long_state='chunk')
questions = {
'team': Choice('Which team should handle this request?', {
'billing': 'payments, invoices, refunds',
'technical': 'bugs, errors, broken software',
'other': 'another kind of request',
}),
'urgency': Score('How urgent is this request?', ['low', 'normal', 'urgent']),
'refund': Noul('The customer explicitly requests a refund.'),
}
state = json.dumps({'message': 'I was charged twice. Please refund the duplicate payment.'})
result = model.predict(state, questions)
print(json.dumps(result, indent=2, allow_nan=False))
if __name__ == '__main__':
main()
|