diff --git a/build.gradle b/build.gradle index af27f16..9b19ffb 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,7 @@ publishing { maven(MavenPublication) { groupId = 'com.cohere' artifactId = 'cohere-java' - version = '1.1.0' + version = '1.2.0' from components.java pom { name = 'cohere' diff --git a/src/main/java/com/cohere/api/Cohere.java b/src/main/java/com/cohere/api/Cohere.java index f4fd761..251c8dd 100644 --- a/src/main/java/com/cohere/api/Cohere.java +++ b/src/main/java/com/cohere/api/Cohere.java @@ -83,7 +83,7 @@ public Iterable chatStream(ChatStreamRequest request) { public Iterable chatStream(ChatStreamRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("chat") + .addPathSegments("v1/chat") .build(); RequestBody body; try { @@ -132,7 +132,7 @@ public NonStreamedChatResponse chat(ChatRequest request) { public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("chat") + .addPathSegments("v1/chat") .build(); RequestBody body; try { @@ -188,7 +188,7 @@ public Iterable generateStream( GenerateStreamRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("generate") + .addPathSegments("v1/generate") .build(); RequestBody body; try { @@ -244,7 +244,7 @@ public Generation generate(GenerateRequest request) { public Generation generate(GenerateRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("generate") + .addPathSegments("v1/generate") .build(); RequestBody body; try { @@ -295,7 +295,7 @@ public EmbedResponse embed(EmbedRequest request) { public EmbedResponse embed(EmbedRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("embed") + .addPathSegments("v1/embed") .build(); RequestBody body; try { @@ -342,7 +342,7 @@ public RerankResponse rerank(RerankRequest request) { public RerankResponse rerank(RerankRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("rerank") + .addPathSegments("v1/rerank") .build(); RequestBody body; try { @@ -391,7 +391,7 @@ public ClassifyResponse classify(ClassifyRequest request) { public ClassifyResponse classify(ClassifyRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("classify") + .addPathSegments("v1/classify") .build(); RequestBody body; try { @@ -446,7 +446,7 @@ public SummarizeResponse summarize(SummarizeRequest request) { public SummarizeResponse summarize(SummarizeRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("summarize") + .addPathSegments("v1/summarize") .build(); RequestBody body; try { @@ -493,7 +493,7 @@ public TokenizeResponse tokenize(TokenizeRequest request) { public TokenizeResponse tokenize(TokenizeRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("tokenize") + .addPathSegments("v1/tokenize") .build(); RequestBody body; try { @@ -540,7 +540,7 @@ public DetokenizeResponse detokenize(DetokenizeRequest request) { public DetokenizeResponse detokenize(DetokenizeRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("detokenize") + .addPathSegments("v1/detokenize") .build(); RequestBody body; try { @@ -587,7 +587,7 @@ public CheckApiKeyResponse checkApiKey() { public CheckApiKeyResponse checkApiKey(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("check-api-key") + .addPathSegments("v1/check-api-key") .build(); Request okhttpRequest = new Request.Builder() .url(httpUrl) diff --git a/src/main/java/com/cohere/api/core/ClientOptions.java b/src/main/java/com/cohere/api/core/ClientOptions.java index 966e197..dd03021 100644 --- a/src/main/java/com/cohere/api/core/ClientOptions.java +++ b/src/main/java/com/cohere/api/core/ClientOptions.java @@ -30,7 +30,7 @@ private ClientOptions( "X-Fern-SDK-Name", "com.cohere.fern:api-sdk", "X-Fern-SDK-Version", - "1.1.0", + "1.2.0", "X-Fern-Language", "JAVA")); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/cohere/api/core/Environment.java b/src/main/java/com/cohere/api/core/Environment.java index fa35d97..16b747a 100644 --- a/src/main/java/com/cohere/api/core/Environment.java +++ b/src/main/java/com/cohere/api/core/Environment.java @@ -4,7 +4,7 @@ package com.cohere.api.core; public final class Environment { - public static final Environment PRODUCTION = new Environment("https://api.cohere.com/v1"); + public static final Environment PRODUCTION = new Environment("https://api.cohere.com"); private final String url; diff --git a/src/main/java/com/cohere/api/requests/ChatRequest.java b/src/main/java/com/cohere/api/requests/ChatRequest.java index 28ed59e..81713b2 100644 --- a/src/main/java/com/cohere/api/requests/ChatRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatRequest.java @@ -7,8 +7,8 @@ import com.cohere.api.types.ChatConnector; import com.cohere.api.types.ChatRequestCitationQuality; import com.cohere.api.types.ChatRequestPromptTruncation; -import com.cohere.api.types.ChatRequestResponseFormat; import com.cohere.api.types.Message; +import com.cohere.api.types.ResponseFormat; import com.cohere.api.types.Tool; import com.cohere.api.types.ToolResult; import com.fasterxml.jackson.annotation.JsonAnyGetter; @@ -76,7 +76,7 @@ public final class ChatRequest { private final Optional forceSingleStep; - private final Optional responseFormat; + private final Optional responseFormat; private final Map additionalProperties; @@ -105,7 +105,7 @@ private ChatRequest( Optional> tools, Optional> toolResults, Optional forceSingleStep, - Optional responseFormat, + Optional responseFormat, Map additionalProperties) { this.message = message; this.model = model; @@ -211,7 +211,7 @@ public Optional getPromptTruncation() { /** * @return Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - *

When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG). + *

When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG). * Compatible Deployments: Cohere Platform

*/ @JsonProperty("connectors") @@ -409,14 +409,8 @@ public Optional getForceSingleStep() { return forceSingleStep; } - /** - * @return Configuration for forcing the model output to adhere to the specified format. Supported on Command R, Command R+ and newer models. - *

The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting { "type": "json_object" }.

- *

A JSON Schema can optionally be provided, to ensure a specific structure.

- *

Note: When using { "type": "json_object" } your message should always explicitly instruct the model to generate a JSON (eg: "Generate a JSON ...") . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.

- */ @JsonProperty("response_format") - public Optional getResponseFormat() { + public Optional getResponseFormat() { return responseFormat; } @@ -599,16 +593,16 @@ public interface _FinalStage { _FinalStage forceSingleStep(Boolean forceSingleStep); - _FinalStage responseFormat(Optional responseFormat); + _FinalStage responseFormat(Optional responseFormat); - _FinalStage responseFormat(ChatRequestResponseFormat responseFormat); + _FinalStage responseFormat(ResponseFormat responseFormat); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements MessageStage, _FinalStage { private String message; - private Optional responseFormat = Optional.empty(); + private Optional responseFormat = Optional.empty(); private Optional forceSingleStep = Optional.empty(); @@ -703,22 +697,15 @@ public _FinalStage message(String message) { return this; } - /** - *

Configuration for forcing the model output to adhere to the specified format. Supported on Command R, Command R+ and newer models.

- *

The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting { "type": "json_object" }.

- *

A JSON Schema can optionally be provided, to ensure a specific structure.

- *

Note: When using { "type": "json_object" } your message should always explicitly instruct the model to generate a JSON (eg: "Generate a JSON ...") . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage responseFormat(ChatRequestResponseFormat responseFormat) { + public _FinalStage responseFormat(ResponseFormat responseFormat) { this.responseFormat = Optional.of(responseFormat); return this; } @java.lang.Override @JsonSetter(value = "response_format", nulls = Nulls.SKIP) - public _FinalStage responseFormat(Optional responseFormat) { + public _FinalStage responseFormat(Optional responseFormat) { this.responseFormat = responseFormat; return this; } @@ -1068,7 +1055,7 @@ public _FinalStage searchQueriesOnly(Optional searchQueriesOnly) { /** *

Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one.

- *

When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG). + *

When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG). * Compatible Deployments: Cohere Platform

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java index a6ed240..aa31f3f 100644 --- a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java @@ -7,8 +7,8 @@ import com.cohere.api.types.ChatConnector; import com.cohere.api.types.ChatStreamRequestCitationQuality; import com.cohere.api.types.ChatStreamRequestPromptTruncation; -import com.cohere.api.types.ChatStreamRequestResponseFormat; import com.cohere.api.types.Message; +import com.cohere.api.types.ResponseFormat; import com.cohere.api.types.Tool; import com.cohere.api.types.ToolResult; import com.fasterxml.jackson.annotation.JsonAnyGetter; @@ -76,7 +76,7 @@ public final class ChatStreamRequest { private final Optional forceSingleStep; - private final Optional responseFormat; + private final Optional responseFormat; private final Map additionalProperties; @@ -105,7 +105,7 @@ private ChatStreamRequest( Optional> tools, Optional> toolResults, Optional forceSingleStep, - Optional responseFormat, + Optional responseFormat, Map additionalProperties) { this.message = message; this.model = model; @@ -211,7 +211,7 @@ public Optional getPromptTruncation() { /** * @return Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - *

When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG). + *

When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG). * Compatible Deployments: Cohere Platform

*/ @JsonProperty("connectors") @@ -409,14 +409,8 @@ public Optional getForceSingleStep() { return forceSingleStep; } - /** - * @return Configuration for forcing the model output to adhere to the specified format. Supported on Command R, Command R+ and newer models. - *

The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting { "type": "json_object" }.

- *

A JSON Schema can optionally be provided, to ensure a specific structure.

- *

Note: When using { "type": "json_object" } your message should always explicitly instruct the model to generate a JSON (eg: "Generate a JSON ...") . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.

- */ @JsonProperty("response_format") - public Optional getResponseFormat() { + public Optional getResponseFormat() { return responseFormat; } @@ -599,16 +593,16 @@ public interface _FinalStage { _FinalStage forceSingleStep(Boolean forceSingleStep); - _FinalStage responseFormat(Optional responseFormat); + _FinalStage responseFormat(Optional responseFormat); - _FinalStage responseFormat(ChatStreamRequestResponseFormat responseFormat); + _FinalStage responseFormat(ResponseFormat responseFormat); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements MessageStage, _FinalStage { private String message; - private Optional responseFormat = Optional.empty(); + private Optional responseFormat = Optional.empty(); private Optional forceSingleStep = Optional.empty(); @@ -703,22 +697,15 @@ public _FinalStage message(String message) { return this; } - /** - *

Configuration for forcing the model output to adhere to the specified format. Supported on Command R, Command R+ and newer models.

- *

The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting { "type": "json_object" }.

- *

A JSON Schema can optionally be provided, to ensure a specific structure.

- *

Note: When using { "type": "json_object" } your message should always explicitly instruct the model to generate a JSON (eg: "Generate a JSON ...") . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage responseFormat(ChatStreamRequestResponseFormat responseFormat) { + public _FinalStage responseFormat(ResponseFormat responseFormat) { this.responseFormat = Optional.of(responseFormat); return this; } @java.lang.Override @JsonSetter(value = "response_format", nulls = Nulls.SKIP) - public _FinalStage responseFormat(Optional responseFormat) { + public _FinalStage responseFormat(Optional responseFormat) { this.responseFormat = responseFormat; return this; } @@ -1068,7 +1055,7 @@ public _FinalStage searchQueriesOnly(Optional searchQueriesOnly) { /** *

Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one.

- *

When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG). + *

When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG). * Compatible Deployments: Cohere Platform

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java b/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java index 79f90e9..a50c95b 100644 --- a/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java +++ b/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java @@ -55,7 +55,7 @@ public ListConnectorsResponse list(ConnectorsListRequest request) { public ListConnectorsResponse list(ConnectorsListRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("connectors"); + .addPathSegments("v1/connectors"); if (request.getLimit().isPresent()) { httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); } @@ -100,7 +100,7 @@ public CreateConnectorResponse create(CreateConnectorRequest request) { public CreateConnectorResponse create(CreateConnectorRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("connectors") + .addPathSegments("v1/connectors") .build(); RequestBody body; try { @@ -147,7 +147,7 @@ public GetConnectorResponse get(String id) { public GetConnectorResponse get(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("connectors") + .addPathSegments("v1/connectors") .addPathSegment(id) .build(); Request okhttpRequest = new Request.Builder() @@ -188,7 +188,7 @@ public Map delete(String id) { public Map delete(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("connectors") + .addPathSegments("v1/connectors") .addPathSegment(id) .build(); Request okhttpRequest = new Request.Builder() @@ -237,7 +237,7 @@ public UpdateConnectorResponse update(String id, UpdateConnectorRequest request) public UpdateConnectorResponse update(String id, UpdateConnectorRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("connectors") + .addPathSegments("v1/connectors") .addPathSegment(id) .build(); RequestBody body; @@ -293,7 +293,7 @@ public OAuthAuthorizeResponse oAuthAuthorize( String id, ConnectorsOAuthAuthorizeRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("connectors") + .addPathSegments("v1/connectors") .addPathSegment(id) .addPathSegments("oauth/authorize"); if (request.getAfterTokenRedirect().isPresent()) { diff --git a/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java b/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java index 643fa51..a591d41 100644 --- a/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java +++ b/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java @@ -56,7 +56,7 @@ public DatasetsListResponse list(DatasetsListRequest request) { public DatasetsListResponse list(DatasetsListRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("datasets"); + .addPathSegments("v1/datasets"); if (request.getDatasetType().isPresent()) { httpUrl.addQueryParameter("datasetType", request.getDatasetType().get()); } @@ -115,7 +115,7 @@ public DatasetsCreateResponse create( File data, Optional evalData, DatasetsCreateRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("datasets"); + .addPathSegments("v1/datasets"); httpUrl.addQueryParameter("name", request.getName()); httpUrl.addQueryParameter("type", request.getType().toString()); if (request.getKeepOriginalFile().isPresent()) { @@ -195,7 +195,7 @@ public DatasetsGetUsageResponse getUsage() { public DatasetsGetUsageResponse getUsage(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("datasets/usage") + .addPathSegments("v1/datasets/usage") .build(); Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -235,7 +235,7 @@ public DatasetsGetResponse get(String id) { public DatasetsGetResponse get(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("datasets") + .addPathSegments("v1/datasets") .addPathSegment(id) .build(); Request okhttpRequest = new Request.Builder() @@ -276,7 +276,7 @@ public Map delete(String id) { public Map delete(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("datasets") + .addPathSegments("v1/datasets") .addPathSegment(id) .build(); Request okhttpRequest = new Request.Builder() diff --git a/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java b/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java index 55a867e..6a8bb10 100644 --- a/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java +++ b/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java @@ -41,7 +41,7 @@ public ListEmbedJobResponse list() { public ListEmbedJobResponse list(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("embed-jobs") + .addPathSegments("v1/embed-jobs") .build(); Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -81,7 +81,7 @@ public CreateEmbedJobResponse create(CreateEmbedJobRequest request) { public CreateEmbedJobResponse create(CreateEmbedJobRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("embed-jobs") + .addPathSegments("v1/embed-jobs") .build(); RequestBody body; try { @@ -128,7 +128,7 @@ public EmbedJob get(String id) { public EmbedJob get(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("embed-jobs") + .addPathSegments("v1/embed-jobs") .addPathSegment(id) .build(); Request okhttpRequest = new Request.Builder() @@ -169,7 +169,7 @@ public void cancel(String id) { public void cancel(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("embed-jobs") + .addPathSegments("v1/embed-jobs") .addPathSegment(id) .addPathSegments("cancel") .build(); diff --git a/src/main/java/com/cohere/api/resources/finetuning/FinetuningClient.java b/src/main/java/com/cohere/api/resources/finetuning/FinetuningClient.java index b504cae..8ae5c8a 100644 --- a/src/main/java/com/cohere/api/resources/finetuning/FinetuningClient.java +++ b/src/main/java/com/cohere/api/resources/finetuning/FinetuningClient.java @@ -50,7 +50,7 @@ public ListFinetunedModelsResponse listFinetunedModels( FinetuningListFinetunedModelsRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("finetuning/finetuned-models"); + .addPathSegments("v1/finetuning/finetuned-models"); if (request.getPageSize().isPresent()) { httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); } @@ -92,7 +92,7 @@ public CreateFinetunedModelResponse createFinetunedModel(FinetunedModel request) public CreateFinetunedModelResponse createFinetunedModel(FinetunedModel request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("finetuning/finetuned-models") + .addPathSegments("v1/finetuning/finetuned-models") .build(); RequestBody body; try { @@ -133,7 +133,7 @@ public GetFinetunedModelResponse getFinetunedModel(String id) { public GetFinetunedModelResponse getFinetunedModel(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("finetuning/finetuned-models") + .addPathSegments("v1/finetuning/finetuned-models") .addPathSegment(id) .build(); Request okhttpRequest = new Request.Builder() @@ -168,7 +168,7 @@ public Map deleteFinetunedModel(String id) { public Map deleteFinetunedModel(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("finetuning/finetuned-models") + .addPathSegments("v1/finetuning/finetuned-models") .addPathSegment(id) .build(); Request okhttpRequest = new Request.Builder() @@ -205,7 +205,7 @@ public UpdateFinetunedModelResponse updateFinetunedModel( String id, FinetuningUpdateFinetunedModelRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("finetuning/finetuned-models") + .addPathSegments("v1/finetuning/finetuned-models") .addPathSegment(id) .build(); RequestBody body; @@ -253,7 +253,7 @@ public ListEventsResponse listEvents( String finetunedModelId, FinetuningListEventsRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("finetuning/finetuned-models") + .addPathSegments("v1/finetuning/finetuned-models") .addPathSegment(finetunedModelId) .addPathSegments("events"); if (request.getPageSize().isPresent()) { @@ -305,7 +305,7 @@ public ListTrainingStepMetricsResponse listTrainingStepMetrics( String finetunedModelId, FinetuningListTrainingStepMetricsRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("finetuning/finetuned-models") + .addPathSegments("v1/finetuning/finetuned-models") .addPathSegment(finetunedModelId) .addPathSegments("training-step-metrics"); if (request.getPageSize().isPresent()) { diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Settings.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Settings.java index a183909..a63112a 100644 --- a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Settings.java +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Settings.java @@ -28,6 +28,8 @@ public final class Settings { private final Optional multiLabel; + private final Optional wandb; + private final Map additionalProperties; private Settings( @@ -35,11 +37,13 @@ private Settings( String datasetId, Optional hyperparameters, Optional multiLabel, + Optional wandb, Map additionalProperties) { this.baseModel = baseModel; this.datasetId = datasetId; this.hyperparameters = hyperparameters; this.multiLabel = multiLabel; + this.wandb = wandb; this.additionalProperties = additionalProperties; } @@ -75,6 +79,14 @@ public Optional getMultiLabel() { return multiLabel; } + /** + * @return The Weights & Biases configuration. + */ + @JsonProperty("wandb") + public Optional getWandb() { + return wandb; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -90,12 +102,13 @@ private boolean equalTo(Settings other) { return baseModel.equals(other.baseModel) && datasetId.equals(other.datasetId) && hyperparameters.equals(other.hyperparameters) - && multiLabel.equals(other.multiLabel); + && multiLabel.equals(other.multiLabel) + && wandb.equals(other.wandb); } @java.lang.Override public int hashCode() { - return Objects.hash(this.baseModel, this.datasetId, this.hyperparameters, this.multiLabel); + return Objects.hash(this.baseModel, this.datasetId, this.hyperparameters, this.multiLabel, this.wandb); } @java.lang.Override @@ -127,6 +140,10 @@ public interface _FinalStage { _FinalStage multiLabel(Optional multiLabel); _FinalStage multiLabel(Boolean multiLabel); + + _FinalStage wandb(Optional wandb); + + _FinalStage wandb(WandbConfig wandb); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -135,6 +152,8 @@ public static final class Builder implements BaseModelStage, DatasetIdStage, _Fi private String datasetId; + private Optional wandb = Optional.empty(); + private Optional multiLabel = Optional.empty(); private Optional hyperparameters = Optional.empty(); @@ -150,6 +169,7 @@ public Builder from(Settings other) { datasetId(other.getDatasetId()); hyperparameters(other.getHyperparameters()); multiLabel(other.getMultiLabel()); + wandb(other.getWandb()); return this; } @@ -175,6 +195,23 @@ public _FinalStage datasetId(String datasetId) { return this; } + /** + *

The Weights & Biases configuration.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage wandb(WandbConfig wandb) { + this.wandb = Optional.of(wandb); + return this; + } + + @java.lang.Override + @JsonSetter(value = "wandb", nulls = Nulls.SKIP) + public _FinalStage wandb(Optional wandb) { + this.wandb = wandb; + return this; + } + /** *

read-only. Whether the model is single-label or multi-label (only for classification).

* @return Reference to {@code this} so that method calls can be chained together. @@ -211,7 +248,7 @@ public _FinalStage hyperparameters(Optional hyperparameters) { @java.lang.Override public Settings build() { - return new Settings(baseModel, datasetId, hyperparameters, multiLabel, additionalProperties); + return new Settings(baseModel, datasetId, hyperparameters, multiLabel, wandb, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/WandbConfig.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/WandbConfig.java new file mode 100644 index 0000000..faa3d79 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/WandbConfig.java @@ -0,0 +1,175 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.types; + +import com.cohere.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = WandbConfig.Builder.class) +public final class WandbConfig { + private final String project; + + private final String apiKey; + + private final Optional entity; + + private final Map additionalProperties; + + private WandbConfig( + String project, String apiKey, Optional entity, Map additionalProperties) { + this.project = project; + this.apiKey = apiKey; + this.entity = entity; + this.additionalProperties = additionalProperties; + } + + /** + * @return The WandB project name to be used during training. + */ + @JsonProperty("project") + public String getProject() { + return project; + } + + /** + * @return The WandB API key to be used during training. + */ + @JsonProperty("api_key") + public String getApiKey() { + return apiKey; + } + + /** + * @return The WandB entity name to be used during training. + */ + @JsonProperty("entity") + public Optional getEntity() { + return entity; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof WandbConfig && equalTo((WandbConfig) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(WandbConfig other) { + return project.equals(other.project) && apiKey.equals(other.apiKey) && entity.equals(other.entity); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.project, this.apiKey, this.entity); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ProjectStage builder() { + return new Builder(); + } + + public interface ProjectStage { + ApiKeyStage project(String project); + + Builder from(WandbConfig other); + } + + public interface ApiKeyStage { + _FinalStage apiKey(String apiKey); + } + + public interface _FinalStage { + WandbConfig build(); + + _FinalStage entity(Optional entity); + + _FinalStage entity(String entity); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ProjectStage, ApiKeyStage, _FinalStage { + private String project; + + private String apiKey; + + private Optional entity = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(WandbConfig other) { + project(other.getProject()); + apiKey(other.getApiKey()); + entity(other.getEntity()); + return this; + } + + /** + *

The WandB project name to be used during training.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("project") + public ApiKeyStage project(String project) { + this.project = project; + return this; + } + + /** + *

The WandB API key to be used during training.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("api_key") + public _FinalStage apiKey(String apiKey) { + this.apiKey = apiKey; + return this; + } + + /** + *

The WandB entity name to be used during training.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage entity(String entity) { + this.entity = Optional.of(entity); + return this; + } + + @java.lang.Override + @JsonSetter(value = "entity", nulls = Nulls.SKIP) + public _FinalStage entity(Optional entity) { + this.entity = entity; + return this; + } + + @java.lang.Override + public WandbConfig build() { + return new WandbConfig(project, apiKey, entity, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/models/ModelsClient.java b/src/main/java/com/cohere/api/resources/models/ModelsClient.java index 22600cb..5694c2f 100644 --- a/src/main/java/com/cohere/api/resources/models/ModelsClient.java +++ b/src/main/java/com/cohere/api/resources/models/ModelsClient.java @@ -38,7 +38,7 @@ public GetModelResponse get(String model) { public GetModelResponse get(String model, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("models") + .addPathSegments("v1/models") .addPathSegment(model) .build(); Request okhttpRequest = new Request.Builder() @@ -86,7 +86,7 @@ public ListModelsResponse list(ModelsListRequest request) { public ListModelsResponse list(ModelsListRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("models"); + .addPathSegments("v1/models"); if (request.getPageSize().isPresent()) { httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); } diff --git a/src/main/java/com/cohere/api/types/ChatRequestResponseFormat.java b/src/main/java/com/cohere/api/types/ChatRequestResponseFormat.java deleted file mode 100644 index 5b6e409..0000000 --- a/src/main/java/com/cohere/api/types/ChatRequestResponseFormat.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.cohere.api.types; - -import com.cohere.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ChatRequestResponseFormat.Builder.class) -public final class ChatRequestResponseFormat { - private final ChatRequestResponseFormatType type; - - private final Optional> schema; - - private final Map additionalProperties; - - private ChatRequestResponseFormat( - ChatRequestResponseFormatType type, - Optional> schema, - Map additionalProperties) { - this.type = type; - this.schema = schema; - this.additionalProperties = additionalProperties; - } - - /** - * @return When set to JSON, the model will return valid JSON. Note that running out of tokens will result in an invalid JSON. - */ - @JsonProperty("type") - public ChatRequestResponseFormatType getType() { - return type; - } - - /** - * @return [BETA] A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to our guide for more information. - * Example (required name and age object): - *
{
-     *   "type": "object",
-     *   "properties": {
-     *     "name": { "type": "string" },
-     *     "age": { "type": "integer" }
-     *   },
-     *   "required": ["name", "age"]
-     * }
-     * 
- */ - @JsonProperty("schema") - public Optional> getSchema() { - return schema; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ChatRequestResponseFormat && equalTo((ChatRequestResponseFormat) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ChatRequestResponseFormat other) { - return type.equals(other.type) && schema.equals(other.schema); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.schema); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TypeStage builder() { - return new Builder(); - } - - public interface TypeStage { - _FinalStage type(ChatRequestResponseFormatType type); - - Builder from(ChatRequestResponseFormat other); - } - - public interface _FinalStage { - ChatRequestResponseFormat build(); - - _FinalStage schema(Optional> schema); - - _FinalStage schema(Map schema); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TypeStage, _FinalStage { - private ChatRequestResponseFormatType type; - - private Optional> schema = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ChatRequestResponseFormat other) { - type(other.getType()); - schema(other.getSchema()); - return this; - } - - /** - *

When set to JSON, the model will return valid JSON. Note that running out of tokens will result in an invalid JSON.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("type") - public _FinalStage type(ChatRequestResponseFormatType type) { - this.type = type; - return this; - } - - /** - *

[BETA] A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to our guide for more information. - * Example (required name and age object):

- *
{
-         *   "type": "object",
-         *   "properties": {
-         *     "name": { "type": "string" },
-         *     "age": { "type": "integer" }
-         *   },
-         *   "required": ["name", "age"]
-         * }
-         * 
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage schema(Map schema) { - this.schema = Optional.of(schema); - return this; - } - - @java.lang.Override - @JsonSetter(value = "schema", nulls = Nulls.SKIP) - public _FinalStage schema(Optional> schema) { - this.schema = schema; - return this; - } - - @java.lang.Override - public ChatRequestResponseFormat build() { - return new ChatRequestResponseFormat(type, schema, additionalProperties); - } - } -} diff --git a/src/main/java/com/cohere/api/types/ChatRequestResponseFormatType.java b/src/main/java/com/cohere/api/types/ChatRequestResponseFormatType.java deleted file mode 100644 index a9f4122..0000000 --- a/src/main/java/com/cohere/api/types/ChatRequestResponseFormatType.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.cohere.api.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ChatRequestResponseFormatType { - TEXT("text"), - - JSON_OBJECT("json_object"); - - private final String value; - - ChatRequestResponseFormatType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestResponseFormat.java b/src/main/java/com/cohere/api/types/ChatStreamRequestResponseFormat.java deleted file mode 100644 index 430baa2..0000000 --- a/src/main/java/com/cohere/api/types/ChatStreamRequestResponseFormat.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.cohere.api.types; - -import com.cohere.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ChatStreamRequestResponseFormat.Builder.class) -public final class ChatStreamRequestResponseFormat { - private final ChatStreamRequestResponseFormatType type; - - private final Optional> schema; - - private final Map additionalProperties; - - private ChatStreamRequestResponseFormat( - ChatStreamRequestResponseFormatType type, - Optional> schema, - Map additionalProperties) { - this.type = type; - this.schema = schema; - this.additionalProperties = additionalProperties; - } - - /** - * @return When set to JSON, the model will return valid JSON. Note that running out of tokens will result in an invalid JSON. - */ - @JsonProperty("type") - public ChatStreamRequestResponseFormatType getType() { - return type; - } - - /** - * @return [BETA] A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to our guide for more information. - * Example (required name and age object): - *
{
-     *   "type": "object",
-     *   "properties": {
-     *     "name": { "type": "string" },
-     *     "age": { "type": "integer" }
-     *   },
-     *   "required": ["name", "age"]
-     * }
-     * 
- */ - @JsonProperty("schema") - public Optional> getSchema() { - return schema; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ChatStreamRequestResponseFormat && equalTo((ChatStreamRequestResponseFormat) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ChatStreamRequestResponseFormat other) { - return type.equals(other.type) && schema.equals(other.schema); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.schema); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TypeStage builder() { - return new Builder(); - } - - public interface TypeStage { - _FinalStage type(ChatStreamRequestResponseFormatType type); - - Builder from(ChatStreamRequestResponseFormat other); - } - - public interface _FinalStage { - ChatStreamRequestResponseFormat build(); - - _FinalStage schema(Optional> schema); - - _FinalStage schema(Map schema); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TypeStage, _FinalStage { - private ChatStreamRequestResponseFormatType type; - - private Optional> schema = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ChatStreamRequestResponseFormat other) { - type(other.getType()); - schema(other.getSchema()); - return this; - } - - /** - *

When set to JSON, the model will return valid JSON. Note that running out of tokens will result in an invalid JSON.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("type") - public _FinalStage type(ChatStreamRequestResponseFormatType type) { - this.type = type; - return this; - } - - /** - *

[BETA] A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to our guide for more information. - * Example (required name and age object):

- *
{
-         *   "type": "object",
-         *   "properties": {
-         *     "name": { "type": "string" },
-         *     "age": { "type": "integer" }
-         *   },
-         *   "required": ["name", "age"]
-         * }
-         * 
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage schema(Map schema) { - this.schema = Optional.of(schema); - return this; - } - - @java.lang.Override - @JsonSetter(value = "schema", nulls = Nulls.SKIP) - public _FinalStage schema(Optional> schema) { - this.schema = schema; - return this; - } - - @java.lang.Override - public ChatStreamRequestResponseFormat build() { - return new ChatStreamRequestResponseFormat(type, schema, additionalProperties); - } - } -} diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestResponseFormatType.java b/src/main/java/com/cohere/api/types/ChatStreamRequestResponseFormatType.java deleted file mode 100644 index 9c8020b..0000000 --- a/src/main/java/com/cohere/api/types/ChatStreamRequestResponseFormatType.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.cohere.api.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ChatStreamRequestResponseFormatType { - TEXT("text"), - - JSON_OBJECT("json_object"); - - private final String value; - - ChatStreamRequestResponseFormatType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/cohere/api/types/JsonResponseFormat.java b/src/main/java/com/cohere/api/types/JsonResponseFormat.java new file mode 100644 index 0000000..ee8a432 --- /dev/null +++ b/src/main/java/com/cohere/api/types/JsonResponseFormat.java @@ -0,0 +1,109 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.cohere.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = JsonResponseFormat.Builder.class) +public final class JsonResponseFormat { + private final Optional> schema; + + private final Map additionalProperties; + + private JsonResponseFormat(Optional> schema, Map additionalProperties) { + this.schema = schema; + this.additionalProperties = additionalProperties; + } + + /** + * @return [BETA] A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to our guide for more information. + * Example (required name and age object): + *
{
+     *   "type": "object",
+     *   "properties": {
+     *     "name": { "type": "string" },
+     *     "age": { "type": "integer" }
+     *   },
+     *   "required": ["name", "age"]
+     * }
+     * 
+ *

Note: This field must not be specified when the type is set to "text".

+ */ + @JsonProperty("schema") + public Optional> getSchema() { + return schema; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof JsonResponseFormat && equalTo((JsonResponseFormat) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(JsonResponseFormat other) { + return schema.equals(other.schema); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.schema); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> schema = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(JsonResponseFormat other) { + schema(other.getSchema()); + return this; + } + + @JsonSetter(value = "schema", nulls = Nulls.SKIP) + public Builder schema(Optional> schema) { + this.schema = schema; + return this; + } + + public Builder schema(Map schema) { + this.schema = Optional.of(schema); + return this; + } + + public JsonResponseFormat build() { + return new JsonResponseFormat(schema, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ResponseFormat.java b/src/main/java/com/cohere/api/types/ResponseFormat.java new file mode 100644 index 0000000..542f653 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ResponseFormat.java @@ -0,0 +1,200 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class ResponseFormat { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private ResponseFormat(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static ResponseFormat text(TextResponseFormat value) { + return new ResponseFormat(new TextValue(value)); + } + + public static ResponseFormat jsonObject(JsonResponseFormat value) { + return new ResponseFormat(new JsonObjectValue(value)); + } + + public boolean isText() { + return value instanceof TextValue; + } + + public boolean isJsonObject() { + return value instanceof JsonObjectValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getText() { + if (isText()) { + return Optional.of(((TextValue) value).value); + } + return Optional.empty(); + } + + public Optional getJsonObject() { + if (isJsonObject()) { + return Optional.of(((JsonObjectValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitText(TextResponseFormat text); + + T visitJsonObject(JsonResponseFormat jsonObject); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({@JsonSubTypes.Type(TextValue.class), @JsonSubTypes.Type(JsonObjectValue.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("text") + private static final class TextValue implements Value { + @JsonUnwrapped + private TextResponseFormat value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private TextValue() {} + + private TextValue(TextResponseFormat value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitText(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TextValue && equalTo((TextValue) other); + } + + private boolean equalTo(TextValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ResponseFormat{" + "value: " + value + "}"; + } + } + + @JsonTypeName("json_object") + private static final class JsonObjectValue implements Value { + @JsonUnwrapped + private JsonResponseFormat value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private JsonObjectValue() {} + + private JsonObjectValue(JsonResponseFormat value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitJsonObject(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof JsonObjectValue && equalTo((JsonObjectValue) other); + } + + private boolean equalTo(JsonObjectValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ResponseFormat{" + "value: " + value + "}"; + } + } + + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "ResponseFormat{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/cohere/api/types/TextResponseFormat.java b/src/main/java/com/cohere/api/types/TextResponseFormat.java new file mode 100644 index 0000000..edc71d8 --- /dev/null +++ b/src/main/java/com/cohere/api/types/TextResponseFormat.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.cohere.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import java.util.Map; + +public final class TextResponseFormat { + private final Map additionalProperties; + + private TextResponseFormat(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TextResponseFormat; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } +}