kodama-core / examples /quickstart.py
Cem13's picture
Expand usage, use cases, performance details, and runnable examples
8ae71a4 verified
Raw History Blame Contribute Delete
1.2 kB
"""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()