diff --git a/build.gradle b/build.gradle index caef60e..2b2c2af 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ java { group = 'com.cohere' -version = '1.8.1' +version = '2.0.0' jar { dependsOn(":generatePomFileForMavenPublication") @@ -77,7 +77,7 @@ publishing { maven(MavenPublication) { groupId = 'com.cohere' artifactId = 'cohere-java' - version = '1.8.1' + version = '2.0.0' from components.java pom { name = 'cohere' diff --git a/reference.md b/reference.md index fa45643..0a2e614 100644 --- a/reference.md +++ b/reference.md @@ -57,19 +57,6 @@ client.chatStream(
-**rawPrompting:** `Optional` - -When enabled, the user's prompt will be sent to the model without -any pre-processing. - -Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - -
-
- -
-
- **message:** `String` Text input for the model to respond to. @@ -371,6 +358,19 @@ Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private D
+**rawPrompting:** `Optional` + +When enabled, the user's prompt will be sent to the model without +any pre-processing. + +Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments + +
+
+ +
+
+ **tools:** `Optional>` A list of available tools (functions) that the model may suggest invoking before producing a text response. @@ -541,19 +541,6 @@ client.chatStream(
-**rawPrompting:** `Optional` - -When enabled, the user's prompt will be sent to the model without -any pre-processing. - -Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - -
-
- -
-
- **message:** `String` Text input for the model to respond to. @@ -855,6 +842,19 @@ Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private D
+**rawPrompting:** `Optional` + +When enabled, the user's prompt will be sent to the model without +any pre-processing. + +Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments + +
+
+ +
+
+ **tools:** `Optional>` A list of available tools (functions) that the model may suggest invoking before producing a text response. @@ -2291,19 +2291,6 @@ When set to `true`, tool calls in the Assistant message will be forced to follow
-**rawPrompting:** `Optional` - -When enabled, the user's prompt will be sent to the model without -any pre-processing. - -Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - -
-
- -
-
- **responseFormat:** `Optional`
@@ -2331,9 +2318,11 @@ Safety modes are not yet configurable in combination with `tools` and `documents **maxTokens:** `Optional` -The maximum number of tokens the model will generate as part of the response. +The maximum number of output tokens the model will generate in the response. If not set, `max_tokens` defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the [model documentation](https://docs.cohere.com/docs/models). + +**Note**: Setting a low value may result in incomplete generations. In such cases, the `finish_reason` field in the response will be set to `"MAX_TOKENS"`. -**Note**: Setting a low value may result in incomplete generations. +**Note**: If `max_tokens` is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.
@@ -2435,8 +2424,14 @@ When `NONE` is specified, the model will be forced **not** to use one of the spe If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not. **Note**: This parameter is only compatible with models [Command-r7b](https://docs.cohere.com/v2/docs/command-r7b) and newer. + +
+
+ +
+
-**Note**: The same functionality can be achieved in `/v1/chat` using the `force_single_step` parameter. If `force_single_step=true`, this is equivalent to specifying `REQUIRED`. While if `force_single_step=true` and `tool_results` are passed, this is equivalent to specifying `NONE`. +**thinking:** `Optional`
@@ -2582,19 +2577,6 @@ When set to `true`, tool calls in the Assistant message will be forced to follow
-**rawPrompting:** `Optional` - -When enabled, the user's prompt will be sent to the model without -any pre-processing. - -Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - -
-
- -
-
- **responseFormat:** `Optional`
@@ -2622,9 +2604,11 @@ Safety modes are not yet configurable in combination with `tools` and `documents **maxTokens:** `Optional` -The maximum number of tokens the model will generate as part of the response. +The maximum number of output tokens the model will generate in the response. If not set, `max_tokens` defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the [model documentation](https://docs.cohere.com/docs/models). + +**Note**: Setting a low value may result in incomplete generations. In such cases, the `finish_reason` field in the response will be set to `"MAX_TOKENS"`. -**Note**: Setting a low value may result in incomplete generations. +**Note**: If `max_tokens` is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.
@@ -2726,8 +2710,14 @@ When `NONE` is specified, the model will be forced **not** to use one of the spe If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not. **Note**: This parameter is only compatible with models [Command-r7b](https://docs.cohere.com/v2/docs/command-r7b) and newer. + +
+
-**Note**: The same functionality can be achieved in `/v1/chat` using the `force_single_step` parameter. If `force_single_step=true`, this is equivalent to specifying `REQUIRED`. While if `force_single_step=true` and `tool_results` are passed, this is equivalent to specifying `NONE`. +
+
+ +**thinking:** `Optional`
@@ -2875,6 +2865,7 @@ Specifies the types of embeddings you want to get back. Can be one or more of th * `"uint8"`: Use this when you want to get back unsigned int8 embeddings. Supported with Embed v3.0 and newer Embed models. * `"binary"`: Use this when you want to get back signed binary embeddings. Supported with Embed v3.0 and newer Embed models. * `"ubinary"`: Use this when you want to get back unsigned binary embeddings. Supported with Embed v3.0 and newer Embed models. +* `"base64"`: Use this when you want to get back base64 embeddings. Supported with Embed v3.0 and newer Embed models. @@ -4365,17 +4356,17 @@ Creates a new fine-tuned model. The model will be trained on the dataset specifi client.finetuning().createFinetunedModel( FinetunedModel .builder() - .name("api-test") + .name("name") .settings( Settings .builder() .baseModel( BaseModel .builder() - .baseType(BaseType.BASE_TYPE_CHAT) + .baseType(BaseType.BASE_TYPE_UNSPECIFIED) .build() ) - .datasetId("my-dataset-id") + .datasetId("dataset_id") .build() ) .build() diff --git a/src/main/java/com/cohere/api/AsyncRawCohere.java b/src/main/java/com/cohere/api/AsyncRawCohere.java index f3276b4..32d586b 100644 --- a/src/main/java/com/cohere/api/AsyncRawCohere.java +++ b/src/main/java/com/cohere/api/AsyncRawCohere.java @@ -87,9 +87,6 @@ public CompletableFuture>> cha .addPathSegments("v1/chat") .build(); Map properties = new HashMap<>(); - if (request.getRawPrompting().isPresent()) { - properties.put("raw_prompting", request.getRawPrompting()); - } properties.put("message", request.getMessage()); if (request.getModel().isPresent()) { properties.put("model", request.getModel()); @@ -146,6 +143,9 @@ public CompletableFuture>> cha if (request.getPresencePenalty().isPresent()) { properties.put("presence_penalty", request.getPresencePenalty()); } + if (request.getRawPrompting().isPresent()) { + properties.put("raw_prompting", request.getRawPrompting()); + } if (request.getTools().isPresent()) { properties.put("tools", request.getTools()); } @@ -299,9 +299,6 @@ public CompletableFuture> chat( .addPathSegments("v1/chat") .build(); Map properties = new HashMap<>(); - if (request.getRawPrompting().isPresent()) { - properties.put("raw_prompting", request.getRawPrompting()); - } properties.put("message", request.getMessage()); if (request.getModel().isPresent()) { properties.put("model", request.getModel()); @@ -358,6 +355,9 @@ public CompletableFuture> chat( if (request.getPresencePenalty().isPresent()) { properties.put("presence_penalty", request.getPresencePenalty()); } + if (request.getRawPrompting().isPresent()) { + properties.put("raw_prompting", request.getRawPrompting()); + } if (request.getTools().isPresent()) { properties.put("tools", request.getTools()); } diff --git a/src/main/java/com/cohere/api/RawCohere.java b/src/main/java/com/cohere/api/RawCohere.java index 8dbeb2b..2e43695 100644 --- a/src/main/java/com/cohere/api/RawCohere.java +++ b/src/main/java/com/cohere/api/RawCohere.java @@ -83,9 +83,6 @@ public CohereHttpResponse> chatStream( .addPathSegments("v1/chat") .build(); Map properties = new HashMap<>(); - if (request.getRawPrompting().isPresent()) { - properties.put("raw_prompting", request.getRawPrompting()); - } properties.put("message", request.getMessage()); if (request.getModel().isPresent()) { properties.put("model", request.getModel()); @@ -142,6 +139,9 @@ public CohereHttpResponse> chatStream( if (request.getPresencePenalty().isPresent()) { properties.put("presence_penalty", request.getPresencePenalty()); } + if (request.getRawPrompting().isPresent()) { + properties.put("raw_prompting", request.getRawPrompting()); + } if (request.getTools().isPresent()) { properties.put("tools", request.getTools()); } @@ -256,9 +256,6 @@ public CohereHttpResponse chat(ChatRequest request, Req .addPathSegments("v1/chat") .build(); Map properties = new HashMap<>(); - if (request.getRawPrompting().isPresent()) { - properties.put("raw_prompting", request.getRawPrompting()); - } properties.put("message", request.getMessage()); if (request.getModel().isPresent()) { properties.put("model", request.getModel()); @@ -315,6 +312,9 @@ public CohereHttpResponse chat(ChatRequest request, Req if (request.getPresencePenalty().isPresent()) { properties.put("presence_penalty", request.getPresencePenalty()); } + if (request.getRawPrompting().isPresent()) { + properties.put("raw_prompting", request.getRawPrompting()); + } if (request.getTools().isPresent()) { properties.put("tools", request.getTools()); } diff --git a/src/main/java/com/cohere/api/core/ClientOptions.java b/src/main/java/com/cohere/api/core/ClientOptions.java index 906ee74..fdcf229 100644 --- a/src/main/java/com/cohere/api/core/ClientOptions.java +++ b/src/main/java/com/cohere/api/core/ClientOptions.java @@ -32,10 +32,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.cohere:cohere-java/1.8.1"); + put("User-Agent", "com.cohere:cohere-java/2.0.0"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.cohere.fern:api-sdk"); - put("X-Fern-SDK-Version", "1.8.1"); + put("X-Fern-SDK-Version", "2.0.0"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/cohere/api/requests/ChatRequest.java b/src/main/java/com/cohere/api/requests/ChatRequest.java index efb2908..487f9c7 100644 --- a/src/main/java/com/cohere/api/requests/ChatRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatRequest.java @@ -32,8 +32,6 @@ public final class ChatRequest { private final Optional accepts; - private final Optional rawPrompting; - private final String message; private final Optional model; @@ -72,6 +70,8 @@ public final class ChatRequest { private final Optional presencePenalty; + private final Optional rawPrompting; + private final Optional> tools; private final Optional> toolResults; @@ -86,7 +86,6 @@ public final class ChatRequest { private ChatRequest( Optional accepts, - Optional rawPrompting, String message, Optional model, Optional preamble, @@ -106,6 +105,7 @@ private ChatRequest( Optional> stopSequences, Optional frequencyPenalty, Optional presencePenalty, + Optional rawPrompting, Optional> tools, Optional> toolResults, Optional forceSingleStep, @@ -113,7 +113,6 @@ private ChatRequest( Optional safetyMode, Map additionalProperties) { this.accepts = accepts; - this.rawPrompting = rawPrompting; this.message = message; this.model = model; this.preamble = preamble; @@ -133,6 +132,7 @@ private ChatRequest( this.stopSequences = stopSequences; this.frequencyPenalty = frequencyPenalty; this.presencePenalty = presencePenalty; + this.rawPrompting = rawPrompting; this.tools = tools; this.toolResults = toolResults; this.forceSingleStep = forceSingleStep; @@ -149,16 +149,6 @@ public Optional getAccepts() { return accepts; } - /** - * @return When enabled, the user's prompt will be sent to the model without - * any pre-processing. - *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - @JsonProperty("raw_prompting") - public Optional getRawPrompting() { - return rawPrompting; - } - /** * @return Text input for the model to respond to. *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

@@ -377,6 +367,16 @@ public Optional getPresencePenalty() { return presencePenalty; } + /** + * @return When enabled, the user's prompt will be sent to the model without + * any pre-processing. + *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

+ */ + @JsonProperty("raw_prompting") + public Optional getRawPrompting() { + return rawPrompting; + } + /** * @return A list of available tools (functions) that the model may suggest invoking before producing a text response. *

When tools is passed (without tool_results), the text field in the response will be "" and the tool_calls field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the tool_calls array will be empty.

@@ -453,7 +453,6 @@ public Map getAdditionalProperties() { private boolean equalTo(ChatRequest other) { return accepts.equals(other.accepts) - && rawPrompting.equals(other.rawPrompting) && message.equals(other.message) && model.equals(other.model) && preamble.equals(other.preamble) @@ -473,6 +472,7 @@ private boolean equalTo(ChatRequest other) { && stopSequences.equals(other.stopSequences) && frequencyPenalty.equals(other.frequencyPenalty) && presencePenalty.equals(other.presencePenalty) + && rawPrompting.equals(other.rawPrompting) && tools.equals(other.tools) && toolResults.equals(other.toolResults) && forceSingleStep.equals(other.forceSingleStep) @@ -484,7 +484,6 @@ private boolean equalTo(ChatRequest other) { public int hashCode() { return Objects.hash( this.accepts, - this.rawPrompting, this.message, this.model, this.preamble, @@ -504,6 +503,7 @@ public int hashCode() { this.stopSequences, this.frequencyPenalty, this.presencePenalty, + this.rawPrompting, this.tools, this.toolResults, this.forceSingleStep, @@ -540,15 +540,6 @@ public interface _FinalStage { _FinalStage accepts(String accepts); - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - _FinalStage rawPrompting(Optional rawPrompting); - - _FinalStage rawPrompting(Boolean rawPrompting); - /** *

The name of a compatible Cohere model or the ID of a fine-tuned model.

*

Compatible Deployments: Cohere Platform, Private Deployments

@@ -729,6 +720,15 @@ public interface _FinalStage { _FinalStage presencePenalty(Double presencePenalty); + /** + *

When enabled, the user's prompt will be sent to the model without + * any pre-processing.

+ *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

+ */ + _FinalStage rawPrompting(Optional rawPrompting); + + _FinalStage rawPrompting(Boolean rawPrompting); + /** *

A list of available tools (functions) that the model may suggest invoking before producing a text response.

*

When tools is passed (without tool_results), the text field in the response will be "" and the tool_calls field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the tool_calls array will be empty.

@@ -802,6 +802,8 @@ public static final class Builder implements MessageStage, _FinalStage { private Optional> tools = Optional.empty(); + private Optional rawPrompting = Optional.empty(); + private Optional presencePenalty = Optional.empty(); private Optional frequencyPenalty = Optional.empty(); @@ -838,8 +840,6 @@ public static final class Builder implements MessageStage, _FinalStage { private Optional model = Optional.empty(); - private Optional rawPrompting = Optional.empty(); - private Optional accepts = Optional.empty(); @JsonAnySetter @@ -850,7 +850,6 @@ private Builder() {} @java.lang.Override public Builder from(ChatRequest other) { accepts(other.getAccepts()); - rawPrompting(other.getRawPrompting()); message(other.getMessage()); model(other.getModel()); preamble(other.getPreamble()); @@ -870,6 +869,7 @@ public Builder from(ChatRequest other) { stopSequences(other.getStopSequences()); frequencyPenalty(other.getFrequencyPenalty()); presencePenalty(other.getPresencePenalty()); + rawPrompting(other.getRawPrompting()); tools(other.getTools()); toolResults(other.getToolResults()); forceSingleStep(other.getForceSingleStep()); @@ -1037,6 +1037,30 @@ public _FinalStage tools(Optional> tools) { return this; } + /** + *

When enabled, the user's prompt will be sent to the model without + * any pre-processing.

+ *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage rawPrompting(Boolean rawPrompting) { + this.rawPrompting = Optional.ofNullable(rawPrompting); + return this; + } + + /** + *

When enabled, the user's prompt will be sent to the model without + * any pre-processing.

+ *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

+ */ + @java.lang.Override + @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) + public _FinalStage rawPrompting(Optional rawPrompting) { + this.rawPrompting = rawPrompting; + return this; + } + /** *

Defaults to 0.0, min value of 0.0, max value of 1.0.

*

Used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

@@ -1505,30 +1529,6 @@ public _FinalStage model(Optional model) { return this; } - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage rawPrompting(Boolean rawPrompting) { - this.rawPrompting = Optional.ofNullable(rawPrompting); - return this; - } - - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - @java.lang.Override - @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) - public _FinalStage rawPrompting(Optional rawPrompting) { - this.rawPrompting = rawPrompting; - return this; - } - /** *

Pass text/event-stream to receive the streamed response as server-sent events. The default is \n delimited events.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1553,7 +1553,6 @@ public _FinalStage accepts(Optional accepts) { public ChatRequest build() { return new ChatRequest( accepts, - rawPrompting, message, model, preamble, @@ -1573,6 +1572,7 @@ public ChatRequest build() { stopSequences, frequencyPenalty, presencePenalty, + rawPrompting, tools, toolResults, forceSingleStep, diff --git a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java index 3cbf491..299342b 100644 --- a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java @@ -32,8 +32,6 @@ public final class ChatStreamRequest { private final Optional accepts; - private final Optional rawPrompting; - private final String message; private final Optional model; @@ -72,6 +70,8 @@ public final class ChatStreamRequest { private final Optional presencePenalty; + private final Optional rawPrompting; + private final Optional> tools; private final Optional> toolResults; @@ -86,7 +86,6 @@ public final class ChatStreamRequest { private ChatStreamRequest( Optional accepts, - Optional rawPrompting, String message, Optional model, Optional preamble, @@ -106,6 +105,7 @@ private ChatStreamRequest( Optional> stopSequences, Optional frequencyPenalty, Optional presencePenalty, + Optional rawPrompting, Optional> tools, Optional> toolResults, Optional forceSingleStep, @@ -113,7 +113,6 @@ private ChatStreamRequest( Optional safetyMode, Map additionalProperties) { this.accepts = accepts; - this.rawPrompting = rawPrompting; this.message = message; this.model = model; this.preamble = preamble; @@ -133,6 +132,7 @@ private ChatStreamRequest( this.stopSequences = stopSequences; this.frequencyPenalty = frequencyPenalty; this.presencePenalty = presencePenalty; + this.rawPrompting = rawPrompting; this.tools = tools; this.toolResults = toolResults; this.forceSingleStep = forceSingleStep; @@ -149,16 +149,6 @@ public Optional getAccepts() { return accepts; } - /** - * @return When enabled, the user's prompt will be sent to the model without - * any pre-processing. - *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - @JsonProperty("raw_prompting") - public Optional getRawPrompting() { - return rawPrompting; - } - /** * @return Text input for the model to respond to. *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

@@ -377,6 +367,16 @@ public Optional getPresencePenalty() { return presencePenalty; } + /** + * @return When enabled, the user's prompt will be sent to the model without + * any pre-processing. + *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

+ */ + @JsonProperty("raw_prompting") + public Optional getRawPrompting() { + return rawPrompting; + } + /** * @return A list of available tools (functions) that the model may suggest invoking before producing a text response. *

When tools is passed (without tool_results), the text field in the response will be "" and the tool_calls field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the tool_calls array will be empty.

@@ -453,7 +453,6 @@ public Map getAdditionalProperties() { private boolean equalTo(ChatStreamRequest other) { return accepts.equals(other.accepts) - && rawPrompting.equals(other.rawPrompting) && message.equals(other.message) && model.equals(other.model) && preamble.equals(other.preamble) @@ -473,6 +472,7 @@ private boolean equalTo(ChatStreamRequest other) { && stopSequences.equals(other.stopSequences) && frequencyPenalty.equals(other.frequencyPenalty) && presencePenalty.equals(other.presencePenalty) + && rawPrompting.equals(other.rawPrompting) && tools.equals(other.tools) && toolResults.equals(other.toolResults) && forceSingleStep.equals(other.forceSingleStep) @@ -484,7 +484,6 @@ private boolean equalTo(ChatStreamRequest other) { public int hashCode() { return Objects.hash( this.accepts, - this.rawPrompting, this.message, this.model, this.preamble, @@ -504,6 +503,7 @@ public int hashCode() { this.stopSequences, this.frequencyPenalty, this.presencePenalty, + this.rawPrompting, this.tools, this.toolResults, this.forceSingleStep, @@ -540,15 +540,6 @@ public interface _FinalStage { _FinalStage accepts(String accepts); - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - _FinalStage rawPrompting(Optional rawPrompting); - - _FinalStage rawPrompting(Boolean rawPrompting); - /** *

The name of a compatible Cohere model or the ID of a fine-tuned model.

*

Compatible Deployments: Cohere Platform, Private Deployments

@@ -729,6 +720,15 @@ public interface _FinalStage { _FinalStage presencePenalty(Double presencePenalty); + /** + *

When enabled, the user's prompt will be sent to the model without + * any pre-processing.

+ *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

+ */ + _FinalStage rawPrompting(Optional rawPrompting); + + _FinalStage rawPrompting(Boolean rawPrompting); + /** *

A list of available tools (functions) that the model may suggest invoking before producing a text response.

*

When tools is passed (without tool_results), the text field in the response will be "" and the tool_calls field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the tool_calls array will be empty.

@@ -802,6 +802,8 @@ public static final class Builder implements MessageStage, _FinalStage { private Optional> tools = Optional.empty(); + private Optional rawPrompting = Optional.empty(); + private Optional presencePenalty = Optional.empty(); private Optional frequencyPenalty = Optional.empty(); @@ -838,8 +840,6 @@ public static final class Builder implements MessageStage, _FinalStage { private Optional model = Optional.empty(); - private Optional rawPrompting = Optional.empty(); - private Optional accepts = Optional.empty(); @JsonAnySetter @@ -850,7 +850,6 @@ private Builder() {} @java.lang.Override public Builder from(ChatStreamRequest other) { accepts(other.getAccepts()); - rawPrompting(other.getRawPrompting()); message(other.getMessage()); model(other.getModel()); preamble(other.getPreamble()); @@ -870,6 +869,7 @@ public Builder from(ChatStreamRequest other) { stopSequences(other.getStopSequences()); frequencyPenalty(other.getFrequencyPenalty()); presencePenalty(other.getPresencePenalty()); + rawPrompting(other.getRawPrompting()); tools(other.getTools()); toolResults(other.getToolResults()); forceSingleStep(other.getForceSingleStep()); @@ -1037,6 +1037,30 @@ public _FinalStage tools(Optional> tools) { return this; } + /** + *

When enabled, the user's prompt will be sent to the model without + * any pre-processing.

+ *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage rawPrompting(Boolean rawPrompting) { + this.rawPrompting = Optional.ofNullable(rawPrompting); + return this; + } + + /** + *

When enabled, the user's prompt will be sent to the model without + * any pre-processing.

+ *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

+ */ + @java.lang.Override + @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) + public _FinalStage rawPrompting(Optional rawPrompting) { + this.rawPrompting = rawPrompting; + return this; + } + /** *

Defaults to 0.0, min value of 0.0, max value of 1.0.

*

Used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

@@ -1505,30 +1529,6 @@ public _FinalStage model(Optional model) { return this; } - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage rawPrompting(Boolean rawPrompting) { - this.rawPrompting = Optional.ofNullable(rawPrompting); - return this; - } - - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - @java.lang.Override - @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) - public _FinalStage rawPrompting(Optional rawPrompting) { - this.rawPrompting = rawPrompting; - return this; - } - /** *

Pass text/event-stream to receive the streamed response as server-sent events. The default is \n delimited events.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1553,7 +1553,6 @@ public _FinalStage accepts(Optional accepts) { public ChatStreamRequest build() { return new ChatStreamRequest( accepts, - rawPrompting, message, model, preamble, @@ -1573,6 +1572,7 @@ public ChatStreamRequest build() { stopSequences, frequencyPenalty, presencePenalty, + rawPrompting, tools, toolResults, forceSingleStep, diff --git a/src/main/java/com/cohere/api/resources/v2/requests/V2ChatRequest.java b/src/main/java/com/cohere/api/resources/v2/requests/V2ChatRequest.java index 2d474c1..1d6b6b8 100644 --- a/src/main/java/com/cohere/api/resources/v2/requests/V2ChatRequest.java +++ b/src/main/java/com/cohere/api/resources/v2/requests/V2ChatRequest.java @@ -10,6 +10,7 @@ import com.cohere.api.types.ChatMessageV2; import com.cohere.api.types.CitationOptions; import com.cohere.api.types.ResponseFormatV2; +import com.cohere.api.types.Thinking; import com.cohere.api.types.ToolV2; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -42,8 +43,6 @@ public final class V2ChatRequest { private final Optional citationOptions; - private final Optional rawPrompting; - private final Optional responseFormat; private final Optional safetyMode; @@ -68,6 +67,8 @@ public final class V2ChatRequest { private final Optional toolChoice; + private final Optional thinking; + private final Map additionalProperties; private V2ChatRequest( @@ -77,7 +78,6 @@ private V2ChatRequest( Optional strictTools, Optional> documents, Optional citationOptions, - Optional rawPrompting, Optional responseFormat, Optional safetyMode, Optional maxTokens, @@ -90,6 +90,7 @@ private V2ChatRequest( Optional p, Optional logprobs, Optional toolChoice, + Optional thinking, Map additionalProperties) { this.model = model; this.messages = messages; @@ -97,7 +98,6 @@ private V2ChatRequest( this.strictTools = strictTools; this.documents = documents; this.citationOptions = citationOptions; - this.rawPrompting = rawPrompting; this.responseFormat = responseFormat; this.safetyMode = safetyMode; this.maxTokens = maxTokens; @@ -110,6 +110,7 @@ private V2ChatRequest( this.p = p; this.logprobs = logprobs; this.toolChoice = toolChoice; + this.thinking = thinking; this.additionalProperties = additionalProperties; } @@ -167,16 +168,6 @@ public Optional getCitationOptions() { return citationOptions; } - /** - * @return When enabled, the user's prompt will be sent to the model without - * any pre-processing. - *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - @JsonProperty("raw_prompting") - public Optional getRawPrompting() { - return rawPrompting; - } - @JsonProperty("response_format") public Optional getResponseFormat() { return responseFormat; @@ -195,8 +186,9 @@ public Optional getSafetyMode() { } /** - * @return The maximum number of tokens the model will generate as part of the response. - *

Note: Setting a low value may result in incomplete generations.

+ * @return The maximum number of output tokens the model will generate in the response. If not set, max_tokens defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the model documentation. + *

Note: Setting a low value may result in incomplete generations. In such cases, the finish_reason field in the response will be set to "MAX_TOKENS".

+ *

Note: If max_tokens is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.

*/ @JsonProperty("max_tokens") public Optional getMaxTokens() { @@ -281,13 +273,17 @@ public Optional getLogprobs() { * When NONE is specified, the model will be forced not to use one of the specified tools, and give a direct response. * If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not. *

Note: This parameter is only compatible with models Command-r7b and newer.

- *

Note: The same functionality can be achieved in /v1/chat using the force_single_step parameter. If force_single_step=true, this is equivalent to specifying REQUIRED. While if force_single_step=true and tool_results are passed, this is equivalent to specifying NONE.

*/ @JsonProperty("tool_choice") public Optional getToolChoice() { return toolChoice; } + @JsonProperty("thinking") + public Optional getThinking() { + return thinking; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -306,7 +302,6 @@ private boolean equalTo(V2ChatRequest other) { && strictTools.equals(other.strictTools) && documents.equals(other.documents) && citationOptions.equals(other.citationOptions) - && rawPrompting.equals(other.rawPrompting) && responseFormat.equals(other.responseFormat) && safetyMode.equals(other.safetyMode) && maxTokens.equals(other.maxTokens) @@ -318,7 +313,8 @@ private boolean equalTo(V2ChatRequest other) { && k.equals(other.k) && p.equals(other.p) && logprobs.equals(other.logprobs) - && toolChoice.equals(other.toolChoice); + && toolChoice.equals(other.toolChoice) + && thinking.equals(other.thinking); } @java.lang.Override @@ -330,7 +326,6 @@ public int hashCode() { this.strictTools, this.documents, this.citationOptions, - this.rawPrompting, this.responseFormat, this.safetyMode, this.maxTokens, @@ -342,7 +337,8 @@ public int hashCode() { this.k, this.p, this.logprobs, - this.toolChoice); + this.toolChoice, + this.thinking); } @java.lang.Override @@ -399,15 +395,6 @@ public interface _FinalStage { _FinalStage citationOptions(CitationOptions citationOptions); - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - _FinalStage rawPrompting(Optional rawPrompting); - - _FinalStage rawPrompting(Boolean rawPrompting); - _FinalStage responseFormat(Optional responseFormat); _FinalStage responseFormat(ResponseFormatV2 responseFormat); @@ -424,8 +411,9 @@ public interface _FinalStage { _FinalStage safetyMode(V2ChatRequestSafetyMode safetyMode); /** - *

The maximum number of tokens the model will generate as part of the response.

- *

Note: Setting a low value may result in incomplete generations.

+ *

The maximum number of output tokens the model will generate in the response. If not set, max_tokens defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the model documentation.

+ *

Note: Setting a low value may result in incomplete generations. In such cases, the finish_reason field in the response will be set to "MAX_TOKENS".

+ *

Note: If max_tokens is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.

*/ _FinalStage maxTokens(Optional maxTokens); @@ -501,17 +489,22 @@ public interface _FinalStage { * When NONE is specified, the model will be forced not to use one of the specified tools, and give a direct response. * If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not.

*

Note: This parameter is only compatible with models Command-r7b and newer.

- *

Note: The same functionality can be achieved in /v1/chat using the force_single_step parameter. If force_single_step=true, this is equivalent to specifying REQUIRED. While if force_single_step=true and tool_results are passed, this is equivalent to specifying NONE.

*/ _FinalStage toolChoice(Optional toolChoice); _FinalStage toolChoice(V2ChatRequestToolChoice toolChoice); + + _FinalStage thinking(Optional thinking); + + _FinalStage thinking(Thinking thinking); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ModelStage, _FinalStage { private String model; + private Optional thinking = Optional.empty(); + private Optional toolChoice = Optional.empty(); private Optional logprobs = Optional.empty(); @@ -536,8 +529,6 @@ public static final class Builder implements ModelStage, _FinalStage { private Optional responseFormat = Optional.empty(); - private Optional rawPrompting = Optional.empty(); - private Optional citationOptions = Optional.empty(); private Optional> documents = Optional.empty(); @@ -561,7 +552,6 @@ public Builder from(V2ChatRequest other) { strictTools(other.getStrictTools()); documents(other.getDocuments()); citationOptions(other.getCitationOptions()); - rawPrompting(other.getRawPrompting()); responseFormat(other.getResponseFormat()); safetyMode(other.getSafetyMode()); maxTokens(other.getMaxTokens()); @@ -574,6 +564,7 @@ public Builder from(V2ChatRequest other) { p(other.getP()); logprobs(other.getLogprobs()); toolChoice(other.getToolChoice()); + thinking(other.getThinking()); return this; } @@ -589,12 +580,24 @@ public _FinalStage model(@NotNull String model) { return this; } + @java.lang.Override + public _FinalStage thinking(Thinking thinking) { + this.thinking = Optional.ofNullable(thinking); + return this; + } + + @java.lang.Override + @JsonSetter(value = "thinking", nulls = Nulls.SKIP) + public _FinalStage thinking(Optional thinking) { + this.thinking = thinking; + return this; + } + /** *

Used to control whether or not the model will be forced to use a tool when answering. When REQUIRED is specified, the model will be forced to use at least one of the user-defined tools, and the tools parameter must be passed in the request. * When NONE is specified, the model will be forced not to use one of the specified tools, and give a direct response. * If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not.

*

Note: This parameter is only compatible with models Command-r7b and newer.

- *

Note: The same functionality can be achieved in /v1/chat using the force_single_step parameter. If force_single_step=true, this is equivalent to specifying REQUIRED. While if force_single_step=true and tool_results are passed, this is equivalent to specifying NONE.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -608,7 +611,6 @@ public _FinalStage toolChoice(V2ChatRequestToolChoice toolChoice) { * When NONE is specified, the model will be forced not to use one of the specified tools, and give a direct response. * If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not.

*

Note: This parameter is only compatible with models Command-r7b and newer.

- *

Note: The same functionality can be achieved in /v1/chat using the force_single_step parameter. If force_single_step=true, this is equivalent to specifying REQUIRED. While if force_single_step=true and tool_results are passed, this is equivalent to specifying NONE.

*/ @java.lang.Override @JsonSetter(value = "tool_choice", nulls = Nulls.SKIP) @@ -796,8 +798,9 @@ public _FinalStage stopSequences(Optional> stopSequences) { } /** - *

The maximum number of tokens the model will generate as part of the response.

- *

Note: Setting a low value may result in incomplete generations.

+ *

The maximum number of output tokens the model will generate in the response. If not set, max_tokens defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the model documentation.

+ *

Note: Setting a low value may result in incomplete generations. In such cases, the finish_reason field in the response will be set to "MAX_TOKENS".

+ *

Note: If max_tokens is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -807,8 +810,9 @@ public _FinalStage maxTokens(Integer maxTokens) { } /** - *

The maximum number of tokens the model will generate as part of the response.

- *

Note: Setting a low value may result in incomplete generations.

+ *

The maximum number of output tokens the model will generate in the response. If not set, max_tokens defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the model documentation.

+ *

Note: Setting a low value may result in incomplete generations. In such cases, the finish_reason field in the response will be set to "MAX_TOKENS".

+ *

Note: If max_tokens is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.

*/ @java.lang.Override @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) @@ -858,30 +862,6 @@ public _FinalStage responseFormat(Optional responseFormat) { return this; } - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage rawPrompting(Boolean rawPrompting) { - this.rawPrompting = Optional.ofNullable(rawPrompting); - return this; - } - - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - @java.lang.Override - @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) - public _FinalStage rawPrompting(Optional rawPrompting) { - this.rawPrompting = rawPrompting; - return this; - } - @java.lang.Override public _FinalStage citationOptions(CitationOptions citationOptions) { this.citationOptions = Optional.ofNullable(citationOptions); @@ -988,7 +968,6 @@ public V2ChatRequest build() { strictTools, documents, citationOptions, - rawPrompting, responseFormat, safetyMode, maxTokens, @@ -1001,6 +980,7 @@ public V2ChatRequest build() { p, logprobs, toolChoice, + thinking, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/resources/v2/requests/V2ChatStreamRequest.java b/src/main/java/com/cohere/api/resources/v2/requests/V2ChatStreamRequest.java index f2cfaf7..8bae398 100644 --- a/src/main/java/com/cohere/api/resources/v2/requests/V2ChatStreamRequest.java +++ b/src/main/java/com/cohere/api/resources/v2/requests/V2ChatStreamRequest.java @@ -10,6 +10,7 @@ import com.cohere.api.types.ChatMessageV2; import com.cohere.api.types.CitationOptions; import com.cohere.api.types.ResponseFormatV2; +import com.cohere.api.types.Thinking; import com.cohere.api.types.ToolV2; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -42,8 +43,6 @@ public final class V2ChatStreamRequest { private final Optional citationOptions; - private final Optional rawPrompting; - private final Optional responseFormat; private final Optional safetyMode; @@ -68,6 +67,8 @@ public final class V2ChatStreamRequest { private final Optional toolChoice; + private final Optional thinking; + private final Map additionalProperties; private V2ChatStreamRequest( @@ -77,7 +78,6 @@ private V2ChatStreamRequest( Optional strictTools, Optional> documents, Optional citationOptions, - Optional rawPrompting, Optional responseFormat, Optional safetyMode, Optional maxTokens, @@ -90,6 +90,7 @@ private V2ChatStreamRequest( Optional p, Optional logprobs, Optional toolChoice, + Optional thinking, Map additionalProperties) { this.model = model; this.messages = messages; @@ -97,7 +98,6 @@ private V2ChatStreamRequest( this.strictTools = strictTools; this.documents = documents; this.citationOptions = citationOptions; - this.rawPrompting = rawPrompting; this.responseFormat = responseFormat; this.safetyMode = safetyMode; this.maxTokens = maxTokens; @@ -110,6 +110,7 @@ private V2ChatStreamRequest( this.p = p; this.logprobs = logprobs; this.toolChoice = toolChoice; + this.thinking = thinking; this.additionalProperties = additionalProperties; } @@ -167,16 +168,6 @@ public Optional getCitationOptions() { return citationOptions; } - /** - * @return When enabled, the user's prompt will be sent to the model without - * any pre-processing. - *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - @JsonProperty("raw_prompting") - public Optional getRawPrompting() { - return rawPrompting; - } - @JsonProperty("response_format") public Optional getResponseFormat() { return responseFormat; @@ -195,8 +186,9 @@ public Optional getSafetyMode() { } /** - * @return The maximum number of tokens the model will generate as part of the response. - *

Note: Setting a low value may result in incomplete generations.

+ * @return The maximum number of output tokens the model will generate in the response. If not set, max_tokens defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the model documentation. + *

Note: Setting a low value may result in incomplete generations. In such cases, the finish_reason field in the response will be set to "MAX_TOKENS".

+ *

Note: If max_tokens is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.

*/ @JsonProperty("max_tokens") public Optional getMaxTokens() { @@ -281,13 +273,17 @@ public Optional getLogprobs() { * When NONE is specified, the model will be forced not to use one of the specified tools, and give a direct response. * If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not. *

Note: This parameter is only compatible with models Command-r7b and newer.

- *

Note: The same functionality can be achieved in /v1/chat using the force_single_step parameter. If force_single_step=true, this is equivalent to specifying REQUIRED. While if force_single_step=true and tool_results are passed, this is equivalent to specifying NONE.

*/ @JsonProperty("tool_choice") public Optional getToolChoice() { return toolChoice; } + @JsonProperty("thinking") + public Optional getThinking() { + return thinking; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -306,7 +302,6 @@ private boolean equalTo(V2ChatStreamRequest other) { && strictTools.equals(other.strictTools) && documents.equals(other.documents) && citationOptions.equals(other.citationOptions) - && rawPrompting.equals(other.rawPrompting) && responseFormat.equals(other.responseFormat) && safetyMode.equals(other.safetyMode) && maxTokens.equals(other.maxTokens) @@ -318,7 +313,8 @@ private boolean equalTo(V2ChatStreamRequest other) { && k.equals(other.k) && p.equals(other.p) && logprobs.equals(other.logprobs) - && toolChoice.equals(other.toolChoice); + && toolChoice.equals(other.toolChoice) + && thinking.equals(other.thinking); } @java.lang.Override @@ -330,7 +326,6 @@ public int hashCode() { this.strictTools, this.documents, this.citationOptions, - this.rawPrompting, this.responseFormat, this.safetyMode, this.maxTokens, @@ -342,7 +337,8 @@ public int hashCode() { this.k, this.p, this.logprobs, - this.toolChoice); + this.toolChoice, + this.thinking); } @java.lang.Override @@ -399,15 +395,6 @@ public interface _FinalStage { _FinalStage citationOptions(CitationOptions citationOptions); - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - _FinalStage rawPrompting(Optional rawPrompting); - - _FinalStage rawPrompting(Boolean rawPrompting); - _FinalStage responseFormat(Optional responseFormat); _FinalStage responseFormat(ResponseFormatV2 responseFormat); @@ -424,8 +411,9 @@ public interface _FinalStage { _FinalStage safetyMode(V2ChatStreamRequestSafetyMode safetyMode); /** - *

The maximum number of tokens the model will generate as part of the response.

- *

Note: Setting a low value may result in incomplete generations.

+ *

The maximum number of output tokens the model will generate in the response. If not set, max_tokens defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the model documentation.

+ *

Note: Setting a low value may result in incomplete generations. In such cases, the finish_reason field in the response will be set to "MAX_TOKENS".

+ *

Note: If max_tokens is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.

*/ _FinalStage maxTokens(Optional maxTokens); @@ -501,17 +489,22 @@ public interface _FinalStage { * When NONE is specified, the model will be forced not to use one of the specified tools, and give a direct response. * If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not.

*

Note: This parameter is only compatible with models Command-r7b and newer.

- *

Note: The same functionality can be achieved in /v1/chat using the force_single_step parameter. If force_single_step=true, this is equivalent to specifying REQUIRED. While if force_single_step=true and tool_results are passed, this is equivalent to specifying NONE.

*/ _FinalStage toolChoice(Optional toolChoice); _FinalStage toolChoice(V2ChatStreamRequestToolChoice toolChoice); + + _FinalStage thinking(Optional thinking); + + _FinalStage thinking(Thinking thinking); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ModelStage, _FinalStage { private String model; + private Optional thinking = Optional.empty(); + private Optional toolChoice = Optional.empty(); private Optional logprobs = Optional.empty(); @@ -536,8 +529,6 @@ public static final class Builder implements ModelStage, _FinalStage { private Optional responseFormat = Optional.empty(); - private Optional rawPrompting = Optional.empty(); - private Optional citationOptions = Optional.empty(); private Optional> documents = Optional.empty(); @@ -561,7 +552,6 @@ public Builder from(V2ChatStreamRequest other) { strictTools(other.getStrictTools()); documents(other.getDocuments()); citationOptions(other.getCitationOptions()); - rawPrompting(other.getRawPrompting()); responseFormat(other.getResponseFormat()); safetyMode(other.getSafetyMode()); maxTokens(other.getMaxTokens()); @@ -574,6 +564,7 @@ public Builder from(V2ChatStreamRequest other) { p(other.getP()); logprobs(other.getLogprobs()); toolChoice(other.getToolChoice()); + thinking(other.getThinking()); return this; } @@ -589,12 +580,24 @@ public _FinalStage model(@NotNull String model) { return this; } + @java.lang.Override + public _FinalStage thinking(Thinking thinking) { + this.thinking = Optional.ofNullable(thinking); + return this; + } + + @java.lang.Override + @JsonSetter(value = "thinking", nulls = Nulls.SKIP) + public _FinalStage thinking(Optional thinking) { + this.thinking = thinking; + return this; + } + /** *

Used to control whether or not the model will be forced to use a tool when answering. When REQUIRED is specified, the model will be forced to use at least one of the user-defined tools, and the tools parameter must be passed in the request. * When NONE is specified, the model will be forced not to use one of the specified tools, and give a direct response. * If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not.

*

Note: This parameter is only compatible with models Command-r7b and newer.

- *

Note: The same functionality can be achieved in /v1/chat using the force_single_step parameter. If force_single_step=true, this is equivalent to specifying REQUIRED. While if force_single_step=true and tool_results are passed, this is equivalent to specifying NONE.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -608,7 +611,6 @@ public _FinalStage toolChoice(V2ChatStreamRequestToolChoice toolChoice) { * When NONE is specified, the model will be forced not to use one of the specified tools, and give a direct response. * If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not.

*

Note: This parameter is only compatible with models Command-r7b and newer.

- *

Note: The same functionality can be achieved in /v1/chat using the force_single_step parameter. If force_single_step=true, this is equivalent to specifying REQUIRED. While if force_single_step=true and tool_results are passed, this is equivalent to specifying NONE.

*/ @java.lang.Override @JsonSetter(value = "tool_choice", nulls = Nulls.SKIP) @@ -796,8 +798,9 @@ public _FinalStage stopSequences(Optional> stopSequences) { } /** - *

The maximum number of tokens the model will generate as part of the response.

- *

Note: Setting a low value may result in incomplete generations.

+ *

The maximum number of output tokens the model will generate in the response. If not set, max_tokens defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the model documentation.

+ *

Note: Setting a low value may result in incomplete generations. In such cases, the finish_reason field in the response will be set to "MAX_TOKENS".

+ *

Note: If max_tokens is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -807,8 +810,9 @@ public _FinalStage maxTokens(Integer maxTokens) { } /** - *

The maximum number of tokens the model will generate as part of the response.

- *

Note: Setting a low value may result in incomplete generations.

+ *

The maximum number of output tokens the model will generate in the response. If not set, max_tokens defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the model documentation.

+ *

Note: Setting a low value may result in incomplete generations. In such cases, the finish_reason field in the response will be set to "MAX_TOKENS".

+ *

Note: If max_tokens is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.

*/ @java.lang.Override @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) @@ -858,30 +862,6 @@ public _FinalStage responseFormat(Optional responseFormat) { return this; } - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage rawPrompting(Boolean rawPrompting) { - this.rawPrompting = Optional.ofNullable(rawPrompting); - return this; - } - - /** - *

When enabled, the user's prompt will be sent to the model without - * any pre-processing.

- *

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

- */ - @java.lang.Override - @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) - public _FinalStage rawPrompting(Optional rawPrompting) { - this.rawPrompting = rawPrompting; - return this; - } - @java.lang.Override public _FinalStage citationOptions(CitationOptions citationOptions) { this.citationOptions = Optional.ofNullable(citationOptions); @@ -988,7 +968,6 @@ public V2ChatStreamRequest build() { strictTools, documents, citationOptions, - rawPrompting, responseFormat, safetyMode, maxTokens, @@ -1001,6 +980,7 @@ public V2ChatStreamRequest build() { p, logprobs, toolChoice, + thinking, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/resources/v2/requests/V2EmbedRequest.java b/src/main/java/com/cohere/api/resources/v2/requests/V2EmbedRequest.java index 3556fcf..aeb1df6 100644 --- a/src/main/java/com/cohere/api/resources/v2/requests/V2EmbedRequest.java +++ b/src/main/java/com/cohere/api/resources/v2/requests/V2EmbedRequest.java @@ -133,6 +133,7 @@ public Optional getOutputDimension() { *
  • "uint8": Use this when you want to get back unsigned int8 embeddings. Supported with Embed v3.0 and newer Embed models.
  • *
  • "binary": Use this when you want to get back signed binary embeddings. Supported with Embed v3.0 and newer Embed models.
  • *
  • "ubinary": Use this when you want to get back unsigned binary embeddings. Supported with Embed v3.0 and newer Embed models.
  • + *
  • "base64": Use this when you want to get back base64 embeddings. Supported with Embed v3.0 and newer Embed models.
  • * */ @JsonProperty("embedding_types") @@ -258,6 +259,7 @@ public interface _FinalStage { *
  • "uint8": Use this when you want to get back unsigned int8 embeddings. Supported with Embed v3.0 and newer Embed models.
  • *
  • "binary": Use this when you want to get back signed binary embeddings. Supported with Embed v3.0 and newer Embed models.
  • *
  • "ubinary": Use this when you want to get back unsigned binary embeddings. Supported with Embed v3.0 and newer Embed models.
  • + *
  • "base64": Use this when you want to get back base64 embeddings. Supported with Embed v3.0 and newer Embed models.
  • * */ _FinalStage embeddingTypes(Optional> embeddingTypes); @@ -364,6 +366,7 @@ public _FinalStage truncate(Optional truncate) { *
  • "uint8": Use this when you want to get back unsigned int8 embeddings. Supported with Embed v3.0 and newer Embed models.
  • *
  • "binary": Use this when you want to get back signed binary embeddings. Supported with Embed v3.0 and newer Embed models.
  • *
  • "ubinary": Use this when you want to get back unsigned binary embeddings. Supported with Embed v3.0 and newer Embed models.
  • + *
  • "base64": Use this when you want to get back base64 embeddings. Supported with Embed v3.0 and newer Embed models.
  • * * @return Reference to {@code this} so that method calls can be chained together. */ @@ -381,6 +384,7 @@ public _FinalStage embeddingTypes(List embeddingTypes) { *
  • "uint8": Use this when you want to get back unsigned int8 embeddings. Supported with Embed v3.0 and newer Embed models.
  • *
  • "binary": Use this when you want to get back signed binary embeddings. Supported with Embed v3.0 and newer Embed models.
  • *
  • "ubinary": Use this when you want to get back unsigned binary embeddings. Supported with Embed v3.0 and newer Embed models.
  • + *
  • "base64": Use this when you want to get back base64 embeddings. Supported with Embed v3.0 and newer Embed models.
  • * */ @java.lang.Override diff --git a/src/main/java/com/cohere/api/types/AssistantMessageResponseContentItem.java b/src/main/java/com/cohere/api/types/AssistantMessageResponseContentItem.java index c18756e..6a44f10 100644 --- a/src/main/java/com/cohere/api/types/AssistantMessageResponseContentItem.java +++ b/src/main/java/com/cohere/api/types/AssistantMessageResponseContentItem.java @@ -30,7 +30,7 @@ public static AssistantMessageResponseContentItem text(ChatTextContent value) { return new AssistantMessageResponseContentItem(new TextValue(value)); } - public static AssistantMessageResponseContentItem thinking(Object value) { + public static AssistantMessageResponseContentItem thinking(ChatThinkingContent value) { return new AssistantMessageResponseContentItem(new ThinkingValue(value)); } @@ -53,7 +53,7 @@ public Optional getText() { return Optional.empty(); } - public Optional getThinking() { + public Optional getThinking() { if (isThinking()) { return Optional.of(((ThinkingValue) value).value); } @@ -75,7 +75,7 @@ private Value getValue() { public interface Visitor { T visitText(ChatTextContent text); - T visitThinking(Object thinking); + T visitThinking(ChatThinkingContent thinking); T _visitUnknown(Object unknownType); } @@ -129,11 +129,13 @@ public String toString() { @JsonTypeName("thinking") @JsonIgnoreProperties("type") private static final class ThinkingValue implements Value { - @JsonProperty("value") - private Object value; + @JsonUnwrapped + private ChatThinkingContent value; @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private ThinkingValue(@JsonProperty("value") Object value) { + private ThinkingValue() {} + + private ThinkingValue(ChatThinkingContent value) { this.value = value; } diff --git a/src/main/java/com/cohere/api/types/AssistantMessageV2ContentItem.java b/src/main/java/com/cohere/api/types/AssistantMessageV2ContentItem.java index e077943..2636dda 100644 --- a/src/main/java/com/cohere/api/types/AssistantMessageV2ContentItem.java +++ b/src/main/java/com/cohere/api/types/AssistantMessageV2ContentItem.java @@ -30,10 +30,18 @@ public static AssistantMessageV2ContentItem text(ChatTextContent value) { return new AssistantMessageV2ContentItem(new TextValue(value)); } + public static AssistantMessageV2ContentItem thinking(ChatThinkingContent value) { + return new AssistantMessageV2ContentItem(new ThinkingValue(value)); + } + public boolean isText() { return value instanceof TextValue; } + public boolean isThinking() { + return value instanceof ThinkingValue; + } + public boolean _isUnknown() { return value instanceof _UnknownValue; } @@ -45,6 +53,13 @@ public Optional getText() { return Optional.empty(); } + public Optional getThinking() { + if (isThinking()) { + return Optional.of(((ThinkingValue) value).value); + } + return Optional.empty(); + } + public Optional _getUnknown() { if (_isUnknown()) { return Optional.of(((_UnknownValue) value).value); @@ -60,11 +75,13 @@ private Value getValue() { public interface Visitor { T visitText(ChatTextContent text); + T visitThinking(ChatThinkingContent thinking); + T _visitUnknown(Object unknownType); } @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) - @JsonSubTypes(@JsonSubTypes.Type(TextValue.class)) + @JsonSubTypes({@JsonSubTypes.Type(TextValue.class), @JsonSubTypes.Type(ThinkingValue.class)}) @JsonIgnoreProperties(ignoreUnknown = true) private interface Value { T visit(Visitor visitor); @@ -109,6 +126,45 @@ public String toString() { } } + @JsonTypeName("thinking") + @JsonIgnoreProperties("type") + private static final class ThinkingValue implements Value { + @JsonUnwrapped + private ChatThinkingContent value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private ThinkingValue() {} + + private ThinkingValue(ChatThinkingContent value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitThinking(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ThinkingValue && equalTo((ThinkingValue) other); + } + + private boolean equalTo(ThinkingValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AssistantMessageV2ContentItem{" + "value: " + value + "}"; + } + } + @JsonIgnoreProperties("type") private static final class _UnknownValue implements Value { private String type; diff --git a/src/main/java/com/cohere/api/types/ChatContentDeltaEventDeltaMessageContent.java b/src/main/java/com/cohere/api/types/ChatContentDeltaEventDeltaMessageContent.java index a100ca0..8005c7d 100644 --- a/src/main/java/com/cohere/api/types/ChatContentDeltaEventDeltaMessageContent.java +++ b/src/main/java/com/cohere/api/types/ChatContentDeltaEventDeltaMessageContent.java @@ -20,15 +20,24 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ChatContentDeltaEventDeltaMessageContent.Builder.class) public final class ChatContentDeltaEventDeltaMessageContent { + private final Optional thinking; + private final Optional text; private final Map additionalProperties; - private ChatContentDeltaEventDeltaMessageContent(Optional text, Map additionalProperties) { + private ChatContentDeltaEventDeltaMessageContent( + Optional thinking, Optional text, Map additionalProperties) { + this.thinking = thinking; this.text = text; this.additionalProperties = additionalProperties; } + @JsonProperty("thinking") + public Optional getThinking() { + return thinking; + } + @JsonProperty("text") public Optional getText() { return text; @@ -47,12 +56,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ChatContentDeltaEventDeltaMessageContent other) { - return text.equals(other.text); + return thinking.equals(other.thinking) && text.equals(other.text); } @java.lang.Override public int hashCode() { - return Objects.hash(this.text); + return Objects.hash(this.thinking, this.text); } @java.lang.Override @@ -66,6 +75,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional thinking = Optional.empty(); + private Optional text = Optional.empty(); @JsonAnySetter @@ -74,10 +85,22 @@ public static final class Builder { private Builder() {} public Builder from(ChatContentDeltaEventDeltaMessageContent other) { + thinking(other.getThinking()); text(other.getText()); return this; } + @JsonSetter(value = "thinking", nulls = Nulls.SKIP) + public Builder thinking(Optional thinking) { + this.thinking = thinking; + return this; + } + + public Builder thinking(String thinking) { + this.thinking = Optional.ofNullable(thinking); + return this; + } + @JsonSetter(value = "text", nulls = Nulls.SKIP) public Builder text(Optional text) { this.text = text; @@ -90,7 +113,7 @@ public Builder text(String text) { } public ChatContentDeltaEventDeltaMessageContent build() { - return new ChatContentDeltaEventDeltaMessageContent(text, additionalProperties); + return new ChatContentDeltaEventDeltaMessageContent(thinking, text, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ChatContentStartEventDeltaMessageContent.java b/src/main/java/com/cohere/api/types/ChatContentStartEventDeltaMessageContent.java index 3feacf4..1ac6730 100644 --- a/src/main/java/com/cohere/api/types/ChatContentStartEventDeltaMessageContent.java +++ b/src/main/java/com/cohere/api/types/ChatContentStartEventDeltaMessageContent.java @@ -20,6 +20,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ChatContentStartEventDeltaMessageContent.Builder.class) public final class ChatContentStartEventDeltaMessageContent { + private final Optional thinking; + private final Optional text; private final Optional type; @@ -27,14 +29,21 @@ public final class ChatContentStartEventDeltaMessageContent { private final Map additionalProperties; private ChatContentStartEventDeltaMessageContent( + Optional thinking, Optional text, Optional type, Map additionalProperties) { + this.thinking = thinking; this.text = text; this.type = type; this.additionalProperties = additionalProperties; } + @JsonProperty("thinking") + public Optional getThinking() { + return thinking; + } + @JsonProperty("text") public Optional getText() { return text; @@ -58,12 +67,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ChatContentStartEventDeltaMessageContent other) { - return text.equals(other.text) && type.equals(other.type); + return thinking.equals(other.thinking) && text.equals(other.text) && type.equals(other.type); } @java.lang.Override public int hashCode() { - return Objects.hash(this.text, this.type); + return Objects.hash(this.thinking, this.text, this.type); } @java.lang.Override @@ -77,6 +86,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional thinking = Optional.empty(); + private Optional text = Optional.empty(); private Optional type = Optional.empty(); @@ -87,11 +98,23 @@ public static final class Builder { private Builder() {} public Builder from(ChatContentStartEventDeltaMessageContent other) { + thinking(other.getThinking()); text(other.getText()); type(other.getType()); return this; } + @JsonSetter(value = "thinking", nulls = Nulls.SKIP) + public Builder thinking(Optional thinking) { + this.thinking = thinking; + return this; + } + + public Builder thinking(String thinking) { + this.thinking = Optional.ofNullable(thinking); + return this; + } + @JsonSetter(value = "text", nulls = Nulls.SKIP) public Builder text(Optional text) { this.text = text; @@ -115,7 +138,7 @@ public Builder type(ChatContentStartEventDeltaMessageContentType type) { } public ChatContentStartEventDeltaMessageContent build() { - return new ChatContentStartEventDeltaMessageContent(text, type, additionalProperties); + return new ChatContentStartEventDeltaMessageContent(thinking, text, type, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ChatThinkingContent.java b/src/main/java/com/cohere/api/types/ChatThinkingContent.java new file mode 100644 index 0000000..0021223 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatThinkingContent.java @@ -0,0 +1,102 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ChatThinkingContent.Builder.class) +public final class ChatThinkingContent { + private final String thinking; + + private final Map additionalProperties; + + private ChatThinkingContent(String thinking, Map additionalProperties) { + this.thinking = thinking; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("thinking") + public String getThinking() { + return thinking; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatThinkingContent && equalTo((ChatThinkingContent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatThinkingContent other) { + return thinking.equals(other.thinking); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.thinking); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ThinkingStage builder() { + return new Builder(); + } + + public interface ThinkingStage { + _FinalStage thinking(@NotNull String thinking); + + Builder from(ChatThinkingContent other); + } + + public interface _FinalStage { + ChatThinkingContent build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ThinkingStage, _FinalStage { + private String thinking; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ChatThinkingContent other) { + thinking(other.getThinking()); + return this; + } + + @java.lang.Override + @JsonSetter("thinking") + public _FinalStage thinking(@NotNull String thinking) { + this.thinking = Objects.requireNonNull(thinking, "thinking must not be null"); + return this; + } + + @java.lang.Override + public ChatThinkingContent build() { + return new ChatThinkingContent(thinking, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java b/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java index 843f74f..4b05a29 100644 --- a/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java +++ b/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java @@ -31,6 +31,8 @@ public final class EmbedByTypeResponseEmbeddings { private final Optional>> ubinary; + private final Optional> base64; + private final Map additionalProperties; private EmbedByTypeResponseEmbeddings( @@ -39,12 +41,14 @@ private EmbedByTypeResponseEmbeddings( Optional>> uint8, Optional>> binary, Optional>> ubinary, + Optional> base64, Map additionalProperties) { this.float_ = float_; this.int8 = int8; this.uint8 = uint8; this.binary = binary; this.ubinary = ubinary; + this.base64 = base64; this.additionalProperties = additionalProperties; } @@ -88,6 +92,14 @@ public Optional>> getUbinary() { return ubinary; } + /** + * @return An array of base64 embeddings. Each string is the result of appending the float embedding bytes together and base64 encoding that. + */ + @JsonProperty("base64") + public Optional> getBase64() { + return base64; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -104,12 +116,13 @@ private boolean equalTo(EmbedByTypeResponseEmbeddings other) { && int8.equals(other.int8) && uint8.equals(other.uint8) && binary.equals(other.binary) - && ubinary.equals(other.ubinary); + && ubinary.equals(other.ubinary) + && base64.equals(other.base64); } @java.lang.Override public int hashCode() { - return Objects.hash(this.float_, this.int8, this.uint8, this.binary, this.ubinary); + return Objects.hash(this.float_, this.int8, this.uint8, this.binary, this.ubinary, this.base64); } @java.lang.Override @@ -133,6 +146,8 @@ public static final class Builder { private Optional>> ubinary = Optional.empty(); + private Optional> base64 = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -144,6 +159,7 @@ public Builder from(EmbedByTypeResponseEmbeddings other) { uint8(other.getUint8()); binary(other.getBinary()); ubinary(other.getUbinary()); + base64(other.getBase64()); return this; } @@ -217,8 +233,23 @@ public Builder ubinary(List> ubinary) { return this; } + /** + *

    An array of base64 embeddings. Each string is the result of appending the float embedding bytes together and base64 encoding that.

    + */ + @JsonSetter(value = "base64", nulls = Nulls.SKIP) + public Builder base64(Optional> base64) { + this.base64 = base64; + return this; + } + + public Builder base64(List base64) { + this.base64 = Optional.ofNullable(base64); + return this; + } + public EmbedByTypeResponseEmbeddings build() { - return new EmbedByTypeResponseEmbeddings(float_, int8, uint8, binary, ubinary, additionalProperties); + return new EmbedByTypeResponseEmbeddings( + float_, int8, uint8, binary, ubinary, base64, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/EmbeddingType.java b/src/main/java/com/cohere/api/types/EmbeddingType.java index 63e8883..daa98e1 100644 --- a/src/main/java/com/cohere/api/types/EmbeddingType.java +++ b/src/main/java/com/cohere/api/types/EmbeddingType.java @@ -14,7 +14,9 @@ public enum EmbeddingType { BINARY("binary"), - UBINARY("ubinary"); + UBINARY("ubinary"), + + BASE_64("base64"); private final String value; diff --git a/src/main/java/com/cohere/api/types/Thinking.java b/src/main/java/com/cohere/api/types/Thinking.java new file mode 100644 index 0000000..476f757 --- /dev/null +++ b/src/main/java/com/cohere/api/types/Thinking.java @@ -0,0 +1,160 @@ +/** + * 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; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Thinking.Builder.class) +public final class Thinking { + private final ThinkingType type; + + private final Optional tokenBudget; + + private final Map additionalProperties; + + private Thinking(ThinkingType type, Optional tokenBudget, Map additionalProperties) { + this.type = type; + this.tokenBudget = tokenBudget; + this.additionalProperties = additionalProperties; + } + + /** + * @return Reasoning is enabled by default for models that support it, but can be turned off by setting "type": "disabled". + */ + @JsonProperty("type") + public ThinkingType getType() { + return type; + } + + /** + * @return The maximum number of tokens the model can use for thinking, which must be set to a positive integer. + * The model will stop thinking if it reaches the thinking token budget and will proceed with the response. + */ + @JsonProperty("token_budget") + public Optional getTokenBudget() { + return tokenBudget; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Thinking && equalTo((Thinking) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Thinking other) { + return type.equals(other.type) && tokenBudget.equals(other.tokenBudget); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.tokenBudget); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + /** + *

    Reasoning is enabled by default for models that support it, but can be turned off by setting "type": "disabled".

    + */ + _FinalStage type(@NotNull ThinkingType type); + + Builder from(Thinking other); + } + + public interface _FinalStage { + Thinking build(); + + /** + *

    The maximum number of tokens the model can use for thinking, which must be set to a positive integer. + * The model will stop thinking if it reaches the thinking token budget and will proceed with the response.

    + */ + _FinalStage tokenBudget(Optional tokenBudget); + + _FinalStage tokenBudget(Integer tokenBudget); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TypeStage, _FinalStage { + private ThinkingType type; + + private Optional tokenBudget = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Thinking other) { + type(other.getType()); + tokenBudget(other.getTokenBudget()); + return this; + } + + /** + *

    Reasoning is enabled by default for models that support it, but can be turned off by setting "type": "disabled".

    + *

    Reasoning is enabled by default for models that support it, but can be turned off by setting "type": "disabled".

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("type") + public _FinalStage type(@NotNull ThinkingType type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + /** + *

    The maximum number of tokens the model can use for thinking, which must be set to a positive integer. + * The model will stop thinking if it reaches the thinking token budget and will proceed with the response.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage tokenBudget(Integer tokenBudget) { + this.tokenBudget = Optional.ofNullable(tokenBudget); + return this; + } + + /** + *

    The maximum number of tokens the model can use for thinking, which must be set to a positive integer. + * The model will stop thinking if it reaches the thinking token budget and will proceed with the response.

    + */ + @java.lang.Override + @JsonSetter(value = "token_budget", nulls = Nulls.SKIP) + public _FinalStage tokenBudget(Optional tokenBudget) { + this.tokenBudget = tokenBudget; + return this; + } + + @java.lang.Override + public Thinking build() { + return new Thinking(type, tokenBudget, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ReasoningEffort.java b/src/main/java/com/cohere/api/types/ThinkingType.java similarity index 72% rename from src/main/java/com/cohere/api/types/ReasoningEffort.java rename to src/main/java/com/cohere/api/types/ThinkingType.java index ea7b528..dff8242 100644 --- a/src/main/java/com/cohere/api/types/ReasoningEffort.java +++ b/src/main/java/com/cohere/api/types/ThinkingType.java @@ -5,16 +5,14 @@ import com.fasterxml.jackson.annotation.JsonValue; -public enum ReasoningEffort { - LOW("low"), +public enum ThinkingType { + ENABLED("enabled"), - MEDIUM("medium"), - - HIGH("high"); + DISABLED("disabled"); private final String value; - ReasoningEffort(String value) { + ThinkingType(String value) { this.value = value; }