typesafer 0.2.0
New features
as_tibble()turns ats_responseinto a one-row tibble with the same answer columns assystem_one_df(), includingprobs = TRUE.system_one_df()andas_tibble()gaininclude_usageto addinput_tokensandoutput_tokenscolumns.New
ts_default_model()reads theTYPESAFE_DEFAULT_MODELenvironment variable, matching the Python SDK, and is now the defaultmodelforsystem_one()andsystem_one_df(). It falls back to"jev-latest".system_one(),system_one_df(), andts_models()gainmax_triesandtimeoutarguments to control retries and the per-attempt timeout for a single call, like the Python SDK’s per-call retry and timeout overrides.ts_responseobjects keep the parsed response body in@json, so fields and answer types typesafer doesn’t model yet are still reachable.
Bug fixes
-
system_one()answers now follow the order the questions were asked in, rather than the order the API returns them.
typesafer 0.1.0
First release of typesafer, an unofficial R client for the TypeSafe System One API.
Questions
-
ts_noul(),ts_choice(), andts_score()create typed questions as S7 classes, validated before any request is sent.- Choice criteria accept a bare character vector of options or a named vector or list of descriptions. Options without a description are sent as JSON
null. A choice can have at most 255 options. - Score criteria take 2 to 10 ordered levels and are always sent as a JSON array.
- Noul criteria optionally describe what
trueandfalsemean. - Instructions, options, and levels accept strings or structured lists.
- Choice criteria accept a bare character vector of options or a named vector or list of descriptions. Options without a description are sent as JSON
Asking questions
-
system_one()asks any number of named questions about one state (a string or structured data) in a single request. It returns ats_responsewith typed answers, the model that answered, and token usage. -
system_one_df()asks the same questions about every row of a data frame, with one request per row, run in parallel withhttr2::req_perform_parallel(). It adds a probability column for each noul, a value and_confidencecolumn for each choice and score, and optional_probslist-columns.on_error = "continue"keeps the rows that succeeded when others fail. - Score answers stay on the API’s 0-based scale, with probabilities and level descriptions returned as vectors ordered by level.
-
ts_models()lists the models available to your account.
Reliability
- Requests are retried on 408, 429, 5xx, and connection failures with exponential backoff and jitter, honoring
retry-after-msandretry-after, matching the official Python SDK’s defaults. - Errors are classed conditions inheriting from
typesafer_error:typesafer_error_auth-
typesafer_error_validation, with adetailstibble of the offending fields typesafer_error_rate_limittypesafer_error_servertypesafer_error_httptypesafer_error_connectiontypesafer_error_input
-
ts_api_key()readsTYPESAFE_API_KEYand gives a clear error when it’s missing. A rejected key’s error says whether it came from that variable or from theapi_keyargument.
