typesafe/lib.rs
1//! Rust client for the [TypeSafe AI](https://typesafe.ai) System One API.
2//!
3//! Send a `state` and a map of typed questions — [`Noul`] (yes/no probability), [`Choice`]
4//! (one of N labels) and [`Score`] (ordered levels) — and get typed answers back.
5//!
6//! Behaviour follows the official Python SDK (`typesafe-sdk`): the same environment variables,
7//! defaults, retry semantics, error classification and forward-compatible decoding.
8//!
9//! Enable the `blocking` feature for a synchronous client in [`blocking`], `reqwest-client`
10//! to supply your own `reqwest::Client`, and `derive` for `#[derive(Rubric)]`: a struct that
11//! describes the questions and receives the answers (see [`rubric`]).
12#![warn(missing_docs)]
13
14pub mod cassette;
15mod client;
16pub mod constants;
17pub mod error;
18pub mod question;
19pub mod response;
20pub mod retry;
21pub mod rubric;
22
23#[cfg(feature = "blocking")]
24pub mod blocking;
25
26pub use client::{Client, ClientBuilder, ListModelsRequest, Models, SystemOneRequest};
27pub use error::{ApiError, ApiErrorKind, Error, ResponseValidationError, Result};
28pub use question::{Choice, Noul, NoulCriteria, Question, Questions, Score};
29pub use response::{
30 Answer, ChoiceAnswer, ListModelsResponse, ModelMetadata, NoulAnswer, ResponseMeta, ScoreAnswer,
31 SystemOneResponse, Usage,
32};
33pub use retry::RetryPolicy;
34pub use rubric::{AskRequest, ChoiceOf, Rubric, RubricChoice};
35/// `#[derive(Rubric)]` and `#[derive(RubricChoice)]` (feature `derive`); see [`rubric`].
36#[cfg(feature = "derive")]
37pub use typesafe_derive::{Rubric, RubricChoice};
38
39/// Re-exported so callers can build headers without adding a dependency.
40pub use http;
41/// Re-exported so callers can build structured instructions/state without adding a dependency.
42pub use serde_json::{self, json};
43
44/// Compiles the README's code samples as doctests (they are not part of the rendered docs).
45#[cfg(doctest)]
46#[doc = include_str!("../README.md")]
47pub struct ReadmeDoctests;