タイプセーフ- TypeSafe Documentation
- System One API Reference
TypeSafeは、System One API を通じて Jev などの意思決定モデルを提供します。
TypeSafeDecisionModelを実装しますDecisionModelその上に API があります。 同じ API は他のサーバーでも実装されています。たとえば、 OpenRouter および推論サーバーなど SGLangはオープンモデルを走らせています。TypeSafeDecisionModelは、ベース URL を設定することで、い ずれの URL でも使用できます (below を参照)。
备注
この統合は実験的なものであり、将来のリリースでは変更される可能性があります。
Maven の依存関係
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-typesafe</artifactId>
<version>1.23.0-beta33</version>
</dependency>
使用法
DecisionModel decisionModel = TypeSafeDecisionModel.builder()
.apiKey(System.getenv("TYPESAFE_API_KEY"))
.modelName("jev-1.13.0")
.build();
DecisionRequest request = DecisionRequest.builder()
.input("Help! My payouts have been failing for 3 days.")
.question("team", ChoiceQuestion.builder()
.text("Which team should handle this ticket?")
.option("billing", "Payments, payouts, invoices, refunds")
.option("support", "Problems using the product")
.build())
.question("urgent", YesNoQuestion.from("Does this need attention today?"))
.build();
DecisionResponse response = decisionModel.decide(request);
ChoiceAnswer team = response.choice("team");
YesNoAnswer urgent = response.yesNo("urgent");
すべての質問タイプと回答の使用方法については、Decision Models チュートリアルを参照してください。
構成
TypeSafeDecisionModel decisionModel = TypeSafeDecisionModel.builder()
.apiKey(...) // required for api.typesafe.ai, optional for other servers
.modelName(...) // required here or on each request (otherwise decide() fails), e.g. "jev-1.13.0"
.baseUrl(...) // defaults to "https://api.typesafe.ai"
.apiPath(...) // path of the System One endpoint, relative to baseUrl; defaults to "v1/systemone"
.timeout(...) // defaults to the HTTP client builder's timeouts, otherwise 15s connect / 60s read
.maxRetries(...) // retries after the first attempt; defaults to 2
.customHeaders(...) // additional HTTP headers, as a Map or a Supplier<Map>
.customParameters(...) // additional parameters in the JSON body, see "Custom parameters" below
.listeners(...) // DecisionModelListeners, see Observability in the Decision Models tutorial
.logRequests(...) // defaults to false
.logResponses(...) // defaults to false
.logger(...) // an alternate SLF4J logger for requests and responses
.httpClientBuilder(...) // see below
.build();
利用可能なモデルは TypeSafe documentation にリストされています。
jev-latest などのエイリアスはいつでも新しいバージョンに移行できます。運用環境では、修正バージョンを使用してください。
HTTP クライアントは httpClientBuilder(...) を使用してカスタマイズできます。Customizable HTTP Client を参照してください。
decide() と decideAsync() の両方がサポートされています。
このモデルは、YesNoQuestion