File size: 861 Bytes
9b7e9d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
"""Example: load the model in this folder and predict.

Run: python example.py
The flow needs the decision-model package (see the How to use section of
README.md).
"""

import json
from pathlib import Path

from decision_model.model import DecisionModel

HERE = Path(__file__).resolve().parent

REQUEST = {
    "state": "Refactor the auth module and add tests. The repo has 40 files.",
    "preferences": {"cost": "low cost before speed"},
    "questions": [
        {"id": "model", "type": "choice", "instructions": "Which model must handle this request?",
         "criteria": {"haiku": "Short and simple tasks", "sonnet": "Normal coding tasks", "opus": "Long or difficult tasks"}},
    ],
}


def main():
    model = DecisionModel.load(HERE)
    result = model.predict(REQUEST)
    print(json.dumps(result, indent=2))


if __name__ == "__main__":
    main()