hyf

Context-aware query service for Radroots
git clone https://radroots.dev/git/hyf.git
Log | Files | Refs | README | LICENSE

eval_jev.mojo (1754B)


      1 from std.os import getenv
      2 
      3 from hyf_provider.jev_client import post_jev_systemone
      4 from hyf_runtime.jev_composition import typesafe_api_key_present
      5 from hyf_core.normalization.candidates import discover_candidates
      6 from std.collections import List
      7 from json import loads, dumps
      8 
      9 
     10 comptime BASE_URL = "https://api.typesafe.ai"
     11 comptime MODEL = "jev-1.13.0"
     12 
     13 
     14 def main() raises:
     15     if getenv("HYF_EVAL_AUTHORIZED", "") != "1":
     16         print(
     17             "BLOCKED: raw-input semantic evaluation is opt-in; set "
     18             "HYF_EVAL_AUTHORIZED=1 with an authorized reviewed corpus."
     19         )
     20         raise Error("eval_not_authorized")
     21     if not typesafe_api_key_present():
     22         print(
     23             "BLOCKED: evaluation requires TYPESAFE_API_KEY; no external call "
     24             "was made."
     25         )
     26         raise Error("live_jev_prerequisite_missing")
     27 
     28     # Raw-input candidate discovery runs locally first.
     29     var products = List[String]()
     30     products.append("roma tomatoes")
     31     var units = List[String]()
     32     units.append("lb")
     33     var dates = List[String]()
     34     dates.append("friday")
     35     var candidates = discover_candidates(
     36         "Got about 80 lb of Roma tomatoes. Can deliver Friday.",
     37         products,
     38         units,
     39         dates,
     40     )
     41     var body = loads(
     42         '{"model":"'
     43         + MODEL
     44         + '","state":"Got about 80 lb of Roma tomatoes. Can deliver Friday.",'
     45         + '"questions":{"supply_status":{"type":"choice","instructions":'
     46         + '"Is produce reported available?","criteria":{"offered":"yes",'
     47         + '"unclear":"no"}}}}'
     48     )
     49     var outcome = post_jev_systemone(BASE_URL, body, 15000)
     50     print("discovered_candidates=" + String(len(candidates)))
     51     print("provider_status=" + String(outcome.status))