diff --git a/build.gradle b/build.gradle index 102bc1e..caef60e 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ java { group = 'com.cohere' -version = '1.8.0' +version = '1.8.1' jar { dependsOn(":generatePomFileForMavenPublication") @@ -77,7 +77,7 @@ publishing { maven(MavenPublication) { groupId = 'com.cohere' artifactId = 'cohere-java' - version = '1.8.0' + version = '1.8.1' from components.java pom { name = 'cohere' diff --git a/reference.md b/reference.md index fb5cb69..fa45643 100644 --- a/reference.md +++ b/reference.md @@ -57,6 +57,19 @@ 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. @@ -528,6 +541,19 @@ 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. @@ -2265,6 +2291,19 @@ 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`
@@ -2543,6 +2582,19 @@ 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`
diff --git a/src/main/java/com/cohere/api/AsyncRawCohere.java b/src/main/java/com/cohere/api/AsyncRawCohere.java index c3728c4..f3276b4 100644 --- a/src/main/java/com/cohere/api/AsyncRawCohere.java +++ b/src/main/java/com/cohere/api/AsyncRawCohere.java @@ -87,6 +87,9 @@ 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()); @@ -296,6 +299,9 @@ 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()); diff --git a/src/main/java/com/cohere/api/RawCohere.java b/src/main/java/com/cohere/api/RawCohere.java index 3f3ec4e..8dbeb2b 100644 --- a/src/main/java/com/cohere/api/RawCohere.java +++ b/src/main/java/com/cohere/api/RawCohere.java @@ -83,6 +83,9 @@ 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()); @@ -253,6 +256,9 @@ 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()); diff --git a/src/main/java/com/cohere/api/core/ClientOptions.java b/src/main/java/com/cohere/api/core/ClientOptions.java index 07e7379..906ee74 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.0"); + put("User-Agent", "com.cohere:cohere-java/1.8.1"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.cohere.fern:api-sdk"); - put("X-Fern-SDK-Version", "1.8.0"); + put("X-Fern-SDK-Version", "1.8.1"); } }); 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 5c4e8d7..efb2908 100644 --- a/src/main/java/com/cohere/api/requests/ChatRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatRequest.java @@ -32,6 +32,8 @@ public final class ChatRequest { private final Optional accepts; + private final Optional rawPrompting; + private final String message; private final Optional model; @@ -84,6 +86,7 @@ public final class ChatRequest { private ChatRequest( Optional accepts, + Optional rawPrompting, String message, Optional model, Optional preamble, @@ -110,6 +113,7 @@ private ChatRequest( Optional safetyMode, Map additionalProperties) { this.accepts = accepts; + this.rawPrompting = rawPrompting; this.message = message; this.model = model; this.preamble = preamble; @@ -145,6 +149,16 @@ 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

@@ -439,6 +453,7 @@ 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) @@ -469,6 +484,7 @@ private boolean equalTo(ChatRequest other) { public int hashCode() { return Objects.hash( this.accepts, + this.rawPrompting, this.message, this.model, this.preamble, @@ -524,6 +540,15 @@ 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

@@ -813,6 +838,8 @@ public static final class Builder implements MessageStage, _FinalStage { private Optional model = Optional.empty(); + private Optional rawPrompting = Optional.empty(); + private Optional accepts = Optional.empty(); @JsonAnySetter @@ -823,6 +850,7 @@ 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()); @@ -1477,6 +1505,30 @@ 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. @@ -1501,6 +1553,7 @@ public _FinalStage accepts(Optional accepts) { public ChatRequest build() { return new ChatRequest( accepts, + rawPrompting, message, model, preamble, diff --git a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java index f3f1089..3cbf491 100644 --- a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java @@ -32,6 +32,8 @@ public final class ChatStreamRequest { private final Optional accepts; + private final Optional rawPrompting; + private final String message; private final Optional model; @@ -84,6 +86,7 @@ public final class ChatStreamRequest { private ChatStreamRequest( Optional accepts, + Optional rawPrompting, String message, Optional model, Optional preamble, @@ -110,6 +113,7 @@ private ChatStreamRequest( Optional safetyMode, Map additionalProperties) { this.accepts = accepts; + this.rawPrompting = rawPrompting; this.message = message; this.model = model; this.preamble = preamble; @@ -145,6 +149,16 @@ 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

@@ -439,6 +453,7 @@ 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) @@ -469,6 +484,7 @@ private boolean equalTo(ChatStreamRequest other) { public int hashCode() { return Objects.hash( this.accepts, + this.rawPrompting, this.message, this.model, this.preamble, @@ -524,6 +540,15 @@ 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

@@ -813,6 +838,8 @@ public static final class Builder implements MessageStage, _FinalStage { private Optional model = Optional.empty(); + private Optional rawPrompting = Optional.empty(); + private Optional accepts = Optional.empty(); @JsonAnySetter @@ -823,6 +850,7 @@ 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()); @@ -1477,6 +1505,30 @@ 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. @@ -1501,6 +1553,7 @@ public _FinalStage accepts(Optional accepts) { public ChatStreamRequest build() { return new ChatStreamRequest( accepts, + rawPrompting, message, model, preamble, 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 b4d05cf..2d474c1 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 @@ -42,6 +42,8 @@ public final class V2ChatRequest { private final Optional citationOptions; + private final Optional rawPrompting; + private final Optional responseFormat; private final Optional safetyMode; @@ -75,6 +77,7 @@ private V2ChatRequest( Optional strictTools, Optional> documents, Optional citationOptions, + Optional rawPrompting, Optional responseFormat, Optional safetyMode, Optional maxTokens, @@ -94,6 +97,7 @@ private V2ChatRequest( this.strictTools = strictTools; this.documents = documents; this.citationOptions = citationOptions; + this.rawPrompting = rawPrompting; this.responseFormat = responseFormat; this.safetyMode = safetyMode; this.maxTokens = maxTokens; @@ -163,6 +167,16 @@ 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; @@ -292,6 +306,7 @@ 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) @@ -315,6 +330,7 @@ public int hashCode() { this.strictTools, this.documents, this.citationOptions, + this.rawPrompting, this.responseFormat, this.safetyMode, this.maxTokens, @@ -383,6 +399,15 @@ 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); @@ -511,6 +536,8 @@ 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(); @@ -534,6 +561,7 @@ 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()); @@ -830,6 +858,30 @@ 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); @@ -936,6 +988,7 @@ public V2ChatRequest build() { strictTools, documents, citationOptions, + rawPrompting, responseFormat, safetyMode, maxTokens, 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 1da787d..f2cfaf7 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 @@ -42,6 +42,8 @@ public final class V2ChatStreamRequest { private final Optional citationOptions; + private final Optional rawPrompting; + private final Optional responseFormat; private final Optional safetyMode; @@ -75,6 +77,7 @@ private V2ChatStreamRequest( Optional strictTools, Optional> documents, Optional citationOptions, + Optional rawPrompting, Optional responseFormat, Optional safetyMode, Optional maxTokens, @@ -94,6 +97,7 @@ private V2ChatStreamRequest( this.strictTools = strictTools; this.documents = documents; this.citationOptions = citationOptions; + this.rawPrompting = rawPrompting; this.responseFormat = responseFormat; this.safetyMode = safetyMode; this.maxTokens = maxTokens; @@ -163,6 +167,16 @@ 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; @@ -292,6 +306,7 @@ 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) @@ -315,6 +330,7 @@ public int hashCode() { this.strictTools, this.documents, this.citationOptions, + this.rawPrompting, this.responseFormat, this.safetyMode, this.maxTokens, @@ -383,6 +399,15 @@ 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); @@ -511,6 +536,8 @@ 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(); @@ -534,6 +561,7 @@ 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()); @@ -830,6 +858,30 @@ 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); @@ -936,6 +988,7 @@ public V2ChatStreamRequest build() { strictTools, documents, citationOptions, + rawPrompting, responseFormat, safetyMode, maxTokens, diff --git a/src/main/java/com/cohere/api/types/ChatMessageEndEventDelta.java b/src/main/java/com/cohere/api/types/ChatMessageEndEventDelta.java index 0b0b55f..f47a71d 100644 --- a/src/main/java/com/cohere/api/types/ChatMessageEndEventDelta.java +++ b/src/main/java/com/cohere/api/types/ChatMessageEndEventDelta.java @@ -22,10 +22,20 @@ public final class ChatMessageEndEventDelta { private final Optional error; + private final Optional finishReason; + + private final Optional usage; + private final Map additionalProperties; - private ChatMessageEndEventDelta(Optional error, Map additionalProperties) { + private ChatMessageEndEventDelta( + Optional error, + Optional finishReason, + Optional usage, + Map additionalProperties) { this.error = error; + this.finishReason = finishReason; + this.usage = usage; this.additionalProperties = additionalProperties; } @@ -37,6 +47,16 @@ public Optional getError() { return error; } + @JsonProperty("finish_reason") + public Optional getFinishReason() { + return finishReason; + } + + @JsonProperty("usage") + public Optional getUsage() { + return usage; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +69,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ChatMessageEndEventDelta other) { - return error.equals(other.error); + return error.equals(other.error) && finishReason.equals(other.finishReason) && usage.equals(other.usage); } @java.lang.Override public int hashCode() { - return Objects.hash(this.error); + return Objects.hash(this.error, this.finishReason, this.usage); } @java.lang.Override @@ -70,6 +90,10 @@ public static Builder builder() { public static final class Builder { private Optional error = Optional.empty(); + private Optional finishReason = Optional.empty(); + + private Optional usage = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +101,8 @@ private Builder() {} public Builder from(ChatMessageEndEventDelta other) { error(other.getError()); + finishReason(other.getFinishReason()); + usage(other.getUsage()); return this; } @@ -94,8 +120,30 @@ public Builder error(String error) { return this; } + @JsonSetter(value = "finish_reason", nulls = Nulls.SKIP) + public Builder finishReason(Optional finishReason) { + this.finishReason = finishReason; + return this; + } + + public Builder finishReason(ChatFinishReason finishReason) { + this.finishReason = Optional.ofNullable(finishReason); + return this; + } + + @JsonSetter(value = "usage", nulls = Nulls.SKIP) + public Builder usage(Optional usage) { + this.usage = usage; + return this; + } + + public Builder usage(Usage usage) { + this.usage = Optional.ofNullable(usage); + return this; + } + public ChatMessageEndEventDelta build() { - return new ChatMessageEndEventDelta(error, additionalProperties); + return new ChatMessageEndEventDelta(error, finishReason, usage, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/Citation.java b/src/main/java/com/cohere/api/types/Citation.java index c65f143..1130368 100644 --- a/src/main/java/com/cohere/api/types/Citation.java +++ b/src/main/java/com/cohere/api/types/Citation.java @@ -29,6 +29,8 @@ public final class Citation { private final Optional> sources; + private final Optional contentIndex; + private final Optional type; private final Map additionalProperties; @@ -38,12 +40,14 @@ private Citation( Optional end, Optional text, Optional> sources, + Optional contentIndex, Optional type, Map additionalProperties) { this.start = start; this.end = end; this.text = text; this.sources = sources; + this.contentIndex = contentIndex; this.type = type; this.additionalProperties = additionalProperties; } @@ -77,6 +81,14 @@ public Optional> getSources() { return sources; } + /** + * @return Index of the content block in which this citation appears. + */ + @JsonProperty("content_index") + public Optional getContentIndex() { + return contentIndex; + } + @JsonProperty("type") public Optional getType() { return type; @@ -98,12 +110,13 @@ private boolean equalTo(Citation other) { && end.equals(other.end) && text.equals(other.text) && sources.equals(other.sources) + && contentIndex.equals(other.contentIndex) && type.equals(other.type); } @java.lang.Override public int hashCode() { - return Objects.hash(this.start, this.end, this.text, this.sources, this.type); + return Objects.hash(this.start, this.end, this.text, this.sources, this.contentIndex, this.type); } @java.lang.Override @@ -125,6 +138,8 @@ public static final class Builder { private Optional> sources = Optional.empty(); + private Optional contentIndex = Optional.empty(); + private Optional type = Optional.empty(); @JsonAnySetter @@ -137,6 +152,7 @@ public Builder from(Citation other) { end(other.getEnd()); text(other.getText()); sources(other.getSources()); + contentIndex(other.getContentIndex()); type(other.getType()); return this; } @@ -194,6 +210,20 @@ public Builder sources(List sources) { return this; } + /** + *

Index of the content block in which this citation appears.

+ */ + @JsonSetter(value = "content_index", nulls = Nulls.SKIP) + public Builder contentIndex(Optional contentIndex) { + this.contentIndex = contentIndex; + return this; + } + + public Builder contentIndex(Integer contentIndex) { + this.contentIndex = Optional.ofNullable(contentIndex); + return this; + } + @JsonSetter(value = "type", nulls = Nulls.SKIP) public Builder type(Optional type) { this.type = type; @@ -206,7 +236,7 @@ public Builder type(CitationType type) { } public Citation build() { - return new Citation(start, end, text, sources, type, additionalProperties); + return new Citation(start, end, text, sources, contentIndex, type, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/CitationType.java b/src/main/java/com/cohere/api/types/CitationType.java index b08618a..1498629 100644 --- a/src/main/java/com/cohere/api/types/CitationType.java +++ b/src/main/java/com/cohere/api/types/CitationType.java @@ -8,6 +8,8 @@ public enum CitationType { TEXT_CONTENT("TEXT_CONTENT"), + THINKING_CONTENT("THINKING_CONTENT"), + PLAN("PLAN"); private final String value;