diff --git a/build.gradle b/build.gradle index 4486d44..e25d0fe 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ repositories { } dependencies { - api 'com.squareup.okhttp3:okhttp:4.9.3' + api 'com.squareup.okhttp3:okhttp:4.12.0' api 'com.fasterxml.jackson.core:jackson-databind:2.13.0' api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.3' api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3' @@ -46,7 +46,7 @@ publishing { maven(MavenPublication) { groupId = 'com.cohere' artifactId = 'cohere-java' - version = '1.0.3' + version = '1.0.6' from components.java } } diff --git a/src/main/java/com/cohere/api/Cohere.java b/src/main/java/com/cohere/api/Cohere.java index 2ac98c3..c71b3dd 100644 --- a/src/main/java/com/cohere/api/Cohere.java +++ b/src/main/java/com/cohere/api/Cohere.java @@ -5,6 +5,7 @@ import com.cohere.api.core.ApiError; import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.MediaTypes; import com.cohere.api.core.ObjectMappers; import com.cohere.api.core.RequestOptions; import com.cohere.api.core.Stream; @@ -12,18 +13,20 @@ import com.cohere.api.requests.ChatRequest; import com.cohere.api.requests.ChatStreamRequest; import com.cohere.api.requests.ClassifyRequest; -import com.cohere.api.requests.DetectLanguageRequest; import com.cohere.api.requests.DetokenizeRequest; import com.cohere.api.requests.EmbedRequest; import com.cohere.api.requests.GenerateRequest; +import com.cohere.api.requests.GenerateStreamRequest; import com.cohere.api.requests.RerankRequest; import com.cohere.api.requests.SummarizeRequest; import com.cohere.api.requests.TokenizeRequest; import com.cohere.api.resources.connectors.ConnectorsClient; +import com.cohere.api.resources.datasets.DatasetsClient; +import com.cohere.api.resources.embedjobs.EmbedJobsClient; import com.cohere.api.types.ClassifyResponse; -import com.cohere.api.types.DetectLanguageResponse; import com.cohere.api.types.DetokenizeResponse; import com.cohere.api.types.EmbedResponse; +import com.cohere.api.types.GenerateStreamedResponse; import com.cohere.api.types.Generation; import com.cohere.api.types.NonStreamedChatResponse; import com.cohere.api.types.RerankResponse; @@ -34,7 +37,6 @@ import java.util.function.Supplier; import okhttp3.Headers; import okhttp3.HttpUrl; -import okhttp3.MediaType; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @@ -42,16 +44,30 @@ public class Cohere { protected final ClientOptions clientOptions; + protected final Supplier embedJobsClient; + + protected final Supplier datasetsClient; + protected final Supplier connectorsClient; public Cohere(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.embedJobsClient = Suppliers.memoize(() -> new EmbedJobsClient(clientOptions)); + this.datasetsClient = Suppliers.memoize(() -> new DatasetsClient(clientOptions)); this.connectorsClient = Suppliers.memoize(() -> new ConnectorsClient(clientOptions)); } /** * The chat endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the conversation_id parameter, or they can pass in their own conversation history using the chat_history parameter. - * The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". + *

The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". For a full breakdown of the Chat API endpoint, document and connector modes, and streaming (with code samples), see this guide.

+ */ + public Iterable chatStream(ChatStreamRequest request) { + return chatStream(request, null); + } + + /** + * The chat endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the conversation_id parameter, or they can pass in their own conversation history using the chat_history parameter. + *

The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". For a full breakdown of the Chat API endpoint, document and connector modes, and streaming (with code samples), see this guide.

*/ public Iterable chatStream(ChatStreamRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -61,7 +77,7 @@ public Iterable chatStream(ChatStreamRequest request, Requ RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -88,15 +104,15 @@ public Iterable chatStream(ChatStreamRequest request, Requ /** * The chat endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the conversation_id parameter, or they can pass in their own conversation history using the chat_history parameter. - * The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". + *

The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". For a full breakdown of the Chat API endpoint, document and connector modes, and streaming (with code samples), see this guide.

*/ - public Iterable chatStream(ChatStreamRequest request) { - return chatStream(request, null); + public NonStreamedChatResponse chat(ChatRequest request) { + return chat(request, null); } /** * The chat endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the conversation_id parameter, or they can pass in their own conversation history using the chat_history parameter. - * The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". + *

The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". For a full breakdown of the Chat API endpoint, document and connector modes, and streaming (with code samples), see this guide.

*/ public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -106,7 +122,7 @@ public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestO RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -131,17 +147,17 @@ public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestO } /** - * The chat endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the conversation_id parameter, or they can pass in their own conversation history using the chat_history parameter. - * The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". + * This endpoint generates realistic text conditioned on a given input. */ - public NonStreamedChatResponse chat(ChatRequest request) { - return chat(request, null); + public Iterable generateStream(GenerateStreamRequest request) { + return generateStream(request, null); } /** * This endpoint generates realistic text conditioned on a given input. */ - public Generation generate(GenerateRequest request, RequestOptions requestOptions) { + public Iterable generateStream( + GenerateStreamRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("generate") @@ -149,7 +165,7 @@ public Generation generate(GenerateRequest request, RequestOptions requestOption RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -163,7 +179,8 @@ public Generation generate(GenerateRequest request, RequestOptions requestOption Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Generation.class); + return new Stream( + GenerateStreamedResponse.class, response.body().charStream(), "\n"); } throw new ApiError( response.code(), @@ -181,19 +198,17 @@ public Generation generate(GenerateRequest request) { } /** - * This endpoint returns text embeddings. An embedding is a list of floating point numbers that captures semantic information about the text that it represents. - *

Embeddings can be used to create text classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.

- *

If you want to learn more how to use the embedding model, have a look at the Semantic Search Guide.

+ * This endpoint generates realistic text conditioned on a given input. */ - public EmbedResponse embed(EmbedRequest request, RequestOptions requestOptions) { + public Generation generate(GenerateRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("embed") + .addPathSegments("generate") .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -207,7 +222,7 @@ public EmbedResponse embed(EmbedRequest request, RequestOptions requestOptions) Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), EmbedResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Generation.class); } throw new ApiError( response.code(), @@ -227,17 +242,19 @@ public EmbedResponse embed(EmbedRequest request) { } /** - * This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score. + * This endpoint returns text embeddings. An embedding is a list of floating point numbers that captures semantic information about the text that it represents. + *

Embeddings can be used to create text classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.

+ *

If you want to learn more how to use the embedding model, have a look at the Semantic Search Guide.

*/ - public RerankResponse rerank(RerankRequest request, RequestOptions requestOptions) { + public EmbedResponse embed(EmbedRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("rerank") + .addPathSegments("embed") .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -251,7 +268,7 @@ public RerankResponse rerank(RerankRequest request, RequestOptions requestOption Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), RerankResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), EmbedResponse.class); } throw new ApiError( response.code(), @@ -269,18 +286,17 @@ public RerankResponse rerank(RerankRequest request) { } /** - * This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided examples of text + label pairs as a reference. - * Note: Custom Models trained on classification examples don't require the examples parameter to be passed in explicitly. + * This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score. */ - public ClassifyResponse classify(ClassifyRequest request, RequestOptions requestOptions) { + public RerankResponse rerank(RerankRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("classify") + .addPathSegments("rerank") .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -294,7 +310,7 @@ public ClassifyResponse classify(ClassifyRequest request, RequestOptions request Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), ClassifyResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), RerankResponse.class); } throw new ApiError( response.code(), @@ -306,24 +322,25 @@ public ClassifyResponse classify(ClassifyRequest request, RequestOptions request /** * This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided examples of text + label pairs as a reference. - * Note: Custom Models trained on classification examples don't require the examples parameter to be passed in explicitly. + * Note: Fine-tuned models trained on classification examples don't require the examples parameter to be passed in explicitly. */ public ClassifyResponse classify(ClassifyRequest request) { return classify(request, null); } /** - * This endpoint identifies which language each of the provided texts is written in. + * This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided examples of text + label pairs as a reference. + * Note: Fine-tuned models trained on classification examples don't require the examples parameter to be passed in explicitly. */ - public DetectLanguageResponse detectLanguage(DetectLanguageRequest request, RequestOptions requestOptions) { + public ClassifyResponse classify(ClassifyRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("detect-language") + .addPathSegments("classify") .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -337,7 +354,7 @@ public DetectLanguageResponse detectLanguage(DetectLanguageRequest request, Requ Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), DetectLanguageResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), ClassifyResponse.class); } throw new ApiError( response.code(), @@ -348,10 +365,10 @@ public DetectLanguageResponse detectLanguage(DetectLanguageRequest request, Requ } /** - * This endpoint identifies which language each of the provided texts is written in. + * This endpoint generates a summary in English for a given text. */ - public DetectLanguageResponse detectLanguage(DetectLanguageRequest request) { - return detectLanguage(request, null); + public SummarizeResponse summarize(SummarizeRequest request) { + return summarize(request, null); } /** @@ -365,7 +382,7 @@ public SummarizeResponse summarize(SummarizeRequest request, RequestOptions requ RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -390,10 +407,10 @@ public SummarizeResponse summarize(SummarizeRequest request, RequestOptions requ } /** - * This endpoint generates a summary in English for a given text. + * This endpoint splits input text into smaller units called tokens using byte-pair encoding (BPE). To learn more about tokenization and byte pair encoding, see the tokens page. */ - public SummarizeResponse summarize(SummarizeRequest request) { - return summarize(request, null); + public TokenizeResponse tokenize(TokenizeRequest request) { + return tokenize(request, null); } /** @@ -407,7 +424,7 @@ public TokenizeResponse tokenize(TokenizeRequest request, RequestOptions request RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -432,10 +449,10 @@ public TokenizeResponse tokenize(TokenizeRequest request, RequestOptions request } /** - * This endpoint splits input text into smaller units called tokens using byte-pair encoding (BPE). To learn more about tokenization and byte pair encoding, see the tokens page. + * This endpoint takes tokens using byte-pair encoding and returns their text representation. To learn more about tokenization and byte pair encoding, see the tokens page. */ - public TokenizeResponse tokenize(TokenizeRequest request) { - return tokenize(request, null); + public DetokenizeResponse detokenize(DetokenizeRequest request) { + return detokenize(request, null); } /** @@ -449,7 +466,7 @@ public DetokenizeResponse detokenize(DetokenizeRequest request, RequestOptions r RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -473,11 +490,12 @@ public DetokenizeResponse detokenize(DetokenizeRequest request, RequestOptions r } } - /** - * This endpoint takes tokens using byte-pair encoding and returns their text representation. To learn more about tokenization and byte pair encoding, see the tokens page. - */ - public DetokenizeResponse detokenize(DetokenizeRequest request) { - return detokenize(request, null); + public EmbedJobsClient embedJobs() { + return this.embedJobsClient.get(); + } + + public DatasetsClient datasets() { + return this.datasetsClient.get(); } public ConnectorsClient connectors() { diff --git a/src/main/java/com/cohere/api/CohereBuilder.java b/src/main/java/com/cohere/api/CohereBuilder.java index 325a94b..0fcfd02 100644 --- a/src/main/java/com/cohere/api/CohereBuilder.java +++ b/src/main/java/com/cohere/api/CohereBuilder.java @@ -9,10 +9,25 @@ public final class CohereBuilder { private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + private String token = null; + + private String clientName = null; + private Environment environment = Environment.PRODUCTION; + /** + * Sets token + */ public CohereBuilder token(String token) { - this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + token); + this.token = token; + return this; + } + + /** + * Sets clientName + */ + public CohereBuilder clientName(String clientName) { + this.clientName = clientName; return this; } @@ -27,6 +42,14 @@ public CohereBuilder url(String url) { } public Cohere build() { + if (token == null) { + throw new RuntimeException("Please provide token"); + } + this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); + if (clientName == null) { + throw new RuntimeException("Please provide clientName"); + } + this.clientOptionsBuilder.addHeader("X-Client-Name", this.clientName); clientOptionsBuilder.environment(this.environment); return new Cohere(clientOptionsBuilder.build()); } diff --git a/src/main/java/com/cohere/api/core/ApiError.java b/src/main/java/com/cohere/api/core/ApiError.java index a8f1d8b..3692156 100644 --- a/src/main/java/com/cohere/api/core/ApiError.java +++ b/src/main/java/com/cohere/api/core/ApiError.java @@ -21,7 +21,7 @@ public Object body() { return this.body; } - @Override + @java.lang.Override public String toString() { return "ApiError{" + "statusCode: " + statusCode + ", body: " + body + "}"; } diff --git a/src/main/java/com/cohere/api/core/ClientOptions.java b/src/main/java/com/cohere/api/core/ClientOptions.java index 17de257..ff4133b 100644 --- a/src/main/java/com/cohere/api/core/ClientOptions.java +++ b/src/main/java/com/cohere/api/core/ClientOptions.java @@ -29,7 +29,7 @@ private ClientOptions( "X-Fern-SDK-Name", "com.cohere.fern:api-sdk", "X-Fern-SDK-Version", - "1.0.3", + "1.0.6", "X-Fern-Language", "JAVA")); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/cohere/api/core/MediaTypes.java b/src/main/java/com/cohere/api/core/MediaTypes.java new file mode 100644 index 0000000..44958be --- /dev/null +++ b/src/main/java/com/cohere/api/core/MediaTypes.java @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.core; + +import okhttp3.MediaType; + +public final class MediaTypes { + + public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); + + private MediaTypes() {} +} diff --git a/src/main/java/com/cohere/api/core/RequestOptions.java b/src/main/java/com/cohere/api/core/RequestOptions.java index 27c6fcc..26fb7cd 100644 --- a/src/main/java/com/cohere/api/core/RequestOptions.java +++ b/src/main/java/com/cohere/api/core/RequestOptions.java @@ -9,8 +9,11 @@ public final class RequestOptions { private final String token; - private RequestOptions(String token) { + private final String clientName; + + private RequestOptions(String token, String clientName) { this.token = token; + this.clientName = clientName; } public Map getHeaders() { @@ -18,6 +21,9 @@ public Map getHeaders() { if (this.token != null) { headers.put("Authorization", "Bearer " + this.token); } + if (this.clientName != null) { + headers.put("X-Client-Name", this.clientName); + } return headers; } @@ -28,13 +34,20 @@ public static Builder builder() { public static final class Builder { private String token = null; + private String clientName = null; + public Builder token(String token) { this.token = token; return this; } + public Builder clientName(String clientName) { + this.clientName = clientName; + return this; + } + public RequestOptions build() { - return new RequestOptions(token); + return new RequestOptions(token, clientName); } } } diff --git a/src/main/java/com/cohere/api/requests/ChatRequest.java b/src/main/java/com/cohere/api/requests/ChatRequest.java index 03236cc..d04575f 100644 --- a/src/main/java/com/cohere/api/requests/ChatRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatRequest.java @@ -29,8 +29,6 @@ public final class ChatRequest { private final Optional model; - private final Boolean stream; - private final Optional preambleOverride; private final Optional> chatHistory; @@ -49,12 +47,21 @@ public final class ChatRequest { private final Optional temperature; + private final Optional maxTokens; + + private final Optional k; + + private final Optional p; + + private final Optional frequencyPenalty; + + private final Optional presencePenalty; + private final Map additionalProperties; private ChatRequest( String message, Optional model, - Boolean stream, Optional preambleOverride, Optional> chatHistory, Optional conversationId, @@ -64,10 +71,14 @@ private ChatRequest( Optional>> documents, Optional citationQuality, Optional temperature, + Optional maxTokens, + Optional k, + Optional p, + Optional frequencyPenalty, + Optional presencePenalty, Map additionalProperties) { this.message = message; this.model = model; - this.stream = stream; this.preambleOverride = preambleOverride; this.chatHistory = chatHistory; this.conversationId = conversationId; @@ -77,6 +88,11 @@ private ChatRequest( this.documents = documents; this.citationQuality = citationQuality; this.temperature = temperature; + this.maxTokens = maxTokens; + this.k = k; + this.p = p; + this.frequencyPenalty = frequencyPenalty; + this.presencePenalty = presencePenalty; this.additionalProperties = additionalProperties; } @@ -91,8 +107,8 @@ public String getMessage() { /** * @return Defaults to command. - * The identifier of the model, which can be one of the existing Cohere models or the full ID for a finetuned custom model. - * Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models. + *

The identifier of the model, which can be one of the existing Cohere models or the full ID for a fine-tuned custom model.

+ *

Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models.

*/ @JsonProperty("model") public Optional getModel() { @@ -101,7 +117,7 @@ public Optional getModel() { @JsonProperty("stream") public Boolean getStream() { - return stream; + return false; } /** @@ -122,7 +138,7 @@ public Optional> getChatHistory() { /** * @return An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation. - * If a conversation with this id does not already exist, a new conversation will be created. + *

If a conversation with this id does not already exist, a new conversation will be created.

*/ @JsonProperty("conversation_id") public Optional getConversationId() { @@ -131,9 +147,9 @@ public Optional getConversationId() { /** * @return Defaults to AUTO when connectors are specified and OFF in all other cases. - * Dictates how the prompt will be constructed. - * With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. - * With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned. + *

Dictates how the prompt will be constructed.

+ *

With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit.

+ *

With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

*/ @JsonProperty("prompt_truncation") public Optional getPromptTruncation() { @@ -142,7 +158,7 @@ public Optional getPromptTruncation() { /** * @return Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - * When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG). + *

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

*/ @JsonProperty("connectors") public Optional> getConnectors() { @@ -151,7 +167,7 @@ public Optional> getConnectors() { /** * @return Defaults to false. - * When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated. + *

When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

*/ @JsonProperty("search_queries_only") public Optional getSearchQueriesOnly() { @@ -168,7 +184,7 @@ public Optional>> getDocuments() { /** * @return Defaults to "accurate". - * Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results. + *

Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results.

*/ @JsonProperty("citation_quality") public Optional getCitationQuality() { @@ -176,15 +192,58 @@ public Optional getCitationQuality() { } /** - * @return Defaults to 0.3 - * A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations. + * @return Defaults to 0.3. + *

A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.

+ *

Randomness can be further maximized by increasing the value of the p parameter.

*/ @JsonProperty("temperature") public Optional getTemperature() { return temperature; } - @Override + /** + * @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. + */ + @JsonProperty("max_tokens") + public Optional getMaxTokens() { + return maxTokens; + } + + /** + * @return Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500. + */ + @JsonProperty("k") + public Optional getK() { + return k; + } + + /** + * @return Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99. + */ + @JsonProperty("p") + public Optional getP() { + return p; + } + + /** + * @return Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + */ + @JsonProperty("frequency_penalty") + public Optional getFrequencyPenalty() { + return frequencyPenalty; + } + + /** + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. Can be 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. + */ + @JsonProperty("presence_penalty") + public Optional getPresencePenalty() { + return presencePenalty; + } + + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatRequest && equalTo((ChatRequest) other); @@ -198,7 +257,6 @@ public Map getAdditionalProperties() { private boolean equalTo(ChatRequest other) { return message.equals(other.message) && model.equals(other.model) - && stream.equals(other.stream) && preambleOverride.equals(other.preambleOverride) && chatHistory.equals(other.chatHistory) && conversationId.equals(other.conversationId) @@ -207,15 +265,19 @@ private boolean equalTo(ChatRequest other) { && searchQueriesOnly.equals(other.searchQueriesOnly) && documents.equals(other.documents) && citationQuality.equals(other.citationQuality) - && temperature.equals(other.temperature); + && temperature.equals(other.temperature) + && maxTokens.equals(other.maxTokens) + && k.equals(other.k) + && p.equals(other.p) + && frequencyPenalty.equals(other.frequencyPenalty) + && presencePenalty.equals(other.presencePenalty); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.message, this.model, - this.stream, this.preambleOverride, this.chatHistory, this.conversationId, @@ -224,10 +286,15 @@ public int hashCode() { this.searchQueriesOnly, this.documents, this.citationQuality, - this.temperature); + this.temperature, + this.maxTokens, + this.k, + this.p, + this.frequencyPenalty, + this.presencePenalty); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -237,15 +304,11 @@ public static MessageStage builder() { } public interface MessageStage { - StreamStage message(String message); + _FinalStage message(String message); Builder from(ChatRequest other); } - public interface StreamStage { - _FinalStage stream(Boolean stream); - } - public interface _FinalStage { ChatRequest build(); @@ -288,13 +351,41 @@ public interface _FinalStage { _FinalStage temperature(Optional temperature); _FinalStage temperature(Double temperature); + + _FinalStage maxTokens(Optional maxTokens); + + _FinalStage maxTokens(Integer maxTokens); + + _FinalStage k(Optional k); + + _FinalStage k(Integer k); + + _FinalStage p(Optional p); + + _FinalStage p(Double p); + + _FinalStage frequencyPenalty(Optional frequencyPenalty); + + _FinalStage frequencyPenalty(Double frequencyPenalty); + + _FinalStage presencePenalty(Optional presencePenalty); + + _FinalStage presencePenalty(Double presencePenalty); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, StreamStage, _FinalStage { + public static final class Builder implements MessageStage, _FinalStage { private String message; - private Boolean stream; + private Optional presencePenalty = Optional.empty(); + + private Optional frequencyPenalty = Optional.empty(); + + private Optional p = Optional.empty(); + + private Optional k = Optional.empty(); + + private Optional maxTokens = Optional.empty(); private Optional temperature = Optional.empty(); @@ -321,11 +412,10 @@ public static final class Builder implements MessageStage, StreamStage, _FinalSt private Builder() {} - @Override + @java.lang.Override public Builder from(ChatRequest other) { message(other.getMessage()); model(other.getModel()); - stream(other.getStream()); preambleOverride(other.getPreambleOverride()); chatHistory(other.getChatHistory()); conversationId(other.getConversationId()); @@ -335,6 +425,11 @@ public Builder from(ChatRequest other) { documents(other.getDocuments()); citationQuality(other.getCitationQuality()); temperature(other.getTemperature()); + maxTokens(other.getMaxTokens()); + k(other.getK()); + p(other.getP()); + frequencyPenalty(other.getFrequencyPenalty()); + presencePenalty(other.getPresencePenalty()); return this; } @@ -343,32 +438,113 @@ public Builder from(ChatRequest other) { * The chat message from the user to the model.

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

Defaults to 0.0, min value of 0.0, max value of 1.0. Can be 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.

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

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

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

Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99.

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

Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500.

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

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 Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage maxTokens(Integer maxTokens) { + this.maxTokens = Optional.of(maxTokens); + return this; + } + + @java.lang.Override + @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) + public _FinalStage maxTokens(Optional maxTokens) { + this.maxTokens = maxTokens; return this; } /** - *

Defaults to 0.3 - * A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.

+ *

Defaults to 0.3.

+ *

A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.

+ *

Randomness can be further maximized by increasing the value of the p parameter.

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

Defaults to "accurate". - * Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results.

+ *

Defaults to "accurate".

+ *

Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage citationQuality(ChatRequestCitationQuality citationQuality) { this.citationQuality = Optional.of(citationQuality); return this; } - @Override + @java.lang.Override @JsonSetter(value = "citation_quality", nulls = Nulls.SKIP) public _FinalStage citationQuality(Optional citationQuality) { this.citationQuality = citationQuality; @@ -397,13 +573,13 @@ public _FinalStage citationQuality(Optional citation *

A list of relevant documents that the model can use to enrich its reply. See 'Document Mode' in the guide for more information.

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

Defaults to false. - * When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

+ *

Defaults to false.

+ *

When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

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

Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - * When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).

+ *

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

+ *

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

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

Defaults to AUTO when connectors are specified and OFF in all other cases. - * Dictates how the prompt will be constructed. - * With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. - * With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

+ *

Defaults to AUTO when connectors are specified and OFF in all other cases.

+ *

Dictates how the prompt will be constructed.

+ *

With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit.

+ *

With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage promptTruncation(ChatRequestPromptTruncation promptTruncation) { this.promptTruncation = Optional.of(promptTruncation); return this; } - @Override + @java.lang.Override @JsonSetter(value = "prompt_truncation", nulls = Nulls.SKIP) public _FinalStage promptTruncation(Optional promptTruncation) { this.promptTruncation = promptTruncation; @@ -467,17 +643,17 @@ public _FinalStage promptTruncation(Optional prompt } /** - *

An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation. - * If a conversation with this id does not already exist, a new conversation will be created.

+ *

An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation.

+ *

If a conversation with this id does not already exist, a new conversation will be created.

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

A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage chatHistory(List chatHistory) { this.chatHistory = Optional.of(chatHistory); return this; } - @Override + @java.lang.Override @JsonSetter(value = "chat_history", nulls = Nulls.SKIP) public _FinalStage chatHistory(Optional> chatHistory) { this.chatHistory = chatHistory; @@ -505,13 +681,13 @@ public _FinalStage chatHistory(Optional> chatHistory) { *

When specified, the default Cohere preamble will be replaced with the provided one.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage preambleOverride(String preambleOverride) { this.preambleOverride = Optional.of(preambleOverride); return this; } - @Override + @java.lang.Override @JsonSetter(value = "preamble_override", nulls = Nulls.SKIP) public _FinalStage preambleOverride(Optional preambleOverride) { this.preambleOverride = preambleOverride; @@ -519,30 +695,29 @@ public _FinalStage preambleOverride(Optional preambleOverride) { } /** - *

Defaults to command. - * The identifier of the model, which can be one of the existing Cohere models or the full ID for a finetuned custom model. - * Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models.

+ *

Defaults to command.

+ *

The identifier of the model, which can be one of the existing Cohere models or the full ID for a fine-tuned custom model.

+ *

Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public ChatRequest build() { return new ChatRequest( message, model, - stream, preambleOverride, chatHistory, conversationId, @@ -552,6 +727,11 @@ public ChatRequest build() { documents, citationQuality, temperature, + maxTokens, + k, + p, + frequencyPenalty, + presencePenalty, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java index 59bc69d..db7cbd0 100644 --- a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java @@ -29,8 +29,6 @@ public final class ChatStreamRequest { private final Optional model; - private final Boolean stream; - private final Optional preambleOverride; private final Optional> chatHistory; @@ -49,12 +47,21 @@ public final class ChatStreamRequest { private final Optional temperature; + private final Optional maxTokens; + + private final Optional k; + + private final Optional p; + + private final Optional frequencyPenalty; + + private final Optional presencePenalty; + private final Map additionalProperties; private ChatStreamRequest( String message, Optional model, - Boolean stream, Optional preambleOverride, Optional> chatHistory, Optional conversationId, @@ -64,10 +71,14 @@ private ChatStreamRequest( Optional>> documents, Optional citationQuality, Optional temperature, + Optional maxTokens, + Optional k, + Optional p, + Optional frequencyPenalty, + Optional presencePenalty, Map additionalProperties) { this.message = message; this.model = model; - this.stream = stream; this.preambleOverride = preambleOverride; this.chatHistory = chatHistory; this.conversationId = conversationId; @@ -77,6 +88,11 @@ private ChatStreamRequest( this.documents = documents; this.citationQuality = citationQuality; this.temperature = temperature; + this.maxTokens = maxTokens; + this.k = k; + this.p = p; + this.frequencyPenalty = frequencyPenalty; + this.presencePenalty = presencePenalty; this.additionalProperties = additionalProperties; } @@ -91,8 +107,8 @@ public String getMessage() { /** * @return Defaults to command. - * The identifier of the model, which can be one of the existing Cohere models or the full ID for a finetuned custom model. - * Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models. + *

The identifier of the model, which can be one of the existing Cohere models or the full ID for a fine-tuned custom model.

+ *

Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models.

*/ @JsonProperty("model") public Optional getModel() { @@ -101,7 +117,7 @@ public Optional getModel() { @JsonProperty("stream") public Boolean getStream() { - return stream; + return true; } /** @@ -122,7 +138,7 @@ public Optional> getChatHistory() { /** * @return An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation. - * If a conversation with this id does not already exist, a new conversation will be created. + *

If a conversation with this id does not already exist, a new conversation will be created.

*/ @JsonProperty("conversation_id") public Optional getConversationId() { @@ -131,9 +147,9 @@ public Optional getConversationId() { /** * @return Defaults to AUTO when connectors are specified and OFF in all other cases. - * Dictates how the prompt will be constructed. - * With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. - * With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned. + *

Dictates how the prompt will be constructed.

+ *

With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit.

+ *

With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

*/ @JsonProperty("prompt_truncation") public Optional getPromptTruncation() { @@ -142,7 +158,7 @@ public Optional getPromptTruncation() { /** * @return Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - * When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG). + *

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

*/ @JsonProperty("connectors") public Optional> getConnectors() { @@ -151,7 +167,7 @@ public Optional> getConnectors() { /** * @return Defaults to false. - * When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated. + *

When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

*/ @JsonProperty("search_queries_only") public Optional getSearchQueriesOnly() { @@ -168,7 +184,7 @@ public Optional>> getDocuments() { /** * @return Defaults to "accurate". - * Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results. + *

Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results.

*/ @JsonProperty("citation_quality") public Optional getCitationQuality() { @@ -176,15 +192,58 @@ public Optional getCitationQuality() { } /** - * @return Defaults to 0.3 - * A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations. + * @return Defaults to 0.3. + *

A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.

+ *

Randomness can be further maximized by increasing the value of the p parameter.

*/ @JsonProperty("temperature") public Optional getTemperature() { return temperature; } - @Override + /** + * @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. + */ + @JsonProperty("max_tokens") + public Optional getMaxTokens() { + return maxTokens; + } + + /** + * @return Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500. + */ + @JsonProperty("k") + public Optional getK() { + return k; + } + + /** + * @return Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99. + */ + @JsonProperty("p") + public Optional getP() { + return p; + } + + /** + * @return Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + */ + @JsonProperty("frequency_penalty") + public Optional getFrequencyPenalty() { + return frequencyPenalty; + } + + /** + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. Can be 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. + */ + @JsonProperty("presence_penalty") + public Optional getPresencePenalty() { + return presencePenalty; + } + + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatStreamRequest && equalTo((ChatStreamRequest) other); @@ -198,7 +257,6 @@ public Map getAdditionalProperties() { private boolean equalTo(ChatStreamRequest other) { return message.equals(other.message) && model.equals(other.model) - && stream.equals(other.stream) && preambleOverride.equals(other.preambleOverride) && chatHistory.equals(other.chatHistory) && conversationId.equals(other.conversationId) @@ -207,15 +265,19 @@ private boolean equalTo(ChatStreamRequest other) { && searchQueriesOnly.equals(other.searchQueriesOnly) && documents.equals(other.documents) && citationQuality.equals(other.citationQuality) - && temperature.equals(other.temperature); + && temperature.equals(other.temperature) + && maxTokens.equals(other.maxTokens) + && k.equals(other.k) + && p.equals(other.p) + && frequencyPenalty.equals(other.frequencyPenalty) + && presencePenalty.equals(other.presencePenalty); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.message, this.model, - this.stream, this.preambleOverride, this.chatHistory, this.conversationId, @@ -224,10 +286,15 @@ public int hashCode() { this.searchQueriesOnly, this.documents, this.citationQuality, - this.temperature); + this.temperature, + this.maxTokens, + this.k, + this.p, + this.frequencyPenalty, + this.presencePenalty); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -237,15 +304,11 @@ public static MessageStage builder() { } public interface MessageStage { - StreamStage message(String message); + _FinalStage message(String message); Builder from(ChatStreamRequest other); } - public interface StreamStage { - _FinalStage stream(Boolean stream); - } - public interface _FinalStage { ChatStreamRequest build(); @@ -288,13 +351,41 @@ public interface _FinalStage { _FinalStage temperature(Optional temperature); _FinalStage temperature(Double temperature); + + _FinalStage maxTokens(Optional maxTokens); + + _FinalStage maxTokens(Integer maxTokens); + + _FinalStage k(Optional k); + + _FinalStage k(Integer k); + + _FinalStage p(Optional p); + + _FinalStage p(Double p); + + _FinalStage frequencyPenalty(Optional frequencyPenalty); + + _FinalStage frequencyPenalty(Double frequencyPenalty); + + _FinalStage presencePenalty(Optional presencePenalty); + + _FinalStage presencePenalty(Double presencePenalty); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, StreamStage, _FinalStage { + public static final class Builder implements MessageStage, _FinalStage { private String message; - private Boolean stream; + private Optional presencePenalty = Optional.empty(); + + private Optional frequencyPenalty = Optional.empty(); + + private Optional p = Optional.empty(); + + private Optional k = Optional.empty(); + + private Optional maxTokens = Optional.empty(); private Optional temperature = Optional.empty(); @@ -321,11 +412,10 @@ public static final class Builder implements MessageStage, StreamStage, _FinalSt private Builder() {} - @Override + @java.lang.Override public Builder from(ChatStreamRequest other) { message(other.getMessage()); model(other.getModel()); - stream(other.getStream()); preambleOverride(other.getPreambleOverride()); chatHistory(other.getChatHistory()); conversationId(other.getConversationId()); @@ -335,6 +425,11 @@ public Builder from(ChatStreamRequest other) { documents(other.getDocuments()); citationQuality(other.getCitationQuality()); temperature(other.getTemperature()); + maxTokens(other.getMaxTokens()); + k(other.getK()); + p(other.getP()); + frequencyPenalty(other.getFrequencyPenalty()); + presencePenalty(other.getPresencePenalty()); return this; } @@ -343,32 +438,113 @@ public Builder from(ChatStreamRequest other) { * The chat message from the user to the model.

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

Defaults to 0.0, min value of 0.0, max value of 1.0. Can be 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.

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

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

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

Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99.

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

Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500.

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

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 Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage maxTokens(Integer maxTokens) { + this.maxTokens = Optional.of(maxTokens); + return this; + } + + @java.lang.Override + @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) + public _FinalStage maxTokens(Optional maxTokens) { + this.maxTokens = maxTokens; return this; } /** - *

Defaults to 0.3 - * A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.

+ *

Defaults to 0.3.

+ *

A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.

+ *

Randomness can be further maximized by increasing the value of the p parameter.

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

Defaults to "accurate". - * Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results.

+ *

Defaults to "accurate".

+ *

Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage citationQuality(ChatStreamRequestCitationQuality citationQuality) { this.citationQuality = Optional.of(citationQuality); return this; } - @Override + @java.lang.Override @JsonSetter(value = "citation_quality", nulls = Nulls.SKIP) public _FinalStage citationQuality(Optional citationQuality) { this.citationQuality = citationQuality; @@ -397,13 +573,13 @@ public _FinalStage citationQuality(Optional ci *

A list of relevant documents that the model can use to enrich its reply. See 'Document Mode' in the guide for more information.

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

Defaults to false. - * When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

+ *

Defaults to false.

+ *

When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

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

Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - * When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).

+ *

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

+ *

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

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

Defaults to AUTO when connectors are specified and OFF in all other cases. - * Dictates how the prompt will be constructed. - * With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. - * With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

+ *

Defaults to AUTO when connectors are specified and OFF in all other cases.

+ *

Dictates how the prompt will be constructed.

+ *

With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit.

+ *

With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

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

An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation. - * If a conversation with this id does not already exist, a new conversation will be created.

+ *

An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation.

+ *

If a conversation with this id does not already exist, a new conversation will be created.

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

A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage chatHistory(List chatHistory) { this.chatHistory = Optional.of(chatHistory); return this; } - @Override + @java.lang.Override @JsonSetter(value = "chat_history", nulls = Nulls.SKIP) public _FinalStage chatHistory(Optional> chatHistory) { this.chatHistory = chatHistory; @@ -505,13 +681,13 @@ public _FinalStage chatHistory(Optional> chatHistory) { *

When specified, the default Cohere preamble will be replaced with the provided one.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage preambleOverride(String preambleOverride) { this.preambleOverride = Optional.of(preambleOverride); return this; } - @Override + @java.lang.Override @JsonSetter(value = "preamble_override", nulls = Nulls.SKIP) public _FinalStage preambleOverride(Optional preambleOverride) { this.preambleOverride = preambleOverride; @@ -519,30 +695,29 @@ public _FinalStage preambleOverride(Optional preambleOverride) { } /** - *

Defaults to command. - * The identifier of the model, which can be one of the existing Cohere models or the full ID for a finetuned custom model. - * Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models.

+ *

Defaults to command.

+ *

The identifier of the model, which can be one of the existing Cohere models or the full ID for a fine-tuned custom model.

+ *

Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public ChatStreamRequest build() { return new ChatStreamRequest( message, model, - stream, preambleOverride, chatHistory, conversationId, @@ -552,6 +727,11 @@ public ChatStreamRequest build() { documents, citationQuality, temperature, + maxTokens, + k, + p, + frequencyPenalty, + presencePenalty, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/requests/ClassifyRequest.java b/src/main/java/com/cohere/api/requests/ClassifyRequest.java index 437990a..28547a5 100644 --- a/src/main/java/com/cohere/api/requests/ClassifyRequest.java +++ b/src/main/java/com/cohere/api/requests/ClassifyRequest.java @@ -4,7 +4,7 @@ package com.cohere.api.requests; import com.cohere.api.core.ObjectMappers; -import com.cohere.api.types.ClassifyRequestExamplesItem; +import com.cohere.api.types.ClassifyExample; import com.cohere.api.types.ClassifyRequestTruncate; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -26,7 +26,7 @@ public final class ClassifyRequest { private final List inputs; - private final List examples; + private final List examples; private final Optional model; @@ -38,7 +38,7 @@ public final class ClassifyRequest { private ClassifyRequest( List inputs, - List examples, + List examples, Optional model, Optional preset, Optional truncate, @@ -52,7 +52,9 @@ private ClassifyRequest( } /** - * @return Represents a list of queries to be classified, each entry must not be empty. The maximum is 96 inputs. + * @return A list of up to 96 texts to be classified. Each one must be a non-empty string. + * There is, however, no consistent, universal limit to the length a particular input can be. We perform classification on the first x tokens of each input, and x varies depending on which underlying model is powering classification. The maximum token length for each model is listed in the "max tokens" column here. + * Note: by default the truncate parameter is set to END, so tokens exceeding the limit will be automatically dropped. This behavior can be disabled by setting truncate to NONE, which will result in validation errors for longer texts. */ @JsonProperty("inputs") public List getInputs() { @@ -61,15 +63,15 @@ public List getInputs() { /** * @return An array of examples to provide context to the model. Each example is a text string and its associated label/class. Each unique label requires at least 2 examples associated with it; the maximum number of examples is 2500, and each example has a maximum length of 512 tokens. The values should be structured as {text: "...",label: "..."}. - * Note: Custom Models trained on classification examples don't require the examples parameter to be passed in explicitly. + * Note: Fine-tuned Models trained on classification examples don't require the examples parameter to be passed in explicitly. */ @JsonProperty("examples") - public List getExamples() { + public List getExamples() { return examples; } /** - * @return The identifier of the model. Currently available models are embed-multilingual-v2.0, embed-english-light-v2.0, and embed-english-v2.0 (default). Smaller "light" models are faster, while larger models will perform better. Custom models can also be supplied with their full ID. + * @return The identifier of the model. Currently available models are embed-multilingual-v2.0, embed-english-light-v2.0, and embed-english-v2.0 (default). Smaller "light" models are faster, while larger models will perform better. Fine-tuned models can also be supplied with their full ID. */ @JsonProperty("model") public Optional getModel() { @@ -94,7 +96,7 @@ public Optional getTruncate() { return truncate; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ClassifyRequest && equalTo((ClassifyRequest) other); @@ -113,12 +115,12 @@ private boolean equalTo(ClassifyRequest other) { && truncate.equals(other.truncate); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.inputs, this.examples, this.model, this.preset, this.truncate); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -131,7 +133,7 @@ public static Builder builder() { public static final class Builder { private List inputs = new ArrayList<>(); - private List examples = new ArrayList<>(); + private List examples = new ArrayList<>(); private Optional model = Optional.empty(); @@ -171,18 +173,18 @@ public Builder addAllInputs(List inputs) { } @JsonSetter(value = "examples", nulls = Nulls.SKIP) - public Builder examples(List examples) { + public Builder examples(List examples) { this.examples.clear(); this.examples.addAll(examples); return this; } - public Builder addExamples(ClassifyRequestExamplesItem examples) { + public Builder addExamples(ClassifyExample examples) { this.examples.add(examples); return this; } - public Builder addAllExamples(List examples) { + public Builder addAllExamples(List examples) { this.examples.addAll(examples); return this; } diff --git a/src/main/java/com/cohere/api/requests/DetectLanguageRequest.java b/src/main/java/com/cohere/api/requests/DetectLanguageRequest.java deleted file mode 100644 index 0e3d471..0000000 --- a/src/main/java/com/cohere/api/requests/DetectLanguageRequest.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.cohere.api.requests; - -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.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = DetectLanguageRequest.Builder.class) -public final class DetectLanguageRequest { - private final List texts; - - private final Optional model; - - private final Map additionalProperties; - - private DetectLanguageRequest( - List texts, Optional model, Map additionalProperties) { - this.texts = texts; - this.model = model; - this.additionalProperties = additionalProperties; - } - - /** - * @return List of strings to run the detection on. - */ - @JsonProperty("texts") - public List getTexts() { - return texts; - } - - /** - * @return The identifier of the model to generate with. - */ - @JsonProperty("model") - public Optional getModel() { - return model; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DetectLanguageRequest && equalTo((DetectLanguageRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DetectLanguageRequest other) { - return texts.equals(other.texts) && model.equals(other.model); - } - - @Override - public int hashCode() { - return Objects.hash(this.texts, this.model); - } - - @Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List texts = new ArrayList<>(); - - private Optional model = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(DetectLanguageRequest other) { - texts(other.getTexts()); - model(other.getModel()); - return this; - } - - @JsonSetter(value = "texts", nulls = Nulls.SKIP) - public Builder texts(List texts) { - this.texts.clear(); - this.texts.addAll(texts); - return this; - } - - public Builder addTexts(String texts) { - this.texts.add(texts); - return this; - } - - public Builder addAllTexts(List texts) { - this.texts.addAll(texts); - return this; - } - - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public Builder model(Optional model) { - this.model = model; - return this; - } - - public Builder model(String model) { - this.model = Optional.of(model); - return this; - } - - public DetectLanguageRequest build() { - return new DetectLanguageRequest(texts, model, additionalProperties); - } - } -} diff --git a/src/main/java/com/cohere/api/requests/DetokenizeRequest.java b/src/main/java/com/cohere/api/requests/DetokenizeRequest.java index 1e8cbee..c0932c0 100644 --- a/src/main/java/com/cohere/api/requests/DetokenizeRequest.java +++ b/src/main/java/com/cohere/api/requests/DetokenizeRequest.java @@ -50,7 +50,7 @@ public Optional getModel() { return model; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof DetokenizeRequest && equalTo((DetokenizeRequest) other); @@ -65,12 +65,12 @@ private boolean equalTo(DetokenizeRequest other) { return tokens.equals(other.tokens) && model.equals(other.model); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.tokens, this.model); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/requests/EmbedRequest.java b/src/main/java/com/cohere/api/requests/EmbedRequest.java index a3c91ed..cd537a0 100644 --- a/src/main/java/com/cohere/api/requests/EmbedRequest.java +++ b/src/main/java/com/cohere/api/requests/EmbedRequest.java @@ -4,6 +4,8 @@ package com.cohere.api.requests; import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.EmbedInputType; +import com.cohere.api.types.EmbedRequestEmbeddingTypesItem; import com.cohere.api.types.EmbedRequestTruncate; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -27,9 +29,9 @@ public final class EmbedRequest { private final Optional model; - private final Optional inputType; + private final Optional inputType; - private final Optional> embeddingTypes; + private final Optional> embeddingTypes; private final Optional truncate; @@ -38,8 +40,8 @@ public final class EmbedRequest { private EmbedRequest( List texts, Optional model, - Optional inputType, - Optional> embeddingTypes, + Optional inputType, + Optional> embeddingTypes, Optional truncate, Map additionalProperties) { this.texts = texts; @@ -91,17 +93,8 @@ public Optional getModel() { return model; } - /** - * @return Specifies the type of input you're giving to the model. Not required for older versions of the embedding models (i.e. anything lower than v3), but is required for more recent versions (i.e. anything bigger than v2). - *
    - *
  • "search_document": Use this when you encode documents for embeddings that you store in a vector database for search use-cases.
  • - *
  • "search_query": Use this when you query your vector DB to find relevant documents.
  • - *
  • "classification": Use this when you use the embeddings as an input to a text classifier.
  • - *
  • "clustering": Use this when you want to cluster the embeddings.
  • - *
- */ @JsonProperty("input_type") - public Optional getInputType() { + public Optional getInputType() { return inputType; } @@ -116,7 +109,7 @@ public Optional getInputType() { * */ @JsonProperty("embedding_types") - public Optional> getEmbeddingTypes() { + public Optional> getEmbeddingTypes() { return embeddingTypes; } @@ -130,7 +123,7 @@ public Optional getTruncate() { return truncate; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbedRequest && equalTo((EmbedRequest) other); @@ -149,12 +142,12 @@ private boolean equalTo(EmbedRequest other) { && truncate.equals(other.truncate); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.texts, this.model, this.inputType, this.embeddingTypes, this.truncate); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -169,9 +162,9 @@ public static final class Builder { private Optional model = Optional.empty(); - private Optional inputType = Optional.empty(); + private Optional inputType = Optional.empty(); - private Optional> embeddingTypes = Optional.empty(); + private Optional> embeddingTypes = Optional.empty(); private Optional truncate = Optional.empty(); @@ -218,23 +211,23 @@ public Builder model(String model) { } @JsonSetter(value = "input_type", nulls = Nulls.SKIP) - public Builder inputType(Optional inputType) { + public Builder inputType(Optional inputType) { this.inputType = inputType; return this; } - public Builder inputType(String inputType) { + public Builder inputType(EmbedInputType inputType) { this.inputType = Optional.of(inputType); return this; } @JsonSetter(value = "embedding_types", nulls = Nulls.SKIP) - public Builder embeddingTypes(Optional> embeddingTypes) { + public Builder embeddingTypes(Optional> embeddingTypes) { this.embeddingTypes = embeddingTypes; return this; } - public Builder embeddingTypes(List embeddingTypes) { + public Builder embeddingTypes(List embeddingTypes) { this.embeddingTypes = Optional.of(embeddingTypes); 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 3fdc366..ca6dcad 100644 --- a/src/main/java/com/cohere/api/requests/GenerateRequest.java +++ b/src/main/java/com/cohere/api/requests/GenerateRequest.java @@ -29,8 +29,6 @@ public final class GenerateRequest { private final Optional numGenerations; - private final Optional stream; - private final Optional maxTokens; private final Optional truncate; @@ -53,7 +51,7 @@ public final class GenerateRequest { private final Optional returnLikelihoods; - private final Optional> logitBias; + private final Optional rawPrompting; private final Map additionalProperties; @@ -61,7 +59,6 @@ private GenerateRequest( String prompt, Optional model, Optional numGenerations, - Optional stream, Optional maxTokens, Optional truncate, Optional temperature, @@ -73,12 +70,11 @@ private GenerateRequest( Optional frequencyPenalty, Optional presencePenalty, Optional returnLikelihoods, - Optional> logitBias, + Optional rawPrompting, Map additionalProperties) { this.prompt = prompt; this.model = model; this.numGenerations = numGenerations; - this.stream = stream; this.maxTokens = maxTokens; this.truncate = truncate; this.temperature = temperature; @@ -90,7 +86,7 @@ private GenerateRequest( this.frequencyPenalty = frequencyPenalty; this.presencePenalty = presencePenalty; this.returnLikelihoods = returnLikelihoods; - this.logitBias = logitBias; + this.rawPrompting = rawPrompting; this.additionalProperties = additionalProperties; } @@ -120,19 +116,9 @@ public Optional getNumGenerations() { return numGenerations; } - /** - * @return When true, the response will be a JSON stream of events. Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated. - *

The final event will contain the complete response, and will contain an is_finished field set to true. The event will also contain a finish_reason, which can be one of the following:

- *
    - *
  • COMPLETE - the model sent back a finished reply
  • - *
  • MAX_TOKENS - the reply was cut off because the model reached the maximum number of tokens for its context length
  • - *
  • ERROR - something went wrong when generating the reply
  • - *
  • ERROR_TOXIC - the model generated a reply that was deemed toxic
  • - *
- */ @JsonProperty("stream") - public Optional getStream() { - return stream; + public Boolean getStream() { + return false; } /** @@ -208,7 +194,8 @@ public Optional getP() { } /** - * @return Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.' + * @return Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

*/ @JsonProperty("frequency_penalty") public Optional getFrequencyPenalty() { @@ -216,7 +203,9 @@ public Optional getFrequencyPenalty() { } /** - * @return Defaults to 0.0, min value of 0.0, max value of 1.0. Can be 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. + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. + *

Can be 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.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

*/ @JsonProperty("presence_penalty") public Optional getPresencePenalty() { @@ -234,16 +223,14 @@ public Optional getReturnLikelihoods() { } /** - * @return Used to prevent the model from generating unwanted tokens or to incentivize it to include desired tokens. The format is {token_id: bias} where bias is a float between -10 and 10. Tokens can be obtained from text using Tokenize. - *

For example, if the value {'11': -10} is provided, the model will be very unlikely to include the token 11 ("\n", the newline character) anywhere in the generated text. In contrast {'11': 10} will result in generations that nearly only contain that token. Values between -10 and 10 will proportionally affect the likelihood of the token appearing in the generated text.

- *

Note: logit bias may not be supported for all custom models.

+ * @return When enabled, the user's prompt will be sent to the model without any pre-processing. */ - @JsonProperty("logit_bias") - public Optional> getLogitBias() { - return logitBias; + @JsonProperty("raw_prompting") + public Optional getRawPrompting() { + return rawPrompting; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof GenerateRequest && equalTo((GenerateRequest) other); @@ -258,7 +245,6 @@ private boolean equalTo(GenerateRequest other) { return prompt.equals(other.prompt) && model.equals(other.model) && numGenerations.equals(other.numGenerations) - && stream.equals(other.stream) && maxTokens.equals(other.maxTokens) && truncate.equals(other.truncate) && temperature.equals(other.temperature) @@ -270,16 +256,15 @@ private boolean equalTo(GenerateRequest other) { && frequencyPenalty.equals(other.frequencyPenalty) && presencePenalty.equals(other.presencePenalty) && returnLikelihoods.equals(other.returnLikelihoods) - && logitBias.equals(other.logitBias); + && rawPrompting.equals(other.rawPrompting); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.prompt, this.model, this.numGenerations, - this.stream, this.maxTokens, this.truncate, this.temperature, @@ -291,10 +276,10 @@ public int hashCode() { this.frequencyPenalty, this.presencePenalty, this.returnLikelihoods, - this.logitBias); + this.rawPrompting); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -320,10 +305,6 @@ public interface _FinalStage { _FinalStage numGenerations(Integer numGenerations); - _FinalStage stream(Optional stream); - - _FinalStage stream(Boolean stream); - _FinalStage maxTokens(Optional maxTokens); _FinalStage maxTokens(Integer maxTokens); @@ -368,16 +349,16 @@ public interface _FinalStage { _FinalStage returnLikelihoods(GenerateRequestReturnLikelihoods returnLikelihoods); - _FinalStage logitBias(Optional> logitBias); + _FinalStage rawPrompting(Optional rawPrompting); - _FinalStage logitBias(Map logitBias); + _FinalStage rawPrompting(Boolean rawPrompting); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements PromptStage, _FinalStage { private String prompt; - private Optional> logitBias = Optional.empty(); + private Optional rawPrompting = Optional.empty(); private Optional returnLikelihoods = Optional.empty(); @@ -401,8 +382,6 @@ public static final class Builder implements PromptStage, _FinalStage { private Optional maxTokens = Optional.empty(); - private Optional stream = Optional.empty(); - private Optional numGenerations = Optional.empty(); private Optional model = Optional.empty(); @@ -412,12 +391,11 @@ public static final class Builder implements PromptStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(GenerateRequest other) { prompt(other.getPrompt()); model(other.getModel()); numGenerations(other.getNumGenerations()); - stream(other.getStream()); maxTokens(other.getMaxTokens()); truncate(other.getTruncate()); temperature(other.getTemperature()); @@ -429,7 +407,7 @@ public Builder from(GenerateRequest other) { frequencyPenalty(other.getFrequencyPenalty()); presencePenalty(other.getPresencePenalty()); returnLikelihoods(other.getReturnLikelihoods()); - logitBias(other.getLogitBias()); + rawPrompting(other.getRawPrompting()); return this; } @@ -438,7 +416,7 @@ public Builder from(GenerateRequest other) { * Note: The prompt will be pre-processed and modified before reaching the model.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("prompt") public _FinalStage prompt(String prompt) { this.prompt = prompt; @@ -446,21 +424,19 @@ public _FinalStage prompt(String prompt) { } /** - *

Used to prevent the model from generating unwanted tokens or to incentivize it to include desired tokens. The format is {token_id: bias} where bias is a float between -10 and 10. Tokens can be obtained from text using Tokenize.

- *

For example, if the value {'11': -10} is provided, the model will be very unlikely to include the token 11 ("\n", the newline character) anywhere in the generated text. In contrast {'11': 10} will result in generations that nearly only contain that token. Values between -10 and 10 will proportionally affect the likelihood of the token appearing in the generated text.

- *

Note: logit bias may not be supported for all custom models.

+ *

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

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override - public _FinalStage logitBias(Map logitBias) { - this.logitBias = Optional.of(logitBias); + @java.lang.Override + public _FinalStage rawPrompting(Boolean rawPrompting) { + this.rawPrompting = Optional.of(rawPrompting); return this; } - @Override - @JsonSetter(value = "logit_bias", nulls = Nulls.SKIP) - public _FinalStage logitBias(Optional> logitBias) { - this.logitBias = logitBias; + @java.lang.Override + @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) + public _FinalStage rawPrompting(Optional rawPrompting) { + this.rawPrompting = rawPrompting; return this; } @@ -470,13 +446,13 @@ public _FinalStage logitBias(Optional> logitBias) { *

If ALL is selected, the token likelihoods will be provided both for the prompt and the generated text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage returnLikelihoods(GenerateRequestReturnLikelihoods returnLikelihoods) { this.returnLikelihoods = Optional.of(returnLikelihoods); return this; } - @Override + @java.lang.Override @JsonSetter(value = "return_likelihoods", nulls = Nulls.SKIP) public _FinalStage returnLikelihoods(Optional returnLikelihoods) { this.returnLikelihoods = returnLikelihoods; @@ -484,16 +460,18 @@ public _FinalStage returnLikelihoods(Optional } /** - *

Defaults to 0.0, min value of 0.0, max value of 1.0. Can be 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.

+ *

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

+ *

Can be 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.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage presencePenalty(Double presencePenalty) { this.presencePenalty = Optional.of(presencePenalty); return this; } - @Override + @java.lang.Override @JsonSetter(value = "presence_penalty", nulls = Nulls.SKIP) public _FinalStage presencePenalty(Optional presencePenalty) { this.presencePenalty = presencePenalty; @@ -501,16 +479,17 @@ public _FinalStage presencePenalty(Optional presencePenalty) { } /** - *

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.'

+ *

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage frequencyPenalty(Double frequencyPenalty) { this.frequencyPenalty = Optional.of(frequencyPenalty); return this; } - @Override + @java.lang.Override @JsonSetter(value = "frequency_penalty", nulls = Nulls.SKIP) public _FinalStage frequencyPenalty(Optional frequencyPenalty) { this.frequencyPenalty = frequencyPenalty; @@ -522,13 +501,13 @@ public _FinalStage frequencyPenalty(Optional frequencyPenalty) { * Defaults to 0.75. min value of 0.01, max value of 0.99.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage p(Double p) { this.p = Optional.of(p); return this; } - @Override + @java.lang.Override @JsonSetter(value = "p", nulls = Nulls.SKIP) public _FinalStage p(Optional p) { this.p = p; @@ -540,13 +519,13 @@ public _FinalStage p(Optional p) { * Defaults to 0, min value of 0, max value of 500.

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

The generated text will be cut at the end of the earliest occurrence of a stop sequence. The sequence will be included the text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage stopSequences(List stopSequences) { this.stopSequences = Optional.of(stopSequences); return this; } - @Override + @java.lang.Override @JsonSetter(value = "stop_sequences", nulls = Nulls.SKIP) public _FinalStage stopSequences(Optional> stopSequences) { this.stopSequences = stopSequences; @@ -574,13 +553,13 @@ public _FinalStage stopSequences(Optional> stopSequences) { *

The generated text will be cut at the beginning of the earliest occurrence of an end sequence. The sequence will be excluded from the text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage endSequences(List endSequences) { this.endSequences = Optional.of(endSequences); return this; } - @Override + @java.lang.Override @JsonSetter(value = "end_sequences", nulls = Nulls.SKIP) public _FinalStage endSequences(Optional> endSequences) { this.endSequences = endSequences; @@ -592,13 +571,13 @@ public _FinalStage endSequences(Optional> endSequences) { * When a preset is specified, the prompt parameter becomes optional, and any included parameters will override the preset's parameters.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage preset(String preset) { this.preset = Optional.of(preset); return this; } - @Override + @java.lang.Override @JsonSetter(value = "preset", nulls = Nulls.SKIP) public _FinalStage preset(Optional preset) { this.preset = preset; @@ -610,13 +589,13 @@ public _FinalStage preset(Optional preset) { * Defaults to 0.75, min value of 0.0, max value of 5.0.

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

If NONE is selected, when the input exceeds the maximum input token length an error will be returned.

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

Can only be set to 0 if return_likelihoods is set to ALL to get the likelihood of the prompt.

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

When true, the response will be a JSON stream of events. Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated.

- *

The final event will contain the complete response, and will contain an is_finished field set to true. The event will also contain a finish_reason, which can be one of the following:

- *
    - *
  • COMPLETE - the model sent back a finished reply
  • - *
  • MAX_TOKENS - the reply was cut off because the model reached the maximum number of tokens for its context length
  • - *
  • ERROR - something went wrong when generating the reply
  • - *
  • ERROR_TOXIC - the model generated a reply that was deemed toxic
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage stream(Boolean stream) { - this.stream = Optional.of(stream); - return this; - } - - @Override - @JsonSetter(value = "stream", nulls = Nulls.SKIP) - public _FinalStage stream(Optional stream) { - this.stream = stream; - return this; - } - /** *

The maximum number of generations that will be returned. Defaults to 1, min value of 1, max value of 5.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage numGenerations(Integer numGenerations) { this.numGenerations = Optional.of(numGenerations); return this; } - @Override + @java.lang.Override @JsonSetter(value = "num_generations", nulls = Nulls.SKIP) public _FinalStage numGenerations(Optional numGenerations) { this.numGenerations = numGenerations; @@ -707,26 +662,25 @@ public _FinalStage numGenerations(Optional numGenerations) { * Smaller, "light" models are faster, while larger models will perform better. Custom models can also be supplied with their full ID.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public GenerateRequest build() { return new GenerateRequest( prompt, model, numGenerations, - stream, maxTokens, truncate, temperature, @@ -738,7 +692,7 @@ public GenerateRequest build() { frequencyPenalty, presencePenalty, returnLikelihoods, - logitBias, + rawPrompting, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java b/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java new file mode 100644 index 0000000..5efa437 --- /dev/null +++ b/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java @@ -0,0 +1,699 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.requests; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.GenerateStreamRequestReturnLikelihoods; +import com.cohere.api.types.GenerateStreamRequestTruncate; +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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = GenerateStreamRequest.Builder.class) +public final class GenerateStreamRequest { + private final String prompt; + + private final Optional model; + + private final Optional numGenerations; + + private final Optional maxTokens; + + private final Optional truncate; + + private final Optional temperature; + + private final Optional preset; + + private final Optional> endSequences; + + private final Optional> stopSequences; + + private final Optional k; + + private final Optional p; + + private final Optional frequencyPenalty; + + private final Optional presencePenalty; + + private final Optional returnLikelihoods; + + private final Optional rawPrompting; + + private final Map additionalProperties; + + private GenerateStreamRequest( + String prompt, + Optional model, + Optional numGenerations, + Optional maxTokens, + Optional truncate, + Optional temperature, + Optional preset, + Optional> endSequences, + Optional> stopSequences, + Optional k, + Optional p, + Optional frequencyPenalty, + Optional presencePenalty, + Optional returnLikelihoods, + Optional rawPrompting, + Map additionalProperties) { + this.prompt = prompt; + this.model = model; + this.numGenerations = numGenerations; + this.maxTokens = maxTokens; + this.truncate = truncate; + this.temperature = temperature; + this.preset = preset; + this.endSequences = endSequences; + this.stopSequences = stopSequences; + this.k = k; + this.p = p; + this.frequencyPenalty = frequencyPenalty; + this.presencePenalty = presencePenalty; + this.returnLikelihoods = returnLikelihoods; + this.rawPrompting = rawPrompting; + this.additionalProperties = additionalProperties; + } + + /** + * @return The input text that serves as the starting point for generating the response. + * Note: The prompt will be pre-processed and modified before reaching the model. + */ + @JsonProperty("prompt") + public String getPrompt() { + return prompt; + } + + /** + * @return The identifier of the model to generate with. Currently available models are command (default), command-nightly (experimental), command-light, and command-light-nightly (experimental). + * Smaller, "light" models are faster, while larger models will perform better. Custom models can also be supplied with their full ID. + */ + @JsonProperty("model") + public Optional getModel() { + return model; + } + + /** + * @return The maximum number of generations that will be returned. Defaults to 1, min value of 1, max value of 5. + */ + @JsonProperty("num_generations") + public Optional getNumGenerations() { + return numGenerations; + } + + @JsonProperty("stream") + public Boolean getStream() { + return true; + } + + /** + * @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. + *

This parameter is off by default, and if it's not specified, the model will continue generating until it emits an EOS completion token. See BPE Tokens for more details.

+ *

Can only be set to 0 if return_likelihoods is set to ALL to get the likelihood of the prompt.

+ */ + @JsonProperty("max_tokens") + public Optional getMaxTokens() { + return maxTokens; + } + + /** + * @return One of NONE|START|END to specify how the API will handle inputs longer than the maximum token length. + *

Passing START will discard the start of the input. END will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

+ *

If NONE is selected, when the input exceeds the maximum input token length an error will be returned.

+ */ + @JsonProperty("truncate") + public Optional getTruncate() { + return truncate; + } + + /** + * @return A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. See Temperature for more details. + * Defaults to 0.75, min value of 0.0, max value of 5.0. + */ + @JsonProperty("temperature") + public Optional getTemperature() { + return temperature; + } + + /** + * @return Identifier of a custom preset. A preset is a combination of parameters, such as prompt, temperature etc. You can create presets in the playground. + * When a preset is specified, the prompt parameter becomes optional, and any included parameters will override the preset's parameters. + */ + @JsonProperty("preset") + public Optional getPreset() { + return preset; + } + + /** + * @return The generated text will be cut at the beginning of the earliest occurrence of an end sequence. The sequence will be excluded from the text. + */ + @JsonProperty("end_sequences") + public Optional> getEndSequences() { + return endSequences; + } + + /** + * @return The generated text will be cut at the end of the earliest occurrence of a stop sequence. The sequence will be included the text. + */ + @JsonProperty("stop_sequences") + public Optional> getStopSequences() { + return stopSequences; + } + + /** + * @return Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500. + */ + @JsonProperty("k") + public Optional getK() { + return k; + } + + /** + * @return Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99. + */ + @JsonProperty("p") + public Optional getP() { + return p; + } + + /** + * @return Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

+ */ + @JsonProperty("frequency_penalty") + public Optional getFrequencyPenalty() { + return frequencyPenalty; + } + + /** + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. + *

Can be 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.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

+ */ + @JsonProperty("presence_penalty") + public Optional getPresencePenalty() { + return presencePenalty; + } + + /** + * @return One of GENERATION|ALL|NONE to specify how and if the token likelihoods are returned with the response. Defaults to NONE. + *

If GENERATION is selected, the token likelihoods will only be provided for generated text.

+ *

If ALL is selected, the token likelihoods will be provided both for the prompt and the generated text.

+ */ + @JsonProperty("return_likelihoods") + public Optional getReturnLikelihoods() { + return returnLikelihoods; + } + + /** + * @return When enabled, the user's prompt will be sent to the model without any pre-processing. + */ + @JsonProperty("raw_prompting") + public Optional getRawPrompting() { + return rawPrompting; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamRequest && equalTo((GenerateStreamRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamRequest other) { + return prompt.equals(other.prompt) + && model.equals(other.model) + && numGenerations.equals(other.numGenerations) + && maxTokens.equals(other.maxTokens) + && truncate.equals(other.truncate) + && temperature.equals(other.temperature) + && preset.equals(other.preset) + && endSequences.equals(other.endSequences) + && stopSequences.equals(other.stopSequences) + && k.equals(other.k) + && p.equals(other.p) + && frequencyPenalty.equals(other.frequencyPenalty) + && presencePenalty.equals(other.presencePenalty) + && returnLikelihoods.equals(other.returnLikelihoods) + && rawPrompting.equals(other.rawPrompting); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.prompt, + this.model, + this.numGenerations, + this.maxTokens, + this.truncate, + this.temperature, + this.preset, + this.endSequences, + this.stopSequences, + this.k, + this.p, + this.frequencyPenalty, + this.presencePenalty, + this.returnLikelihoods, + this.rawPrompting); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PromptStage builder() { + return new Builder(); + } + + public interface PromptStage { + _FinalStage prompt(String prompt); + + Builder from(GenerateStreamRequest other); + } + + public interface _FinalStage { + GenerateStreamRequest build(); + + _FinalStage model(Optional model); + + _FinalStage model(String model); + + _FinalStage numGenerations(Optional numGenerations); + + _FinalStage numGenerations(Integer numGenerations); + + _FinalStage maxTokens(Optional maxTokens); + + _FinalStage maxTokens(Integer maxTokens); + + _FinalStage truncate(Optional truncate); + + _FinalStage truncate(GenerateStreamRequestTruncate truncate); + + _FinalStage temperature(Optional temperature); + + _FinalStage temperature(Double temperature); + + _FinalStage preset(Optional preset); + + _FinalStage preset(String preset); + + _FinalStage endSequences(Optional> endSequences); + + _FinalStage endSequences(List endSequences); + + _FinalStage stopSequences(Optional> stopSequences); + + _FinalStage stopSequences(List stopSequences); + + _FinalStage k(Optional k); + + _FinalStage k(Integer k); + + _FinalStage p(Optional p); + + _FinalStage p(Double p); + + _FinalStage frequencyPenalty(Optional frequencyPenalty); + + _FinalStage frequencyPenalty(Double frequencyPenalty); + + _FinalStage presencePenalty(Optional presencePenalty); + + _FinalStage presencePenalty(Double presencePenalty); + + _FinalStage returnLikelihoods(Optional returnLikelihoods); + + _FinalStage returnLikelihoods(GenerateStreamRequestReturnLikelihoods returnLikelihoods); + + _FinalStage rawPrompting(Optional rawPrompting); + + _FinalStage rawPrompting(Boolean rawPrompting); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PromptStage, _FinalStage { + private String prompt; + + private Optional rawPrompting = Optional.empty(); + + private Optional returnLikelihoods = Optional.empty(); + + private Optional presencePenalty = Optional.empty(); + + private Optional frequencyPenalty = Optional.empty(); + + private Optional p = Optional.empty(); + + private Optional k = Optional.empty(); + + private Optional> stopSequences = Optional.empty(); + + private Optional> endSequences = Optional.empty(); + + private Optional preset = Optional.empty(); + + private Optional temperature = Optional.empty(); + + private Optional truncate = Optional.empty(); + + private Optional maxTokens = Optional.empty(); + + private Optional numGenerations = Optional.empty(); + + private Optional model = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamRequest other) { + prompt(other.getPrompt()); + model(other.getModel()); + numGenerations(other.getNumGenerations()); + maxTokens(other.getMaxTokens()); + truncate(other.getTruncate()); + temperature(other.getTemperature()); + preset(other.getPreset()); + endSequences(other.getEndSequences()); + stopSequences(other.getStopSequences()); + k(other.getK()); + p(other.getP()); + frequencyPenalty(other.getFrequencyPenalty()); + presencePenalty(other.getPresencePenalty()); + returnLikelihoods(other.getReturnLikelihoods()); + rawPrompting(other.getRawPrompting()); + return this; + } + + /** + *

The input text that serves as the starting point for generating the response. + * Note: The prompt will be pre-processed and modified before reaching the model.

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

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

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

One of GENERATION|ALL|NONE to specify how and if the token likelihoods are returned with the response. Defaults to NONE.

+ *

If GENERATION is selected, the token likelihoods will only be provided for generated text.

+ *

If ALL is selected, the token likelihoods will be provided both for the prompt and the generated text.

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

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

+ *

Can be 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.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

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

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

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

Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99.

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

Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500.

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

The generated text will be cut at the end of the earliest occurrence of a stop sequence. The sequence will be included the text.

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

The generated text will be cut at the beginning of the earliest occurrence of an end sequence. The sequence will be excluded from the text.

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

Identifier of a custom preset. A preset is a combination of parameters, such as prompt, temperature etc. You can create presets in the playground. + * When a preset is specified, the prompt parameter becomes optional, and any included parameters will override the preset's parameters.

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

A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. See Temperature for more details. + * Defaults to 0.75, min value of 0.0, max value of 5.0.

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

One of NONE|START|END to specify how the API will handle inputs longer than the maximum token length.

+ *

Passing START will discard the start of the input. END will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

+ *

If NONE is selected, when the input exceeds the maximum input token length an error will be returned.

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

The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.

+ *

This parameter is off by default, and if it's not specified, the model will continue generating until it emits an EOS completion token. See BPE Tokens for more details.

+ *

Can only be set to 0 if return_likelihoods is set to ALL to get the likelihood of the prompt.

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

The maximum number of generations that will be returned. Defaults to 1, min value of 1, max value of 5.

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

The identifier of the model to generate with. Currently available models are command (default), command-nightly (experimental), command-light, and command-light-nightly (experimental). + * Smaller, "light" models are faster, while larger models will perform better. Custom models can also be supplied with their full ID.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage model(String model) { + this.model = Optional.of(model); + return this; + } + + @java.lang.Override + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public _FinalStage model(Optional model) { + this.model = model; + return this; + } + + @java.lang.Override + public GenerateStreamRequest build() { + return new GenerateStreamRequest( + prompt, + model, + numGenerations, + maxTokens, + truncate, + temperature, + preset, + endSequences, + stopSequences, + k, + p, + frequencyPenalty, + presencePenalty, + returnLikelihoods, + rawPrompting, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/requests/RerankRequest.java b/src/main/java/com/cohere/api/requests/RerankRequest.java index cac0623..c11fae4 100644 --- a/src/main/java/com/cohere/api/requests/RerankRequest.java +++ b/src/main/java/com/cohere/api/requests/RerankRequest.java @@ -108,7 +108,7 @@ public Optional getMaxChunksPerDoc() { return maxChunksPerDoc; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankRequest && equalTo((RerankRequest) other); @@ -128,13 +128,13 @@ private boolean equalTo(RerankRequest other) { && maxChunksPerDoc.equals(other.maxChunksPerDoc); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.model, this.query, this.documents, this.topN, this.returnDocuments, this.maxChunksPerDoc); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -194,7 +194,7 @@ public static final class Builder implements QueryStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(RerankRequest other) { model(other.getModel()); query(other.getQuery()); @@ -209,7 +209,7 @@ public Builder from(RerankRequest other) { *

The search query

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

The maximum number of chunks to produce internally from a document

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage maxChunksPerDoc(Integer maxChunksPerDoc) { this.maxChunksPerDoc = Optional.of(maxChunksPerDoc); return this; } - @Override + @java.lang.Override @JsonSetter(value = "max_chunks_per_doc", nulls = Nulls.SKIP) public _FinalStage maxChunksPerDoc(Optional maxChunksPerDoc) { this.maxChunksPerDoc = maxChunksPerDoc; @@ -240,13 +240,13 @@ public _FinalStage maxChunksPerDoc(Optional maxChunksPerDoc) { * * @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage returnDocuments(Boolean returnDocuments) { this.returnDocuments = Optional.of(returnDocuments); return this; } - @Override + @java.lang.Override @JsonSetter(value = "return_documents", nulls = Nulls.SKIP) public _FinalStage returnDocuments(Optional returnDocuments) { this.returnDocuments = returnDocuments; @@ -257,13 +257,13 @@ public _FinalStage returnDocuments(Optional returnDocuments) { *

The number of most relevant documents or indices to return, defaults to the length of the documents

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

We recommend a maximum of 1,000 documents for optimal endpoint performance.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllDocuments(List documents) { this.documents.addAll(documents); return this; @@ -290,13 +290,13 @@ public _FinalStage addAllDocuments(List documents) { *

We recommend a maximum of 1,000 documents for optimal endpoint performance.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addDocuments(RerankRequestDocumentsItem documents) { this.documents.add(documents); return this; } - @Override + @java.lang.Override @JsonSetter(value = "documents", nulls = Nulls.SKIP) public _FinalStage documents(List documents) { this.documents.clear(); @@ -308,20 +308,20 @@ public _FinalStage documents(List documents) { *

The identifier of the model to use, one of : rerank-english-v2.0, rerank-multilingual-v2.0

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public RerankRequest build() { return new RerankRequest( model, query, documents, topN, returnDocuments, maxChunksPerDoc, additionalProperties); diff --git a/src/main/java/com/cohere/api/requests/SummarizeRequest.java b/src/main/java/com/cohere/api/requests/SummarizeRequest.java index bdbb6d5..1b173db 100644 --- a/src/main/java/com/cohere/api/requests/SummarizeRequest.java +++ b/src/main/java/com/cohere/api/requests/SummarizeRequest.java @@ -114,7 +114,7 @@ public Optional getAdditionalCommand() { return additionalCommand; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SummarizeRequest && equalTo((SummarizeRequest) other); @@ -135,7 +135,7 @@ private boolean equalTo(SummarizeRequest other) { && additionalCommand.equals(other.additionalCommand); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.text, @@ -147,7 +147,7 @@ public int hashCode() { this.additionalCommand); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -211,7 +211,7 @@ public static final class Builder implements TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(SummarizeRequest other) { text(other.getText()); length(other.getLength()); @@ -227,7 +227,7 @@ public Builder from(SummarizeRequest other) { *

The text to generate a summary for. Can be up to 100,000 characters long. Currently the only supported language is English.

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

A free-form instruction for modifying how the summaries get generated. Should complete the sentence "Generate a summary _". Eg. "focusing on the next steps" or "written by Yoda"

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

Ranges from 0 to 5. Controls the randomness of the output. Lower values tend to generate more “predictable” output, while higher values tend to generate more “creative” output. The sweet spot is typically between 0 and 1.

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

One of low, medium, high, or auto, defaults to auto. Controls how close to the original text the summary is. high extractiveness summaries will lean towards reusing sentences verbatim, while low extractiveness summaries will tend to paraphrase more. If auto is selected, the best option will be picked based on the input text.

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

The identifier of the model to generate the summary with. Currently available models are command (default), command-nightly (experimental), command-light, and command-light-nightly (experimental). Smaller, "light" models are faster, while larger models will perform better.

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

One of paragraph, bullets, or auto, defaults to auto. Indicates the style in which the summary will be delivered - in a free form paragraph or in bullet points. If auto is selected, the best option will be picked based on the input text.

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

One of short, medium, long, or auto defaults to auto. Indicates the approximate length of the summary. If auto is selected, the best option will be picked based on the input text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage length(SummarizeRequestLength length) { this.length = Optional.of(length); return this; } - @Override + @java.lang.Override @JsonSetter(value = "length", nulls = Nulls.SKIP) public _FinalStage length(Optional length) { this.length = length; return this; } - @Override + @java.lang.Override public SummarizeRequest build() { return new SummarizeRequest( text, length, format, model, extractiveness, temperature, additionalCommand, additionalProperties); diff --git a/src/main/java/com/cohere/api/requests/TokenizeRequest.java b/src/main/java/com/cohere/api/requests/TokenizeRequest.java index 9a55b4d..4cad5a5 100644 --- a/src/main/java/com/cohere/api/requests/TokenizeRequest.java +++ b/src/main/java/com/cohere/api/requests/TokenizeRequest.java @@ -48,7 +48,7 @@ public Optional getModel() { return model; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof TokenizeRequest && equalTo((TokenizeRequest) other); @@ -63,12 +63,12 @@ private boolean equalTo(TokenizeRequest other) { return text.equals(other.text) && model.equals(other.model); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text, this.model); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -102,7 +102,7 @@ public static final class Builder implements TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(TokenizeRequest other) { text(other.getText()); model(other.getModel()); @@ -113,7 +113,7 @@ public Builder from(TokenizeRequest other) { *

The string to be tokenized, the minimum text length is 1 character, and the maximum text length is 65536 characters.

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

An optional parameter to provide the model name. This will ensure that the tokenization uses the tokenizer used by that model.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public TokenizeRequest build() { return new TokenizeRequest(text, model, additionalProperties); } diff --git a/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java b/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java index b259d60..80af52c 100644 --- a/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java +++ b/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java @@ -5,22 +5,23 @@ import com.cohere.api.core.ApiError; import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.MediaTypes; import com.cohere.api.core.ObjectMappers; import com.cohere.api.core.RequestOptions; import com.cohere.api.resources.connectors.requests.ConnectorsListRequest; -import com.cohere.api.resources.connectors.requests.CreateRequest; -import com.cohere.api.resources.connectors.requests.UpdateRequest; -import com.cohere.api.types.CreateResponse; -import com.cohere.api.types.GetResponse; -import com.cohere.api.types.ListResponse; +import com.cohere.api.resources.connectors.requests.ConnectorsOAuthAuthorizeRequest; +import com.cohere.api.resources.connectors.requests.CreateConnectorRequest; +import com.cohere.api.resources.connectors.requests.UpdateConnectorRequest; +import com.cohere.api.types.CreateConnectorResponse; +import com.cohere.api.types.GetConnectorResponse; +import com.cohere.api.types.ListConnectorsResponse; import com.cohere.api.types.OAuthAuthorizeResponse; -import com.cohere.api.types.UpdateResponse; +import com.cohere.api.types.UpdateConnectorResponse; import com.fasterxml.jackson.core.type.TypeReference; import java.io.IOException; import java.util.Map; import okhttp3.Headers; import okhttp3.HttpUrl; -import okhttp3.MediaType; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @@ -35,14 +36,21 @@ public ConnectorsClient(ClientOptions clientOptions) { /** * Returns a list of connectors ordered by descending creation date (newer first). See 'Managing your Connector' for more information. */ - public ListResponse list() { + public ListConnectorsResponse list() { return list(ConnectorsListRequest.builder().build()); } /** * Returns a list of connectors ordered by descending creation date (newer first). See 'Managing your Connector' for more information. */ - public ListResponse list(ConnectorsListRequest request, RequestOptions requestOptions) { + public ListConnectorsResponse list(ConnectorsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of connectors ordered by descending creation date (newer first). See 'Managing your Connector' for more information. + */ + public ListConnectorsResponse list(ConnectorsListRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors"); @@ -62,7 +70,7 @@ public ListResponse list(ConnectorsListRequest request, RequestOptions requestOp Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), ListResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), ListConnectorsResponse.class); } throw new ApiError( response.code(), @@ -73,16 +81,16 @@ public ListResponse list(ConnectorsListRequest request, RequestOptions requestOp } /** - * Returns a list of connectors ordered by descending creation date (newer first). See 'Managing your Connector' for more information. + * Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See 'Creating and Deploying a Connector' for more information. */ - public ListResponse list(ConnectorsListRequest request) { - return list(request, null); + public CreateConnectorResponse create(CreateConnectorRequest request) { + return create(request, null); } /** * Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See 'Creating and Deploying a Connector' for more information. */ - public CreateResponse create(CreateRequest request, RequestOptions requestOptions) { + public CreateConnectorResponse create(CreateConnectorRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors") @@ -90,7 +98,7 @@ public CreateResponse create(CreateRequest request, RequestOptions requestOption RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -104,7 +112,7 @@ public CreateResponse create(CreateRequest request, RequestOptions requestOption Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), CreateResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), CreateConnectorResponse.class); } throw new ApiError( response.code(), @@ -115,16 +123,16 @@ public CreateResponse create(CreateRequest request, RequestOptions requestOption } /** - * Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See 'Creating and Deploying a Connector' for more information. + * Retrieve a connector by ID. See 'Connectors' for more information. */ - public CreateResponse create(CreateRequest request) { - return create(request, null); + public GetConnectorResponse get(String id) { + return get(id, null); } /** * Retrieve a connector by ID. See 'Connectors' for more information. */ - public GetResponse get(String id, RequestOptions requestOptions) { + public GetConnectorResponse get(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors") @@ -140,7 +148,7 @@ public GetResponse get(String id, RequestOptions requestOptions) { Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), GetResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), GetConnectorResponse.class); } throw new ApiError( response.code(), @@ -151,10 +159,10 @@ public GetResponse get(String id, RequestOptions requestOptions) { } /** - * Retrieve a connector by ID. See 'Connectors' for more information. + * Delete a connector by ID. See 'Connectors' for more information. */ - public GetResponse get(String id) { - return get(id, null); + public Map delete(String id) { + return delete(id, null); } /** @@ -188,23 +196,23 @@ public Map delete(String id, RequestOptions requestOptions) { } /** - * Delete a connector by ID. See 'Connectors' for more information. + * Update a connector by ID. Omitted fields will not be updated. See 'Managing your Connector' for more information. */ - public Map delete(String id) { - return delete(id, null); + public UpdateConnectorResponse update(String id) { + return update(id, UpdateConnectorRequest.builder().build()); } /** * Update a connector by ID. Omitted fields will not be updated. See 'Managing your Connector' for more information. */ - public UpdateResponse update(String id) { - return update(id, UpdateRequest.builder().build()); + public UpdateConnectorResponse update(String id, UpdateConnectorRequest request) { + return update(id, request, null); } /** * Update a connector by ID. Omitted fields will not be updated. See 'Managing your Connector' for more information. */ - public UpdateResponse update(String id, UpdateRequest request, RequestOptions requestOptions) { + public UpdateConnectorResponse update(String id, UpdateConnectorRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors") @@ -213,7 +221,7 @@ public UpdateResponse update(String id, UpdateRequest request, RequestOptions re RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -227,7 +235,7 @@ public UpdateResponse update(String id, UpdateRequest request, RequestOptions re Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), UpdateResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), UpdateConnectorResponse.class); } throw new ApiError( response.code(), @@ -238,28 +246,39 @@ public UpdateResponse update(String id, UpdateRequest request, RequestOptions re } /** - * Update a connector by ID. Omitted fields will not be updated. See 'Managing your Connector' for more information. + * Authorize the connector with the given ID for the connector oauth app. See 'Connector Authentication' for more information. */ - public UpdateResponse update(String id, UpdateRequest request) { - return update(id, request, null); + public OAuthAuthorizeResponse oAuthAuthorize(String id) { + return oAuthAuthorize(id, ConnectorsOAuthAuthorizeRequest.builder().build()); } /** * Authorize the connector with the given ID for the connector oauth app. See 'Connector Authentication' for more information. */ - public OAuthAuthorizeResponse oAuthAuthorize(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public OAuthAuthorizeResponse oAuthAuthorize(String id, ConnectorsOAuthAuthorizeRequest request) { + return oAuthAuthorize(id, request, null); + } + + /** + * Authorize the connector with the given ID for the connector oauth app. See 'Connector Authentication' for more information. + */ + public OAuthAuthorizeResponse oAuthAuthorize( + String id, ConnectorsOAuthAuthorizeRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors") .addPathSegment(id) - .addPathSegments("oauth/authorize") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .addPathSegments("oauth/authorize"); + if (request.getAfterTokenRedirect().isPresent()) { + httpUrl.addQueryParameter( + "after_token_redirect", request.getAfterTokenRedirect().get()); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) .method("POST", RequestBody.create("", null)) .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.build(); try { Response response = clientOptions.httpClient().newCall(okhttpRequest).execute(); @@ -273,11 +292,4 @@ public OAuthAuthorizeResponse oAuthAuthorize(String id, RequestOptions requestOp throw new RuntimeException(e); } } - - /** - * Authorize the connector with the given ID for the connector oauth app. See 'Connector Authentication' for more information. - */ - public OAuthAuthorizeResponse oAuthAuthorize(String id) { - return oAuthAuthorize(id, null); - } } diff --git a/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsListRequest.java b/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsListRequest.java index 179db53..edc7478 100644 --- a/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsListRequest.java +++ b/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsListRequest.java @@ -49,7 +49,7 @@ public Optional getOffset() { return offset; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ConnectorsListRequest && equalTo((ConnectorsListRequest) other); @@ -64,12 +64,12 @@ private boolean equalTo(ConnectorsListRequest other) { return limit.equals(other.limit) && offset.equals(other.offset); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.limit, this.offset); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsOAuthAuthorizeRequest.java b/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsOAuthAuthorizeRequest.java new file mode 100644 index 0000000..e6c83be --- /dev/null +++ b/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsOAuthAuthorizeRequest.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.connectors.requests; + +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 = ConnectorsOAuthAuthorizeRequest.Builder.class) +public final class ConnectorsOAuthAuthorizeRequest { + private final Optional afterTokenRedirect; + + private final Map additionalProperties; + + private ConnectorsOAuthAuthorizeRequest( + Optional afterTokenRedirect, Map additionalProperties) { + this.afterTokenRedirect = afterTokenRedirect; + this.additionalProperties = additionalProperties; + } + + /** + * @return The URL to redirect to after the connector has been authorized. + */ + @JsonProperty("after_token_redirect") + public Optional getAfterTokenRedirect() { + return afterTokenRedirect; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConnectorsOAuthAuthorizeRequest && equalTo((ConnectorsOAuthAuthorizeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ConnectorsOAuthAuthorizeRequest other) { + return afterTokenRedirect.equals(other.afterTokenRedirect); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.afterTokenRedirect); + } + + @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 afterTokenRedirect = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ConnectorsOAuthAuthorizeRequest other) { + afterTokenRedirect(other.getAfterTokenRedirect()); + return this; + } + + @JsonSetter(value = "after_token_redirect", nulls = Nulls.SKIP) + public Builder afterTokenRedirect(Optional afterTokenRedirect) { + this.afterTokenRedirect = afterTokenRedirect; + return this; + } + + public Builder afterTokenRedirect(String afterTokenRedirect) { + this.afterTokenRedirect = Optional.of(afterTokenRedirect); + return this; + } + + public ConnectorsOAuthAuthorizeRequest build() { + return new ConnectorsOAuthAuthorizeRequest(afterTokenRedirect, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/connectors/requests/CreateRequest.java b/src/main/java/com/cohere/api/resources/connectors/requests/CreateConnectorRequest.java similarity index 91% rename from src/main/java/com/cohere/api/resources/connectors/requests/CreateRequest.java rename to src/main/java/com/cohere/api/resources/connectors/requests/CreateConnectorRequest.java index 557d196..979d6fd 100644 --- a/src/main/java/com/cohere/api/resources/connectors/requests/CreateRequest.java +++ b/src/main/java/com/cohere/api/resources/connectors/requests/CreateConnectorRequest.java @@ -21,8 +21,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = CreateRequest.Builder.class) -public final class CreateRequest { +@JsonDeserialize(builder = CreateConnectorRequest.Builder.class) +public final class CreateConnectorRequest { private final String name; private final Optional description; @@ -41,7 +41,7 @@ public final class CreateRequest { private final Map additionalProperties; - private CreateRequest( + private CreateConnectorRequest( String name, Optional description, String url, @@ -126,10 +126,10 @@ public Optional getServiceAuth() { return serviceAuth; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof CreateRequest && equalTo((CreateRequest) other); + return other instanceof CreateConnectorRequest && equalTo((CreateConnectorRequest) other); } @JsonAnyGetter @@ -137,7 +137,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(CreateRequest other) { + private boolean equalTo(CreateConnectorRequest other) { return name.equals(other.name) && description.equals(other.description) && url.equals(other.url) @@ -148,7 +148,7 @@ private boolean equalTo(CreateRequest other) { && serviceAuth.equals(other.serviceAuth); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.name, @@ -161,7 +161,7 @@ public int hashCode() { this.serviceAuth); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -173,7 +173,7 @@ public static NameStage builder() { public interface NameStage { UrlStage name(String name); - Builder from(CreateRequest other); + Builder from(CreateConnectorRequest other); } public interface UrlStage { @@ -181,7 +181,7 @@ public interface UrlStage { } public interface _FinalStage { - CreateRequest build(); + CreateConnectorRequest build(); _FinalStage description(Optional description); @@ -231,8 +231,8 @@ public static final class Builder implements NameStage, UrlStage, _FinalStage { private Builder() {} - @Override - public Builder from(CreateRequest other) { + @java.lang.Override + public Builder from(CreateConnectorRequest other) { name(other.getName()); description(other.getDescription()); url(other.getUrl()); @@ -248,7 +248,7 @@ public Builder from(CreateRequest other) { *

A human-readable name for the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("name") public UrlStage name(String name) { this.name = name; @@ -259,7 +259,7 @@ public UrlStage name(String name) { *

The URL of the connector that will be used to search for documents.

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

The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.

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

Whether a chat request should continue or not if the request to this connector fails.

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

Whether the connector is active or not.

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

The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.

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

A list of fields to exclude from the prompt (fields remain in the document).

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

A description of the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage description(String description) { this.description = Optional.of(description); return this; } - @Override + @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { this.description = description; return this; } - @Override - public CreateRequest build() { - return new CreateRequest( + @java.lang.Override + public CreateConnectorRequest build() { + return new CreateConnectorRequest( name, description, url, diff --git a/src/main/java/com/cohere/api/resources/connectors/requests/UpdateRequest.java b/src/main/java/com/cohere/api/resources/connectors/requests/UpdateConnectorRequest.java similarity index 93% rename from src/main/java/com/cohere/api/resources/connectors/requests/UpdateRequest.java rename to src/main/java/com/cohere/api/resources/connectors/requests/UpdateConnectorRequest.java index 19b9547..04028d3 100644 --- a/src/main/java/com/cohere/api/resources/connectors/requests/UpdateRequest.java +++ b/src/main/java/com/cohere/api/resources/connectors/requests/UpdateConnectorRequest.java @@ -21,8 +21,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UpdateRequest.Builder.class) -public final class UpdateRequest { +@JsonDeserialize(builder = UpdateConnectorRequest.Builder.class) +public final class UpdateConnectorRequest { private final Optional name; private final Optional url; @@ -39,7 +39,7 @@ public final class UpdateRequest { private final Map additionalProperties; - private UpdateRequest( + private UpdateConnectorRequest( Optional name, Optional url, Optional> excludes, @@ -108,10 +108,10 @@ public Optional getServiceAuth() { return serviceAuth; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof UpdateRequest && equalTo((UpdateRequest) other); + return other instanceof UpdateConnectorRequest && equalTo((UpdateConnectorRequest) other); } @JsonAnyGetter @@ -119,7 +119,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(UpdateRequest other) { + private boolean equalTo(UpdateConnectorRequest other) { return name.equals(other.name) && url.equals(other.url) && excludes.equals(other.excludes) @@ -129,13 +129,13 @@ private boolean equalTo(UpdateRequest other) { && serviceAuth.equals(other.serviceAuth); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.name, this.url, this.excludes, this.oauth, this.active, this.continueOnFailure, this.serviceAuth); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -165,7 +165,7 @@ public static final class Builder { private Builder() {} - public Builder from(UpdateRequest other) { + public Builder from(UpdateConnectorRequest other) { name(other.getName()); url(other.getUrl()); excludes(other.getExcludes()); @@ -253,8 +253,8 @@ public Builder serviceAuth(CreateConnectorServiceAuth serviceAuth) { return this; } - public UpdateRequest build() { - return new UpdateRequest( + public UpdateConnectorRequest build() { + return new UpdateConnectorRequest( name, url, excludes, oauth, active, continueOnFailure, serviceAuth, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java b/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java new file mode 100644 index 0000000..d238222 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java @@ -0,0 +1,277 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets; + +import com.cohere.api.core.ApiError; +import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.core.RequestOptions; +import com.cohere.api.resources.datasets.requests.DatasetsCreateRequest; +import com.cohere.api.resources.datasets.requests.DatasetsListRequest; +import com.cohere.api.resources.datasets.types.DatasetsCreateResponse; +import com.cohere.api.resources.datasets.types.DatasetsGetResponse; +import com.cohere.api.resources.datasets.types.DatasetsGetUsageResponse; +import com.cohere.api.resources.datasets.types.DatasetsListResponse; +import com.fasterxml.jackson.core.type.TypeReference; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Map; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.MultipartBody; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class DatasetsClient { + protected final ClientOptions clientOptions; + + public DatasetsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List datasets that have been created. + */ + public DatasetsListResponse list() { + return list(DatasetsListRequest.builder().build()); + } + + /** + * List datasets that have been created. + */ + public DatasetsListResponse list(DatasetsListRequest request) { + return list(request, null); + } + + /** + * List datasets that have been created. + */ + public DatasetsListResponse list(DatasetsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets"); + if (request.getDatasetType().isPresent()) { + httpUrl.addQueryParameter("datasetType", request.getDatasetType().get()); + } + if (request.getBefore().isPresent()) { + httpUrl.addQueryParameter("before", request.getBefore().get().toString()); + } + if (request.getAfter().isPresent()) { + httpUrl.addQueryParameter("after", request.getAfter().get().toString()); + } + if (request.getLimit().isPresent()) { + httpUrl.addQueryParameter("limit", request.getLimit().get()); + } + if (request.getOffset().isPresent()) { + httpUrl.addQueryParameter("offset", request.getOffset().get()); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + try { + Response response = + clientOptions.httpClient().newCall(okhttpRequest).execute(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), DatasetsListResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Create a dataset by uploading a file. See 'Dataset Creation' for more information. + */ + public DatasetsCreateResponse create(File data, Optional evalData, DatasetsCreateRequest request) { + return create(data, evalData, request, null); + } + + /** + * Create a dataset by uploading a file. See 'Dataset Creation' for more information. + */ + public DatasetsCreateResponse create( + File data, Optional evalData, DatasetsCreateRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets"); + if (request.getName().isPresent()) { + httpUrl.addQueryParameter("name", request.getName().get()); + } + if (request.getType().isPresent()) { + httpUrl.addQueryParameter("type", request.getType().get().toString()); + } + if (request.getKeepOriginalFile().isPresent()) { + httpUrl.addQueryParameter( + "keep_original_file", request.getKeepOriginalFile().get().toString()); + } + if (request.getSkipMalformedInput().isPresent()) { + httpUrl.addQueryParameter( + "skip_malformed_input", + request.getSkipMalformedInput().get().toString()); + } + if (request.getKeepFields().isPresent()) { + httpUrl.addQueryParameter("keep_fields", request.getKeepFields().get()); + } + if (request.getOptionalFields().isPresent()) { + httpUrl.addQueryParameter( + "optional_fields", request.getOptionalFields().get()); + } + if (request.getTextSeparator().isPresent()) { + httpUrl.addQueryParameter( + "text_separator", request.getTextSeparator().get()); + } + if (request.getCsvDelimiter().isPresent()) { + httpUrl.addQueryParameter("csv_delimiter", request.getCsvDelimiter().get()); + } + MultipartBody.Builder body = new MultipartBody.Builder().setType(MultipartBody.FORM); + try { + String dataMimeType = Files.probeContentType(data.toPath()); + MediaType dataMediaType = dataMimeType != null ? MediaType.parse(mimeType) : null; + body.addFormDataPart("data", data.getName(), RequestBody.create(dataMediaType, data)); + if (evalData.isPresent()) { + String evalDataMimeType = Files.probeContentType(evalData.toPath()); + MediaType evalDataMediaType = evalDataMimeType != null ? MediaType.parse(mimeType) : null; + body.addFormDataPart( + "eval_data", evalData.getName(), RequestBody.create(evalDataMediaType, evalData.get())); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body.build()) + .headers(Headers.of(clientOptions.headers(requestOptions))); + Request okhttpRequest = _requestBuilder.build(); + try { + Response response = + clientOptions.httpClient().newCall(okhttpRequest).execute(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), DatasetsCreateResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * View the dataset storage usage for your Organization. Each Organization can have up to 10GB of storage across all their users. + */ + public DatasetsGetUsageResponse getUsage() { + return getUsage(null); + } + + /** + * View the dataset storage usage for your Organization. Each Organization can have up to 10GB of storage across all their users. + */ + public DatasetsGetUsageResponse getUsage(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets/usage") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + try { + Response response = + clientOptions.httpClient().newCall(okhttpRequest).execute(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), DatasetsGetUsageResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Retrieve a dataset by ID. See 'Datasets' for more information. + */ + public DatasetsGetResponse get(String id) { + return get(id, null); + } + + /** + * Retrieve a dataset by ID. See 'Datasets' for more information. + */ + public DatasetsGetResponse get(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + try { + Response response = + clientOptions.httpClient().newCall(okhttpRequest).execute(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), DatasetsGetResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually. + */ + public Map delete(String id) { + return delete(id, null); + } + + /** + * Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually. + */ + public Map delete(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + try { + Response response = + clientOptions.httpClient().newCall(okhttpRequest).execute(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue( + response.body().string(), new TypeReference>() {}); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsCreateRequest.java b/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsCreateRequest.java new file mode 100644 index 0000000..b474c0a --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsCreateRequest.java @@ -0,0 +1,307 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.requests; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.DatasetType; +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 = DatasetsCreateRequest.Builder.class) +public final class DatasetsCreateRequest { + private final Optional name; + + private final Optional type; + + private final Optional keepOriginalFile; + + private final Optional skipMalformedInput; + + private final Optional keepFields; + + private final Optional optionalFields; + + private final Optional textSeparator; + + private final Optional csvDelimiter; + + private final Map additionalProperties; + + private DatasetsCreateRequest( + Optional name, + Optional type, + Optional keepOriginalFile, + Optional skipMalformedInput, + Optional keepFields, + Optional optionalFields, + Optional textSeparator, + Optional csvDelimiter, + Map additionalProperties) { + this.name = name; + this.type = type; + this.keepOriginalFile = keepOriginalFile; + this.skipMalformedInput = skipMalformedInput; + this.keepFields = keepFields; + this.optionalFields = optionalFields; + this.textSeparator = textSeparator; + this.csvDelimiter = csvDelimiter; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the uploaded dataset. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The dataset type, which is used to validate the data. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return Indicates if the original file should be stored. + */ + @JsonProperty("keep_original_file") + public Optional getKeepOriginalFile() { + return keepOriginalFile; + } + + /** + * @return Indicates whether rows with malformed input should be dropped (instead of failing the validation check). Dropped rows will be returned in the warnings field. + */ + @JsonProperty("skip_malformed_input") + public Optional getSkipMalformedInput() { + return skipMalformedInput; + } + + /** + * @return List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the schema for the corresponding Dataset type. For example, datasets of type embed-input will drop all fields other than the required text field. If any of the fields in keep_fields are missing from the uploaded file, Dataset validation will fail. + */ + @JsonProperty("keep_fields") + public Optional getKeepFields() { + return keepFields; + } + + /** + * @return List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the schema for the corresponding Dataset type. For example, Datasets of type embed-input will drop all fields other than the required text field. If any of the fields in optional_fields are missing from the uploaded file, Dataset validation will pass. + */ + @JsonProperty("optional_fields") + public Optional getOptionalFields() { + return optionalFields; + } + + /** + * @return Raw .txt uploads will be split into entries using the text_separator value. + */ + @JsonProperty("text_separator") + public Optional getTextSeparator() { + return textSeparator; + } + + /** + * @return The delimiter used for .csv uploads. + */ + @JsonProperty("csv_delimiter") + public Optional getCsvDelimiter() { + return csvDelimiter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsCreateRequest && equalTo((DatasetsCreateRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsCreateRequest other) { + return name.equals(other.name) + && type.equals(other.type) + && keepOriginalFile.equals(other.keepOriginalFile) + && skipMalformedInput.equals(other.skipMalformedInput) + && keepFields.equals(other.keepFields) + && optionalFields.equals(other.optionalFields) + && textSeparator.equals(other.textSeparator) + && csvDelimiter.equals(other.csvDelimiter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.type, + this.keepOriginalFile, + this.skipMalformedInput, + this.keepFields, + this.optionalFields, + this.textSeparator, + this.csvDelimiter); + } + + @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 type = Optional.empty(); + + private Optional keepOriginalFile = Optional.empty(); + + private Optional skipMalformedInput = Optional.empty(); + + private Optional keepFields = Optional.empty(); + + private Optional optionalFields = Optional.empty(); + + private Optional textSeparator = Optional.empty(); + + private Optional csvDelimiter = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsCreateRequest other) { + name(other.getName()); + type(other.getType()); + keepOriginalFile(other.getKeepOriginalFile()); + skipMalformedInput(other.getSkipMalformedInput()); + keepFields(other.getKeepFields()); + optionalFields(other.getOptionalFields()); + textSeparator(other.getTextSeparator()); + csvDelimiter(other.getCsvDelimiter()); + 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 = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(DatasetType type) { + this.type = Optional.of(type); + return this; + } + + @JsonSetter(value = "keep_original_file", nulls = Nulls.SKIP) + public Builder keepOriginalFile(Optional keepOriginalFile) { + this.keepOriginalFile = keepOriginalFile; + return this; + } + + public Builder keepOriginalFile(Boolean keepOriginalFile) { + this.keepOriginalFile = Optional.of(keepOriginalFile); + return this; + } + + @JsonSetter(value = "skip_malformed_input", nulls = Nulls.SKIP) + public Builder skipMalformedInput(Optional skipMalformedInput) { + this.skipMalformedInput = skipMalformedInput; + return this; + } + + public Builder skipMalformedInput(Boolean skipMalformedInput) { + this.skipMalformedInput = Optional.of(skipMalformedInput); + return this; + } + + @JsonSetter(value = "keep_fields", nulls = Nulls.SKIP) + public Builder keepFields(Optional keepFields) { + this.keepFields = keepFields; + return this; + } + + public Builder keepFields(String keepFields) { + this.keepFields = Optional.of(keepFields); + return this; + } + + @JsonSetter(value = "optional_fields", nulls = Nulls.SKIP) + public Builder optionalFields(Optional optionalFields) { + this.optionalFields = optionalFields; + return this; + } + + public Builder optionalFields(String optionalFields) { + this.optionalFields = Optional.of(optionalFields); + return this; + } + + @JsonSetter(value = "text_separator", nulls = Nulls.SKIP) + public Builder textSeparator(Optional textSeparator) { + this.textSeparator = textSeparator; + return this; + } + + public Builder textSeparator(String textSeparator) { + this.textSeparator = Optional.of(textSeparator); + return this; + } + + @JsonSetter(value = "csv_delimiter", nulls = Nulls.SKIP) + public Builder csvDelimiter(Optional csvDelimiter) { + this.csvDelimiter = csvDelimiter; + return this; + } + + public Builder csvDelimiter(String csvDelimiter) { + this.csvDelimiter = Optional.of(csvDelimiter); + return this; + } + + public DatasetsCreateRequest build() { + return new DatasetsCreateRequest( + name, + type, + keepOriginalFile, + skipMalformedInput, + keepFields, + optionalFields, + textSeparator, + csvDelimiter, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsListRequest.java b/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsListRequest.java new file mode 100644 index 0000000..118addf --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsListRequest.java @@ -0,0 +1,209 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.requests; + +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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = DatasetsListRequest.Builder.class) +public final class DatasetsListRequest { + private final Optional datasetType; + + private final Optional before; + + private final Optional after; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private DatasetsListRequest( + Optional datasetType, + Optional before, + Optional after, + Optional limit, + Optional offset, + Map additionalProperties) { + this.datasetType = datasetType; + this.before = before; + this.after = after; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + /** + * @return optional filter by dataset type + */ + @JsonProperty("datasetType") + public Optional getDatasetType() { + return datasetType; + } + + /** + * @return optional filter before a date + */ + @JsonProperty("before") + public Optional getBefore() { + return before; + } + + /** + * @return optional filter after a date + */ + @JsonProperty("after") + public Optional getAfter() { + return after; + } + + /** + * @return optional limit to number of results + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return optional offset to start of results + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsListRequest && equalTo((DatasetsListRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsListRequest other) { + return datasetType.equals(other.datasetType) + && before.equals(other.before) + && after.equals(other.after) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.datasetType, this.before, this.after, this.limit, this.offset); + } + + @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 datasetType = Optional.empty(); + + private Optional before = Optional.empty(); + + private Optional after = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsListRequest other) { + datasetType(other.getDatasetType()); + before(other.getBefore()); + after(other.getAfter()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "datasetType", nulls = Nulls.SKIP) + public Builder datasetType(Optional datasetType) { + this.datasetType = datasetType; + return this; + } + + public Builder datasetType(String datasetType) { + this.datasetType = Optional.of(datasetType); + return this; + } + + @JsonSetter(value = "before", nulls = Nulls.SKIP) + public Builder before(Optional before) { + this.before = before; + return this; + } + + public Builder before(OffsetDateTime before) { + this.before = Optional.of(before); + return this; + } + + @JsonSetter(value = "after", nulls = Nulls.SKIP) + public Builder after(Optional after) { + this.after = after; + return this; + } + + public Builder after(OffsetDateTime after) { + this.after = Optional.of(after); + return this; + } + + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(String limit) { + this.limit = Optional.of(limit); + return this; + } + + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(String offset) { + this.offset = Optional.of(offset); + return this; + } + + public DatasetsListRequest build() { + return new DatasetsListRequest(datasetType, before, after, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponse.java b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponse.java new file mode 100644 index 0000000..72043dd --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponse.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.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 = DatasetsCreateResponse.Builder.class) +public final class DatasetsCreateResponse { + private final Optional id; + + private final Map additionalProperties; + + private DatasetsCreateResponse(Optional id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The dataset ID + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsCreateResponse && equalTo((DatasetsCreateResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsCreateResponse other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @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 id = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsCreateResponse other) { + id(other.getId()); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + public DatasetsCreateResponse build() { + return new DatasetsCreateResponse(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetResponse.java b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetResponse.java new file mode 100644 index 0000000..595d2f4 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetResponse.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.types; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.Dataset; +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 = DatasetsGetResponse.Builder.class) +public final class DatasetsGetResponse { + private final Dataset dataset; + + private final Map additionalProperties; + + private DatasetsGetResponse(Dataset dataset, Map additionalProperties) { + this.dataset = dataset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("dataset") + public Dataset getDataset() { + return dataset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsGetResponse && equalTo((DatasetsGetResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsGetResponse other) { + return dataset.equals(other.dataset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.dataset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DatasetStage builder() { + return new Builder(); + } + + public interface DatasetStage { + _FinalStage dataset(Dataset dataset); + + Builder from(DatasetsGetResponse other); + } + + public interface _FinalStage { + DatasetsGetResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DatasetStage, _FinalStage { + private Dataset dataset; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DatasetsGetResponse other) { + dataset(other.getDataset()); + return this; + } + + @java.lang.Override + @JsonSetter("dataset") + public _FinalStage dataset(Dataset dataset) { + this.dataset = dataset; + return this; + } + + @java.lang.Override + public DatasetsGetResponse build() { + return new DatasetsGetResponse(dataset, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetUsageResponse.java b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetUsageResponse.java new file mode 100644 index 0000000..d0dbd5c --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetUsageResponse.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.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 = DatasetsGetUsageResponse.Builder.class) +public final class DatasetsGetUsageResponse { + private final Optional organizationUsage; + + private final Map additionalProperties; + + private DatasetsGetUsageResponse(Optional organizationUsage, Map additionalProperties) { + this.organizationUsage = organizationUsage; + this.additionalProperties = additionalProperties; + } + + /** + * @return The total number of bytes used by the organization. + */ + @JsonProperty("organization_usage") + public Optional getOrganizationUsage() { + return organizationUsage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsGetUsageResponse && equalTo((DatasetsGetUsageResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsGetUsageResponse other) { + return organizationUsage.equals(other.organizationUsage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.organizationUsage); + } + + @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 organizationUsage = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsGetUsageResponse other) { + organizationUsage(other.getOrganizationUsage()); + return this; + } + + @JsonSetter(value = "organization_usage", nulls = Nulls.SKIP) + public Builder organizationUsage(Optional organizationUsage) { + this.organizationUsage = organizationUsage; + return this; + } + + public Builder organizationUsage(String organizationUsage) { + this.organizationUsage = Optional.of(organizationUsage); + return this; + } + + public DatasetsGetUsageResponse build() { + return new DatasetsGetUsageResponse(organizationUsage, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/types/DatasetsListResponse.java b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsListResponse.java new file mode 100644 index 0000000..4af6494 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsListResponse.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.types; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.Dataset; +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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = DatasetsListResponse.Builder.class) +public final class DatasetsListResponse { + private final Optional> datasets; + + private final Map additionalProperties; + + private DatasetsListResponse(Optional> datasets, Map additionalProperties) { + this.datasets = datasets; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("datasets") + public Optional> getDatasets() { + return datasets; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsListResponse && equalTo((DatasetsListResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsListResponse other) { + return datasets.equals(other.datasets); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.datasets); + } + + @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> datasets = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsListResponse other) { + datasets(other.getDatasets()); + return this; + } + + @JsonSetter(value = "datasets", nulls = Nulls.SKIP) + public Builder datasets(Optional> datasets) { + this.datasets = datasets; + return this; + } + + public Builder datasets(List datasets) { + this.datasets = Optional.of(datasets); + return this; + } + + public DatasetsListResponse build() { + return new DatasetsListResponse(datasets, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java b/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java new file mode 100644 index 0000000..1b5af68 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java @@ -0,0 +1,177 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.embedjobs; + +import com.cohere.api.core.ApiError; +import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.MediaTypes; +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.core.RequestOptions; +import com.cohere.api.resources.embedjobs.requests.CreateEmbedJobRequest; +import com.cohere.api.types.CreateEmbedJobResponse; +import com.cohere.api.types.EmbedJob; +import com.cohere.api.types.ListEmbedJobResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class EmbedJobsClient { + protected final ClientOptions clientOptions; + + public EmbedJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * The list embed job endpoint allows users to view all embed jobs history for that specific user. + */ + public ListEmbedJobResponse list() { + return list(null); + } + + /** + * The list embed job endpoint allows users to view all embed jobs history for that specific user. + */ + public ListEmbedJobResponse list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("embed-jobs") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + try { + Response response = + clientOptions.httpClient().newCall(okhttpRequest).execute(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), ListEmbedJobResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * This API launches an async Embed job for a Dataset of type embed-input. The result of a completed embed job is new Dataset of type embed-output, which contains the original text entries and the corresponding embeddings. + */ + public CreateEmbedJobResponse create(CreateEmbedJobRequest request) { + return create(request, null); + } + + /** + * This API launches an async Embed job for a Dataset of type embed-input. The result of a completed embed job is new Dataset of type embed-output, which contains the original text entries and the corresponding embeddings. + */ + public CreateEmbedJobResponse create(CreateEmbedJobRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("embed-jobs") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + try { + Response response = + clientOptions.httpClient().newCall(okhttpRequest).execute(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), CreateEmbedJobResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * This API retrieves the details about an embed job started by the same user. + */ + public EmbedJob get(String id) { + return get(id, null); + } + + /** + * This API retrieves the details about an embed job started by the same user. + */ + public EmbedJob get(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("embed-jobs") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + try { + Response response = + clientOptions.httpClient().newCall(okhttpRequest).execute(); + if (response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), EmbedJob.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * This API allows users to cancel an active embed job. Once invoked, the embedding process will be terminated, and users will be charged for the embeddings processed up to the cancellation point. It's important to note that partial results will not be available to users after cancellation. + */ + public void cancel(String id) { + cancel(id, null); + } + + /** + * This API allows users to cancel an active embed job. Once invoked, the embedding process will be terminated, and users will be charged for the embeddings processed up to the cancellation point. It's important to note that partial results will not be available to users after cancellation. + */ + public void cancel(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("embed-jobs") + .addPathSegment(id) + .addPathSegments("cancel") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + try { + Response response = + clientOptions.httpClient().newCall(okhttpRequest).execute(); + if (response.isSuccessful()) { + return; + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/embedjobs/requests/CreateEmbedJobRequest.java b/src/main/java/com/cohere/api/resources/embedjobs/requests/CreateEmbedJobRequest.java new file mode 100644 index 0000000..8ce1e26 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/embedjobs/requests/CreateEmbedJobRequest.java @@ -0,0 +1,259 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.embedjobs.requests; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.resources.embedjobs.types.CreateEmbedJobRequestTruncate; +import com.cohere.api.types.EmbedInputType; +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 = CreateEmbedJobRequest.Builder.class) +public final class CreateEmbedJobRequest { + private final String model; + + private final String datasetId; + + private final EmbedInputType inputType; + + private final Optional name; + + private final Optional truncate; + + private final Map additionalProperties; + + private CreateEmbedJobRequest( + String model, + String datasetId, + EmbedInputType inputType, + Optional name, + Optional truncate, + Map additionalProperties) { + this.model = model; + this.datasetId = datasetId; + this.inputType = inputType; + this.name = name; + this.truncate = truncate; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the embedding model. + *

Available models and corresponding embedding dimensions:

+ *
    + *
  • embed-english-v3.0 : 1024
  • + *
  • embed-multilingual-v3.0 : 1024
  • + *
  • embed-english-light-v3.0 : 384
  • + *
  • embed-multilingual-light-v3.0 : 384
  • + *
+ */ + @JsonProperty("model") + public String getModel() { + return model; + } + + /** + * @return ID of a Dataset. The Dataset must be of type embed-input and must have a validation status Validated + */ + @JsonProperty("dataset_id") + public String getDatasetId() { + return datasetId; + } + + @JsonProperty("input_type") + public EmbedInputType getInputType() { + return inputType; + } + + /** + * @return The name of the embed job. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return One of START|END to specify how the API will handle inputs longer than the maximum token length. + *

Passing START will discard the start of the input. END will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

+ */ + @JsonProperty("truncate") + public Optional getTruncate() { + return truncate; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateEmbedJobRequest && equalTo((CreateEmbedJobRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateEmbedJobRequest other) { + return model.equals(other.model) + && datasetId.equals(other.datasetId) + && inputType.equals(other.inputType) + && name.equals(other.name) + && truncate.equals(other.truncate); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.model, this.datasetId, this.inputType, this.name, this.truncate); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ModelStage builder() { + return new Builder(); + } + + public interface ModelStage { + DatasetIdStage model(String model); + + Builder from(CreateEmbedJobRequest other); + } + + public interface DatasetIdStage { + InputTypeStage datasetId(String datasetId); + } + + public interface InputTypeStage { + _FinalStage inputType(EmbedInputType inputType); + } + + public interface _FinalStage { + CreateEmbedJobRequest build(); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage truncate(Optional truncate); + + _FinalStage truncate(CreateEmbedJobRequestTruncate truncate); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ModelStage, DatasetIdStage, InputTypeStage, _FinalStage { + private String model; + + private String datasetId; + + private EmbedInputType inputType; + + private Optional truncate = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateEmbedJobRequest other) { + model(other.getModel()); + datasetId(other.getDatasetId()); + inputType(other.getInputType()); + name(other.getName()); + truncate(other.getTruncate()); + return this; + } + + /** + *

ID of the embedding model.

+ *

Available models and corresponding embedding dimensions:

+ *
    + *
  • embed-english-v3.0 : 1024
  • + *
  • embed-multilingual-v3.0 : 1024
  • + *
  • embed-english-light-v3.0 : 384
  • + *
  • embed-multilingual-light-v3.0 : 384
  • + *
+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("model") + public DatasetIdStage model(String model) { + this.model = model; + return this; + } + + /** + *

ID of a Dataset. The Dataset must be of type embed-input and must have a validation status Validated

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

One of START|END to specify how the API will handle inputs longer than the maximum token length.

+ *

Passing START will discard the start of the input. END will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

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

The name of the embed job.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.of(name); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public CreateEmbedJobRequest build() { + return new CreateEmbedJobRequest(model, datasetId, inputType, name, truncate, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/embedjobs/types/CreateEmbedJobRequestTruncate.java b/src/main/java/com/cohere/api/resources/embedjobs/types/CreateEmbedJobRequestTruncate.java new file mode 100644 index 0000000..1c63e90 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/embedjobs/types/CreateEmbedJobRequestTruncate.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.embedjobs.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CreateEmbedJobRequestTruncate { + START("START"), + + END("END"); + + private final String value; + + CreateEmbedJobRequestTruncate(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/ApiMeta.java b/src/main/java/com/cohere/api/types/ApiMeta.java index faaa8ba..fc1f496 100644 --- a/src/main/java/com/cohere/api/types/ApiMeta.java +++ b/src/main/java/com/cohere/api/types/ApiMeta.java @@ -23,15 +23,19 @@ public final class ApiMeta { private final Optional apiVersion; + private final Optional billedUnits; + private final Optional> warnings; private final Map additionalProperties; private ApiMeta( Optional apiVersion, + Optional billedUnits, Optional> warnings, Map additionalProperties) { this.apiVersion = apiVersion; + this.billedUnits = billedUnits; this.warnings = warnings; this.additionalProperties = additionalProperties; } @@ -41,12 +45,17 @@ public Optional getApiVersion() { return apiVersion; } + @JsonProperty("billed_units") + public Optional getBilledUnits() { + return billedUnits; + } + @JsonProperty("warnings") public Optional> getWarnings() { return warnings; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ApiMeta && equalTo((ApiMeta) other); @@ -58,15 +67,17 @@ public Map getAdditionalProperties() { } private boolean equalTo(ApiMeta other) { - return apiVersion.equals(other.apiVersion) && warnings.equals(other.warnings); + return apiVersion.equals(other.apiVersion) + && billedUnits.equals(other.billedUnits) + && warnings.equals(other.warnings); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.apiVersion, this.warnings); + return Objects.hash(this.apiVersion, this.billedUnits, this.warnings); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -79,6 +90,8 @@ public static Builder builder() { public static final class Builder { private Optional apiVersion = Optional.empty(); + private Optional billedUnits = Optional.empty(); + private Optional> warnings = Optional.empty(); @JsonAnySetter @@ -88,6 +101,7 @@ private Builder() {} public Builder from(ApiMeta other) { apiVersion(other.getApiVersion()); + billedUnits(other.getBilledUnits()); warnings(other.getWarnings()); return this; } @@ -103,6 +117,17 @@ public Builder apiVersion(ApiMetaApiVersion apiVersion) { return this; } + @JsonSetter(value = "billed_units", nulls = Nulls.SKIP) + public Builder billedUnits(Optional billedUnits) { + this.billedUnits = billedUnits; + return this; + } + + public Builder billedUnits(ApiMetaBilledUnits billedUnits) { + this.billedUnits = Optional.of(billedUnits); + return this; + } + @JsonSetter(value = "warnings", nulls = Nulls.SKIP) public Builder warnings(Optional> warnings) { this.warnings = warnings; @@ -115,7 +140,7 @@ public Builder warnings(List warnings) { } public ApiMeta build() { - return new ApiMeta(apiVersion, warnings, additionalProperties); + return new ApiMeta(apiVersion, billedUnits, warnings, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ApiMetaApiVersion.java b/src/main/java/com/cohere/api/types/ApiMetaApiVersion.java index eacb5c0..e3defb3 100644 --- a/src/main/java/com/cohere/api/types/ApiMetaApiVersion.java +++ b/src/main/java/com/cohere/api/types/ApiMetaApiVersion.java @@ -26,20 +26,16 @@ public final class ApiMetaApiVersion { private final Optional isExperimental; - private final Optional billedUnits; - private final Map additionalProperties; private ApiMetaApiVersion( String version, Optional isDeprecated, Optional isExperimental, - Optional billedUnits, Map additionalProperties) { this.version = version; this.isDeprecated = isDeprecated; this.isExperimental = isExperimental; - this.billedUnits = billedUnits; this.additionalProperties = additionalProperties; } @@ -58,12 +54,7 @@ public Optional getIsExperimental() { return isExperimental; } - @JsonProperty("billed_units") - public Optional getBilledUnits() { - return billedUnits; - } - - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ApiMetaApiVersion && equalTo((ApiMetaApiVersion) other); @@ -77,16 +68,15 @@ public Map getAdditionalProperties() { private boolean equalTo(ApiMetaApiVersion other) { return version.equals(other.version) && isDeprecated.equals(other.isDeprecated) - && isExperimental.equals(other.isExperimental) - && billedUnits.equals(other.billedUnits); + && isExperimental.equals(other.isExperimental); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.version, this.isDeprecated, this.isExperimental, this.billedUnits); + return Objects.hash(this.version, this.isDeprecated, this.isExperimental); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -111,18 +101,12 @@ public interface _FinalStage { _FinalStage isExperimental(Optional isExperimental); _FinalStage isExperimental(Boolean isExperimental); - - _FinalStage billedUnits(Optional billedUnits); - - _FinalStage billedUnits(ApiMetaApiVersionBilledUnits billedUnits); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements VersionStage, _FinalStage { private String version; - private Optional billedUnits = Optional.empty(); - private Optional isExperimental = Optional.empty(); private Optional isDeprecated = Optional.empty(); @@ -132,64 +116,50 @@ public static final class Builder implements VersionStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ApiMetaApiVersion other) { version(other.getVersion()); isDeprecated(other.getIsDeprecated()); isExperimental(other.getIsExperimental()); - billedUnits(other.getBilledUnits()); return this; } - @Override + @java.lang.Override @JsonSetter("version") public _FinalStage version(String version) { this.version = version; return this; } - @Override - public _FinalStage billedUnits(ApiMetaApiVersionBilledUnits billedUnits) { - this.billedUnits = Optional.of(billedUnits); - return this; - } - - @Override - @JsonSetter(value = "billed_units", nulls = Nulls.SKIP) - public _FinalStage billedUnits(Optional billedUnits) { - this.billedUnits = billedUnits; - return this; - } - - @Override + @java.lang.Override public _FinalStage isExperimental(Boolean isExperimental) { this.isExperimental = Optional.of(isExperimental); return this; } - @Override + @java.lang.Override @JsonSetter(value = "is_experimental", nulls = Nulls.SKIP) public _FinalStage isExperimental(Optional isExperimental) { this.isExperimental = isExperimental; return this; } - @Override + @java.lang.Override public _FinalStage isDeprecated(Boolean isDeprecated) { this.isDeprecated = Optional.of(isDeprecated); return this; } - @Override + @java.lang.Override @JsonSetter(value = "is_deprecated", nulls = Nulls.SKIP) public _FinalStage isDeprecated(Optional isDeprecated) { this.isDeprecated = isDeprecated; return this; } - @Override + @java.lang.Override public ApiMetaApiVersion build() { - return new ApiMetaApiVersion(version, isDeprecated, isExperimental, billedUnits, additionalProperties); + return new ApiMetaApiVersion(version, isDeprecated, isExperimental, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ApiMetaApiVersionBilledUnits.java b/src/main/java/com/cohere/api/types/ApiMetaBilledUnits.java similarity index 90% rename from src/main/java/com/cohere/api/types/ApiMetaApiVersionBilledUnits.java rename to src/main/java/com/cohere/api/types/ApiMetaBilledUnits.java index 77ec04f..3c40206 100644 --- a/src/main/java/com/cohere/api/types/ApiMetaApiVersionBilledUnits.java +++ b/src/main/java/com/cohere/api/types/ApiMetaBilledUnits.java @@ -18,8 +18,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ApiMetaApiVersionBilledUnits.Builder.class) -public final class ApiMetaApiVersionBilledUnits { +@JsonDeserialize(builder = ApiMetaBilledUnits.Builder.class) +public final class ApiMetaBilledUnits { private final Optional inputTokens; private final Optional outputTokens; @@ -30,7 +30,7 @@ public final class ApiMetaApiVersionBilledUnits { private final Map additionalProperties; - private ApiMetaApiVersionBilledUnits( + private ApiMetaBilledUnits( Optional inputTokens, Optional outputTokens, Optional searchUnits, @@ -75,10 +75,10 @@ public Optional getClassifications() { return classifications; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ApiMetaApiVersionBilledUnits && equalTo((ApiMetaApiVersionBilledUnits) other); + return other instanceof ApiMetaBilledUnits && equalTo((ApiMetaBilledUnits) other); } @JsonAnyGetter @@ -86,19 +86,19 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ApiMetaApiVersionBilledUnits other) { + private boolean equalTo(ApiMetaBilledUnits other) { return inputTokens.equals(other.inputTokens) && outputTokens.equals(other.outputTokens) && searchUnits.equals(other.searchUnits) && classifications.equals(other.classifications); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.inputTokens, this.outputTokens, this.searchUnits, this.classifications); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -122,7 +122,7 @@ public static final class Builder { private Builder() {} - public Builder from(ApiMetaApiVersionBilledUnits other) { + public Builder from(ApiMetaBilledUnits other) { inputTokens(other.getInputTokens()); outputTokens(other.getOutputTokens()); searchUnits(other.getSearchUnits()); @@ -174,8 +174,8 @@ public Builder classifications(Double classifications) { return this; } - public ApiMetaApiVersionBilledUnits build() { - return new ApiMetaApiVersionBilledUnits( + public ApiMetaBilledUnits build() { + return new ApiMetaBilledUnits( inputTokens, outputTokens, searchUnits, classifications, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/types/AuthTokenType.java b/src/main/java/com/cohere/api/types/AuthTokenType.java new file mode 100644 index 0000000..1b40260 --- /dev/null +++ b/src/main/java/com/cohere/api/types/AuthTokenType.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AuthTokenType { + BEARER("bearer"), + + BASIC("basic"), + + NOSCHEME("noscheme"); + + private final String value; + + AuthTokenType(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/ChatCitation.java b/src/main/java/com/cohere/api/types/ChatCitation.java index 9e83c67..af8c032 100644 --- a/src/main/java/com/cohere/api/types/ChatCitation.java +++ b/src/main/java/com/cohere/api/types/ChatCitation.java @@ -72,7 +72,7 @@ public List getDocumentIds() { return documentIds; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatCitation && equalTo((ChatCitation) other); @@ -90,12 +90,12 @@ private boolean equalTo(ChatCitation other) { && documentIds.equals(other.documentIds); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.start, this.end, this.text, this.documentIds); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -143,7 +143,7 @@ public static final class Builder implements StartStage, EndStage, TextStage, _F private Builder() {} - @Override + @java.lang.Override public Builder from(ChatCitation other) { start(other.getStart()); end(other.getEnd()); @@ -156,7 +156,7 @@ public Builder from(ChatCitation other) { *

The index of text that the citation starts at, counting from zero. For example, a generation of Hello, world! with a citation on world would have a start value of 7. This is because the citation starts at w, which is the seventh character.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("start") public EndStage start(int start) { this.start = start; @@ -167,7 +167,7 @@ public EndStage start(int start) { *

The index of text that the citation ends after, counting from zero. For example, a generation of Hello, world! with a citation on world would have an end value of 11. This is because the citation ends after d, which is the eleventh character.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("end") public TextStage end(int end) { this.end = end; @@ -178,7 +178,7 @@ public TextStage end(int end) { *

The text of the citation. For example, a generation of Hello, world! with a citation of world would have a text value of world.

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

Identifiers of documents cited by this section of the generated reply.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllDocumentIds(List documentIds) { this.documentIds.addAll(documentIds); return this; @@ -199,13 +199,13 @@ public _FinalStage addAllDocumentIds(List documentIds) { *

Identifiers of documents cited by this section of the generated reply.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addDocumentIds(String documentIds) { this.documentIds.add(documentIds); return this; } - @Override + @java.lang.Override @JsonSetter(value = "document_ids", nulls = Nulls.SKIP) public _FinalStage documentIds(List documentIds) { this.documentIds.clear(); @@ -213,7 +213,7 @@ public _FinalStage documentIds(List documentIds) { return this; } - @Override + @java.lang.Override public ChatCitation build() { return new ChatCitation(start, end, text, documentIds, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatCitationGenerationEvent.java b/src/main/java/com/cohere/api/types/ChatCitationGenerationEvent.java index b618b55..8125683 100644 --- a/src/main/java/com/cohere/api/types/ChatCitationGenerationEvent.java +++ b/src/main/java/com/cohere/api/types/ChatCitationGenerationEvent.java @@ -38,7 +38,7 @@ public List getCitations() { return citations; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatCitationGenerationEvent && equalTo((ChatCitationGenerationEvent) other); @@ -53,12 +53,12 @@ private boolean equalTo(ChatCitationGenerationEvent other) { return citations.equals(other.citations); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.citations); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/ChatConnector.java b/src/main/java/com/cohere/api/types/ChatConnector.java index 6e092aa..d861ced 100644 --- a/src/main/java/com/cohere/api/types/ChatConnector.java +++ b/src/main/java/com/cohere/api/types/ChatConnector.java @@ -44,7 +44,7 @@ private ChatConnector( } /** - * @return The identifier of the connector. Currently only 'web-search' is supported. + * @return The identifier of the connector. */ @JsonProperty("id") public String getId() { @@ -83,7 +83,7 @@ public Optional> getOptions() { return options; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatConnector && equalTo((ChatConnector) other); @@ -101,12 +101,12 @@ private boolean equalTo(ChatConnector other) { && options.equals(other.options); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.userAccessToken, this.continueOnFailure, this.options); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -152,7 +152,7 @@ public static final class Builder implements IdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ChatConnector other) { id(other.getId()); userAccessToken(other.getUserAccessToken()); @@ -162,10 +162,10 @@ public Builder from(ChatConnector other) { } /** - *

The identifier of the connector. Currently only 'web-search' is supported.

+ *

The identifier of the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("id") public _FinalStage id(String id) { this.id = id; @@ -184,13 +184,13 @@ public _FinalStage id(String id) { * * @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage options(Map options) { this.options = Optional.of(options); return this; } - @Override + @java.lang.Override @JsonSetter(value = "options", nulls = Nulls.SKIP) public _FinalStage options(Optional> options) { this.options = options; @@ -201,13 +201,13 @@ public _FinalStage options(Optional> options) { *

An optional override to set whether or not the request continues if this connector fails.

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

An optional override to set the token that Cohere passes to the connector in the Authorization header.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage userAccessToken(String userAccessToken) { this.userAccessToken = Optional.of(userAccessToken); return this; } - @Override + @java.lang.Override @JsonSetter(value = "user_access_token", nulls = Nulls.SKIP) public _FinalStage userAccessToken(Optional userAccessToken) { this.userAccessToken = userAccessToken; return this; } - @Override + @java.lang.Override public ChatConnector build() { return new ChatConnector(id, userAccessToken, continueOnFailure, options, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatMessage.java b/src/main/java/com/cohere/api/types/ChatMessage.java index ddd838b..e0d6046 100644 --- a/src/main/java/com/cohere/api/types/ChatMessage.java +++ b/src/main/java/com/cohere/api/types/ChatMessage.java @@ -51,7 +51,7 @@ public Optional getUserName() { return userName; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatMessage && equalTo((ChatMessage) other); @@ -66,12 +66,12 @@ private boolean equalTo(ChatMessage other) { return role.equals(other.role) && message.equals(other.message) && userName.equals(other.userName); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.role, this.message, this.userName); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -111,7 +111,7 @@ public static final class Builder implements RoleStage, MessageStage, _FinalStag private Builder() {} - @Override + @java.lang.Override public Builder from(ChatMessage other) { role(other.getRole()); message(other.getMessage()); @@ -119,34 +119,34 @@ public Builder from(ChatMessage other) { return this; } - @Override + @java.lang.Override @JsonSetter("role") public MessageStage role(ChatMessageRole role) { this.role = role; return this; } - @Override + @java.lang.Override @JsonSetter("message") public _FinalStage message(String message) { this.message = message; return this; } - @Override + @java.lang.Override public _FinalStage userName(String userName) { this.userName = Optional.of(userName); return this; } - @Override + @java.lang.Override @JsonSetter(value = "user_name", nulls = Nulls.SKIP) public _FinalStage userName(Optional userName) { this.userName = userName; return this; } - @Override + @java.lang.Override public ChatMessage build() { return new ChatMessage(role, message, userName, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatMessageRole.java b/src/main/java/com/cohere/api/types/ChatMessageRole.java index 1bbd846..27612cc 100644 --- a/src/main/java/com/cohere/api/types/ChatMessageRole.java +++ b/src/main/java/com/cohere/api/types/ChatMessageRole.java @@ -17,7 +17,7 @@ public enum ChatMessageRole { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatRequestCitationQuality.java b/src/main/java/com/cohere/api/types/ChatRequestCitationQuality.java index 7917903..d2b6a1c 100644 --- a/src/main/java/com/cohere/api/types/ChatRequestCitationQuality.java +++ b/src/main/java/com/cohere/api/types/ChatRequestCitationQuality.java @@ -17,7 +17,7 @@ public enum ChatRequestCitationQuality { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatRequestPromptOverride.java b/src/main/java/com/cohere/api/types/ChatRequestPromptOverride.java new file mode 100644 index 0000000..061aa68 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatRequestPromptOverride.java @@ -0,0 +1,145 @@ +/** + * 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 = ChatRequestPromptOverride.Builder.class) +public final class ChatRequestPromptOverride { + private final Optional preamble; + + private final Optional taskDescription; + + private final Optional styleGuide; + + private final Map additionalProperties; + + private ChatRequestPromptOverride( + Optional preamble, + Optional taskDescription, + Optional styleGuide, + Map additionalProperties) { + this.preamble = preamble; + this.taskDescription = taskDescription; + this.styleGuide = styleGuide; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("preamble") + public Optional getPreamble() { + return preamble; + } + + @JsonProperty("task_description") + public Optional getTaskDescription() { + return taskDescription; + } + + @JsonProperty("style_guide") + public Optional getStyleGuide() { + return styleGuide; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatRequestPromptOverride && equalTo((ChatRequestPromptOverride) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatRequestPromptOverride other) { + return preamble.equals(other.preamble) + && taskDescription.equals(other.taskDescription) + && styleGuide.equals(other.styleGuide); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.preamble, this.taskDescription, this.styleGuide); + } + + @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 preamble = Optional.empty(); + + private Optional taskDescription = Optional.empty(); + + private Optional styleGuide = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ChatRequestPromptOverride other) { + preamble(other.getPreamble()); + taskDescription(other.getTaskDescription()); + styleGuide(other.getStyleGuide()); + 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 = "task_description", nulls = Nulls.SKIP) + public Builder taskDescription(Optional taskDescription) { + this.taskDescription = taskDescription; + return this; + } + + public Builder taskDescription(Object taskDescription) { + this.taskDescription = Optional.of(taskDescription); + return this; + } + + @JsonSetter(value = "style_guide", nulls = Nulls.SKIP) + public Builder styleGuide(Optional styleGuide) { + this.styleGuide = styleGuide; + return this; + } + + public Builder styleGuide(Object styleGuide) { + this.styleGuide = Optional.of(styleGuide); + return this; + } + + public ChatRequestPromptOverride build() { + return new ChatRequestPromptOverride(preamble, taskDescription, styleGuide, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatRequestPromptTruncation.java b/src/main/java/com/cohere/api/types/ChatRequestPromptTruncation.java index 4d9065b..35c0ae2 100644 --- a/src/main/java/com/cohere/api/types/ChatRequestPromptTruncation.java +++ b/src/main/java/com/cohere/api/types/ChatRequestPromptTruncation.java @@ -17,7 +17,7 @@ public enum ChatRequestPromptTruncation { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatRequestSearchOptions.java b/src/main/java/com/cohere/api/types/ChatRequestSearchOptions.java new file mode 100644 index 0000000..93453fe --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatRequestSearchOptions.java @@ -0,0 +1,196 @@ +/** + * 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 = ChatRequestSearchOptions.Builder.class) +public final class ChatRequestSearchOptions { + private final Optional model; + + private final Optional temperature; + + private final Optional maxTokens; + + private final Optional preamble; + + private final Optional seed; + + private final Map additionalProperties; + + private ChatRequestSearchOptions( + Optional model, + Optional temperature, + Optional maxTokens, + Optional preamble, + Optional seed, + Map additionalProperties) { + this.model = model; + this.temperature = temperature; + this.maxTokens = maxTokens; + this.preamble = preamble; + 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. + */ + @JsonProperty("seed") + public Optional getSeed() { + return seed; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatRequestSearchOptions && equalTo((ChatRequestSearchOptions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatRequestSearchOptions other) { + return model.equals(other.model) + && temperature.equals(other.temperature) + && maxTokens.equals(other.maxTokens) + && preamble.equals(other.preamble) + && seed.equals(other.seed); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.model, this.temperature, this.maxTokens, this.preamble, this.seed); + } + + @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 model = Optional.empty(); + + private Optional temperature = Optional.empty(); + + private Optional maxTokens = Optional.empty(); + + private Optional preamble = Optional.empty(); + + private Optional seed = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ChatRequestSearchOptions 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) { + this.seed = seed; + return this; + } + + public Builder seed(Double seed) { + this.seed = Optional.of(seed); + return this; + } + + public ChatRequestSearchOptions build() { + return new ChatRequestSearchOptions(model, temperature, maxTokens, preamble, seed, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatSearchQueriesGenerationEvent.java b/src/main/java/com/cohere/api/types/ChatSearchQueriesGenerationEvent.java index 61f837d..12d193a 100644 --- a/src/main/java/com/cohere/api/types/ChatSearchQueriesGenerationEvent.java +++ b/src/main/java/com/cohere/api/types/ChatSearchQueriesGenerationEvent.java @@ -39,7 +39,7 @@ public List getSearchQueries() { return searchQueries; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatSearchQueriesGenerationEvent && equalTo((ChatSearchQueriesGenerationEvent) other); @@ -54,12 +54,12 @@ private boolean equalTo(ChatSearchQueriesGenerationEvent other) { return searchQueries.equals(other.searchQueries); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.searchQueries); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/ChatSearchQuery.java b/src/main/java/com/cohere/api/types/ChatSearchQuery.java index a9f5711..eb89352 100644 --- a/src/main/java/com/cohere/api/types/ChatSearchQuery.java +++ b/src/main/java/com/cohere/api/types/ChatSearchQuery.java @@ -46,7 +46,7 @@ public String getGenerationId() { return generationId; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatSearchQuery && equalTo((ChatSearchQuery) other); @@ -61,12 +61,12 @@ private boolean equalTo(ChatSearchQuery other) { return text.equals(other.text) && generationId.equals(other.generationId); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text, this.generationId); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -100,7 +100,7 @@ public static final class Builder implements TextStage, GenerationIdStage, _Fina private Builder() {} - @Override + @java.lang.Override public Builder from(ChatSearchQuery other) { text(other.getText()); generationId(other.getGenerationId()); @@ -111,7 +111,7 @@ public Builder from(ChatSearchQuery other) { *

The text of the search query.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public GenerationIdStage text(String text) { this.text = text; @@ -122,14 +122,14 @@ public GenerationIdStage text(String text) { *

Unique identifier for the generated search query. Useful for submitting feedback.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("generation_id") public _FinalStage generationId(String generationId) { this.generationId = generationId; return this; } - @Override + @java.lang.Override public ChatSearchQuery build() { return new ChatSearchQuery(text, generationId, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatSearchResult.java b/src/main/java/com/cohere/api/types/ChatSearchResult.java index ad8d8a9..6828c2b 100644 --- a/src/main/java/com/cohere/api/types/ChatSearchResult.java +++ b/src/main/java/com/cohere/api/types/ChatSearchResult.java @@ -23,7 +23,7 @@ public final class ChatSearchResult { private final ChatSearchQuery searchQuery; - private final ChatConnector connector; + private final ChatSearchResultConnector connector; private final List documentIds; @@ -31,7 +31,7 @@ public final class ChatSearchResult { private ChatSearchResult( ChatSearchQuery searchQuery, - ChatConnector connector, + ChatSearchResultConnector connector, List documentIds, Map additionalProperties) { this.searchQuery = searchQuery; @@ -49,7 +49,7 @@ public ChatSearchQuery getSearchQuery() { * @return The connector from which this result comes from. */ @JsonProperty("connector") - public ChatConnector getConnector() { + public ChatSearchResultConnector getConnector() { return connector; } @@ -61,7 +61,7 @@ public List getDocumentIds() { return documentIds; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatSearchResult && equalTo((ChatSearchResult) other); @@ -78,12 +78,12 @@ private boolean equalTo(ChatSearchResult other) { && documentIds.equals(other.documentIds); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.searchQuery, this.connector, this.documentIds); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -99,7 +99,7 @@ public interface SearchQueryStage { } public interface ConnectorStage { - _FinalStage connector(ChatConnector connector); + _FinalStage connector(ChatSearchResultConnector connector); } public interface _FinalStage { @@ -116,7 +116,7 @@ public interface _FinalStage { public static final class Builder implements SearchQueryStage, ConnectorStage, _FinalStage { private ChatSearchQuery searchQuery; - private ChatConnector connector; + private ChatSearchResultConnector connector; private List documentIds = new ArrayList<>(); @@ -125,7 +125,7 @@ public static final class Builder implements SearchQueryStage, ConnectorStage, _ private Builder() {} - @Override + @java.lang.Override public Builder from(ChatSearchResult other) { searchQuery(other.getSearchQuery()); connector(other.getConnector()); @@ -133,7 +133,7 @@ public Builder from(ChatSearchResult other) { return this; } - @Override + @java.lang.Override @JsonSetter("search_query") public ConnectorStage searchQuery(ChatSearchQuery searchQuery) { this.searchQuery = searchQuery; @@ -144,9 +144,9 @@ public ConnectorStage searchQuery(ChatSearchQuery searchQuery) { *

The connector from which this result comes from.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("connector") - public _FinalStage connector(ChatConnector connector) { + public _FinalStage connector(ChatSearchResultConnector connector) { this.connector = connector; return this; } @@ -155,7 +155,7 @@ public _FinalStage connector(ChatConnector connector) { *

Identifiers of documents found by this search query.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllDocumentIds(List documentIds) { this.documentIds.addAll(documentIds); return this; @@ -165,13 +165,13 @@ public _FinalStage addAllDocumentIds(List documentIds) { *

Identifiers of documents found by this search query.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addDocumentIds(String documentIds) { this.documentIds.add(documentIds); return this; } - @Override + @java.lang.Override @JsonSetter(value = "document_ids", nulls = Nulls.SKIP) public _FinalStage documentIds(List documentIds) { this.documentIds.clear(); @@ -179,7 +179,7 @@ public _FinalStage documentIds(List documentIds) { return this; } - @Override + @java.lang.Override public ChatSearchResult build() { return new ChatSearchResult(searchQuery, connector, documentIds, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatSearchResultConnector.java b/src/main/java/com/cohere/api/types/ChatSearchResultConnector.java new file mode 100644 index 0000000..cc969cb --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatSearchResultConnector.java @@ -0,0 +1,108 @@ +/** + * 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 = ChatSearchResultConnector.Builder.class) +public final class ChatSearchResultConnector { + private final String id; + + private final Map additionalProperties; + + private ChatSearchResultConnector(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier of the connector. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatSearchResultConnector && equalTo((ChatSearchResultConnector) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatSearchResultConnector other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + _FinalStage id(String id); + + Builder from(ChatSearchResultConnector other); + } + + public interface _FinalStage { + ChatSearchResultConnector build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ChatSearchResultConnector other) { + id(other.getId()); + return this; + } + + /** + *

The identifier of the connector.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(String id) { + this.id = id; + return this; + } + + @java.lang.Override + public ChatSearchResultConnector build() { + return new ChatSearchResultConnector(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatSearchResultsEvent.java b/src/main/java/com/cohere/api/types/ChatSearchResultsEvent.java index e3a1524..22ff4dc 100644 --- a/src/main/java/com/cohere/api/types/ChatSearchResultsEvent.java +++ b/src/main/java/com/cohere/api/types/ChatSearchResultsEvent.java @@ -52,7 +52,7 @@ public List> getDocuments() { return documents; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatSearchResultsEvent && equalTo((ChatSearchResultsEvent) other); @@ -67,12 +67,12 @@ private boolean equalTo(ChatSearchResultsEvent other) { return searchResults.equals(other.searchResults) && documents.equals(other.documents); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.searchResults, this.documents); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/ChatStreamEndEvent.java b/src/main/java/com/cohere/api/types/ChatStreamEndEvent.java index eeb547d..6f34855 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamEndEvent.java +++ b/src/main/java/com/cohere/api/types/ChatStreamEndEvent.java @@ -20,13 +20,13 @@ public final class ChatStreamEndEvent implements IChatStreamEvent { private final ChatStreamEndEventFinishReason finishReason; - private final ChatStreamEndEventResponse response; + private final NonStreamedChatResponse response; private final Map additionalProperties; private ChatStreamEndEvent( ChatStreamEndEventFinishReason finishReason, - ChatStreamEndEventResponse response, + NonStreamedChatResponse response, Map additionalProperties) { this.finishReason = finishReason; this.response = response; @@ -51,11 +51,11 @@ public ChatStreamEndEventFinishReason getFinishReason() { * @return The consolidated response from the model. Contains the generated reply and all the other information streamed back in the previous events. */ @JsonProperty("response") - public ChatStreamEndEventResponse getResponse() { + public NonStreamedChatResponse getResponse() { return response; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatStreamEndEvent && equalTo((ChatStreamEndEvent) other); @@ -70,12 +70,12 @@ private boolean equalTo(ChatStreamEndEvent other) { return finishReason.equals(other.finishReason) && response.equals(other.response); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.finishReason, this.response); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -91,7 +91,7 @@ public interface FinishReasonStage { } public interface ResponseStage { - _FinalStage response(ChatStreamEndEventResponse response); + _FinalStage response(NonStreamedChatResponse response); } public interface _FinalStage { @@ -102,14 +102,14 @@ public interface _FinalStage { public static final class Builder implements FinishReasonStage, ResponseStage, _FinalStage { private ChatStreamEndEventFinishReason finishReason; - private ChatStreamEndEventResponse response; + private NonStreamedChatResponse response; @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @Override + @java.lang.Override public Builder from(ChatStreamEndEvent other) { finishReason(other.getFinishReason()); response(other.getResponse()); @@ -126,7 +126,7 @@ public Builder from(ChatStreamEndEvent other) { * * @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("finish_reason") public ResponseStage finishReason(ChatStreamEndEventFinishReason finishReason) { this.finishReason = finishReason; @@ -137,14 +137,14 @@ public ResponseStage finishReason(ChatStreamEndEventFinishReason finishReason) { *

The consolidated response from the model. Contains the generated reply and all the other information streamed back in the previous events.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("response") - public _FinalStage response(ChatStreamEndEventResponse response) { + public _FinalStage response(NonStreamedChatResponse response) { this.response = response; return this; } - @Override + @java.lang.Override public ChatStreamEndEvent build() { return new ChatStreamEndEvent(finishReason, response, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatStreamEndEventFinishReason.java b/src/main/java/com/cohere/api/types/ChatStreamEndEventFinishReason.java index 861df09..1dd7b70 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamEndEventFinishReason.java +++ b/src/main/java/com/cohere/api/types/ChatStreamEndEventFinishReason.java @@ -23,7 +23,7 @@ public enum ChatStreamEndEventFinishReason { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatStreamEndEventResponse.java b/src/main/java/com/cohere/api/types/ChatStreamEndEventResponse.java deleted file mode 100644 index 8ec8a26..0000000 --- a/src/main/java/com/cohere/api/types/ChatStreamEndEventResponse.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.cohere.api.types; - -import com.cohere.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ChatStreamEndEventResponse.Deserializer.class) -public final class ChatStreamEndEventResponse { - private final Object value; - - private final int type; - - private ChatStreamEndEventResponse(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((NonStreamedChatResponse) this.value); - } else if (this.type == 1) { - return visitor.visit((SearchQueriesOnlyResponse) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ChatStreamEndEventResponse && equalTo((ChatStreamEndEventResponse) other); - } - - private boolean equalTo(ChatStreamEndEventResponse other) { - return value.equals(other.value); - } - - @Override - public int hashCode() { - return Objects.hash(this.value); - } - - @Override - public String toString() { - return this.value.toString(); - } - - public static ChatStreamEndEventResponse of(NonStreamedChatResponse value) { - return new ChatStreamEndEventResponse(value, 0); - } - - public static ChatStreamEndEventResponse of(SearchQueriesOnlyResponse value) { - return new ChatStreamEndEventResponse(value, 1); - } - - public interface Visitor { - T visit(NonStreamedChatResponse value); - - T visit(SearchQueriesOnlyResponse value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ChatStreamEndEventResponse.class); - } - - @Override - public ChatStreamEndEventResponse deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, NonStreamedChatResponse.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SearchQueriesOnlyResponse.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/cohere/api/types/ChatStreamEvent.java b/src/main/java/com/cohere/api/types/ChatStreamEvent.java index 3671afb..b9d7f22 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamEvent.java +++ b/src/main/java/com/cohere/api/types/ChatStreamEvent.java @@ -14,7 +14,7 @@ private ChatStreamEvent(Map additionalProperties) { this.additionalProperties = additionalProperties; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatStreamEvent; @@ -25,7 +25,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestCitationQuality.java b/src/main/java/com/cohere/api/types/ChatStreamRequestCitationQuality.java index 356f24d..ff2d4ba 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamRequestCitationQuality.java +++ b/src/main/java/com/cohere/api/types/ChatStreamRequestCitationQuality.java @@ -17,7 +17,7 @@ public enum ChatStreamRequestCitationQuality { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestPromptOverride.java b/src/main/java/com/cohere/api/types/ChatStreamRequestPromptOverride.java new file mode 100644 index 0000000..40acfe8 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatStreamRequestPromptOverride.java @@ -0,0 +1,145 @@ +/** + * 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 = ChatStreamRequestPromptOverride.Builder.class) +public final class ChatStreamRequestPromptOverride { + private final Optional preamble; + + private final Optional taskDescription; + + private final Optional styleGuide; + + private final Map additionalProperties; + + private ChatStreamRequestPromptOverride( + Optional preamble, + Optional taskDescription, + Optional styleGuide, + Map additionalProperties) { + this.preamble = preamble; + this.taskDescription = taskDescription; + this.styleGuide = styleGuide; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("preamble") + public Optional getPreamble() { + return preamble; + } + + @JsonProperty("task_description") + public Optional getTaskDescription() { + return taskDescription; + } + + @JsonProperty("style_guide") + public Optional getStyleGuide() { + return styleGuide; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatStreamRequestPromptOverride && equalTo((ChatStreamRequestPromptOverride) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatStreamRequestPromptOverride other) { + return preamble.equals(other.preamble) + && taskDescription.equals(other.taskDescription) + && styleGuide.equals(other.styleGuide); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.preamble, this.taskDescription, this.styleGuide); + } + + @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 preamble = Optional.empty(); + + private Optional taskDescription = Optional.empty(); + + private Optional styleGuide = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ChatStreamRequestPromptOverride other) { + preamble(other.getPreamble()); + taskDescription(other.getTaskDescription()); + styleGuide(other.getStyleGuide()); + 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 = "task_description", nulls = Nulls.SKIP) + public Builder taskDescription(Optional taskDescription) { + this.taskDescription = taskDescription; + return this; + } + + public Builder taskDescription(Object taskDescription) { + this.taskDescription = Optional.of(taskDescription); + return this; + } + + @JsonSetter(value = "style_guide", nulls = Nulls.SKIP) + public Builder styleGuide(Optional styleGuide) { + this.styleGuide = styleGuide; + return this; + } + + public Builder styleGuide(Object styleGuide) { + this.styleGuide = Optional.of(styleGuide); + return this; + } + + public ChatStreamRequestPromptOverride build() { + return new ChatStreamRequestPromptOverride(preamble, taskDescription, styleGuide, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestPromptTruncation.java b/src/main/java/com/cohere/api/types/ChatStreamRequestPromptTruncation.java index 4874d27..80f18c8 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamRequestPromptTruncation.java +++ b/src/main/java/com/cohere/api/types/ChatStreamRequestPromptTruncation.java @@ -17,7 +17,7 @@ public enum ChatStreamRequestPromptTruncation { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestSearchOptions.java b/src/main/java/com/cohere/api/types/ChatStreamRequestSearchOptions.java new file mode 100644 index 0000000..6205fac --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatStreamRequestSearchOptions.java @@ -0,0 +1,197 @@ +/** + * 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 = ChatStreamRequestSearchOptions.Builder.class) +public final class ChatStreamRequestSearchOptions { + private final Optional model; + + private final Optional temperature; + + private final Optional maxTokens; + + private final Optional preamble; + + private final Optional seed; + + private final Map additionalProperties; + + private ChatStreamRequestSearchOptions( + Optional model, + Optional temperature, + Optional maxTokens, + Optional preamble, + Optional seed, + Map additionalProperties) { + this.model = model; + this.temperature = temperature; + this.maxTokens = maxTokens; + this.preamble = preamble; + 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. + */ + @JsonProperty("seed") + public Optional getSeed() { + return seed; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatStreamRequestSearchOptions && equalTo((ChatStreamRequestSearchOptions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatStreamRequestSearchOptions other) { + return model.equals(other.model) + && temperature.equals(other.temperature) + && maxTokens.equals(other.maxTokens) + && preamble.equals(other.preamble) + && seed.equals(other.seed); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.model, this.temperature, this.maxTokens, this.preamble, this.seed); + } + + @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 model = Optional.empty(); + + private Optional temperature = Optional.empty(); + + private Optional maxTokens = Optional.empty(); + + private Optional preamble = Optional.empty(); + + private Optional seed = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ChatStreamRequestSearchOptions 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) { + this.seed = seed; + return this; + } + + public Builder seed(Double seed) { + this.seed = Optional.of(seed); + return this; + } + + public ChatStreamRequestSearchOptions build() { + return new ChatStreamRequestSearchOptions( + model, temperature, maxTokens, preamble, seed, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatStreamStartEvent.java b/src/main/java/com/cohere/api/types/ChatStreamStartEvent.java index c0afa5c..0e69d98 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamStartEvent.java +++ b/src/main/java/com/cohere/api/types/ChatStreamStartEvent.java @@ -35,7 +35,7 @@ public String getGenerationId() { return generationId; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatStreamStartEvent && equalTo((ChatStreamStartEvent) other); @@ -50,12 +50,12 @@ private boolean equalTo(ChatStreamStartEvent other) { return generationId.equals(other.generationId); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.generationId); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -83,7 +83,7 @@ public static final class Builder implements GenerationIdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ChatStreamStartEvent other) { generationId(other.getGenerationId()); return this; @@ -93,14 +93,14 @@ public Builder from(ChatStreamStartEvent other) { *

Unique identifier for the generated reply. Useful for submitting feedback.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("generation_id") public _FinalStage generationId(String generationId) { this.generationId = generationId; return this; } - @Override + @java.lang.Override public ChatStreamStartEvent build() { return new ChatStreamStartEvent(generationId, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatTextGenerationEvent.java b/src/main/java/com/cohere/api/types/ChatTextGenerationEvent.java index 55e8acd..39f953e 100644 --- a/src/main/java/com/cohere/api/types/ChatTextGenerationEvent.java +++ b/src/main/java/com/cohere/api/types/ChatTextGenerationEvent.java @@ -35,7 +35,7 @@ public String getText() { return text; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatTextGenerationEvent && equalTo((ChatTextGenerationEvent) other); @@ -50,12 +50,12 @@ private boolean equalTo(ChatTextGenerationEvent other) { return text.equals(other.text); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -83,7 +83,7 @@ public static final class Builder implements TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ChatTextGenerationEvent other) { text(other.getText()); return this; @@ -93,14 +93,14 @@ public Builder from(ChatTextGenerationEvent other) { *

The next batch of text generated by the model.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; return this; } - @Override + @java.lang.Override public ChatTextGenerationEvent build() { return new ChatTextGenerationEvent(text, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ClassifyRequestExamplesItem.java b/src/main/java/com/cohere/api/types/ClassifyExample.java similarity index 80% rename from src/main/java/com/cohere/api/types/ClassifyRequestExamplesItem.java rename to src/main/java/com/cohere/api/types/ClassifyExample.java index 708454c..ddff171 100644 --- a/src/main/java/com/cohere/api/types/ClassifyRequestExamplesItem.java +++ b/src/main/java/com/cohere/api/types/ClassifyExample.java @@ -18,16 +18,15 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ClassifyRequestExamplesItem.Builder.class) -public final class ClassifyRequestExamplesItem { +@JsonDeserialize(builder = ClassifyExample.Builder.class) +public final class ClassifyExample { private final Optional text; private final Optional label; private final Map additionalProperties; - private ClassifyRequestExamplesItem( - Optional text, Optional label, Map additionalProperties) { + private ClassifyExample(Optional text, Optional label, Map additionalProperties) { this.text = text; this.label = label; this.additionalProperties = additionalProperties; @@ -43,10 +42,10 @@ public Optional getLabel() { return label; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ClassifyRequestExamplesItem && equalTo((ClassifyRequestExamplesItem) other); + return other instanceof ClassifyExample && equalTo((ClassifyExample) other); } @JsonAnyGetter @@ -54,16 +53,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ClassifyRequestExamplesItem other) { + private boolean equalTo(ClassifyExample other) { return text.equals(other.text) && label.equals(other.label); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text, this.label); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -83,7 +82,7 @@ public static final class Builder { private Builder() {} - public Builder from(ClassifyRequestExamplesItem other) { + public Builder from(ClassifyExample other) { text(other.getText()); label(other.getLabel()); return this; @@ -111,8 +110,8 @@ public Builder label(String label) { return this; } - public ClassifyRequestExamplesItem build() { - return new ClassifyRequestExamplesItem(text, label, additionalProperties); + public ClassifyExample build() { + return new ClassifyExample(text, label, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ClassifyRequestTruncate.java b/src/main/java/com/cohere/api/types/ClassifyRequestTruncate.java index f83d07f..0065233 100644 --- a/src/main/java/com/cohere/api/types/ClassifyRequestTruncate.java +++ b/src/main/java/com/cohere/api/types/ClassifyRequestTruncate.java @@ -19,7 +19,7 @@ public enum ClassifyRequestTruncate { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ClassifyResponse.java b/src/main/java/com/cohere/api/types/ClassifyResponse.java index 6281fe5..76fb1fa 100644 --- a/src/main/java/com/cohere/api/types/ClassifyResponse.java +++ b/src/main/java/com/cohere/api/types/ClassifyResponse.java @@ -56,7 +56,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ClassifyResponse && equalTo((ClassifyResponse) other); @@ -71,12 +71,12 @@ private boolean equalTo(ClassifyResponse other) { return id.equals(other.id) && classifications.equals(other.classifications) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.classifications, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -118,7 +118,7 @@ public static final class Builder implements IdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ClassifyResponse other) { id(other.getId()); classifications(other.getClassifications()); @@ -126,39 +126,39 @@ public Builder from(ClassifyResponse other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public _FinalStage id(String id) { this.id = id; return this; } - @Override + @java.lang.Override public _FinalStage meta(ApiMeta meta) { this.meta = Optional.of(meta); return this; } - @Override + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Optional meta) { this.meta = meta; return this; } - @Override + @java.lang.Override public _FinalStage addAllClassifications(List classifications) { this.classifications.addAll(classifications); return this; } - @Override + @java.lang.Override public _FinalStage addClassifications(ClassifyResponseClassificationsItem classifications) { this.classifications.add(classifications); return this; } - @Override + @java.lang.Override @JsonSetter(value = "classifications", nulls = Nulls.SKIP) public _FinalStage classifications(List classifications) { this.classifications.clear(); @@ -166,7 +166,7 @@ public _FinalStage classifications(List cla return this; } - @Override + @java.lang.Override public ClassifyResponse build() { return new ClassifyResponse(id, classifications, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItem.java b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItem.java index 206d667..9ca9573 100644 --- a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItem.java +++ b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItem.java @@ -123,7 +123,7 @@ public ClassifyResponseClassificationsItemClassificationType getClassificationTy return classificationType; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ClassifyResponseClassificationsItem @@ -146,7 +146,7 @@ private boolean equalTo(ClassifyResponseClassificationsItem other) { && classificationType.equals(other.classificationType); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.id, @@ -159,7 +159,7 @@ public int hashCode() { this.classificationType); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -235,7 +235,7 @@ public static final class Builder implements IdStage, ClassificationTypeStage, _ private Builder() {} - @Override + @java.lang.Override public Builder from(ClassifyResponseClassificationsItem other) { id(other.getId()); input(other.getInput()); @@ -248,7 +248,7 @@ public Builder from(ClassifyResponseClassificationsItem other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public ClassificationTypeStage id(String id) { this.id = id; @@ -259,7 +259,7 @@ public ClassificationTypeStage id(String id) { *

The type of classification performed

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("classification_type") public _FinalStage classificationType( ClassifyResponseClassificationsItemClassificationType classificationType) { @@ -271,7 +271,7 @@ public _FinalStage classificationType( *

A map containing each label and its confidence score according to the classifier. All the confidence scores add up to 1 for single-label classification. For multi-label classification the label confidences are independent of each other, so they don't have to sum up to 1.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage labels(String key, ClassifyResponseClassificationsItemLabelsValue value) { this.labels.put(key, value); return this; @@ -281,13 +281,13 @@ public _FinalStage labels(String key, ClassifyResponseClassificationsItemLabelsV *

A map containing each label and its confidence score according to the classifier. All the confidence scores add up to 1 for single-label classification. For multi-label classification the label confidences are independent of each other, so they don't have to sum up to 1.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage putAllLabels(Map labels) { this.labels.putAll(labels); return this; } - @Override + @java.lang.Override @JsonSetter(value = "labels", nulls = Nulls.SKIP) public _FinalStage labels(Map labels) { this.labels.clear(); @@ -299,7 +299,7 @@ public _FinalStage labels(MapAn array containing the confidence scores of all the predictions in the same order

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllConfidences(List confidences) { this.confidences.addAll(confidences); return this; @@ -309,13 +309,13 @@ public _FinalStage addAllConfidences(List confidences) { *

An array containing the confidence scores of all the predictions in the same order

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addConfidences(Double confidences) { this.confidences.add(confidences); return this; } - @Override + @java.lang.Override @JsonSetter(value = "confidences", nulls = Nulls.SKIP) public _FinalStage confidences(List confidences) { this.confidences.clear(); @@ -327,13 +327,13 @@ public _FinalStage confidences(List confidences) { *

The confidence score for the top predicted class (only filled for single-label classification)

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

An array containing the predicted labels for the associated query (only filled for single-label classification)

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllPredictions(List predictions) { this.predictions.addAll(predictions); return this; @@ -354,13 +354,13 @@ public _FinalStage addAllPredictions(List predictions) { *

An array containing the predicted labels for the associated query (only filled for single-label classification)

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addPredictions(String predictions) { this.predictions.add(predictions); return this; } - @Override + @java.lang.Override @JsonSetter(value = "predictions", nulls = Nulls.SKIP) public _FinalStage predictions(List predictions) { this.predictions.clear(); @@ -372,13 +372,13 @@ public _FinalStage predictions(List predictions) { *

The predicted label for the associated query (only filled for single-label models)

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

The input text that was classified

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage input(String input) { this.input = Optional.of(input); return this; } - @Override + @java.lang.Override @JsonSetter(value = "input", nulls = Nulls.SKIP) public _FinalStage input(Optional input) { this.input = input; return this; } - @Override + @java.lang.Override public ClassifyResponseClassificationsItem build() { return new ClassifyResponseClassificationsItem( id, diff --git a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemClassificationType.java b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemClassificationType.java index e4f847f..3ffff13 100644 --- a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemClassificationType.java +++ b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemClassificationType.java @@ -17,7 +17,7 @@ public enum ClassifyResponseClassificationsItemClassificationType { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemLabelsValue.java b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemLabelsValue.java index 66f858d..417ed76 100644 --- a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemLabelsValue.java +++ b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemLabelsValue.java @@ -35,7 +35,7 @@ public Optional getConfidence() { return confidence; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ClassifyResponseClassificationsItemLabelsValue @@ -51,12 +51,12 @@ private boolean equalTo(ClassifyResponseClassificationsItemLabelsValue other) { return confidence.equals(other.confidence); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.confidence); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/Connector.java b/src/main/java/com/cohere/api/types/Connector.java index 978ca83..9ae6670 100644 --- a/src/main/java/com/cohere/api/types/Connector.java +++ b/src/main/java/com/cohere/api/types/Connector.java @@ -187,7 +187,7 @@ public Optional getContinueOnFailure() { return continueOnFailure; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof Connector && equalTo((Connector) other); @@ -214,7 +214,7 @@ private boolean equalTo(Connector other) { && continueOnFailure.equals(other.continueOnFailure); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.id, @@ -232,7 +232,7 @@ public int hashCode() { this.continueOnFailure); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -332,7 +332,7 @@ public static final class Builder implements IdStage, NameStage, CreatedAtStage, private Builder() {} - @Override + @java.lang.Override public Builder from(Connector other) { id(other.getId()); organizationId(other.getOrganizationId()); @@ -355,7 +355,7 @@ public Builder from(Connector other) { * This is automatically created from the name of the connector upon registration.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("id") public NameStage id(String id) { this.id = id; @@ -366,7 +366,7 @@ public NameStage id(String id) { *

A human-readable name for the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("name") public CreatedAtStage name(String name) { this.name = name; @@ -377,7 +377,7 @@ public CreatedAtStage name(String name) { *

The UTC time at which the connector was created.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("created_at") public UpdatedAtStage createdAt(OffsetDateTime createdAt) { this.createdAt = createdAt; @@ -388,7 +388,7 @@ public UpdatedAtStage createdAt(OffsetDateTime createdAt) { *

The UTC time at which the connector was last updated.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("updated_at") public _FinalStage updatedAt(OffsetDateTime updatedAt) { this.updatedAt = updatedAt; @@ -399,13 +399,13 @@ public _FinalStage updatedAt(OffsetDateTime updatedAt) { *

Whether a chat request should continue or not if the request to this connector fails.

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

Whether the connector is active or not.

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

The OAuth status for the user making the request. One of ["valid", "expired", ""]. Empty string (field is omitted) means the user has not authorized the connector yet.

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

The OAuth 2.0 configuration for the connector.

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

The type of authentication/authorization used by the connector. Possible values: [oauth, service_auth]

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

A list of fields to exclude from the prompt (fields remain in the document).

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

The URL of the connector that will be used to search for documents.

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

A description of the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage description(String description) { this.description = Optional.of(description); return this; } - @Override + @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { this.description = description; @@ -536,20 +536,20 @@ public _FinalStage description(Optional description) { * the organization of the user who created the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage organizationId(String organizationId) { this.organizationId = Optional.of(organizationId); return this; } - @Override + @java.lang.Override @JsonSetter(value = "organization_id", nulls = Nulls.SKIP) public _FinalStage organizationId(Optional organizationId) { this.organizationId = organizationId; return this; } - @Override + @java.lang.Override public Connector build() { return new Connector( id, diff --git a/src/main/java/com/cohere/api/types/ConnectorAuthStatus.java b/src/main/java/com/cohere/api/types/ConnectorAuthStatus.java index 63b8e32..2f0a4f1 100644 --- a/src/main/java/com/cohere/api/types/ConnectorAuthStatus.java +++ b/src/main/java/com/cohere/api/types/ConnectorAuthStatus.java @@ -17,7 +17,7 @@ public enum ConnectorAuthStatus { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ConnectorOAuth.java b/src/main/java/com/cohere/api/types/ConnectorOAuth.java index b9e4340..ffe974c 100644 --- a/src/main/java/com/cohere/api/types/ConnectorOAuth.java +++ b/src/main/java/com/cohere/api/types/ConnectorOAuth.java @@ -20,38 +20,62 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = ConnectorOAuth.Builder.class) public final class ConnectorOAuth { - private final Optional authorizeUrl; + private final Optional clientId; - private final Optional tokenUrl; + private final Optional clientSecret; + + private final String authorizeUrl; + + private final String tokenUrl; private final Optional scope; private final Map additionalProperties; private ConnectorOAuth( - Optional authorizeUrl, - Optional tokenUrl, + Optional clientId, + Optional clientSecret, + String authorizeUrl, + String tokenUrl, Optional scope, Map additionalProperties) { + this.clientId = clientId; + this.clientSecret = clientSecret; this.authorizeUrl = authorizeUrl; this.tokenUrl = tokenUrl; this.scope = scope; this.additionalProperties = additionalProperties; } + /** + * @return The OAuth 2.0 client ID. This field is encrypted at rest. + */ + @JsonProperty("client_id") + public Optional getClientId() { + return clientId; + } + + /** + * @return The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response. + */ + @JsonProperty("client_secret") + public Optional getClientSecret() { + return clientSecret; + } + /** * @return The OAuth 2.0 /authorize endpoint to use when users authorize the connector. */ - @JsonProperty("authorizeUrl") - public Optional getAuthorizeUrl() { + @JsonProperty("authorize_url") + public String getAuthorizeUrl() { return authorizeUrl; } /** * @return The OAuth 2.0 /token endpoint to use when users authorize the connector. */ - @JsonProperty("tokenUrl") - public Optional getTokenUrl() { + @JsonProperty("token_url") + public String getTokenUrl() { return tokenUrl; } @@ -63,7 +87,7 @@ public Optional getScope() { return scope; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ConnectorOAuth && equalTo((ConnectorOAuth) other); @@ -75,78 +99,156 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConnectorOAuth other) { - return authorizeUrl.equals(other.authorizeUrl) && tokenUrl.equals(other.tokenUrl) && scope.equals(other.scope); + return clientId.equals(other.clientId) + && clientSecret.equals(other.clientSecret) + && authorizeUrl.equals(other.authorizeUrl) + && tokenUrl.equals(other.tokenUrl) + && scope.equals(other.scope); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.authorizeUrl, this.tokenUrl, this.scope); + return Objects.hash(this.clientId, this.clientSecret, this.authorizeUrl, this.tokenUrl, this.scope); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } - public static Builder builder() { + public static AuthorizeUrlStage builder() { return new Builder(); } + public interface AuthorizeUrlStage { + TokenUrlStage authorizeUrl(String authorizeUrl); + + Builder from(ConnectorOAuth other); + } + + public interface TokenUrlStage { + _FinalStage tokenUrl(String tokenUrl); + } + + public interface _FinalStage { + ConnectorOAuth build(); + + _FinalStage clientId(Optional clientId); + + _FinalStage clientId(String clientId); + + _FinalStage clientSecret(Optional clientSecret); + + _FinalStage clientSecret(String clientSecret); + + _FinalStage scope(Optional scope); + + _FinalStage scope(String scope); + } + @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional authorizeUrl = Optional.empty(); + public static final class Builder implements AuthorizeUrlStage, TokenUrlStage, _FinalStage { + private String authorizeUrl; - private Optional tokenUrl = Optional.empty(); + private String tokenUrl; private Optional scope = Optional.empty(); + private Optional clientSecret = Optional.empty(); + + private Optional clientId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} + @java.lang.Override public Builder from(ConnectorOAuth other) { + clientId(other.getClientId()); + clientSecret(other.getClientSecret()); authorizeUrl(other.getAuthorizeUrl()); tokenUrl(other.getTokenUrl()); scope(other.getScope()); return this; } - @JsonSetter(value = "authorizeUrl", nulls = Nulls.SKIP) - public Builder authorizeUrl(Optional authorizeUrl) { + /** + *

The OAuth 2.0 /authorize endpoint to use when users authorize the connector.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("authorize_url") + public TokenUrlStage authorizeUrl(String authorizeUrl) { this.authorizeUrl = authorizeUrl; return this; } - public Builder authorizeUrl(String authorizeUrl) { - this.authorizeUrl = Optional.of(authorizeUrl); - return this; - } - - @JsonSetter(value = "tokenUrl", nulls = Nulls.SKIP) - public Builder tokenUrl(Optional tokenUrl) { + /** + *

The OAuth 2.0 /token endpoint to use when users authorize the connector.

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

The OAuth scopes to request when users authorize the connector.

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

The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response.

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

The OAuth 2.0 client ID. This field is encrypted at rest.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage clientId(String clientId) { + this.clientId = Optional.of(clientId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "client_id", nulls = Nulls.SKIP) + public _FinalStage clientId(Optional clientId) { + this.clientId = clientId; return this; } + @java.lang.Override public ConnectorOAuth build() { - return new ConnectorOAuth(authorizeUrl, tokenUrl, scope, additionalProperties); + return new ConnectorOAuth(clientId, clientSecret, authorizeUrl, tokenUrl, scope, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/CreateConnectorOAuth.java b/src/main/java/com/cohere/api/types/CreateConnectorOAuth.java index 4762e89..329eb3d 100644 --- a/src/main/java/com/cohere/api/types/CreateConnectorOAuth.java +++ b/src/main/java/com/cohere/api/types/CreateConnectorOAuth.java @@ -20,23 +20,23 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = CreateConnectorOAuth.Builder.class) public final class CreateConnectorOAuth { - private final String clientId; + private final Optional clientId; - private final String clientSecret; + private final Optional clientSecret; - private final String authorizeUrl; + private final Optional authorizeUrl; - private final String tokenUrl; + private final Optional tokenUrl; private final Optional scope; private final Map additionalProperties; private CreateConnectorOAuth( - String clientId, - String clientSecret, - String authorizeUrl, - String tokenUrl, + Optional clientId, + Optional clientSecret, + Optional authorizeUrl, + Optional tokenUrl, Optional scope, Map additionalProperties) { this.clientId = clientId; @@ -50,32 +50,32 @@ private CreateConnectorOAuth( /** * @return The OAuth 2.0 client ID. This fields is encrypted at rest. */ - @JsonProperty("clientId") - public String getClientId() { + @JsonProperty("client_id") + public Optional getClientId() { return clientId; } /** * @return The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response. */ - @JsonProperty("clientSecret") - public String getClientSecret() { + @JsonProperty("client_secret") + public Optional getClientSecret() { return clientSecret; } /** * @return The OAuth 2.0 /authorize endpoint to use when users authorize the connector. */ - @JsonProperty("authorizeUrl") - public String getAuthorizeUrl() { + @JsonProperty("authorize_url") + public Optional getAuthorizeUrl() { return authorizeUrl; } /** * @return The OAuth 2.0 /token endpoint to use when users authorize the connector. */ - @JsonProperty("tokenUrl") - public String getTokenUrl() { + @JsonProperty("token_url") + public Optional getTokenUrl() { return tokenUrl; } @@ -87,7 +87,7 @@ public Optional getScope() { return scope; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof CreateConnectorOAuth && equalTo((CreateConnectorOAuth) other); @@ -106,56 +106,29 @@ private boolean equalTo(CreateConnectorOAuth other) { && scope.equals(other.scope); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.clientId, this.clientSecret, this.authorizeUrl, this.tokenUrl, this.scope); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } - public static ClientIdStage builder() { + public static Builder builder() { return new Builder(); } - public interface ClientIdStage { - ClientSecretStage clientId(String clientId); - - Builder from(CreateConnectorOAuth other); - } - - public interface ClientSecretStage { - AuthorizeUrlStage clientSecret(String clientSecret); - } - - public interface AuthorizeUrlStage { - TokenUrlStage authorizeUrl(String authorizeUrl); - } - - public interface TokenUrlStage { - _FinalStage tokenUrl(String tokenUrl); - } - - public interface _FinalStage { - CreateConnectorOAuth build(); - - _FinalStage scope(Optional scope); - - _FinalStage scope(String scope); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements ClientIdStage, ClientSecretStage, AuthorizeUrlStage, TokenUrlStage, _FinalStage { - private String clientId; + public static final class Builder { + private Optional clientId = Optional.empty(); - private String clientSecret; + private Optional clientSecret = Optional.empty(); - private String authorizeUrl; + private Optional authorizeUrl = Optional.empty(); - private String tokenUrl; + private Optional tokenUrl = Optional.empty(); private Optional scope = Optional.empty(); @@ -164,7 +137,6 @@ public static final class Builder private Builder() {} - @Override public Builder from(CreateConnectorOAuth other) { clientId(other.getClientId()); clientSecret(other.getClientSecret()); @@ -174,68 +146,61 @@ public Builder from(CreateConnectorOAuth other) { return this; } - /** - *

The OAuth 2.0 client ID. This fields is encrypted at rest.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("clientId") - public ClientSecretStage clientId(String clientId) { + @JsonSetter(value = "client_id", nulls = Nulls.SKIP) + public Builder clientId(Optional clientId) { this.clientId = clientId; return this; } - /** - *

The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("clientSecret") - public AuthorizeUrlStage clientSecret(String clientSecret) { + public Builder clientId(String clientId) { + this.clientId = Optional.of(clientId); + return this; + } + + @JsonSetter(value = "client_secret", nulls = Nulls.SKIP) + public Builder clientSecret(Optional clientSecret) { this.clientSecret = clientSecret; return this; } - /** - *

The OAuth 2.0 /authorize endpoint to use when users authorize the connector.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("authorizeUrl") - public TokenUrlStage authorizeUrl(String authorizeUrl) { + public Builder clientSecret(String clientSecret) { + this.clientSecret = Optional.of(clientSecret); + return this; + } + + @JsonSetter(value = "authorize_url", nulls = Nulls.SKIP) + public Builder authorizeUrl(Optional authorizeUrl) { this.authorizeUrl = authorizeUrl; return this; } - /** - *

The OAuth 2.0 /token endpoint to use when users authorize the connector.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("tokenUrl") - public _FinalStage tokenUrl(String tokenUrl) { + public Builder authorizeUrl(String authorizeUrl) { + this.authorizeUrl = Optional.of(authorizeUrl); + return this; + } + + @JsonSetter(value = "token_url", nulls = Nulls.SKIP) + public Builder tokenUrl(Optional tokenUrl) { this.tokenUrl = tokenUrl; return this; } - /** - *

The OAuth scopes to request when users authorize the connector.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage scope(String scope) { - this.scope = Optional.of(scope); + public Builder tokenUrl(String tokenUrl) { + this.tokenUrl = Optional.of(tokenUrl); return this; } - @Override @JsonSetter(value = "scope", nulls = Nulls.SKIP) - public _FinalStage scope(Optional scope) { + public Builder scope(Optional scope) { this.scope = scope; return this; } - @Override + public Builder scope(String scope) { + this.scope = Optional.of(scope); + return this; + } + public CreateConnectorOAuth build() { return new CreateConnectorOAuth( clientId, clientSecret, authorizeUrl, tokenUrl, scope, additionalProperties); diff --git a/src/main/java/com/cohere/api/types/CreateResponse.java b/src/main/java/com/cohere/api/types/CreateConnectorResponse.java similarity index 72% rename from src/main/java/com/cohere/api/types/CreateResponse.java rename to src/main/java/com/cohere/api/types/CreateConnectorResponse.java index e00fdae..3766fbe 100644 --- a/src/main/java/com/cohere/api/types/CreateResponse.java +++ b/src/main/java/com/cohere/api/types/CreateConnectorResponse.java @@ -16,13 +16,13 @@ import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = CreateResponse.Builder.class) -public final class CreateResponse { +@JsonDeserialize(builder = CreateConnectorResponse.Builder.class) +public final class CreateConnectorResponse { private final Connector connector; private final Map additionalProperties; - private CreateResponse(Connector connector, Map additionalProperties) { + private CreateConnectorResponse(Connector connector, Map additionalProperties) { this.connector = connector; this.additionalProperties = additionalProperties; } @@ -32,10 +32,10 @@ public Connector getConnector() { return connector; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof CreateResponse && equalTo((CreateResponse) other); + return other instanceof CreateConnectorResponse && equalTo((CreateConnectorResponse) other); } @JsonAnyGetter @@ -43,16 +43,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(CreateResponse other) { + private boolean equalTo(CreateConnectorResponse other) { return connector.equals(other.connector); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.connector); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -64,11 +64,11 @@ public static ConnectorStage builder() { public interface ConnectorStage { _FinalStage connector(Connector connector); - Builder from(CreateResponse other); + Builder from(CreateConnectorResponse other); } public interface _FinalStage { - CreateResponse build(); + CreateConnectorResponse build(); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -80,22 +80,22 @@ public static final class Builder implements ConnectorStage, _FinalStage { private Builder() {} - @Override - public Builder from(CreateResponse other) { + @java.lang.Override + public Builder from(CreateConnectorResponse other) { connector(other.getConnector()); return this; } - @Override + @java.lang.Override @JsonSetter("connector") public _FinalStage connector(Connector connector) { this.connector = connector; return this; } - @Override - public CreateResponse build() { - return new CreateResponse(connector, additionalProperties); + @java.lang.Override + public CreateConnectorResponse build() { + return new CreateConnectorResponse(connector, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/CreateConnectorServiceAuth.java b/src/main/java/com/cohere/api/types/CreateConnectorServiceAuth.java index 58d7068..6c91370 100644 --- a/src/main/java/com/cohere/api/types/CreateConnectorServiceAuth.java +++ b/src/main/java/com/cohere/api/types/CreateConnectorServiceAuth.java @@ -18,23 +18,20 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = CreateConnectorServiceAuth.Builder.class) public final class CreateConnectorServiceAuth { - private final String type; + private final AuthTokenType type; private final String token; private final Map additionalProperties; - private CreateConnectorServiceAuth(String type, String token, Map additionalProperties) { + private CreateConnectorServiceAuth(AuthTokenType type, String token, Map additionalProperties) { this.type = type; this.token = token; this.additionalProperties = additionalProperties; } - /** - * @return The token_type specifies the way the token is passed in the Authorization header. Valid values are "bearer", "basic", and "noscheme". - */ @JsonProperty("type") - public String getType() { + public AuthTokenType getType() { return type; } @@ -46,7 +43,7 @@ public String getToken() { return token; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof CreateConnectorServiceAuth && equalTo((CreateConnectorServiceAuth) other); @@ -61,12 +58,12 @@ private boolean equalTo(CreateConnectorServiceAuth other) { return type.equals(other.type) && token.equals(other.token); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.type, this.token); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -76,7 +73,7 @@ public static TypeStage builder() { } public interface TypeStage { - TokenStage type(String type); + TokenStage type(AuthTokenType type); Builder from(CreateConnectorServiceAuth other); } @@ -91,7 +88,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements TypeStage, TokenStage, _FinalStage { - private String type; + private AuthTokenType type; private String token; @@ -100,20 +97,16 @@ public static final class Builder implements TypeStage, TokenStage, _FinalStage private Builder() {} - @Override + @java.lang.Override public Builder from(CreateConnectorServiceAuth other) { type(other.getType()); token(other.getToken()); return this; } - /** - *

The token_type specifies the way the token is passed in the Authorization header. Valid values are "bearer", "basic", and "noscheme".

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override + @java.lang.Override @JsonSetter("type") - public TokenStage type(String type) { + public TokenStage type(AuthTokenType type) { this.type = type; return this; } @@ -122,14 +115,14 @@ public TokenStage type(String type) { *

The token that will be used in the HTTP Authorization header when making requests to the connector. This field is encrypted at rest and never returned in a response.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("token") public _FinalStage token(String token) { this.token = token; return this; } - @Override + @java.lang.Override public CreateConnectorServiceAuth build() { return new CreateConnectorServiceAuth(type, token, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/DetectLanguageResponse.java b/src/main/java/com/cohere/api/types/CreateEmbedJobResponse.java similarity index 52% rename from src/main/java/com/cohere/api/types/DetectLanguageResponse.java rename to src/main/java/com/cohere/api/types/CreateEmbedJobResponse.java index 90af909..ce919ca 100644 --- a/src/main/java/com/cohere/api/types/DetectLanguageResponse.java +++ b/src/main/java/com/cohere/api/types/CreateEmbedJobResponse.java @@ -13,35 +13,28 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = DetectLanguageResponse.Builder.class) -public final class DetectLanguageResponse { - private final Optional> results; +@JsonDeserialize(builder = CreateEmbedJobResponse.Builder.class) +public final class CreateEmbedJobResponse { + private final String jobId; private final Optional meta; private final Map additionalProperties; - private DetectLanguageResponse( - Optional> results, - Optional meta, - Map additionalProperties) { - this.results = results; + private CreateEmbedJobResponse(String jobId, Optional meta, Map additionalProperties) { + this.jobId = jobId; this.meta = meta; this.additionalProperties = additionalProperties; } - /** - * @return List of languages, one per input text - */ - @JsonProperty("results") - public Optional> getResults() { - return results; + @JsonProperty("job_id") + public String getJobId() { + return jobId; } @JsonProperty("meta") @@ -49,10 +42,10 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof DetectLanguageResponse && equalTo((DetectLanguageResponse) other); + return other instanceof CreateEmbedJobResponse && equalTo((CreateEmbedJobResponse) other); } @JsonAnyGetter @@ -60,27 +53,41 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(DetectLanguageResponse other) { - return results.equals(other.results) && meta.equals(other.meta); + private boolean equalTo(CreateEmbedJobResponse other) { + return jobId.equals(other.jobId) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.results, this.meta); + return Objects.hash(this.jobId, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } - public static Builder builder() { + public static JobIdStage builder() { return new Builder(); } + public interface JobIdStage { + _FinalStage jobId(String jobId); + + Builder from(CreateEmbedJobResponse other); + } + + public interface _FinalStage { + CreateEmbedJobResponse build(); + + _FinalStage meta(Optional meta); + + _FinalStage meta(ApiMeta meta); + } + @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> results = Optional.empty(); + public static final class Builder implements JobIdStage, _FinalStage { + private String jobId; private Optional meta = Optional.empty(); @@ -89,36 +96,36 @@ public static final class Builder { private Builder() {} - public Builder from(DetectLanguageResponse other) { - results(other.getResults()); + @java.lang.Override + public Builder from(CreateEmbedJobResponse other) { + jobId(other.getJobId()); meta(other.getMeta()); return this; } - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public Builder results(Optional> results) { - this.results = results; + @java.lang.Override + @JsonSetter("job_id") + public _FinalStage jobId(String jobId) { + this.jobId = jobId; return this; } - public Builder results(List results) { - this.results = Optional.of(results); + @java.lang.Override + public _FinalStage meta(ApiMeta meta) { + this.meta = Optional.of(meta); return this; } + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) - public Builder meta(Optional meta) { + public _FinalStage meta(Optional meta) { this.meta = meta; return this; } - public Builder meta(ApiMeta meta) { - this.meta = Optional.of(meta); - return this; - } - - public DetectLanguageResponse build() { - return new DetectLanguageResponse(results, meta, additionalProperties); + @java.lang.Override + public CreateEmbedJobResponse build() { + return new CreateEmbedJobResponse(jobId, meta, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/Dataset.java b/src/main/java/com/cohere/api/types/Dataset.java new file mode 100644 index 0000000..7c6652a --- /dev/null +++ b/src/main/java/com/cohere/api/types/Dataset.java @@ -0,0 +1,495 @@ +/** + * 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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = Dataset.Builder.class) +public final class Dataset { + private final String id; + + private final String name; + + private final OffsetDateTime createdAt; + + private final OffsetDateTime updatedAt; + + private final DatasetType datasetType; + + private final DatasetValidationStatus validationStatus; + + private final Optional validationError; + + private final Optional schema; + + private final Optional> requiredFields; + + private final Optional> preserveFields; + + private final Optional> datasetParts; + + private final Optional> validationWarnings; + + private final Map additionalProperties; + + private Dataset( + String id, + String name, + OffsetDateTime createdAt, + OffsetDateTime updatedAt, + DatasetType datasetType, + DatasetValidationStatus validationStatus, + Optional validationError, + Optional schema, + Optional> requiredFields, + Optional> preserveFields, + Optional> datasetParts, + Optional> validationWarnings, + Map additionalProperties) { + this.id = id; + this.name = name; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.datasetType = datasetType; + this.validationStatus = validationStatus; + this.validationError = validationError; + this.schema = schema; + this.requiredFields = requiredFields; + this.preserveFields = preserveFields; + this.datasetParts = datasetParts; + this.validationWarnings = validationWarnings; + this.additionalProperties = additionalProperties; + } + + /** + * @return The dataset ID + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the dataset + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The creation date + */ + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * @return The last update date + */ + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("dataset_type") + public DatasetType getDatasetType() { + return datasetType; + } + + @JsonProperty("validation_status") + public DatasetValidationStatus getValidationStatus() { + return validationStatus; + } + + /** + * @return Errors found during validation + */ + @JsonProperty("validation_error") + public Optional getValidationError() { + return validationError; + } + + /** + * @return the avro schema of the dataset + */ + @JsonProperty("schema") + public Optional getSchema() { + return schema; + } + + @JsonProperty("required_fields") + public Optional> getRequiredFields() { + return requiredFields; + } + + @JsonProperty("preserve_fields") + public Optional> getPreserveFields() { + return preserveFields; + } + + /** + * @return the underlying files that make up the dataset + */ + @JsonProperty("dataset_parts") + public Optional> getDatasetParts() { + return datasetParts; + } + + /** + * @return warnings found during validation + */ + @JsonProperty("validation_warnings") + public Optional> getValidationWarnings() { + return validationWarnings; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Dataset && equalTo((Dataset) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Dataset other) { + return id.equals(other.id) + && name.equals(other.name) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && datasetType.equals(other.datasetType) + && validationStatus.equals(other.validationStatus) + && validationError.equals(other.validationError) + && schema.equals(other.schema) + && requiredFields.equals(other.requiredFields) + && preserveFields.equals(other.preserveFields) + && datasetParts.equals(other.datasetParts) + && validationWarnings.equals(other.validationWarnings); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.name, + this.createdAt, + this.updatedAt, + this.datasetType, + this.validationStatus, + this.validationError, + this.schema, + this.requiredFields, + this.preserveFields, + this.datasetParts, + this.validationWarnings); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(String id); + + Builder from(Dataset other); + } + + public interface NameStage { + CreatedAtStage name(String name); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(OffsetDateTime createdAt); + } + + public interface UpdatedAtStage { + DatasetTypeStage updatedAt(OffsetDateTime updatedAt); + } + + public interface DatasetTypeStage { + ValidationStatusStage datasetType(DatasetType datasetType); + } + + public interface ValidationStatusStage { + _FinalStage validationStatus(DatasetValidationStatus validationStatus); + } + + public interface _FinalStage { + Dataset build(); + + _FinalStage validationError(Optional validationError); + + _FinalStage validationError(String validationError); + + _FinalStage schema(Optional schema); + + _FinalStage schema(String schema); + + _FinalStage requiredFields(Optional> requiredFields); + + _FinalStage requiredFields(List requiredFields); + + _FinalStage preserveFields(Optional> preserveFields); + + _FinalStage preserveFields(List preserveFields); + + _FinalStage datasetParts(Optional> datasetParts); + + _FinalStage datasetParts(List datasetParts); + + _FinalStage validationWarnings(Optional> validationWarnings); + + _FinalStage validationWarnings(List validationWarnings); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + NameStage, + CreatedAtStage, + UpdatedAtStage, + DatasetTypeStage, + ValidationStatusStage, + _FinalStage { + private String id; + + private String name; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + private DatasetType datasetType; + + private DatasetValidationStatus validationStatus; + + private Optional> validationWarnings = Optional.empty(); + + private Optional> datasetParts = Optional.empty(); + + private Optional> preserveFields = Optional.empty(); + + private Optional> requiredFields = Optional.empty(); + + private Optional schema = Optional.empty(); + + private Optional validationError = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Dataset other) { + id(other.getId()); + name(other.getName()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + datasetType(other.getDatasetType()); + validationStatus(other.getValidationStatus()); + validationError(other.getValidationError()); + schema(other.getSchema()); + requiredFields(other.getRequiredFields()); + preserveFields(other.getPreserveFields()); + datasetParts(other.getDatasetParts()); + validationWarnings(other.getValidationWarnings()); + return this; + } + + /** + *

The dataset ID

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

The name of the dataset

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

The creation date

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

The last update date

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public DatasetTypeStage updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + @JsonSetter("dataset_type") + public ValidationStatusStage datasetType(DatasetType datasetType) { + this.datasetType = datasetType; + return this; + } + + @java.lang.Override + @JsonSetter("validation_status") + public _FinalStage validationStatus(DatasetValidationStatus validationStatus) { + this.validationStatus = validationStatus; + return this; + } + + /** + *

warnings found during validation

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

the underlying files that make up the dataset

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage datasetParts(List datasetParts) { + this.datasetParts = Optional.of(datasetParts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "dataset_parts", nulls = Nulls.SKIP) + public _FinalStage datasetParts(Optional> datasetParts) { + this.datasetParts = datasetParts; + return this; + } + + @java.lang.Override + public _FinalStage preserveFields(List preserveFields) { + this.preserveFields = Optional.of(preserveFields); + return this; + } + + @java.lang.Override + @JsonSetter(value = "preserve_fields", nulls = Nulls.SKIP) + public _FinalStage preserveFields(Optional> preserveFields) { + this.preserveFields = preserveFields; + return this; + } + + @java.lang.Override + public _FinalStage requiredFields(List requiredFields) { + this.requiredFields = Optional.of(requiredFields); + return this; + } + + @java.lang.Override + @JsonSetter(value = "required_fields", nulls = Nulls.SKIP) + public _FinalStage requiredFields(Optional> requiredFields) { + this.requiredFields = requiredFields; + return this; + } + + /** + *

the avro schema of the dataset

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

Errors found during validation

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage validationError(String validationError) { + this.validationError = Optional.of(validationError); + return this; + } + + @java.lang.Override + @JsonSetter(value = "validation_error", nulls = Nulls.SKIP) + public _FinalStage validationError(Optional validationError) { + this.validationError = validationError; + return this; + } + + @java.lang.Override + public Dataset build() { + return new Dataset( + id, + name, + createdAt, + updatedAt, + datasetType, + validationStatus, + validationError, + schema, + requiredFields, + preserveFields, + datasetParts, + validationWarnings, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/DatasetPart.java b/src/main/java/com/cohere/api/types/DatasetPart.java new file mode 100644 index 0000000..fd06846 --- /dev/null +++ b/src/main/java/com/cohere/api/types/DatasetPart.java @@ -0,0 +1,328 @@ +/** + * 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 = DatasetPart.Builder.class) +public final class DatasetPart { + private final String id; + + private final String name; + + private final Optional url; + + private final Optional index; + + private final Optional sizeBytes; + + private final Optional numRows; + + private final Optional originalUrl; + + private final Map additionalProperties; + + private DatasetPart( + String id, + String name, + Optional url, + Optional index, + Optional sizeBytes, + Optional numRows, + Optional originalUrl, + Map additionalProperties) { + this.id = id; + this.name = name; + this.url = url; + this.index = index; + this.sizeBytes = sizeBytes; + this.numRows = numRows; + this.originalUrl = originalUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The dataset part ID + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the dataset part + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The download url of the file + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The index of the file + */ + @JsonProperty("index") + public Optional getIndex() { + return index; + } + + /** + * @return The size of the file in bytes + */ + @JsonProperty("size_bytes") + public Optional getSizeBytes() { + return sizeBytes; + } + + /** + * @return The number of rows in the file + */ + @JsonProperty("num_rows") + public Optional getNumRows() { + return numRows; + } + + /** + * @return The download url of the original file + */ + @JsonProperty("original_url") + public Optional getOriginalUrl() { + return originalUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetPart && equalTo((DatasetPart) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetPart other) { + return id.equals(other.id) + && name.equals(other.name) + && url.equals(other.url) + && index.equals(other.index) + && sizeBytes.equals(other.sizeBytes) + && numRows.equals(other.numRows) + && originalUrl.equals(other.originalUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.url, this.index, this.sizeBytes, this.numRows, this.originalUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(String id); + + Builder from(DatasetPart other); + } + + public interface NameStage { + _FinalStage name(String name); + } + + public interface _FinalStage { + DatasetPart build(); + + _FinalStage url(Optional url); + + _FinalStage url(String url); + + _FinalStage index(Optional index); + + _FinalStage index(Integer index); + + _FinalStage sizeBytes(Optional sizeBytes); + + _FinalStage sizeBytes(Integer sizeBytes); + + _FinalStage numRows(Optional numRows); + + _FinalStage numRows(Integer numRows); + + _FinalStage originalUrl(Optional originalUrl); + + _FinalStage originalUrl(String originalUrl); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, _FinalStage { + private String id; + + private String name; + + private Optional originalUrl = Optional.empty(); + + private Optional numRows = Optional.empty(); + + private Optional sizeBytes = Optional.empty(); + + private Optional index = Optional.empty(); + + private Optional url = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DatasetPart other) { + id(other.getId()); + name(other.getName()); + url(other.getUrl()); + index(other.getIndex()); + sizeBytes(other.getSizeBytes()); + numRows(other.getNumRows()); + originalUrl(other.getOriginalUrl()); + return this; + } + + /** + *

The dataset part ID

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

The name of the dataset part

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

The download url of the original file

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

The number of rows in the file

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

The size of the file in bytes

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

The index of the file

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

The download url of the file

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage url(String url) { + this.url = Optional.of(url); + return this; + } + + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + @java.lang.Override + public DatasetPart build() { + return new DatasetPart(id, name, url, index, sizeBytes, numRows, originalUrl, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/DatasetType.java b/src/main/java/com/cohere/api/types/DatasetType.java new file mode 100644 index 0000000..7cf2beb --- /dev/null +++ b/src/main/java/com/cohere/api/types/DatasetType.java @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DatasetType { + EMBED_INPUT("embed-input"), + + EMBED_RESULT("embed-result"), + + CLUSTER_RESULT("cluster-result"), + + CLUSTER_OUTLIERS("cluster-outliers"), + + RERANKER_FINETUNE_INPUT("reranker-finetune-input"), + + PROMPT_COMPLETION_FINETUNE_INPUT("prompt-completion-finetune-input"), + + SINGLE_LABEL_CLASSIFICATION_FINETUNE_INPUT("single-label-classification-finetune-input"), + + CHAT_FINETUNE_INPUT("chat-finetune-input"), + + MULTI_LABEL_CLASSIFICATION_FINETUNE_INPUT("multi-label-classification-finetune-input"); + + private final String value; + + DatasetType(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/DatasetValidationStatus.java b/src/main/java/com/cohere/api/types/DatasetValidationStatus.java new file mode 100644 index 0000000..5b041aa --- /dev/null +++ b/src/main/java/com/cohere/api/types/DatasetValidationStatus.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DatasetValidationStatus { + UNKNOWN("unknown"), + + QUEUED("queued"), + + PROCESSING("processing"), + + FAILED("failed"), + + VALIDATED("validated"), + + SKIPPED("skipped"); + + private final String value; + + DatasetValidationStatus(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/DetectLanguageResponseResultsItem.java b/src/main/java/com/cohere/api/types/DetectLanguageResponseResultsItem.java deleted file mode 100644 index e204466..0000000 --- a/src/main/java/com/cohere/api/types/DetectLanguageResponseResultsItem.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.cohere.api.types; - -import com.cohere.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = DetectLanguageResponseResultsItem.Builder.class) -public final class DetectLanguageResponseResultsItem { - private final Optional languageName; - - private final Optional languageCode; - - private final Map additionalProperties; - - private DetectLanguageResponseResultsItem( - Optional languageName, Optional languageCode, Map additionalProperties) { - this.languageName = languageName; - this.languageCode = languageCode; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("language_name") - public Optional getLanguageName() { - return languageName; - } - - @JsonProperty("language_code") - public Optional getLanguageCode() { - return languageCode; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DetectLanguageResponseResultsItem && equalTo((DetectLanguageResponseResultsItem) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DetectLanguageResponseResultsItem other) { - return languageName.equals(other.languageName) && languageCode.equals(other.languageCode); - } - - @Override - public int hashCode() { - return Objects.hash(this.languageName, this.languageCode); - } - - @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 languageName = Optional.empty(); - - private Optional languageCode = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(DetectLanguageResponseResultsItem other) { - languageName(other.getLanguageName()); - languageCode(other.getLanguageCode()); - return this; - } - - @JsonSetter(value = "language_name", nulls = Nulls.SKIP) - public Builder languageName(Optional languageName) { - this.languageName = languageName; - return this; - } - - public Builder languageName(String languageName) { - this.languageName = Optional.of(languageName); - return this; - } - - @JsonSetter(value = "language_code", nulls = Nulls.SKIP) - public Builder languageCode(Optional languageCode) { - this.languageCode = languageCode; - return this; - } - - public Builder languageCode(String languageCode) { - this.languageCode = Optional.of(languageCode); - return this; - } - - public DetectLanguageResponseResultsItem build() { - return new DetectLanguageResponseResultsItem(languageName, languageCode, additionalProperties); - } - } -} diff --git a/src/main/java/com/cohere/api/types/DetokenizeResponse.java b/src/main/java/com/cohere/api/types/DetokenizeResponse.java index 3b36745..80273f4 100644 --- a/src/main/java/com/cohere/api/types/DetokenizeResponse.java +++ b/src/main/java/com/cohere/api/types/DetokenizeResponse.java @@ -45,7 +45,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof DetokenizeResponse && equalTo((DetokenizeResponse) other); @@ -60,12 +60,12 @@ private boolean equalTo(DetokenizeResponse other) { return text.equals(other.text) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -99,7 +99,7 @@ public static final class Builder implements TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(DetokenizeResponse other) { text(other.getText()); meta(other.getMeta()); @@ -110,27 +110,27 @@ public Builder from(DetokenizeResponse other) { *

A string representing the list of tokens.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; return this; } - @Override + @java.lang.Override public _FinalStage meta(ApiMeta meta) { this.meta = Optional.of(meta); return this; } - @Override + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Optional meta) { this.meta = meta; return this; } - @Override + @java.lang.Override public DetokenizeResponse build() { return new DetokenizeResponse(text, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/EmbedByTypeResponse.java b/src/main/java/com/cohere/api/types/EmbedByTypeResponse.java index 79ea844..8dee976 100644 --- a/src/main/java/com/cohere/api/types/EmbedByTypeResponse.java +++ b/src/main/java/com/cohere/api/types/EmbedByTypeResponse.java @@ -71,7 +71,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbedByTypeResponse && equalTo((EmbedByTypeResponse) other); @@ -89,12 +89,12 @@ private boolean equalTo(EmbedByTypeResponse other) { && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.embeddings, this.texts, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -142,7 +142,7 @@ public static final class Builder implements IdStage, EmbeddingsStage, _FinalSta private Builder() {} - @Override + @java.lang.Override public Builder from(EmbedByTypeResponse other) { id(other.getId()); embeddings(other.getEmbeddings()); @@ -151,7 +151,7 @@ public Builder from(EmbedByTypeResponse other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public EmbeddingsStage id(String id) { this.id = id; @@ -162,20 +162,20 @@ public EmbeddingsStage id(String id) { *

An object with different embedding types. The length of each embedding type array will be the same as the length of the original texts array.

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

The text entries for which embeddings were returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllTexts(List texts) { this.texts.addAll(texts); return this; @@ -196,13 +196,13 @@ public _FinalStage addAllTexts(List texts) { *

The text entries for which embeddings were returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addTexts(String texts) { this.texts.add(texts); return this; } - @Override + @java.lang.Override @JsonSetter(value = "texts", nulls = Nulls.SKIP) public _FinalStage texts(List texts) { this.texts.clear(); @@ -210,7 +210,7 @@ public _FinalStage texts(List texts) { return this; } - @Override + @java.lang.Override public EmbedByTypeResponse build() { return new EmbedByTypeResponse(id, embeddings, texts, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java b/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java index 566a0f2..8d4aee6 100644 --- a/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java +++ b/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java @@ -88,7 +88,7 @@ public Optional>> getUbinary() { return ubinary; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbedByTypeResponseEmbeddings && equalTo((EmbedByTypeResponseEmbeddings) other); @@ -107,12 +107,12 @@ private boolean equalTo(EmbedByTypeResponseEmbeddings other) { && ubinary.equals(other.ubinary); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.float_, this.int8, this.uint8, this.binary, this.ubinary); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/EmbedFloatsResponse.java b/src/main/java/com/cohere/api/types/EmbedFloatsResponse.java index 7f3970d..8969319 100644 --- a/src/main/java/com/cohere/api/types/EmbedFloatsResponse.java +++ b/src/main/java/com/cohere/api/types/EmbedFloatsResponse.java @@ -71,7 +71,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbedFloatsResponse && equalTo((EmbedFloatsResponse) other); @@ -89,12 +89,12 @@ private boolean equalTo(EmbedFloatsResponse other) { && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.embeddings, this.texts, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -144,7 +144,7 @@ public static final class Builder implements IdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(EmbedFloatsResponse other) { id(other.getId()); embeddings(other.getEmbeddings()); @@ -153,20 +153,20 @@ public Builder from(EmbedFloatsResponse other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public _FinalStage id(String id) { this.id = id; return this; } - @Override + @java.lang.Override public _FinalStage meta(ApiMeta meta) { this.meta = Optional.of(meta); return this; } - @Override + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Optional meta) { this.meta = meta; @@ -177,7 +177,7 @@ public _FinalStage meta(Optional meta) { *

The text entries for which embeddings were returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllTexts(List texts) { this.texts.addAll(texts); return this; @@ -187,13 +187,13 @@ public _FinalStage addAllTexts(List texts) { *

The text entries for which embeddings were returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addTexts(String texts) { this.texts.add(texts); return this; } - @Override + @java.lang.Override @JsonSetter(value = "texts", nulls = Nulls.SKIP) public _FinalStage texts(List texts) { this.texts.clear(); @@ -205,7 +205,7 @@ public _FinalStage texts(List texts) { *

An array of embeddings, where each embedding is an array of floats. The length of the embeddings array will be the same as the length of the original texts array.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllEmbeddings(List> embeddings) { this.embeddings.addAll(embeddings); return this; @@ -215,13 +215,13 @@ public _FinalStage addAllEmbeddings(List> embeddings) { *

An array of embeddings, where each embedding is an array of floats. The length of the embeddings array will be the same as the length of the original texts array.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addEmbeddings(List embeddings) { this.embeddings.add(embeddings); return this; } - @Override + @java.lang.Override @JsonSetter(value = "embeddings", nulls = Nulls.SKIP) public _FinalStage embeddings(List> embeddings) { this.embeddings.clear(); @@ -229,7 +229,7 @@ public _FinalStage embeddings(List> embeddings) { return this; } - @Override + @java.lang.Override public EmbedFloatsResponse build() { return new EmbedFloatsResponse(id, embeddings, texts, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/EmbedInputType.java b/src/main/java/com/cohere/api/types/EmbedInputType.java new file mode 100644 index 0000000..0e507cf --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbedInputType.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmbedInputType { + SEARCH_DOCUMENT("search_document"), + + SEARCH_QUERY("search_query"), + + CLASSIFICATION("classification"), + + CLUSTERING("clustering"); + + private final String value; + + EmbedInputType(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedJob.java b/src/main/java/com/cohere/api/types/EmbedJob.java new file mode 100644 index 0000000..8e17be9 --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbedJob.java @@ -0,0 +1,398 @@ +/** + * 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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = EmbedJob.Builder.class) +public final class EmbedJob { + private final String jobId; + + private final Optional name; + + private final EmbedJobStatus status; + + private final OffsetDateTime createdAt; + + private final String inputDatasetId; + + private final Optional outputDatasetId; + + private final String model; + + private final EmbedJobTruncate truncate; + + private final Optional meta; + + private final Map additionalProperties; + + private EmbedJob( + String jobId, + Optional name, + EmbedJobStatus status, + OffsetDateTime createdAt, + String inputDatasetId, + Optional outputDatasetId, + String model, + EmbedJobTruncate truncate, + Optional meta, + Map additionalProperties) { + this.jobId = jobId; + this.name = name; + this.status = status; + this.createdAt = createdAt; + this.inputDatasetId = inputDatasetId; + this.outputDatasetId = outputDatasetId; + this.model = model; + this.truncate = truncate; + this.meta = meta; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the embed job + */ + @JsonProperty("job_id") + public String getJobId() { + return jobId; + } + + /** + * @return The name of the embed job + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The status of the embed job + */ + @JsonProperty("status") + public EmbedJobStatus getStatus() { + return status; + } + + /** + * @return The creation date of the embed job + */ + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * @return ID of the input dataset + */ + @JsonProperty("input_dataset_id") + public String getInputDatasetId() { + return inputDatasetId; + } + + /** + * @return ID of the resulting output dataset + */ + @JsonProperty("output_dataset_id") + public Optional getOutputDatasetId() { + return outputDatasetId; + } + + /** + * @return ID of the model used to embed + */ + @JsonProperty("model") + public String getModel() { + return model; + } + + /** + * @return The truncation option used + */ + @JsonProperty("truncate") + public EmbedJobTruncate getTruncate() { + return truncate; + } + + @JsonProperty("meta") + public Optional getMeta() { + return meta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EmbedJob && equalTo((EmbedJob) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EmbedJob other) { + return jobId.equals(other.jobId) + && name.equals(other.name) + && status.equals(other.status) + && createdAt.equals(other.createdAt) + && inputDatasetId.equals(other.inputDatasetId) + && outputDatasetId.equals(other.outputDatasetId) + && model.equals(other.model) + && truncate.equals(other.truncate) + && meta.equals(other.meta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.jobId, + this.name, + this.status, + this.createdAt, + this.inputDatasetId, + this.outputDatasetId, + this.model, + this.truncate, + this.meta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdStage builder() { + return new Builder(); + } + + public interface JobIdStage { + StatusStage jobId(String jobId); + + Builder from(EmbedJob other); + } + + public interface StatusStage { + CreatedAtStage status(EmbedJobStatus status); + } + + public interface CreatedAtStage { + InputDatasetIdStage createdAt(OffsetDateTime createdAt); + } + + public interface InputDatasetIdStage { + ModelStage inputDatasetId(String inputDatasetId); + } + + public interface ModelStage { + TruncateStage model(String model); + } + + public interface TruncateStage { + _FinalStage truncate(EmbedJobTruncate truncate); + } + + public interface _FinalStage { + EmbedJob build(); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage outputDatasetId(Optional outputDatasetId); + + _FinalStage outputDatasetId(String outputDatasetId); + + _FinalStage meta(Optional meta); + + _FinalStage meta(ApiMeta meta); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements JobIdStage, + StatusStage, + CreatedAtStage, + InputDatasetIdStage, + ModelStage, + TruncateStage, + _FinalStage { + private String jobId; + + private EmbedJobStatus status; + + private OffsetDateTime createdAt; + + private String inputDatasetId; + + private String model; + + private EmbedJobTruncate truncate; + + private Optional meta = Optional.empty(); + + private Optional outputDatasetId = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(EmbedJob other) { + jobId(other.getJobId()); + name(other.getName()); + status(other.getStatus()); + createdAt(other.getCreatedAt()); + inputDatasetId(other.getInputDatasetId()); + outputDatasetId(other.getOutputDatasetId()); + model(other.getModel()); + truncate(other.getTruncate()); + meta(other.getMeta()); + return this; + } + + /** + *

ID of the embed job

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

The status of the embed job

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

The creation date of the embed job

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

ID of the input dataset

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

ID of the model used to embed

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

The truncation option used

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

ID of the resulting output dataset

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

The name of the embed job

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.of(name); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public EmbedJob build() { + return new EmbedJob( + jobId, + name, + status, + createdAt, + inputDatasetId, + outputDatasetId, + model, + truncate, + meta, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedJobStatus.java b/src/main/java/com/cohere/api/types/EmbedJobStatus.java new file mode 100644 index 0000000..b24b7f1 --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbedJobStatus.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmbedJobStatus { + PROCESSING("processing"), + + COMPLETE("complete"), + + CANCELLING("cancelling"), + + CANCELLED("cancelled"), + + FAILED("failed"); + + private final String value; + + EmbedJobStatus(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedJobTruncate.java b/src/main/java/com/cohere/api/types/EmbedJobTruncate.java new file mode 100644 index 0000000..8309552 --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbedJobTruncate.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmbedJobTruncate { + START("START"), + + END("END"); + + private final String value; + + EmbedJobTruncate(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedRequestEmbeddingTypesItem.java b/src/main/java/com/cohere/api/types/EmbedRequestEmbeddingTypesItem.java new file mode 100644 index 0000000..1fa9d81 --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbedRequestEmbeddingTypesItem.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmbedRequestEmbeddingTypesItem { + FLOAT("float"), + + INT_8("int8"), + + UINT_8("uint8"), + + BINARY("binary"), + + UBINARY("ubinary"); + + private final String value; + + EmbedRequestEmbeddingTypesItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedRequestTruncate.java b/src/main/java/com/cohere/api/types/EmbedRequestTruncate.java index 0d146cd..9475444 100644 --- a/src/main/java/com/cohere/api/types/EmbedRequestTruncate.java +++ b/src/main/java/com/cohere/api/types/EmbedRequestTruncate.java @@ -19,7 +19,7 @@ public enum EmbedRequestTruncate { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/EmbedResponse.java b/src/main/java/com/cohere/api/types/EmbedResponse.java index 6720e90..052ac33 100644 --- a/src/main/java/com/cohere/api/types/EmbedResponse.java +++ b/src/main/java/com/cohere/api/types/EmbedResponse.java @@ -103,12 +103,12 @@ private EmbeddingsFloatsValue(EmbedFloatsResponse value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitEmbeddingsFloats(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbeddingsFloatsValue && equalTo((EmbeddingsFloatsValue) other); @@ -118,12 +118,12 @@ private boolean equalTo(EmbeddingsFloatsValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "EmbedResponse{" + "value: " + value + "}"; } @@ -141,12 +141,12 @@ private EmbeddingsByTypeValue(EmbedByTypeResponse value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitEmbeddingsByType(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbeddingsByTypeValue && equalTo((EmbeddingsByTypeValue) other); @@ -156,12 +156,12 @@ private boolean equalTo(EmbeddingsByTypeValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "EmbedResponse{" + "value: " + value + "}"; } @@ -176,12 +176,12 @@ private static final class _UnknownValue implements Value { @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) private _UnknownValue(@JsonProperty("value") Object value) {} - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor._visitUnknown(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof _UnknownValue && equalTo((_UnknownValue) other); @@ -191,12 +191,12 @@ private boolean equalTo(_UnknownValue other) { return type.equals(other.type) && value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.type, this.value); } - @Override + @java.lang.Override public String toString() { return "EmbedResponse{" + "type: " + type + ", value: " + value + "}"; } diff --git a/src/main/java/com/cohere/api/types/FinishReason.java b/src/main/java/com/cohere/api/types/FinishReason.java new file mode 100644 index 0000000..67713cc --- /dev/null +++ b/src/main/java/com/cohere/api/types/FinishReason.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum FinishReason { + COMPLETE("COMPLETE"), + + ERROR("ERROR"), + + ERROR_TOXIC("ERROR_TOXIC"), + + ERROR_LIMIT("ERROR_LIMIT"), + + USER_CANCEL("USER_CANCEL"), + + MAX_TOKENS("MAX_TOKENS"); + + private final String value; + + FinishReason(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateRequestReturnLikelihoods.java b/src/main/java/com/cohere/api/types/GenerateRequestReturnLikelihoods.java index cb88cb9..1e1f986 100644 --- a/src/main/java/com/cohere/api/types/GenerateRequestReturnLikelihoods.java +++ b/src/main/java/com/cohere/api/types/GenerateRequestReturnLikelihoods.java @@ -19,7 +19,7 @@ public enum GenerateRequestReturnLikelihoods { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/GenerateRequestTruncate.java b/src/main/java/com/cohere/api/types/GenerateRequestTruncate.java index 6227dbd..2e1dc45 100644 --- a/src/main/java/com/cohere/api/types/GenerateRequestTruncate.java +++ b/src/main/java/com/cohere/api/types/GenerateRequestTruncate.java @@ -19,7 +19,7 @@ public enum GenerateRequestTruncate { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/GenerateStreamEnd.java b/src/main/java/com/cohere/api/types/GenerateStreamEnd.java new file mode 100644 index 0000000..ec5dd34 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamEnd.java @@ -0,0 +1,159 @@ +/** + * 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 = GenerateStreamEnd.Builder.class) +public final class GenerateStreamEnd implements IGenerateStreamEvent { + private final boolean isFinished; + + private final Optional finishReason; + + private final GenerateStreamEndResponse response; + + private final Map additionalProperties; + + private GenerateStreamEnd( + boolean isFinished, + Optional finishReason, + GenerateStreamEndResponse response, + Map additionalProperties) { + this.isFinished = isFinished; + this.finishReason = finishReason; + this.response = response; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("is_finished") + public boolean getIsFinished() { + return isFinished; + } + + @JsonProperty("finish_reason") + public Optional getFinishReason() { + return finishReason; + } + + @JsonProperty("response") + public GenerateStreamEndResponse getResponse() { + return response; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamEnd && equalTo((GenerateStreamEnd) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamEnd other) { + return isFinished == other.isFinished + && finishReason.equals(other.finishReason) + && response.equals(other.response); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.isFinished, this.finishReason, this.response); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IsFinishedStage builder() { + return new Builder(); + } + + public interface IsFinishedStage { + ResponseStage isFinished(boolean isFinished); + + Builder from(GenerateStreamEnd other); + } + + public interface ResponseStage { + _FinalStage response(GenerateStreamEndResponse response); + } + + public interface _FinalStage { + GenerateStreamEnd build(); + + _FinalStage finishReason(Optional finishReason); + + _FinalStage finishReason(FinishReason finishReason); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IsFinishedStage, ResponseStage, _FinalStage { + private boolean isFinished; + + private GenerateStreamEndResponse response; + + private Optional finishReason = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamEnd other) { + isFinished(other.getIsFinished()); + finishReason(other.getFinishReason()); + response(other.getResponse()); + return this; + } + + @java.lang.Override + @JsonSetter("is_finished") + public ResponseStage isFinished(boolean isFinished) { + this.isFinished = isFinished; + return this; + } + + @java.lang.Override + @JsonSetter("response") + public _FinalStage response(GenerateStreamEndResponse response) { + this.response = response; + return this; + } + + @java.lang.Override + public _FinalStage finishReason(FinishReason finishReason) { + this.finishReason = Optional.of(finishReason); + return this; + } + + @java.lang.Override + @JsonSetter(value = "finish_reason", nulls = Nulls.SKIP) + public _FinalStage finishReason(Optional finishReason) { + this.finishReason = finishReason; + return this; + } + + @java.lang.Override + public GenerateStreamEnd build() { + return new GenerateStreamEnd(isFinished, finishReason, response, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamEndResponse.java b/src/main/java/com/cohere/api/types/GenerateStreamEndResponse.java new file mode 100644 index 0000000..3df4226 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamEndResponse.java @@ -0,0 +1,164 @@ +/** + * 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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = GenerateStreamEndResponse.Builder.class) +public final class GenerateStreamEndResponse { + private final String id; + + private final Optional prompt; + + private final Optional> generations; + + private final Map additionalProperties; + + private GenerateStreamEndResponse( + String id, + Optional prompt, + Optional> generations, + Map additionalProperties) { + this.id = id; + this.prompt = prompt; + this.generations = generations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("prompt") + public Optional getPrompt() { + return prompt; + } + + @JsonProperty("generations") + public Optional> getGenerations() { + return generations; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamEndResponse && equalTo((GenerateStreamEndResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamEndResponse other) { + return id.equals(other.id) && prompt.equals(other.prompt) && generations.equals(other.generations); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.prompt, this.generations); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + _FinalStage id(String id); + + Builder from(GenerateStreamEndResponse other); + } + + public interface _FinalStage { + GenerateStreamEndResponse build(); + + _FinalStage prompt(Optional prompt); + + _FinalStage prompt(String prompt); + + _FinalStage generations(Optional> generations); + + _FinalStage generations(List generations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + private Optional> generations = Optional.empty(); + + private Optional prompt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamEndResponse other) { + id(other.getId()); + prompt(other.getPrompt()); + generations(other.getGenerations()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(String id) { + this.id = id; + return this; + } + + @java.lang.Override + public _FinalStage generations(List generations) { + this.generations = Optional.of(generations); + return this; + } + + @java.lang.Override + @JsonSetter(value = "generations", nulls = Nulls.SKIP) + public _FinalStage generations(Optional> generations) { + this.generations = generations; + return this; + } + + @java.lang.Override + public _FinalStage prompt(String prompt) { + this.prompt = Optional.of(prompt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "prompt", nulls = Nulls.SKIP) + public _FinalStage prompt(Optional prompt) { + this.prompt = prompt; + return this; + } + + @java.lang.Override + public GenerateStreamEndResponse build() { + return new GenerateStreamEndResponse(id, prompt, generations, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamError.java b/src/main/java/com/cohere/api/types/GenerateStreamError.java new file mode 100644 index 0000000..55c6ac8 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamError.java @@ -0,0 +1,197 @@ +/** + * 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 = GenerateStreamError.Builder.class) +public final class GenerateStreamError implements IGenerateStreamEvent { + private final Optional index; + + private final boolean isFinished; + + private final FinishReason finishReason; + + private final String err; + + private final Map additionalProperties; + + private GenerateStreamError( + Optional index, + boolean isFinished, + FinishReason finishReason, + String err, + Map additionalProperties) { + this.index = index; + this.isFinished = isFinished; + this.finishReason = finishReason; + this.err = err; + this.additionalProperties = additionalProperties; + } + + /** + * @return Refers to the nth generation. Only present when num_generations is greater than zero. + */ + @JsonProperty("index") + public Optional getIndex() { + return index; + } + + @JsonProperty("is_finished") + public boolean getIsFinished() { + return isFinished; + } + + @JsonProperty("finish_reason") + public FinishReason getFinishReason() { + return finishReason; + } + + /** + * @return Error message + */ + @JsonProperty("err") + public String getErr() { + return err; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamError && equalTo((GenerateStreamError) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamError other) { + return index.equals(other.index) + && isFinished == other.isFinished + && finishReason.equals(other.finishReason) + && err.equals(other.err); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.index, this.isFinished, this.finishReason, this.err); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IsFinishedStage builder() { + return new Builder(); + } + + public interface IsFinishedStage { + FinishReasonStage isFinished(boolean isFinished); + + Builder from(GenerateStreamError other); + } + + public interface FinishReasonStage { + ErrStage finishReason(FinishReason finishReason); + } + + public interface ErrStage { + _FinalStage err(String err); + } + + public interface _FinalStage { + GenerateStreamError build(); + + _FinalStage index(Optional index); + + _FinalStage index(Integer index); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IsFinishedStage, FinishReasonStage, ErrStage, _FinalStage { + private boolean isFinished; + + private FinishReason finishReason; + + private String err; + + private Optional index = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamError other) { + index(other.getIndex()); + isFinished(other.getIsFinished()); + finishReason(other.getFinishReason()); + err(other.getErr()); + return this; + } + + @java.lang.Override + @JsonSetter("is_finished") + public FinishReasonStage isFinished(boolean isFinished) { + this.isFinished = isFinished; + return this; + } + + @java.lang.Override + @JsonSetter("finish_reason") + public ErrStage finishReason(FinishReason finishReason) { + this.finishReason = finishReason; + return this; + } + + /** + *

Error message

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

Refers to the nth generation. Only present when num_generations is greater than zero.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage index(Integer index) { + this.index = Optional.of(index); + return this; + } + + @java.lang.Override + @JsonSetter(value = "index", nulls = Nulls.SKIP) + public _FinalStage index(Optional index) { + this.index = index; + return this; + } + + @java.lang.Override + public GenerateStreamError build() { + return new GenerateStreamError(index, isFinished, finishReason, err, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamEvent.java b/src/main/java/com/cohere/api/types/GenerateStreamEvent.java new file mode 100644 index 0000000..cd36550 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamEvent.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.cohere.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import java.util.Map; + +public final class GenerateStreamEvent implements IGenerateStreamEvent { + private final Map additionalProperties; + + private GenerateStreamEvent(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamEvent; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamRequestReturnLikelihoods.java b/src/main/java/com/cohere/api/types/GenerateStreamRequestReturnLikelihoods.java new file mode 100644 index 0000000..face700 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamRequestReturnLikelihoods.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum GenerateStreamRequestReturnLikelihoods { + GENERATION("GENERATION"), + + ALL("ALL"), + + NONE("NONE"); + + private final String value; + + GenerateStreamRequestReturnLikelihoods(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamRequestTruncate.java b/src/main/java/com/cohere/api/types/GenerateStreamRequestTruncate.java new file mode 100644 index 0000000..cefed5a --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamRequestTruncate.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum GenerateStreamRequestTruncate { + NONE("NONE"), + + START("START"), + + END("END"); + + private final String value; + + GenerateStreamRequestTruncate(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamText.java b/src/main/java/com/cohere/api/types/GenerateStreamText.java new file mode 100644 index 0000000..cdd1414 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamText.java @@ -0,0 +1,168 @@ +/** + * 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 = GenerateStreamText.Builder.class) +public final class GenerateStreamText implements IGenerateStreamEvent { + private final String text; + + private final Optional index; + + private final boolean isFinished; + + private final Map additionalProperties; + + private GenerateStreamText( + String text, Optional index, boolean isFinished, Map additionalProperties) { + this.text = text; + this.index = index; + this.isFinished = isFinished; + this.additionalProperties = additionalProperties; + } + + /** + * @return A segment of text of the generation. + */ + @JsonProperty("text") + public String getText() { + return text; + } + + /** + * @return Refers to the nth generation. Only present when num_generations is greater than zero, and only when text responses are being streamed. + */ + @JsonProperty("index") + public Optional getIndex() { + return index; + } + + @JsonProperty("is_finished") + public boolean getIsFinished() { + return isFinished; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamText && equalTo((GenerateStreamText) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamText other) { + return text.equals(other.text) && index.equals(other.index) && isFinished == other.isFinished; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.text, this.index, this.isFinished); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TextStage builder() { + return new Builder(); + } + + public interface TextStage { + IsFinishedStage text(String text); + + Builder from(GenerateStreamText other); + } + + public interface IsFinishedStage { + _FinalStage isFinished(boolean isFinished); + } + + public interface _FinalStage { + GenerateStreamText build(); + + _FinalStage index(Optional index); + + _FinalStage index(Integer index); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TextStage, IsFinishedStage, _FinalStage { + private String text; + + private boolean isFinished; + + private Optional index = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamText other) { + text(other.getText()); + index(other.getIndex()); + isFinished(other.getIsFinished()); + return this; + } + + /** + *

A segment of text of the generation.

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

Refers to the nth generation. Only present when num_generations is greater than zero, and only when text responses are being streamed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage index(Integer index) { + this.index = Optional.of(index); + return this; + } + + @java.lang.Override + @JsonSetter(value = "index", nulls = Nulls.SKIP) + public _FinalStage index(Optional index) { + this.index = index; + return this; + } + + @java.lang.Override + public GenerateStreamText build() { + return new GenerateStreamText(text, index, isFinished, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamedResponse.java b/src/main/java/com/cohere/api/types/GenerateStreamedResponse.java new file mode 100644 index 0000000..96a238e --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamedResponse.java @@ -0,0 +1,263 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class GenerateStreamedResponse { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private GenerateStreamedResponse(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static GenerateStreamedResponse textGeneration(GenerateStreamText value) { + return new GenerateStreamedResponse(new TextGenerationValue(value)); + } + + public static GenerateStreamedResponse streamEnd(GenerateStreamEnd value) { + return new GenerateStreamedResponse(new StreamEndValue(value)); + } + + public static GenerateStreamedResponse streamError(GenerateStreamError value) { + return new GenerateStreamedResponse(new StreamErrorValue(value)); + } + + public boolean isTextGeneration() { + return value instanceof TextGenerationValue; + } + + public boolean isStreamEnd() { + return value instanceof StreamEndValue; + } + + public boolean isStreamError() { + return value instanceof StreamErrorValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getTextGeneration() { + if (isTextGeneration()) { + return Optional.of(((TextGenerationValue) value).value); + } + return Optional.empty(); + } + + public Optional getStreamEnd() { + if (isStreamEnd()) { + return Optional.of(((StreamEndValue) value).value); + } + return Optional.empty(); + } + + public Optional getStreamError() { + if (isStreamError()) { + return Optional.of(((StreamErrorValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitTextGeneration(GenerateStreamText textGeneration); + + T visitStreamEnd(GenerateStreamEnd streamEnd); + + T visitStreamError(GenerateStreamError streamError); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "event_type", + visible = true, + defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(TextGenerationValue.class), + @JsonSubTypes.Type(StreamEndValue.class), + @JsonSubTypes.Type(StreamErrorValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("text-generation") + private static final class TextGenerationValue implements Value { + @JsonUnwrapped + private GenerateStreamText value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private TextGenerationValue() {} + + private TextGenerationValue(GenerateStreamText value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitTextGeneration(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TextGenerationValue && equalTo((TextGenerationValue) other); + } + + private boolean equalTo(TextGenerationValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "GenerateStreamedResponse{" + "value: " + value + "}"; + } + } + + @JsonTypeName("stream-end") + private static final class StreamEndValue implements Value { + @JsonUnwrapped + private GenerateStreamEnd value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private StreamEndValue() {} + + private StreamEndValue(GenerateStreamEnd value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitStreamEnd(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StreamEndValue && equalTo((StreamEndValue) other); + } + + private boolean equalTo(StreamEndValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "GenerateStreamedResponse{" + "value: " + value + "}"; + } + } + + @JsonTypeName("stream-error") + private static final class StreamErrorValue implements Value { + @JsonUnwrapped + private GenerateStreamError value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private StreamErrorValue() {} + + private StreamErrorValue(GenerateStreamError value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitStreamError(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StreamErrorValue && equalTo((StreamErrorValue) other); + } + + private boolean equalTo(StreamErrorValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "GenerateStreamedResponse{" + "value: " + value + "}"; + } + } + + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "GenerateStreamedResponse{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/cohere/api/types/Generation.java b/src/main/java/com/cohere/api/types/Generation.java index eb20a39..16d548f 100644 --- a/src/main/java/com/cohere/api/types/Generation.java +++ b/src/main/java/com/cohere/api/types/Generation.java @@ -71,7 +71,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof Generation && equalTo((Generation) other); @@ -89,12 +89,12 @@ private boolean equalTo(Generation other) { && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.prompt, this.generations, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -142,7 +142,7 @@ public static final class Builder implements IdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(Generation other) { id(other.getId()); prompt(other.getPrompt()); @@ -151,20 +151,20 @@ public Builder from(Generation other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public _FinalStage id(String id) { this.id = id; return this; } - @Override + @java.lang.Override public _FinalStage meta(ApiMeta meta) { this.meta = Optional.of(meta); return this; } - @Override + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Optional meta) { this.meta = meta; @@ -175,7 +175,7 @@ public _FinalStage meta(Optional meta) { *

List of generated results

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllGenerations(List generations) { this.generations.addAll(generations); return this; @@ -185,13 +185,13 @@ public _FinalStage addAllGenerations(List generations) { *

List of generated results

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addGenerations(SingleGeneration generations) { this.generations.add(generations); return this; } - @Override + @java.lang.Override @JsonSetter(value = "generations", nulls = Nulls.SKIP) public _FinalStage generations(List generations) { this.generations.clear(); @@ -203,20 +203,20 @@ public _FinalStage generations(List generations) { *

Prompt used for generations.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage prompt(String prompt) { this.prompt = Optional.of(prompt); return this; } - @Override + @java.lang.Override @JsonSetter(value = "prompt", nulls = Nulls.SKIP) public _FinalStage prompt(Optional prompt) { this.prompt = prompt; return this; } - @Override + @java.lang.Override public Generation build() { return new Generation(id, prompt, generations, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/GetResponse.java b/src/main/java/com/cohere/api/types/GetConnectorResponse.java similarity index 73% rename from src/main/java/com/cohere/api/types/GetResponse.java rename to src/main/java/com/cohere/api/types/GetConnectorResponse.java index 5b2e7fa..3727064 100644 --- a/src/main/java/com/cohere/api/types/GetResponse.java +++ b/src/main/java/com/cohere/api/types/GetConnectorResponse.java @@ -16,13 +16,13 @@ import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetResponse.Builder.class) -public final class GetResponse { +@JsonDeserialize(builder = GetConnectorResponse.Builder.class) +public final class GetConnectorResponse { private final Connector connector; private final Map additionalProperties; - private GetResponse(Connector connector, Map additionalProperties) { + private GetConnectorResponse(Connector connector, Map additionalProperties) { this.connector = connector; this.additionalProperties = additionalProperties; } @@ -32,10 +32,10 @@ public Connector getConnector() { return connector; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof GetResponse && equalTo((GetResponse) other); + return other instanceof GetConnectorResponse && equalTo((GetConnectorResponse) other); } @JsonAnyGetter @@ -43,16 +43,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(GetResponse other) { + private boolean equalTo(GetConnectorResponse other) { return connector.equals(other.connector); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.connector); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -64,11 +64,11 @@ public static ConnectorStage builder() { public interface ConnectorStage { _FinalStage connector(Connector connector); - Builder from(GetResponse other); + Builder from(GetConnectorResponse other); } public interface _FinalStage { - GetResponse build(); + GetConnectorResponse build(); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -80,22 +80,22 @@ public static final class Builder implements ConnectorStage, _FinalStage { private Builder() {} - @Override - public Builder from(GetResponse other) { + @java.lang.Override + public Builder from(GetConnectorResponse other) { connector(other.getConnector()); return this; } - @Override + @java.lang.Override @JsonSetter("connector") public _FinalStage connector(Connector connector) { this.connector = connector; return this; } - @Override - public GetResponse build() { - return new GetResponse(connector, additionalProperties); + @java.lang.Override + public GetConnectorResponse build() { + return new GetConnectorResponse(connector, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/IGenerateStreamEvent.java b/src/main/java/com/cohere/api/types/IGenerateStreamEvent.java new file mode 100644 index 0000000..d78cc89 --- /dev/null +++ b/src/main/java/com/cohere/api/types/IGenerateStreamEvent.java @@ -0,0 +1,6 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +public interface IGenerateStreamEvent {} diff --git a/src/main/java/com/cohere/api/types/ListResponse.java b/src/main/java/com/cohere/api/types/ListConnectorsResponse.java similarity index 60% rename from src/main/java/com/cohere/api/types/ListResponse.java rename to src/main/java/com/cohere/api/types/ListConnectorsResponse.java index 63fce2b..b441f1a 100644 --- a/src/main/java/com/cohere/api/types/ListResponse.java +++ b/src/main/java/com/cohere/api/types/ListConnectorsResponse.java @@ -17,16 +17,21 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListResponse.Builder.class) -public final class ListResponse { +@JsonDeserialize(builder = ListConnectorsResponse.Builder.class) +public final class ListConnectorsResponse { private final List connectors; + private final Optional totalCount; + private final Map additionalProperties; - private ListResponse(List connectors, Map additionalProperties) { + private ListConnectorsResponse( + List connectors, Optional totalCount, Map additionalProperties) { this.connectors = connectors; + this.totalCount = totalCount; this.additionalProperties = additionalProperties; } @@ -35,10 +40,18 @@ public List getConnectors() { return connectors; } - @Override + /** + * @return Total number of connectors. + */ + @JsonProperty("total_count") + public Optional getTotalCount() { + return totalCount; + } + + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ListResponse && equalTo((ListResponse) other); + return other instanceof ListConnectorsResponse && equalTo((ListConnectorsResponse) other); } @JsonAnyGetter @@ -46,16 +59,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ListResponse other) { - return connectors.equals(other.connectors); + private boolean equalTo(ListConnectorsResponse other) { + return connectors.equals(other.connectors) && totalCount.equals(other.totalCount); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.connectors); + return Objects.hash(this.connectors, this.totalCount); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -68,13 +81,16 @@ public static Builder builder() { public static final class Builder { private List connectors = new ArrayList<>(); + private Optional totalCount = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(ListResponse other) { + public Builder from(ListConnectorsResponse other) { connectors(other.getConnectors()); + totalCount(other.getTotalCount()); return this; } @@ -95,8 +111,19 @@ public Builder addAllConnectors(List connectors) { return this; } - public ListResponse build() { - return new ListResponse(connectors, additionalProperties); + @JsonSetter(value = "total_count", nulls = Nulls.SKIP) + public Builder totalCount(Optional totalCount) { + this.totalCount = totalCount; + return this; + } + + public Builder totalCount(Double totalCount) { + this.totalCount = Optional.of(totalCount); + return this; + } + + public ListConnectorsResponse build() { + return new ListConnectorsResponse(connectors, totalCount, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ListEmbedJobResponse.java b/src/main/java/com/cohere/api/types/ListEmbedJobResponse.java new file mode 100644 index 0000000..be125fc --- /dev/null +++ b/src/main/java/com/cohere/api/types/ListEmbedJobResponse.java @@ -0,0 +1,96 @@ +/** + * 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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ListEmbedJobResponse.Builder.class) +public final class ListEmbedJobResponse { + private final Optional> embedJobs; + + private final Map additionalProperties; + + private ListEmbedJobResponse(Optional> embedJobs, Map additionalProperties) { + this.embedJobs = embedJobs; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("embed_jobs") + public Optional> getEmbedJobs() { + return embedJobs; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListEmbedJobResponse && equalTo((ListEmbedJobResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListEmbedJobResponse other) { + return embedJobs.equals(other.embedJobs); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.embedJobs); + } + + @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> embedJobs = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListEmbedJobResponse other) { + embedJobs(other.getEmbedJobs()); + return this; + } + + @JsonSetter(value = "embed_jobs", nulls = Nulls.SKIP) + public Builder embedJobs(Optional> embedJobs) { + this.embedJobs = embedJobs; + return this; + } + + public Builder embedJobs(List embedJobs) { + this.embedJobs = Optional.of(embedJobs); + return this; + } + + public ListEmbedJobResponse build() { + return new ListEmbedJobResponse(embedJobs, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/NonStreamedChatResponse.java b/src/main/java/com/cohere/api/types/NonStreamedChatResponse.java index 579243b..ba6d1eb 100644 --- a/src/main/java/com/cohere/api/types/NonStreamedChatResponse.java +++ b/src/main/java/com/cohere/api/types/NonStreamedChatResponse.java @@ -23,32 +23,40 @@ public final class NonStreamedChatResponse { private final String text; - private final String generationId; + private final Optional generationId; private final Optional> citations; private final Optional>> documents; + private final Optional isSearchRequired; + private final Optional> searchQueries; private final Optional> searchResults; + private final Optional finishReason; + private final Map additionalProperties; private NonStreamedChatResponse( String text, - String generationId, + Optional generationId, Optional> citations, Optional>> documents, + Optional isSearchRequired, Optional> searchQueries, Optional> searchResults, + Optional finishReason, Map additionalProperties) { this.text = text; this.generationId = generationId; this.citations = citations; this.documents = documents; + this.isSearchRequired = isSearchRequired; this.searchQueries = searchQueries; this.searchResults = searchResults; + this.finishReason = finishReason; this.additionalProperties = additionalProperties; } @@ -64,7 +72,7 @@ public String getText() { * @return Unique identifier for the generated reply. Useful for submitting feedback. */ @JsonProperty("generation_id") - public String getGenerationId() { + public Optional getGenerationId() { return generationId; } @@ -84,6 +92,14 @@ public Optional>> getDocuments() { return documents; } + /** + * @return Denotes that a search for documents is required during the RAG flow. + */ + @JsonProperty("is_search_required") + public Optional getIsSearchRequired() { + return isSearchRequired; + } + /** * @return Generated search queries, meant to be used as part of the RAG flow. */ @@ -100,7 +116,12 @@ public Optional> getSearchResults() { return searchResults; } - @Override + @JsonProperty("finish_reason") + public Optional getFinishReason() { + return finishReason; + } + + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof NonStreamedChatResponse && equalTo((NonStreamedChatResponse) other); @@ -116,17 +137,26 @@ private boolean equalTo(NonStreamedChatResponse other) { && generationId.equals(other.generationId) && citations.equals(other.citations) && documents.equals(other.documents) + && isSearchRequired.equals(other.isSearchRequired) && searchQueries.equals(other.searchQueries) - && searchResults.equals(other.searchResults); + && searchResults.equals(other.searchResults) + && finishReason.equals(other.finishReason); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( - this.text, this.generationId, this.citations, this.documents, this.searchQueries, this.searchResults); + this.text, + this.generationId, + this.citations, + this.documents, + this.isSearchRequired, + this.searchQueries, + this.searchResults, + this.finishReason); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -136,18 +166,18 @@ public static TextStage builder() { } public interface TextStage { - GenerationIdStage text(String text); + _FinalStage text(String text); Builder from(NonStreamedChatResponse other); } - public interface GenerationIdStage { - _FinalStage generationId(String generationId); - } - public interface _FinalStage { NonStreamedChatResponse build(); + _FinalStage generationId(Optional generationId); + + _FinalStage generationId(String generationId); + _FinalStage citations(Optional> citations); _FinalStage citations(List citations); @@ -156,6 +186,10 @@ public interface _FinalStage { _FinalStage documents(List> documents); + _FinalStage isSearchRequired(Optional isSearchRequired); + + _FinalStage isSearchRequired(Boolean isSearchRequired); + _FinalStage searchQueries(Optional> searchQueries); _FinalStage searchQueries(List searchQueries); @@ -163,35 +197,45 @@ public interface _FinalStage { _FinalStage searchResults(Optional> searchResults); _FinalStage searchResults(List searchResults); + + _FinalStage finishReason(Optional finishReason); + + _FinalStage finishReason(FinishReason finishReason); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TextStage, GenerationIdStage, _FinalStage { + public static final class Builder implements TextStage, _FinalStage { private String text; - private String generationId; + private Optional finishReason = Optional.empty(); private Optional> searchResults = Optional.empty(); private Optional> searchQueries = Optional.empty(); + private Optional isSearchRequired = Optional.empty(); + private Optional>> documents = Optional.empty(); private Optional> citations = Optional.empty(); + private Optional generationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @Override + @java.lang.Override public Builder from(NonStreamedChatResponse other) { text(other.getText()); generationId(other.getGenerationId()); citations(other.getCitations()); documents(other.getDocuments()); + isSearchRequired(other.getIsSearchRequired()); searchQueries(other.getSearchQueries()); searchResults(other.getSearchResults()); + finishReason(other.getFinishReason()); return this; } @@ -199,21 +243,23 @@ public Builder from(NonStreamedChatResponse other) { *

Contents of the reply generated by the model.

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

Unique identifier for the generated reply. Useful for submitting feedback.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("generation_id") - public _FinalStage generationId(String generationId) { - this.generationId = generationId; + @java.lang.Override + public _FinalStage finishReason(FinishReason finishReason) { + this.finishReason = Optional.of(finishReason); + return this; + } + + @java.lang.Override + @JsonSetter(value = "finish_reason", nulls = Nulls.SKIP) + public _FinalStage finishReason(Optional finishReason) { + this.finishReason = finishReason; return this; } @@ -221,13 +267,13 @@ public _FinalStage generationId(String generationId) { *

Documents retrieved from each of the conducted searches.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage searchResults(List searchResults) { this.searchResults = Optional.of(searchResults); return this; } - @Override + @java.lang.Override @JsonSetter(value = "search_results", nulls = Nulls.SKIP) public _FinalStage searchResults(Optional> searchResults) { this.searchResults = searchResults; @@ -238,30 +284,47 @@ public _FinalStage searchResults(Optional> searchResults) *

Generated search queries, meant to be used as part of the RAG flow.

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

Denotes that a search for documents is required during the RAG flow.

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

Documents seen by the model when generating the reply.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage documents(List> documents) { this.documents = Optional.of(documents); return this; } - @Override + @java.lang.Override @JsonSetter(value = "documents", nulls = Nulls.SKIP) public _FinalStage documents(Optional>> documents) { this.documents = documents; @@ -272,23 +335,48 @@ public _FinalStage documents(Optional>> documents) { *

Inline citations for the generated reply.

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

Unique identifier for the generated reply. Useful for submitting feedback.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage generationId(String generationId) { + this.generationId = Optional.of(generationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "generation_id", nulls = Nulls.SKIP) + public _FinalStage generationId(Optional generationId) { + this.generationId = generationId; + return this; + } + + @java.lang.Override public NonStreamedChatResponse build() { return new NonStreamedChatResponse( - text, generationId, citations, documents, searchQueries, searchResults, additionalProperties); + text, + generationId, + citations, + documents, + isSearchRequired, + searchQueries, + searchResults, + finishReason, + additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/OAuthAuthorizeResponse.java b/src/main/java/com/cohere/api/types/OAuthAuthorizeResponse.java index 9abedfa..b46c99e 100644 --- a/src/main/java/com/cohere/api/types/OAuthAuthorizeResponse.java +++ b/src/main/java/com/cohere/api/types/OAuthAuthorizeResponse.java @@ -37,7 +37,7 @@ public Optional getRedirectUrl() { return redirectUrl; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof OAuthAuthorizeResponse && equalTo((OAuthAuthorizeResponse) other); @@ -52,12 +52,12 @@ private boolean equalTo(OAuthAuthorizeResponse other) { return redirectUrl.equals(other.redirectUrl); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.redirectUrl); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/ParseInfo.java b/src/main/java/com/cohere/api/types/ParseInfo.java new file mode 100644 index 0000000..b1045db --- /dev/null +++ b/src/main/java/com/cohere/api/types/ParseInfo.java @@ -0,0 +1,118 @@ +/** + * 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 = ParseInfo.Builder.class) +public final class ParseInfo { + private final Optional separator; + + private final Optional delimiter; + + private final Map additionalProperties; + + private ParseInfo( + Optional separator, Optional delimiter, Map additionalProperties) { + this.separator = separator; + this.delimiter = delimiter; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("separator") + public Optional getSeparator() { + return separator; + } + + @JsonProperty("delimiter") + public Optional getDelimiter() { + return delimiter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ParseInfo && equalTo((ParseInfo) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ParseInfo other) { + return separator.equals(other.separator) && delimiter.equals(other.delimiter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.separator, this.delimiter); + } + + @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 separator = Optional.empty(); + + private Optional delimiter = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ParseInfo other) { + separator(other.getSeparator()); + delimiter(other.getDelimiter()); + return this; + } + + @JsonSetter(value = "separator", nulls = Nulls.SKIP) + public Builder separator(Optional separator) { + this.separator = separator; + return this; + } + + public Builder separator(String separator) { + this.separator = Optional.of(separator); + return this; + } + + @JsonSetter(value = "delimiter", nulls = Nulls.SKIP) + public Builder delimiter(Optional delimiter) { + this.delimiter = delimiter; + return this; + } + + public Builder delimiter(String delimiter) { + this.delimiter = Optional.of(delimiter); + return this; + } + + public ParseInfo build() { + return new ParseInfo(separator, delimiter, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/RerankRequestDocumentsItem.java b/src/main/java/com/cohere/api/types/RerankRequestDocumentsItem.java index a92da20..91aed13 100644 --- a/src/main/java/com/cohere/api/types/RerankRequestDocumentsItem.java +++ b/src/main/java/com/cohere/api/types/RerankRequestDocumentsItem.java @@ -38,7 +38,7 @@ public T visit(Visitor visitor) { throw new IllegalStateException("Failed to visit value. This should never happen."); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankRequestDocumentsItem && equalTo((RerankRequestDocumentsItem) other); @@ -48,12 +48,12 @@ private boolean equalTo(RerankRequestDocumentsItem other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return this.value.toString(); } @@ -77,7 +77,7 @@ static final class Deserializer extends StdDeserializerThe text of the document to rerank.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; return this; } - @Override + @java.lang.Override public RerankRequestDocumentsItemText build() { return new RerankRequestDocumentsItemText(text, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/RerankResponse.java b/src/main/java/com/cohere/api/types/RerankResponse.java index 19ecc1e..303e0ae 100644 --- a/src/main/java/com/cohere/api/types/RerankResponse.java +++ b/src/main/java/com/cohere/api/types/RerankResponse.java @@ -59,7 +59,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankResponse && equalTo((RerankResponse) other); @@ -74,12 +74,12 @@ private boolean equalTo(RerankResponse other) { return id.equals(other.id) && results.equals(other.results) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.results, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/RerankResponseResultsItem.java b/src/main/java/com/cohere/api/types/RerankResponseResultsItem.java index bdaf1e3..e32fe3b 100644 --- a/src/main/java/com/cohere/api/types/RerankResponseResultsItem.java +++ b/src/main/java/com/cohere/api/types/RerankResponseResultsItem.java @@ -63,7 +63,7 @@ public double getRelevanceScore() { return relevanceScore; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankResponseResultsItem && equalTo((RerankResponseResultsItem) other); @@ -78,12 +78,12 @@ private boolean equalTo(RerankResponseResultsItem other) { return document.equals(other.document) && index == other.index && relevanceScore == other.relevanceScore; } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.document, this.index, this.relevanceScore); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -123,7 +123,7 @@ public static final class Builder implements IndexStage, RelevanceScoreStage, _F private Builder() {} - @Override + @java.lang.Override public Builder from(RerankResponseResultsItem other) { document(other.getDocument()); index(other.getIndex()); @@ -135,7 +135,7 @@ public Builder from(RerankResponseResultsItem other) { *

The index of the input document

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("index") public RelevanceScoreStage index(int index) { this.index = index; @@ -146,7 +146,7 @@ public RelevanceScoreStage index(int index) { *

A relevance score assigned to the ranking

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("relevance_score") public _FinalStage relevanceScore(double relevanceScore) { this.relevanceScore = relevanceScore; @@ -157,20 +157,20 @@ public _FinalStage relevanceScore(double relevanceScore) { *

The doc object which was ranked

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage document(RerankResponseResultsItemDocument document) { this.document = Optional.of(document); return this; } - @Override + @java.lang.Override @JsonSetter(value = "document", nulls = Nulls.SKIP) public _FinalStage document(Optional document) { this.document = document; return this; } - @Override + @java.lang.Override public RerankResponseResultsItem build() { return new RerankResponseResultsItem(document, index, relevanceScore, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/RerankResponseResultsItemDocument.java b/src/main/java/com/cohere/api/types/RerankResponseResultsItemDocument.java index 7bde141..35fc243 100644 --- a/src/main/java/com/cohere/api/types/RerankResponseResultsItemDocument.java +++ b/src/main/java/com/cohere/api/types/RerankResponseResultsItemDocument.java @@ -35,7 +35,7 @@ public String getText() { return text; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankResponseResultsItemDocument && equalTo((RerankResponseResultsItemDocument) other); @@ -50,12 +50,12 @@ private boolean equalTo(RerankResponseResultsItemDocument other) { return text.equals(other.text); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -83,7 +83,7 @@ public static final class Builder implements TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(RerankResponseResultsItemDocument other) { text(other.getText()); return this; @@ -93,14 +93,14 @@ public Builder from(RerankResponseResultsItemDocument other) { *

The text of the document to rerank

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; return this; } - @Override + @java.lang.Override public RerankResponseResultsItemDocument build() { return new RerankResponseResultsItemDocument(text, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/SearchQueriesOnlyResponse.java b/src/main/java/com/cohere/api/types/SearchQueriesOnlyResponse.java deleted file mode 100644 index 735e470..0000000 --- a/src/main/java/com/cohere/api/types/SearchQueriesOnlyResponse.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.cohere.api.types; - -import com.cohere.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SearchQueriesOnlyResponse.Builder.class) -public final class SearchQueriesOnlyResponse { - private final List searchQueries; - - private final Map additionalProperties; - - private SearchQueriesOnlyResponse(List searchQueries, Map additionalProperties) { - this.searchQueries = searchQueries; - this.additionalProperties = additionalProperties; - } - - /** - * @return Generated search queries, meant to be used as part of the RAG flow. - */ - @JsonProperty("search_queries") - public List getSearchQueries() { - return searchQueries; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SearchQueriesOnlyResponse && equalTo((SearchQueriesOnlyResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SearchQueriesOnlyResponse other) { - return searchQueries.equals(other.searchQueries); - } - - @Override - public int hashCode() { - return Objects.hash(this.searchQueries); - } - - @Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List searchQueries = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SearchQueriesOnlyResponse other) { - searchQueries(other.getSearchQueries()); - return this; - } - - @JsonSetter(value = "search_queries", nulls = Nulls.SKIP) - public Builder searchQueries(List searchQueries) { - this.searchQueries.clear(); - this.searchQueries.addAll(searchQueries); - return this; - } - - public Builder addSearchQueries(ChatSearchQuery searchQueries) { - this.searchQueries.add(searchQueries); - return this; - } - - public Builder addAllSearchQueries(List searchQueries) { - this.searchQueries.addAll(searchQueries); - return this; - } - - public SearchQueriesOnlyResponse build() { - return new SearchQueriesOnlyResponse(searchQueries, additionalProperties); - } - } -} diff --git a/src/main/java/com/cohere/api/types/SingleGeneration.java b/src/main/java/com/cohere/api/types/SingleGeneration.java index cd66282..6bd9158 100644 --- a/src/main/java/com/cohere/api/types/SingleGeneration.java +++ b/src/main/java/com/cohere/api/types/SingleGeneration.java @@ -79,7 +79,7 @@ public Optional> getTokenLikelihoods( return tokenLikelihoods; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SingleGeneration && equalTo((SingleGeneration) other); @@ -98,12 +98,12 @@ private boolean equalTo(SingleGeneration other) { && tokenLikelihoods.equals(other.tokenLikelihoods); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.text, this.index, this.likelihood, this.tokenLikelihoods); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -155,7 +155,7 @@ public static final class Builder implements IdStage, TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(SingleGeneration other) { id(other.getId()); text(other.getText()); @@ -165,14 +165,14 @@ public Builder from(SingleGeneration other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public TextStage id(String id) { this.id = id; return this; } - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; @@ -183,26 +183,26 @@ public _FinalStage text(String text) { *

Only returned if return_likelihoods is set to GENERATION or ALL. The likelihood refers to the average log-likelihood of the entire specified string, which is useful for evaluating the performance of your model, especially if you've created a custom model. Individual token likelihoods provide the log-likelihood of each token. The first token will not have a likelihood.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage tokenLikelihoods(List tokenLikelihoods) { this.tokenLikelihoods = Optional.of(tokenLikelihoods); return this; } - @Override + @java.lang.Override @JsonSetter(value = "token_likelihoods", nulls = Nulls.SKIP) public _FinalStage tokenLikelihoods(Optional> tokenLikelihoods) { this.tokenLikelihoods = tokenLikelihoods; return this; } - @Override + @java.lang.Override public _FinalStage likelihood(Double likelihood) { this.likelihood = Optional.of(likelihood); return this; } - @Override + @java.lang.Override @JsonSetter(value = "likelihood", nulls = Nulls.SKIP) public _FinalStage likelihood(Optional likelihood) { this.likelihood = likelihood; @@ -213,20 +213,20 @@ public _FinalStage likelihood(Optional likelihood) { *

Refers to the nth generation. Only present when num_generations is greater than zero.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage index(Integer index) { this.index = Optional.of(index); return this; } - @Override + @java.lang.Override @JsonSetter(value = "index", nulls = Nulls.SKIP) public _FinalStage index(Optional index) { this.index = index; return this; } - @Override + @java.lang.Override public SingleGeneration build() { return new SingleGeneration(id, text, index, likelihood, tokenLikelihoods, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/SingleGenerationInStream.java b/src/main/java/com/cohere/api/types/SingleGenerationInStream.java new file mode 100644 index 0000000..15829d9 --- /dev/null +++ b/src/main/java/com/cohere/api/types/SingleGenerationInStream.java @@ -0,0 +1,197 @@ +/** + * 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 = SingleGenerationInStream.Builder.class) +public final class SingleGenerationInStream { + private final String id; + + private final String text; + + private final Optional index; + + private final FinishReason finishReason; + + private final Map additionalProperties; + + private SingleGenerationInStream( + String id, + String text, + Optional index, + FinishReason finishReason, + Map additionalProperties) { + this.id = id; + this.text = text; + this.index = index; + this.finishReason = finishReason; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return Full text of the generation. + */ + @JsonProperty("text") + public String getText() { + return text; + } + + /** + * @return Refers to the nth generation. Only present when num_generations is greater than zero. + */ + @JsonProperty("index") + public Optional getIndex() { + return index; + } + + @JsonProperty("finish_reason") + public FinishReason getFinishReason() { + return finishReason; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SingleGenerationInStream && equalTo((SingleGenerationInStream) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SingleGenerationInStream other) { + return id.equals(other.id) + && text.equals(other.text) + && index.equals(other.index) + && finishReason.equals(other.finishReason); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.text, this.index, this.finishReason); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + TextStage id(String id); + + Builder from(SingleGenerationInStream other); + } + + public interface TextStage { + FinishReasonStage text(String text); + } + + public interface FinishReasonStage { + _FinalStage finishReason(FinishReason finishReason); + } + + public interface _FinalStage { + SingleGenerationInStream build(); + + _FinalStage index(Optional index); + + _FinalStage index(Integer index); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, TextStage, FinishReasonStage, _FinalStage { + private String id; + + private String text; + + private FinishReason finishReason; + + private Optional index = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SingleGenerationInStream other) { + id(other.getId()); + text(other.getText()); + index(other.getIndex()); + finishReason(other.getFinishReason()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public TextStage id(String id) { + this.id = id; + return this; + } + + /** + *

Full text of the generation.

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

Refers to the nth generation. Only present when num_generations is greater than zero.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage index(Integer index) { + this.index = Optional.of(index); + return this; + } + + @java.lang.Override + @JsonSetter(value = "index", nulls = Nulls.SKIP) + public _FinalStage index(Optional index) { + this.index = index; + return this; + } + + @java.lang.Override + public SingleGenerationInStream build() { + return new SingleGenerationInStream(id, text, index, finishReason, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/SingleGenerationTokenLikelihoodsItem.java b/src/main/java/com/cohere/api/types/SingleGenerationTokenLikelihoodsItem.java index 1699a36..512ab9e 100644 --- a/src/main/java/com/cohere/api/types/SingleGenerationTokenLikelihoodsItem.java +++ b/src/main/java/com/cohere/api/types/SingleGenerationTokenLikelihoodsItem.java @@ -41,7 +41,7 @@ public double getLikelihood() { return likelihood; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SingleGenerationTokenLikelihoodsItem @@ -57,12 +57,12 @@ private boolean equalTo(SingleGenerationTokenLikelihoodsItem other) { return token.equals(other.token) && likelihood == other.likelihood; } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.token, this.likelihood); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -96,28 +96,28 @@ public static final class Builder implements TokenStage, LikelihoodStage, _Final private Builder() {} - @Override + @java.lang.Override public Builder from(SingleGenerationTokenLikelihoodsItem other) { token(other.getToken()); likelihood(other.getLikelihood()); return this; } - @Override + @java.lang.Override @JsonSetter("token") public LikelihoodStage token(String token) { this.token = token; return this; } - @Override + @java.lang.Override @JsonSetter("likelihood") public _FinalStage likelihood(double likelihood) { this.likelihood = likelihood; return this; } - @Override + @java.lang.Override public SingleGenerationTokenLikelihoodsItem build() { return new SingleGenerationTokenLikelihoodsItem(token, likelihood, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/StreamedChatResponse.java b/src/main/java/com/cohere/api/types/StreamedChatResponse.java index 6fb6ff8..749ba78 100644 --- a/src/main/java/com/cohere/api/types/StreamedChatResponse.java +++ b/src/main/java/com/cohere/api/types/StreamedChatResponse.java @@ -178,12 +178,12 @@ private StreamStartValue(ChatStreamStartEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitStreamStart(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof StreamStartValue && equalTo((StreamStartValue) other); @@ -193,12 +193,12 @@ private boolean equalTo(StreamStartValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -216,12 +216,12 @@ private SearchQueriesGenerationValue(ChatSearchQueriesGenerationEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitSearchQueriesGeneration(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SearchQueriesGenerationValue && equalTo((SearchQueriesGenerationValue) other); @@ -231,12 +231,12 @@ private boolean equalTo(SearchQueriesGenerationValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -254,12 +254,12 @@ private SearchResultsValue(ChatSearchResultsEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitSearchResults(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SearchResultsValue && equalTo((SearchResultsValue) other); @@ -269,12 +269,12 @@ private boolean equalTo(SearchResultsValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -292,12 +292,12 @@ private TextGenerationValue(ChatTextGenerationEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitTextGeneration(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof TextGenerationValue && equalTo((TextGenerationValue) other); @@ -307,12 +307,12 @@ private boolean equalTo(TextGenerationValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -330,12 +330,12 @@ private CitationGenerationValue(ChatCitationGenerationEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitCitationGeneration(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof CitationGenerationValue && equalTo((CitationGenerationValue) other); @@ -345,12 +345,12 @@ private boolean equalTo(CitationGenerationValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -368,12 +368,12 @@ private StreamEndValue(ChatStreamEndEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitStreamEnd(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof StreamEndValue && equalTo((StreamEndValue) other); @@ -383,12 +383,12 @@ private boolean equalTo(StreamEndValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -403,12 +403,12 @@ private static final class _UnknownValue implements Value { @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) private _UnknownValue(@JsonProperty("value") Object value) {} - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor._visitUnknown(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof _UnknownValue && equalTo((_UnknownValue) other); @@ -418,12 +418,12 @@ private boolean equalTo(_UnknownValue other) { return type.equals(other.type) && value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.type, this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "type: " + type + ", value: " + value + "}"; } diff --git a/src/main/java/com/cohere/api/types/SummarizeRequestExtractiveness.java b/src/main/java/com/cohere/api/types/SummarizeRequestExtractiveness.java index ff2a6b7..cad2968 100644 --- a/src/main/java/com/cohere/api/types/SummarizeRequestExtractiveness.java +++ b/src/main/java/com/cohere/api/types/SummarizeRequestExtractiveness.java @@ -19,7 +19,7 @@ public enum SummarizeRequestExtractiveness { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/SummarizeRequestFormat.java b/src/main/java/com/cohere/api/types/SummarizeRequestFormat.java index ab3aa6c..8be83d8 100644 --- a/src/main/java/com/cohere/api/types/SummarizeRequestFormat.java +++ b/src/main/java/com/cohere/api/types/SummarizeRequestFormat.java @@ -17,7 +17,7 @@ public enum SummarizeRequestFormat { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/SummarizeRequestLength.java b/src/main/java/com/cohere/api/types/SummarizeRequestLength.java index a62850d..fd552e2 100644 --- a/src/main/java/com/cohere/api/types/SummarizeRequestLength.java +++ b/src/main/java/com/cohere/api/types/SummarizeRequestLength.java @@ -19,7 +19,7 @@ public enum SummarizeRequestLength { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/SummarizeResponse.java b/src/main/java/com/cohere/api/types/SummarizeResponse.java index f999fad..32a2d8b 100644 --- a/src/main/java/com/cohere/api/types/SummarizeResponse.java +++ b/src/main/java/com/cohere/api/types/SummarizeResponse.java @@ -60,7 +60,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SummarizeResponse && equalTo((SummarizeResponse) other); @@ -75,12 +75,12 @@ private boolean equalTo(SummarizeResponse other) { return id.equals(other.id) && summary.equals(other.summary) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.summary, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/TokenizeResponse.java b/src/main/java/com/cohere/api/types/TokenizeResponse.java index 6e51495..66aeed9 100644 --- a/src/main/java/com/cohere/api/types/TokenizeResponse.java +++ b/src/main/java/com/cohere/api/types/TokenizeResponse.java @@ -59,7 +59,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof TokenizeResponse && equalTo((TokenizeResponse) other); @@ -74,12 +74,12 @@ private boolean equalTo(TokenizeResponse other) { return tokens.equals(other.tokens) && tokenStrings.equals(other.tokenStrings) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.tokens, this.tokenStrings, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/UpdateResponse.java b/src/main/java/com/cohere/api/types/UpdateConnectorResponse.java similarity index 72% rename from src/main/java/com/cohere/api/types/UpdateResponse.java rename to src/main/java/com/cohere/api/types/UpdateConnectorResponse.java index 4000622..7bb1f56 100644 --- a/src/main/java/com/cohere/api/types/UpdateResponse.java +++ b/src/main/java/com/cohere/api/types/UpdateConnectorResponse.java @@ -16,13 +16,13 @@ import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UpdateResponse.Builder.class) -public final class UpdateResponse { +@JsonDeserialize(builder = UpdateConnectorResponse.Builder.class) +public final class UpdateConnectorResponse { private final Connector connector; private final Map additionalProperties; - private UpdateResponse(Connector connector, Map additionalProperties) { + private UpdateConnectorResponse(Connector connector, Map additionalProperties) { this.connector = connector; this.additionalProperties = additionalProperties; } @@ -32,10 +32,10 @@ public Connector getConnector() { return connector; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof UpdateResponse && equalTo((UpdateResponse) other); + return other instanceof UpdateConnectorResponse && equalTo((UpdateConnectorResponse) other); } @JsonAnyGetter @@ -43,16 +43,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(UpdateResponse other) { + private boolean equalTo(UpdateConnectorResponse other) { return connector.equals(other.connector); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.connector); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -64,11 +64,11 @@ public static ConnectorStage builder() { public interface ConnectorStage { _FinalStage connector(Connector connector); - Builder from(UpdateResponse other); + Builder from(UpdateConnectorResponse other); } public interface _FinalStage { - UpdateResponse build(); + UpdateConnectorResponse build(); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -80,22 +80,22 @@ public static final class Builder implements ConnectorStage, _FinalStage { private Builder() {} - @Override - public Builder from(UpdateResponse other) { + @java.lang.Override + public Builder from(UpdateConnectorResponse other) { connector(other.getConnector()); return this; } - @Override + @java.lang.Override @JsonSetter("connector") public _FinalStage connector(Connector connector) { this.connector = connector; return this; } - @Override - public UpdateResponse build() { - return new UpdateResponse(connector, additionalProperties); + @java.lang.Override + public UpdateConnectorResponse build() { + return new UpdateConnectorResponse(connector, additionalProperties); } } }