mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
22 lines
796 B
Python
22 lines
796 B
Python
from hanzo_kai import AuthenticationError, BadRequestError, Kai, Noul
|
|
|
|
QUESTIONS = {
|
|
"refund": Noul(
|
|
instructions="The customer asks for money back.",
|
|
criteria={"true": "the ticket asks for a refund", "false": "the ticket asks for something else"},
|
|
)
|
|
}
|
|
|
|
with Kai() as kai:
|
|
try:
|
|
kai.decide("Please refund the duplicate charge.", QUESTIONS, model="no-such-model")
|
|
except BadRequestError as error:
|
|
print(type(error).__name__, error.status, error.code, error.message)
|
|
print(error.request_id is not None, error.body)
|
|
|
|
with Kai(api_key="sk-no-such-key") as kai:
|
|
try:
|
|
kai.decide("Please refund the duplicate charge.", QUESTIONS)
|
|
except AuthenticationError as error:
|
|
print(type(error).__name__, error.status, error.message)
|