Download examples/quickstart.py from Agnosia-Piko/piko: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/Agnosia-Piko/piko/resolve/main/examples/quickstart.py
- Command line
-
hf download hf://Agnosia-Piko/piko/examples/quickstart.py
-
curl -L -o quickstart.py https://huggingface.co/Agnosia-Piko/piko/resolve/main/examples/quickstart.py
1.36 kB
| """Three closed forms, one wire — choice, noul, score. | |
| python examples/quickstart.py # against the hosted endpoint | |
| PIKO_BASE_URL=http://127.0.0.1:8000/v1 python examples/quickstart.py # against serve.sh | |
| """ | |
| import os | |
| import sys | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) | |
| from piko import Piko # noqa: E402 | |
| def main(): | |
| piko = Piko() | |
| # 1. choice — a closed menu of named options. | |
| r = piko.choice( | |
| state="The minister announced a plan on Tuesday.", | |
| question="event type", | |
| options=["ANNOUNCE", "MEET", "VOTE"], | |
| ) | |
| print("choice :", r.explain()) | |
| print(" probabilities:", {k: round(v, 4) for k, v in zip(r.options, r.probabilities)}) | |
| print(" letter kept too:", r.letter, "| cost:", r.cost["total_cost_usd"], r.cost["currency"]) | |
| # 2. noul — a boolean, any language, the two options the caller declares. | |
| b = piko.noul("The minister announced a plan.", "is this about policy?") | |
| print("noul :", b.explain(), "->", b.value) | |
| # 3. score — a 1..5 scale; the expectation is the graded answer. | |
| s = piko.score("The minister announced a plan with three named measures.", "how concrete is it?", 5) | |
| print("score :", s.explain(), "->", s.value, "E =", round(s.expectation, 2)) | |
| if __name__ == "__main__": | |
| main() | |