mirror of
https://github.com/hanzoai/kai.git
synced 2026-10-17 11:18:06 +00:00
The Python and TypeScript examples imported a client that hanzoai does not ship: `from hanzoai import Hanzo` and `import Hanzo from 'hanzoai'` both fail on 8.5.704, so none of them ran. They now call AiApi.post_decisions / postDecisions, which builds every question shape the cookbook uses (choice with object or list criteria, score, noul), and package.json and requirements.txt pin the version that was checked. The noul examples read action.act_probability, which the API does not return; they print P(true) only. A failed TypeScript call now rethrows only its HTTP status and body, because the axios error holds the request's Authorization header and an uncaught one prints it. The raw HTTP clients drop model ids the API refuses and exit non-zero on failure. Co-authored-by: Hanzo Dev <[email protected]>
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
import os
|
|
|
|
from hanzoai.cloud import ApiClient, Configuration
|
|
from hanzoai.cloud.api import AiApi
|
|
from hanzoai.cloud.models.ai_decisions_request import AiDecisionsRequest
|
|
|
|
ai = AiApi(ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"])))
|
|
|
|
decision = ai.post_decisions(AiDecisionsRequest.from_dict({
|
|
"model": os.environ.get("KAI_MODEL", "kai"), # or "typesafe/jev-1.13"
|
|
"state": "Pull Request #412 changes 1,200 lines across core cryptography and authentication middleware.",
|
|
"questions": {
|
|
"review_depth": {
|
|
"type": "score",
|
|
"instructions": "Determine required code review rigor",
|
|
"criteria": [
|
|
"level 1: automated linter pass only",
|
|
"level 2: single peer review",
|
|
"level 3: senior engineer deep dive",
|
|
"level 4: full security audit and pen-test",
|
|
],
|
|
}
|
|
},
|
|
}))
|
|
|
|
ans = decision.answers["review_depth"]
|
|
print(f"Model: {decision.model}")
|
|
print(f"Expected Score Level: {ans.score:.2f}")
|
|
print(f"Confidence: {ans.confidence:.4f}")
|
|
for level, prob in ans.probabilities.items():
|
|
print(f" - {ans.legend[level]}: {prob * 100:.2f}%")
|