shipwithjev

Catalog / Tools & apps

0493GitHub

typesafe-sdk-java

Community Java 17 client for Choice, Score, and Noul, with an optional Spring Boot starter.

Premo-Cloud/typesafe-sdk-javaREADME ↗
# TypeSafe SDK for Java

A community Java client for the [TypeSafe](https://typesafe.ai) System One API. Ask small, typed questions over your
application state and get calibrated probabilities back, in one round trip, with no prompt parsing.

This library is an independent, community-maintained project and is not affiliated with, endorsed by, or supported by
TypeSafe AI. It follows the conventions of the official [Python](https://github.com/typesafe-ai/typesafe-sdk-python) and
[JavaScript](https://github.com/typesafe-ai/typesafe-sdk-js) SDKs so the three read alike. TypeSafe is a trademark of
its owner; the name is used here only to describe what the library connects to.

Requires Java 17 or newer. Depends only on Jackson.

## Install

Gradle:

```kotlin
implementation("io.github.premo-cloud:typesafe-sdk:0.3.0")
```

Maven:

```xml
<dependency>
  <groupId>io.github.premo-cloud</groupId>
  <artifactId>typesafe-sdk</artifactId>
  <version>0.3.0</version>
</dependency>
```

Spring Boot users can add `io.github.premo-cloud:typesafe-sdk-spring-boot-starter` instead and get a `TypeSafeClient` bean from
`typesafe.api-key` and friends in `application.properties`.

## Use

The shape mirrors the Python and JavaScript SDKs: a client, `systemOne(state, questions)`, and question types named
`Noul`, `Choice`, and `Score` that take `(instructions, criteria)`.

```java
TypeSafeClient client = TypeSafeClient.fromEnvironment();   // reads TYPESAFE_API_KEY

TypeSafeResponse response = client.systemOne(
        Map.of("document", "I was charged twice. Please fix this ASAP."),
        Map.of("category", Choice.of("What is this ticket about?", "billing", "technical", "other"),
               "urgent", Noul.of("Does `document` convey urgency?")));

response.choices().get("category").choice();

Also filed under Tools & apps