Class SystemOneClient
java.lang.Object
org.springframework.ai.systemone.api.SystemOneClient
The System One client. Wraps
SystemOneApi with a default model, a retry policy
and the typed exceptions, and stitches the x-typesafe-request-id header onto
the response so it travels with the data it describes.
SystemOneClient client = SystemOneClient.builder().apiKey(apiKey).build();
SystemOneResponse response = client.systemOne(SystemOneRequest.builder()
.state(Map.of("message", "Help! My payouts have been failing for 3 days."))
.question("is_urgent", Noul.of("Does this convey urgency?"))
.question("department", Choice.builder()
.instructions("Which team should handle this?")
.option("billing", "Payments, invoicing, refunds")
.option("technical", "Bugs, outages, integrations")
.build())
.build());
if (response.noulValue("is_urgent") > 0.8) {
escalate(response.choiceValue("department"));
}
Every question of a call is answered against the same state in parallel, so asking
several narrow questions costs little more than asking one, and each answer stays
independently thresholdable.- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSystemOneClient(SystemOneApi systemOneApi, String defaultModel, org.springframework.core.retry.RetryTemplate retryTemplate) Creates a client over an API instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic SystemOneClient.Builderbuilder()Lists the models available to the account.Answers questions about a text state.Answers questions about a sequence, for example the turns of a conversation.Answers questions about a structured state.systemOne(JsonContent state, Map<String, ? extends Question> questions) Answers questions about a state.systemOne(SystemOneRequest request) Answers a fully assembled request, applying the client's default model when the request does not name one.
-
Constructor Details
-
SystemOneClient
public SystemOneClient(SystemOneApi systemOneApi, String defaultModel, org.springframework.core.retry.RetryTemplate retryTemplate) Creates a client over an API instance.- Parameters:
systemOneApi- the transport layerdefaultModel- the model applied to a request that does not name oneretryTemplate- how transient failures are retried; seeSystemOneRetryUtils
-
-
Method Details
-
systemOne
Answers questions about a text state.- Parameters:
state- the content to evaluatequestions- the questions, keyed by the names their answers will carry- Returns:
- the answers
-
systemOne
Answers questions about a structured state. Naming the parts of the state is the recommended shape: it lets a question point at a field instead of relying on position inside a serialized blob.The fields and questions are sent in the maps' iteration order, which can change an answer. Pass ordered maps, or use
JsonContent.object(Object...)for the state andSystemOneRequest.builder()for the questions:Map.ofiterates in an order that changes with every JVM run.- Parameters:
state- the content to evaluatequestions- the questions, keyed by the names their answers will carry- Returns:
- the answers
-
systemOne
Answers questions about a sequence, for example the turns of a conversation.- Parameters:
state- the content to evaluatequestions- the questions, keyed by the names their answers will carry- Returns:
- the answers
-
systemOne
Answers questions about a state.- Parameters:
state- the content to evaluatequestions- the questions, keyed by the names their answers will carry- Returns:
- the answers
-
systemOne
Answers a fully assembled request, applying the client's default model when the request does not name one.- Parameters:
request- the request- Returns:
- the answers, carrying the request id from the response headers
-
listModels
Lists the models available to the account.- Returns:
- the models, never
null
-
defaultModel
- Returns:
- the model applied to requests that do not name one
-
builder
- Returns:
- a new builder
-