Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465"""Time the endpoint through the official SDK: one cold request, then warm ones.
just smoke [app]"""
import jsonimport osimport statisticsimport time
from typesafe_sdk import TypeSafeClient
STATE = { "from": "user@acme.com", "subject": "Duplicate charge on invoice #4411", "body": "Hi, we were billed twice for March. Please refund the duplicate today or we will cancel our plan.",}QUESTIONS = { "department": { "type": "choice", "instructions": "Which department should handle this request?", "criteria": { "billing": "invoices, payments, refunds", "technical": "bugs, outages, system errors", "sales": "pricing, new contracts", "other": "everything else", }, }, "urgency": { "type": "score", "instructions": "How urgent is this request?", "criteria": ["not urgent", "soon", "critical deadline or blocking issue"], }, "churn_risk": { "type": "noul", "instructions": "Does the user threaten to cancel or leave?", },}
def main() -> None: client = TypeSafeClient( api_key=os.environ["SYSTEMONE_API_KEY"], base_url=os.environ["SYSTEMONE_URL"], model="kev-latest", timeout=600, ) with client: t = time.perf_counter() first = client.system_one(state=STATE, questions=QUESTIONS) cold = time.perf_counter() - t warm = [] for _ in range(5): t = time.perf_counter() client.system_one(state=STATE, questions=QUESTIONS) warm.append(time.perf_counter() - t) print(json.dumps(first.model_dump(), indent=1, default=str)) print( f"first request {cold:.1f}s, warm median {statistics.median(warm) * 1000:.0f}ms, warm max {max(warm) * 1000:.0f}ms" )
if __name__ == "__main__": main()