‹ BackHN Continuity

Thread

Jev in 25 Lines of Python

691 points · 212 comments · bashbjorn

  1. 0123456789ABCDE · · focus · HN ↗
    this is such a trivial thing to do in DSPY, no one bothered to give it a name…

    here's 7 lines

      import os
      import dspy
    
      lm = dspy.LM("openrouter/z-ai/glm-5.3-flash", api_key=os.environ["OPENROUTER_API_KEY"])
      jev = dspy.Predict('email:str -> choice:Literal["Legitimate", "Spam", "Phishing"]')
      email = "Payroll asks for your password on a non-company sign-in page."
      pred = jev(email=email, lm=lm)
      print(pred.choice)
    
    there are other options, obviously. you can choose to give it some tools, maybe some reasoning stage before picking a choice, and that's on top of the "reasoning" the llm model already does api side
    1. amai · · focus · HN ↗
      What about the probabilities?
      1. 0123456789ABCDE · · focus · HN ↗
        so you can pick the choice with the highest probability?

        the example uses an external api, and i don't think they return probabilities from those anyway.

    2. 0123456789ABCDE · · focus · HN ↗
      after looking closer at the typesafe's jev, i want to point out that i misunderstood the significance of this jev model

      it is the latency that makes it significant

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.