Releases: sitehostnz/sthai-py
Releases · sitehostnz/sthai-py
Release list
v1.2.0
Changed
- Breaking:
embed()andbatch_embed()now return the fullEmbeddingResponseinstead of bare vectors, on both clients. Get the vectors viaoutput()(one per input, sooutput()[0]forembed()), and token usage viausage()- previously usage on embedding calls was unrecoverable. - Breaking:
rerank()now returns the fullRerankResponseinstead of alist[RerankResult], on both clients. Get the sorted results viaoutput()(orresults), and token usage viausage(). - Breaking:
EmbeddingResponse.output()now returns validated float vectors (list[list[float]]) and raisessthai.ResponseErrorfor non-float encoding formats or when the response carries no embeddings. The raw entries stay available ondata.
v1.1.0
[1.1.0]
Added
- Session pin accessors on both clients:
session_pin()returns the pin in use (constructor-passed,auto_session-generated, or set later;Nonewhen unpinned),set_session_pin()pins subsequent requests to a session (Noneunpins), andnew_session()switches to a freshly generated pin and returns it. - Chat history accessors:
history()returns the stored turns as role/content dicts, oldest first, andset_history()replaces them, for restoring a persisted conversation. Invalid turns raiseInputError. write_history()andset_write_history()read and toggle turn recording after construction. Turning recording off keeps the stored history and still sends it; only recording stops.history_usage()returns summed token usage across the calls that built the stored history. The tally resets withclear_history()andset_history(). Each call resends the conversation so far, so input tokens count what the server processed (as billed), not unique tokens.- Added a package-specific exception hierarchy in
sthai.exceptions, exported from the top-level package:SthaiError(root),InputError,TransportError,APIStatusErrorwithClientError(4xx) andAPIError(5xx), andResponseErrorwithResponseParseError. CatchingSthaiErroris enough to handle anything the client raises. - HTTP error responses now parse the server's error body:
ClientErrorandAPIErrorcarrystatus_code,server_message,error_typeand the rawresponse.