File size: 904 Bytes
31e8d5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
35
36
37
38
39
"""
example.py

Minimal usage example.
"""

from hv_router import HVRouter


def main():
    router = HVRouter.load("router_model")

    print("Single predictions:")
    for q in [
        "what is the weather today",
        "remind me to buy milk",
        "play some jazz",
        "how do i get to the airport",
        "transfer money to savings",
    ]:
        print(f"  {q:<35} -> {router.route(q)}")

    print()
    print("Top-3 with confidence:")
    for q in ["draft an email to sarah", "what time is it"]:
        print(f"  {q}")
        for label, conf in router.route_topk(q, k=3):
            print(f"    {label:<14} {conf:.3f}")

    print()
    print("Batch:")
    queries = ["hello", "what time is it", "play jazz", "tell me a joke"]
    preds = router.route_batch(queries)
    for q, p in zip(queries, preds):
        print(f"  {q:<20} -> {p}")


if __name__ == "__main__":
    main()