hv-router-v1 / example.py
zeechimp's picture
Create example.py
31e8d5a verified
Raw History Blame Contribute Delete
904 Bytes
"""
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()