diff --git a/build.gradle b/build.gradle index 5ea8590..82ce699 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,7 @@ publishing { maven(MavenPublication) { groupId = 'com.cohere' artifactId = 'cohere-java' - version = '1.0.8' + version = '1.0.9' from components.java pom { name = 'cohere' diff --git a/src/main/java/com/cohere/api/Cohere.java b/src/main/java/com/cohere/api/Cohere.java index 12f0c31..f4fd761 100644 --- a/src/main/java/com/cohere/api/Cohere.java +++ b/src/main/java/com/cohere/api/Cohere.java @@ -70,7 +70,7 @@ public Cohere(ClientOptions clientOptions) { /** * Generates a text response to a user message. - * To learn how to use Chat with Streaming and RAG follow this guide. + * To learn how to use the Chat API with Streaming and RAG follow our Text Generation guides. */ public Iterable chatStream(ChatStreamRequest request) { return chatStream(request, null); @@ -78,7 +78,7 @@ public Iterable chatStream(ChatStreamRequest request) { /** * Generates a text response to a user message. - * To learn how to use Chat with Streaming and RAG follow this guide. + * To learn how to use the Chat API with Streaming and RAG follow our Text Generation guides. */ public Iterable chatStream(ChatStreamRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -119,7 +119,7 @@ public Iterable chatStream(ChatStreamRequest request, Requ /** * Generates a text response to a user message. - * To learn how to use Chat with Streaming and RAG follow this guide. + * To learn how to use the Chat API with Streaming and RAG follow our Text Generation guides. */ public NonStreamedChatResponse chat(ChatRequest request) { return chat(request, null); @@ -127,7 +127,7 @@ public NonStreamedChatResponse chat(ChatRequest request) { /** * Generates a text response to a user message. - * To learn how to use Chat with Streaming and RAG follow this guide. + * To learn how to use the Chat API with Streaming and RAG follow our Text Generation guides. */ public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) diff --git a/src/main/java/com/cohere/api/CohereBuilder.java b/src/main/java/com/cohere/api/CohereBuilder.java index 133039f..e6fa445 100644 --- a/src/main/java/com/cohere/api/CohereBuilder.java +++ b/src/main/java/com/cohere/api/CohereBuilder.java @@ -47,7 +47,7 @@ public Cohere build() { throw new RuntimeException("Please provide token or set the CO_API_KEY environment variable."); } this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); - if (clientName != null) { + if (clientName.isPresent()) { this.clientOptionsBuilder.addHeader("X-Client-Name", this.clientName); } clientOptionsBuilder.environment(this.environment); diff --git a/src/main/java/com/cohere/api/core/ClientOptions.java b/src/main/java/com/cohere/api/core/ClientOptions.java index 3d6612d..62f3eea 100644 --- a/src/main/java/com/cohere/api/core/ClientOptions.java +++ b/src/main/java/com/cohere/api/core/ClientOptions.java @@ -30,7 +30,7 @@ private ClientOptions( "X-Fern-SDK-Name", "com.cohere.fern:api-sdk", "X-Fern-SDK-Version", - "1.0.8", + "1.0.9", "X-Fern-Language", "JAVA")); 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 604eaaa..80b9d73 100644 --- a/src/main/java/com/cohere/api/requests/ChatRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatRequest.java @@ -57,7 +57,7 @@ public final class ChatRequest { private final Optional p; - private final Optional seed; + private final Optional seed; private final Optional> stopSequences; @@ -93,7 +93,7 @@ private ChatRequest( Optional maxInputTokens, Optional k, Optional p, - Optional seed, + Optional seed, Optional> stopSequences, Optional frequencyPenalty, Optional presencePenalty, @@ -308,7 +308,7 @@ public Optional getP() { * Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments */ @JsonProperty("seed") - public Optional getSeed() { + public Optional getSeed() { return seed; } @@ -545,9 +545,9 @@ public interface _FinalStage { _FinalStage p(Double p); - _FinalStage seed(Optional seed); + _FinalStage seed(Optional seed); - _FinalStage seed(Double seed); + _FinalStage seed(Integer seed); _FinalStage stopSequences(Optional> stopSequences); @@ -602,7 +602,7 @@ public static final class Builder implements MessageStage, _FinalStage { private Optional> stopSequences = Optional.empty(); - private Optional seed = Optional.empty(); + private Optional seed = Optional.empty(); private Optional p = Optional.empty(); @@ -851,14 +851,14 @@ public _FinalStage stopSequences(Optional> stopSequences) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage seed(Double seed) { + public _FinalStage seed(Integer seed) { this.seed = Optional.of(seed); return this; } @java.lang.Override @JsonSetter(value = "seed", nulls = Nulls.SKIP) - public _FinalStage seed(Optional seed) { + public _FinalStage seed(Optional seed) { this.seed = seed; return this; } diff --git a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java index 10ef461..c302f67 100644 --- a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java @@ -57,7 +57,7 @@ public final class ChatStreamRequest { private final Optional p; - private final Optional seed; + private final Optional seed; private final Optional> stopSequences; @@ -93,7 +93,7 @@ private ChatStreamRequest( Optional maxInputTokens, Optional k, Optional p, - Optional seed, + Optional seed, Optional> stopSequences, Optional frequencyPenalty, Optional presencePenalty, @@ -308,7 +308,7 @@ public Optional getP() { * Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments */ @JsonProperty("seed") - public Optional getSeed() { + public Optional getSeed() { return seed; } @@ -545,9 +545,9 @@ public interface _FinalStage { _FinalStage p(Double p); - _FinalStage seed(Optional seed); + _FinalStage seed(Optional seed); - _FinalStage seed(Double seed); + _FinalStage seed(Integer seed); _FinalStage stopSequences(Optional> stopSequences); @@ -602,7 +602,7 @@ public static final class Builder implements MessageStage, _FinalStage { private Optional> stopSequences = Optional.empty(); - private Optional seed = Optional.empty(); + private Optional seed = Optional.empty(); private Optional p = Optional.empty(); @@ -851,14 +851,14 @@ public _FinalStage stopSequences(Optional> stopSequences) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage seed(Double seed) { + public _FinalStage seed(Integer seed) { this.seed = Optional.of(seed); return this; } @java.lang.Override @JsonSetter(value = "seed", nulls = Nulls.SKIP) - public _FinalStage seed(Optional seed) { + public _FinalStage seed(Optional seed) { this.seed = seed; return this; } diff --git a/src/main/java/com/cohere/api/requests/GenerateRequest.java b/src/main/java/com/cohere/api/requests/GenerateRequest.java index 0b2ede9..5d448bf 100644 --- a/src/main/java/com/cohere/api/requests/GenerateRequest.java +++ b/src/main/java/com/cohere/api/requests/GenerateRequest.java @@ -35,7 +35,7 @@ public final class GenerateRequest { private final Optional temperature; - private final Optional seed; + private final Optional seed; private final Optional preset; @@ -64,7 +64,7 @@ private GenerateRequest( Optional maxTokens, Optional truncate, Optional temperature, - Optional seed, + Optional seed, Optional preset, Optional> endSequences, Optional> stopSequences, @@ -165,10 +165,14 @@ public Optional getTemperature() { } /** - * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed. + * @return If specified, the backend will make a best effort to sample tokens + * deterministically, such that repeated requests with the same + * seed and parameters should return the same result. However, + * determinism cannot be totally guaranteed. + * Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments */ @JsonProperty("seed") - public Optional getSeed() { + public Optional getSeed() { return seed; } @@ -341,9 +345,9 @@ public interface _FinalStage { _FinalStage temperature(Double temperature); - _FinalStage seed(Optional seed); + _FinalStage seed(Optional seed); - _FinalStage seed(Double seed); + _FinalStage seed(Integer seed); _FinalStage preset(Optional preset); @@ -404,7 +408,7 @@ public static final class Builder implements PromptStage, _FinalStage { private Optional preset = Optional.empty(); - private Optional seed = Optional.empty(); + private Optional seed = Optional.empty(); private Optional temperature = Optional.empty(); @@ -616,18 +620,22 @@ public _FinalStage preset(Optional preset) { } /** - *

If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed.

+ *

If specified, the backend will make a best effort to sample tokens + * deterministically, such that repeated requests with the same + * seed and parameters should return the same result. However, + * determinism cannot be totally guaranteed. + * Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage seed(Double seed) { + public _FinalStage seed(Integer seed) { this.seed = Optional.of(seed); return this; } @java.lang.Override @JsonSetter(value = "seed", nulls = Nulls.SKIP) - public _FinalStage seed(Optional seed) { + public _FinalStage seed(Optional seed) { this.seed = seed; return this; } diff --git a/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java b/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java index 505e978..d79fb82 100644 --- a/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java +++ b/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java @@ -35,7 +35,7 @@ public final class GenerateStreamRequest { private final Optional temperature; - private final Optional seed; + private final Optional seed; private final Optional preset; @@ -64,7 +64,7 @@ private GenerateStreamRequest( Optional maxTokens, Optional truncate, Optional temperature, - Optional seed, + Optional seed, Optional preset, Optional> endSequences, Optional> stopSequences, @@ -165,10 +165,14 @@ public Optional getTemperature() { } /** - * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed. + * @return If specified, the backend will make a best effort to sample tokens + * deterministically, such that repeated requests with the same + * seed and parameters should return the same result. However, + * determinism cannot be totally guaranteed. + * Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments */ @JsonProperty("seed") - public Optional getSeed() { + public Optional getSeed() { return seed; } @@ -341,9 +345,9 @@ public interface _FinalStage { _FinalStage temperature(Double temperature); - _FinalStage seed(Optional seed); + _FinalStage seed(Optional seed); - _FinalStage seed(Double seed); + _FinalStage seed(Integer seed); _FinalStage preset(Optional preset); @@ -404,7 +408,7 @@ public static final class Builder implements PromptStage, _FinalStage { private Optional preset = Optional.empty(); - private Optional seed = Optional.empty(); + private Optional seed = Optional.empty(); private Optional temperature = Optional.empty(); @@ -616,18 +620,22 @@ public _FinalStage preset(Optional preset) { } /** - *

If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed.

+ *

If specified, the backend will make a best effort to sample tokens + * deterministically, such that repeated requests with the same + * seed and parameters should return the same result. However, + * determinism cannot be totally guaranteed. + * Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage seed(Double seed) { + public _FinalStage seed(Integer seed) { this.seed = Optional.of(seed); return this; } @java.lang.Override @JsonSetter(value = "seed", nulls = Nulls.SKIP) - public _FinalStage seed(Optional seed) { + public _FinalStage seed(Optional seed) { this.seed = seed; return this; } diff --git a/src/main/java/com/cohere/api/types/ChatRequestConnectorsSearchOptions.java b/src/main/java/com/cohere/api/types/ChatRequestConnectorsSearchOptions.java index 23d2541..e071292 100644 --- a/src/main/java/com/cohere/api/types/ChatRequestConnectorsSearchOptions.java +++ b/src/main/java/com/cohere/api/types/ChatRequestConnectorsSearchOptions.java @@ -20,58 +20,24 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = ChatRequestConnectorsSearchOptions.Builder.class) public final class ChatRequestConnectorsSearchOptions { - private final Optional model; - - private final Optional temperature; - - private final Optional maxTokens; - - private final Optional preamble; - - private final Optional seed; + private final Optional seed; private final Map additionalProperties; - private ChatRequestConnectorsSearchOptions( - Optional model, - Optional temperature, - Optional maxTokens, - Optional preamble, - Optional seed, - Map additionalProperties) { - this.model = model; - this.temperature = temperature; - this.maxTokens = maxTokens; - this.preamble = preamble; + private ChatRequestConnectorsSearchOptions(Optional seed, Map additionalProperties) { this.seed = seed; this.additionalProperties = additionalProperties; } - @JsonProperty("model") - public Optional getModel() { - return model; - } - - @JsonProperty("temperature") - public Optional getTemperature() { - return temperature; - } - - @JsonProperty("max_tokens") - public Optional getMaxTokens() { - return maxTokens; - } - - @JsonProperty("preamble") - public Optional getPreamble() { - return preamble; - } - /** - * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed. + * @return If specified, the backend will make a best effort to sample tokens + * deterministically, such that repeated requests with the same + * seed and parameters should return the same result. However, + * determinism cannot be totally guaranteed. + * Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments */ @JsonProperty("seed") - public Optional getSeed() { + public Optional getSeed() { return seed; } @@ -88,16 +54,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ChatRequestConnectorsSearchOptions other) { - return model.equals(other.model) - && temperature.equals(other.temperature) - && maxTokens.equals(other.maxTokens) - && preamble.equals(other.preamble) - && seed.equals(other.seed); + return seed.equals(other.seed); } @java.lang.Override public int hashCode() { - return Objects.hash(this.model, this.temperature, this.maxTokens, this.preamble, this.seed); + return Objects.hash(this.seed); } @java.lang.Override @@ -111,15 +73,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional model = Optional.empty(); - - private Optional temperature = Optional.empty(); - - private Optional maxTokens = Optional.empty(); - - private Optional preamble = Optional.empty(); - - private Optional seed = Optional.empty(); + private Optional seed = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -127,72 +81,23 @@ public static final class Builder { private Builder() {} public Builder from(ChatRequestConnectorsSearchOptions other) { - model(other.getModel()); - temperature(other.getTemperature()); - maxTokens(other.getMaxTokens()); - preamble(other.getPreamble()); seed(other.getSeed()); return this; } - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public Builder model(Optional model) { - this.model = model; - return this; - } - - public Builder model(Object model) { - this.model = Optional.of(model); - return this; - } - - @JsonSetter(value = "temperature", nulls = Nulls.SKIP) - public Builder temperature(Optional temperature) { - this.temperature = temperature; - return this; - } - - public Builder temperature(Object temperature) { - this.temperature = Optional.of(temperature); - return this; - } - - @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) - public Builder maxTokens(Optional maxTokens) { - this.maxTokens = maxTokens; - return this; - } - - public Builder maxTokens(Object maxTokens) { - this.maxTokens = Optional.of(maxTokens); - return this; - } - - @JsonSetter(value = "preamble", nulls = Nulls.SKIP) - public Builder preamble(Optional preamble) { - this.preamble = preamble; - return this; - } - - public Builder preamble(Object preamble) { - this.preamble = Optional.of(preamble); - return this; - } - @JsonSetter(value = "seed", nulls = Nulls.SKIP) - public Builder seed(Optional seed) { + public Builder seed(Optional seed) { this.seed = seed; return this; } - public Builder seed(Double seed) { + public Builder seed(Integer seed) { this.seed = Optional.of(seed); return this; } public ChatRequestConnectorsSearchOptions build() { - return new ChatRequestConnectorsSearchOptions( - model, temperature, maxTokens, preamble, seed, additionalProperties); + return new ChatRequestConnectorsSearchOptions(seed, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestConnectorsSearchOptions.java b/src/main/java/com/cohere/api/types/ChatStreamRequestConnectorsSearchOptions.java index 5d446b4..28a83b3 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamRequestConnectorsSearchOptions.java +++ b/src/main/java/com/cohere/api/types/ChatStreamRequestConnectorsSearchOptions.java @@ -20,58 +20,24 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = ChatStreamRequestConnectorsSearchOptions.Builder.class) public final class ChatStreamRequestConnectorsSearchOptions { - private final Optional model; - - private final Optional temperature; - - private final Optional maxTokens; - - private final Optional preamble; - - private final Optional seed; + private final Optional seed; private final Map additionalProperties; - private ChatStreamRequestConnectorsSearchOptions( - Optional model, - Optional temperature, - Optional maxTokens, - Optional preamble, - Optional seed, - Map additionalProperties) { - this.model = model; - this.temperature = temperature; - this.maxTokens = maxTokens; - this.preamble = preamble; + private ChatStreamRequestConnectorsSearchOptions(Optional seed, Map additionalProperties) { this.seed = seed; this.additionalProperties = additionalProperties; } - @JsonProperty("model") - public Optional getModel() { - return model; - } - - @JsonProperty("temperature") - public Optional getTemperature() { - return temperature; - } - - @JsonProperty("max_tokens") - public Optional getMaxTokens() { - return maxTokens; - } - - @JsonProperty("preamble") - public Optional getPreamble() { - return preamble; - } - /** - * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed. + * @return If specified, the backend will make a best effort to sample tokens + * deterministically, such that repeated requests with the same + * seed and parameters should return the same result. However, + * determinism cannot be totally guaranteed. + * Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments */ @JsonProperty("seed") - public Optional getSeed() { + public Optional getSeed() { return seed; } @@ -88,16 +54,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ChatStreamRequestConnectorsSearchOptions other) { - return model.equals(other.model) - && temperature.equals(other.temperature) - && maxTokens.equals(other.maxTokens) - && preamble.equals(other.preamble) - && seed.equals(other.seed); + return seed.equals(other.seed); } @java.lang.Override public int hashCode() { - return Objects.hash(this.model, this.temperature, this.maxTokens, this.preamble, this.seed); + return Objects.hash(this.seed); } @java.lang.Override @@ -111,15 +73,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional model = Optional.empty(); - - private Optional temperature = Optional.empty(); - - private Optional maxTokens = Optional.empty(); - - private Optional preamble = Optional.empty(); - - private Optional seed = Optional.empty(); + private Optional seed = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -127,72 +81,23 @@ public static final class Builder { private Builder() {} public Builder from(ChatStreamRequestConnectorsSearchOptions other) { - model(other.getModel()); - temperature(other.getTemperature()); - maxTokens(other.getMaxTokens()); - preamble(other.getPreamble()); seed(other.getSeed()); return this; } - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public Builder model(Optional model) { - this.model = model; - return this; - } - - public Builder model(Object model) { - this.model = Optional.of(model); - return this; - } - - @JsonSetter(value = "temperature", nulls = Nulls.SKIP) - public Builder temperature(Optional temperature) { - this.temperature = temperature; - return this; - } - - public Builder temperature(Object temperature) { - this.temperature = Optional.of(temperature); - return this; - } - - @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) - public Builder maxTokens(Optional maxTokens) { - this.maxTokens = maxTokens; - return this; - } - - public Builder maxTokens(Object maxTokens) { - this.maxTokens = Optional.of(maxTokens); - return this; - } - - @JsonSetter(value = "preamble", nulls = Nulls.SKIP) - public Builder preamble(Optional preamble) { - this.preamble = preamble; - return this; - } - - public Builder preamble(Object preamble) { - this.preamble = Optional.of(preamble); - return this; - } - @JsonSetter(value = "seed", nulls = Nulls.SKIP) - public Builder seed(Optional seed) { + public Builder seed(Optional seed) { this.seed = seed; return this; } - public Builder seed(Double seed) { + public Builder seed(Integer seed) { this.seed = Optional.of(seed); return this; } public ChatStreamRequestConnectorsSearchOptions build() { - return new ChatStreamRequestConnectorsSearchOptions( - model, temperature, maxTokens, preamble, seed, additionalProperties); + return new ChatStreamRequestConnectorsSearchOptions(seed, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ChatToolCallsChunkEvent.java b/src/main/java/com/cohere/api/types/ChatToolCallsChunkEvent.java new file mode 100644 index 0000000..5f2da08 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatToolCallsChunkEvent.java @@ -0,0 +1,101 @@ +/** + * 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; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ChatToolCallsChunkEvent.Builder.class) +public final class ChatToolCallsChunkEvent implements IChatStreamEvent { + private final ToolCallDelta toolCallDelta; + + private final Map additionalProperties; + + private ChatToolCallsChunkEvent(ToolCallDelta toolCallDelta, Map additionalProperties) { + this.toolCallDelta = toolCallDelta; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("tool_call_delta") + public ToolCallDelta getToolCallDelta() { + return toolCallDelta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatToolCallsChunkEvent && equalTo((ChatToolCallsChunkEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatToolCallsChunkEvent other) { + return toolCallDelta.equals(other.toolCallDelta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.toolCallDelta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ToolCallDeltaStage builder() { + return new Builder(); + } + + public interface ToolCallDeltaStage { + _FinalStage toolCallDelta(ToolCallDelta toolCallDelta); + + Builder from(ChatToolCallsChunkEvent other); + } + + public interface _FinalStage { + ChatToolCallsChunkEvent build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ToolCallDeltaStage, _FinalStage { + private ToolCallDelta toolCallDelta; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ChatToolCallsChunkEvent other) { + toolCallDelta(other.getToolCallDelta()); + return this; + } + + @java.lang.Override + @JsonSetter("tool_call_delta") + public _FinalStage toolCallDelta(ToolCallDelta toolCallDelta) { + this.toolCallDelta = toolCallDelta; + return this; + } + + @java.lang.Override + public ChatToolCallsChunkEvent build() { + return new ChatToolCallsChunkEvent(toolCallDelta, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatToolCallsGenerationEvent.java b/src/main/java/com/cohere/api/types/ChatToolCallsGenerationEvent.java index e6097bc..1d8e3f1 100644 --- a/src/main/java/com/cohere/api/types/ChatToolCallsGenerationEvent.java +++ b/src/main/java/com/cohere/api/types/ChatToolCallsGenerationEvent.java @@ -17,19 +17,32 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = ChatToolCallsGenerationEvent.Builder.class) public final class ChatToolCallsGenerationEvent implements IChatStreamEvent { + private final Optional text; + private final List toolCalls; private final Map additionalProperties; - private ChatToolCallsGenerationEvent(List toolCalls, Map additionalProperties) { + private ChatToolCallsGenerationEvent( + Optional text, List toolCalls, Map additionalProperties) { + this.text = text; this.toolCalls = toolCalls; this.additionalProperties = additionalProperties; } + /** + * @return The text generated related to the tool calls generated + */ + @JsonProperty("text") + public Optional getText() { + return text; + } + @JsonProperty("tool_calls") public List getToolCalls() { return toolCalls; @@ -47,12 +60,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ChatToolCallsGenerationEvent other) { - return toolCalls.equals(other.toolCalls); + return text.equals(other.text) && toolCalls.equals(other.toolCalls); } @java.lang.Override public int hashCode() { - return Objects.hash(this.toolCalls); + return Objects.hash(this.text, this.toolCalls); } @java.lang.Override @@ -66,6 +79,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional text = Optional.empty(); + private List toolCalls = new ArrayList<>(); @JsonAnySetter @@ -74,10 +89,22 @@ public static final class Builder { private Builder() {} public Builder from(ChatToolCallsGenerationEvent other) { + text(other.getText()); toolCalls(other.getToolCalls()); return this; } + @JsonSetter(value = "text", nulls = Nulls.SKIP) + public Builder text(Optional text) { + this.text = text; + return this; + } + + public Builder text(String text) { + this.text = Optional.of(text); + return this; + } + @JsonSetter(value = "tool_calls", nulls = Nulls.SKIP) public Builder toolCalls(List toolCalls) { this.toolCalls.clear(); @@ -96,7 +123,7 @@ public Builder addAllToolCalls(List toolCalls) { } public ChatToolCallsGenerationEvent build() { - return new ChatToolCallsGenerationEvent(toolCalls, additionalProperties); + return new ChatToolCallsGenerationEvent(text, toolCalls, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ClientClosedRequestErrorBody.java b/src/main/java/com/cohere/api/types/ClientClosedRequestErrorBody.java new file mode 100644 index 0000000..7551093 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ClientClosedRequestErrorBody.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.cohere.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClientClosedRequestErrorBody.Builder.class) +public final class ClientClosedRequestErrorBody { + private final Optional data; + + private final Map additionalProperties; + + private ClientClosedRequestErrorBody(Optional data, Map additionalProperties) { + this.data = data; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public Optional getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClientClosedRequestErrorBody && equalTo((ClientClosedRequestErrorBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ClientClosedRequestErrorBody other) { + return data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ClientClosedRequestErrorBody other) { + data(other.getData()); + return this; + } + + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(String data) { + this.data = Optional.of(data); + return this; + } + + public ClientClosedRequestErrorBody build() { + return new ClientClosedRequestErrorBody(data, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/FinishReason.java b/src/main/java/com/cohere/api/types/FinishReason.java index 67713cc..951b334 100644 --- a/src/main/java/com/cohere/api/types/FinishReason.java +++ b/src/main/java/com/cohere/api/types/FinishReason.java @@ -8,6 +8,8 @@ public enum FinishReason { COMPLETE("COMPLETE"), + STOP_SEQUENCE("STOP_SEQUENCE"), + ERROR("ERROR"), ERROR_TOXIC("ERROR_TOXIC"), diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Error.java b/src/main/java/com/cohere/api/types/GatewayTimeoutErrorBody.java similarity index 59% rename from src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Error.java rename to src/main/java/com/cohere/api/types/GatewayTimeoutErrorBody.java index 23e8833..12a90c0 100644 --- a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Error.java +++ b/src/main/java/com/cohere/api/types/GatewayTimeoutErrorBody.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.cohere.api.resources.finetuning.finetuning.types; +package com.cohere.api.types; import com.cohere.api.core.ObjectMappers; import com.fasterxml.jackson.annotation.JsonAnyGetter; @@ -18,29 +18,26 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Error.Builder.class) -public final class Error { - private final Optional message; +@JsonDeserialize(builder = GatewayTimeoutErrorBody.Builder.class) +public final class GatewayTimeoutErrorBody { + private final Optional data; private final Map additionalProperties; - private Error(Optional message, Map additionalProperties) { - this.message = message; + private GatewayTimeoutErrorBody(Optional data, Map additionalProperties) { + this.data = data; this.additionalProperties = additionalProperties; } - /** - * @return A developer-facing error message. - */ - @JsonProperty("message") - public Optional getMessage() { - return message; + @JsonProperty("data") + public Optional getData() { + return data; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof Error && equalTo((Error) other); + return other instanceof GatewayTimeoutErrorBody && equalTo((GatewayTimeoutErrorBody) other); } @JsonAnyGetter @@ -48,13 +45,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(Error other) { - return message.equals(other.message); + private boolean equalTo(GatewayTimeoutErrorBody other) { + return data.equals(other.data); } @java.lang.Override public int hashCode() { - return Objects.hash(this.message); + return Objects.hash(this.data); } @java.lang.Override @@ -68,31 +65,31 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional message = Optional.empty(); + private Optional data = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(Error other) { - message(other.getMessage()); + public Builder from(GatewayTimeoutErrorBody other) { + data(other.getData()); return this; } - @JsonSetter(value = "message", nulls = Nulls.SKIP) - public Builder message(Optional message) { - this.message = message; + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; return this; } - public Builder message(String message) { - this.message = Optional.of(message); + public Builder data(String data) { + this.data = Optional.of(data); return this; } - public Error build() { - return new Error(message, additionalProperties); + public GatewayTimeoutErrorBody build() { + return new GatewayTimeoutErrorBody(data, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/NotImplementedErrorBody.java b/src/main/java/com/cohere/api/types/NotImplementedErrorBody.java new file mode 100644 index 0000000..73a1926 --- /dev/null +++ b/src/main/java/com/cohere/api/types/NotImplementedErrorBody.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.cohere.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = NotImplementedErrorBody.Builder.class) +public final class NotImplementedErrorBody { + private final Optional data; + + private final Map additionalProperties; + + private NotImplementedErrorBody(Optional data, Map additionalProperties) { + this.data = data; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public Optional getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NotImplementedErrorBody && equalTo((NotImplementedErrorBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NotImplementedErrorBody other) { + return data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(NotImplementedErrorBody other) { + data(other.getData()); + return this; + } + + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(String data) { + this.data = Optional.of(data); + return this; + } + + public NotImplementedErrorBody build() { + return new NotImplementedErrorBody(data, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/StreamedChatResponse.java b/src/main/java/com/cohere/api/types/StreamedChatResponse.java index 1ae5d66..6407773 100644 --- a/src/main/java/com/cohere/api/types/StreamedChatResponse.java +++ b/src/main/java/com/cohere/api/types/StreamedChatResponse.java @@ -54,6 +54,10 @@ public static StreamedChatResponse streamEnd(ChatStreamEndEvent value) { return new StreamedChatResponse(new StreamEndValue(value)); } + public static StreamedChatResponse toolCallsChunk(ChatToolCallsChunkEvent value) { + return new StreamedChatResponse(new ToolCallsChunkValue(value)); + } + public boolean isStreamStart() { return value instanceof StreamStartValue; } @@ -82,6 +86,10 @@ public boolean isStreamEnd() { return value instanceof StreamEndValue; } + public boolean isToolCallsChunk() { + return value instanceof ToolCallsChunkValue; + } + public boolean _isUnknown() { return value instanceof _UnknownValue; } @@ -135,6 +143,13 @@ public Optional getStreamEnd() { return Optional.empty(); } + public Optional getToolCallsChunk() { + if (isToolCallsChunk()) { + return Optional.of(((ToolCallsChunkValue) value).value); + } + return Optional.empty(); + } + public Optional _getUnknown() { if (_isUnknown()) { return Optional.of(((_UnknownValue) value).value); @@ -162,6 +177,8 @@ public interface Visitor { T visitStreamEnd(ChatStreamEndEvent streamEnd); + T visitToolCallsChunk(ChatToolCallsChunkEvent toolCallsChunk); + T _visitUnknown(Object unknownType); } @@ -177,7 +194,8 @@ public interface Visitor { @JsonSubTypes.Type(TextGenerationValue.class), @JsonSubTypes.Type(CitationGenerationValue.class), @JsonSubTypes.Type(ToolCallsGenerationValue.class), - @JsonSubTypes.Type(StreamEndValue.class) + @JsonSubTypes.Type(StreamEndValue.class), + @JsonSubTypes.Type(ToolCallsChunkValue.class) }) @JsonIgnoreProperties(ignoreUnknown = true) private interface Value { @@ -450,6 +468,44 @@ public String toString() { } } + @JsonTypeName("tool-calls-chunk") + private static final class ToolCallsChunkValue implements Value { + @JsonUnwrapped + private ChatToolCallsChunkEvent value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private ToolCallsChunkValue() {} + + private ToolCallsChunkValue(ChatToolCallsChunkEvent value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitToolCallsChunk(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ToolCallsChunkValue && equalTo((ToolCallsChunkValue) other); + } + + private boolean equalTo(ToolCallsChunkValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "StreamedChatResponse{" + "value: " + value + "}"; + } + } + private static final class _UnknownValue implements Value { private String type; diff --git a/src/main/java/com/cohere/api/types/ToolCallDelta.java b/src/main/java/com/cohere/api/types/ToolCallDelta.java new file mode 100644 index 0000000..afc69cb --- /dev/null +++ b/src/main/java/com/cohere/api/types/ToolCallDelta.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.cohere.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ToolCallDelta.Builder.class) +public final class ToolCallDelta { + private final Optional name; + + private final Optional index; + + private final Optional parameters; + + private final Optional text; + + private final Map additionalProperties; + + private ToolCallDelta( + Optional name, + Optional index, + Optional parameters, + Optional text, + Map additionalProperties) { + this.name = name; + this.index = index; + this.parameters = parameters; + this.text = text; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name of the tool call + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return Index of the tool call generated + */ + @JsonProperty("index") + public Optional getIndex() { + return index; + } + + /** + * @return Chunk of the tool parameters + */ + @JsonProperty("parameters") + public Optional getParameters() { + return parameters; + } + + /** + * @return Chunk of the tool plan text + */ + @JsonProperty("text") + public Optional getText() { + return text; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ToolCallDelta && equalTo((ToolCallDelta) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ToolCallDelta other) { + return name.equals(other.name) + && index.equals(other.index) + && parameters.equals(other.parameters) + && text.equals(other.text); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.index, this.parameters, this.text); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional name = Optional.empty(); + + private Optional index = Optional.empty(); + + private Optional parameters = Optional.empty(); + + private Optional text = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ToolCallDelta other) { + name(other.getName()); + index(other.getIndex()); + parameters(other.getParameters()); + text(other.getText()); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.of(name); + return this; + } + + @JsonSetter(value = "index", nulls = Nulls.SKIP) + public Builder index(Optional index) { + this.index = index; + return this; + } + + public Builder index(Double index) { + this.index = Optional.of(index); + return this; + } + + @JsonSetter(value = "parameters", nulls = Nulls.SKIP) + public Builder parameters(Optional parameters) { + this.parameters = parameters; + return this; + } + + public Builder parameters(String parameters) { + this.parameters = Optional.of(parameters); + return this; + } + + @JsonSetter(value = "text", nulls = Nulls.SKIP) + public Builder text(Optional text) { + this.text = text; + return this; + } + + public Builder text(String text) { + this.text = Optional.of(text); + return this; + } + + public ToolCallDelta build() { + return new ToolCallDelta(name, index, parameters, text, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/UnprocessableEntityErrorBody.java b/src/main/java/com/cohere/api/types/UnprocessableEntityErrorBody.java new file mode 100644 index 0000000..7015d24 --- /dev/null +++ b/src/main/java/com/cohere/api/types/UnprocessableEntityErrorBody.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.cohere.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UnprocessableEntityErrorBody.Builder.class) +public final class UnprocessableEntityErrorBody { + private final Optional data; + + private final Map additionalProperties; + + private UnprocessableEntityErrorBody(Optional data, Map additionalProperties) { + this.data = data; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public Optional getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UnprocessableEntityErrorBody && equalTo((UnprocessableEntityErrorBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UnprocessableEntityErrorBody other) { + return data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UnprocessableEntityErrorBody other) { + data(other.getData()); + return this; + } + + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(String data) { + this.data = Optional.of(data); + return this; + } + + public UnprocessableEntityErrorBody build() { + return new UnprocessableEntityErrorBody(data, additionalProperties); + } + } +}