From 09e86056ca05b0fe2be5e56107707cbb3cdbaf9c Mon Sep 17 00:00:00 2001
From: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
Date: Tue, 20 Feb 2024 16:37:12 +0000
Subject: [PATCH] SDK regeneration
---
build.gradle | 4 +-
src/main/java/com/cohere/api/Cohere.java | 134 ++--
.../java/com/cohere/api/CohereBuilder.java | 25 +-
.../java/com/cohere/api/core/ApiError.java | 2 +-
.../com/cohere/api/core/ClientOptions.java | 2 +-
.../java/com/cohere/api/core/MediaTypes.java | 13 +
.../com/cohere/api/core/RequestOptions.java | 17 +-
.../com/cohere/api/requests/ChatRequest.java | 334 +++++++--
.../api/requests/ChatStreamRequest.java | 334 +++++++--
.../cohere/api/requests/ClassifyRequest.java | 30 +-
.../api/requests/DetectLanguageRequest.java | 132 ----
.../api/requests/DetokenizeRequest.java | 6 +-
.../com/cohere/api/requests/EmbedRequest.java | 41 +-
.../cohere/api/requests/GenerateRequest.java | 178 ++---
.../api/requests/GenerateStreamRequest.java | 699 ++++++++++++++++++
.../cohere/api/requests/RerankRequest.java | 34 +-
.../cohere/api/requests/SummarizeRequest.java | 36 +-
.../cohere/api/requests/TokenizeRequest.java | 16 +-
.../connectors/ConnectorsClient.java | 112 +--
.../requests/ConnectorsListRequest.java | 6 +-
.../ConnectorsOAuthAuthorizeRequest.java | 99 +++
...quest.java => CreateConnectorRequest.java} | 58 +-
...quest.java => UpdateConnectorRequest.java} | 22 +-
.../resources/datasets/DatasetsClient.java | 277 +++++++
.../requests/DatasetsCreateRequest.java | 307 ++++++++
.../requests/DatasetsListRequest.java | 209 ++++++
.../types/DatasetsCreateResponse.java | 98 +++
.../datasets/types/DatasetsGetResponse.java | 102 +++
.../types/DatasetsGetUsageResponse.java | 98 +++
.../datasets/types/DatasetsListResponse.java | 97 +++
.../resources/embedjobs/EmbedJobsClient.java | 177 +++++
.../requests/CreateEmbedJobRequest.java | 259 +++++++
.../types/CreateEmbedJobRequestTruncate.java | 24 +
.../java/com/cohere/api/types/ApiMeta.java | 37 +-
.../cohere/api/types/ApiMetaApiVersion.java | 56 +-
...lledUnits.java => ApiMetaBilledUnits.java} | 22 +-
.../com/cohere/api/types/AuthTokenType.java | 26 +
.../com/cohere/api/types/ChatCitation.java | 22 +-
.../types/ChatCitationGenerationEvent.java | 6 +-
.../com/cohere/api/types/ChatConnector.java | 28 +-
.../com/cohere/api/types/ChatMessage.java | 18 +-
.../com/cohere/api/types/ChatMessageRole.java | 2 +-
.../api/types/ChatRequestCitationQuality.java | 2 +-
.../api/types/ChatRequestPromptOverride.java | 145 ++++
.../types/ChatRequestPromptTruncation.java | 2 +-
.../api/types/ChatRequestSearchOptions.java | 196 +++++
.../ChatSearchQueriesGenerationEvent.java | 6 +-
.../com/cohere/api/types/ChatSearchQuery.java | 14 +-
.../cohere/api/types/ChatSearchResult.java | 32 +-
.../api/types/ChatSearchResultConnector.java | 108 +++
.../api/types/ChatSearchResultsEvent.java | 6 +-
.../cohere/api/types/ChatStreamEndEvent.java | 26 +-
.../types/ChatStreamEndEventFinishReason.java | 2 +-
.../api/types/ChatStreamEndEventResponse.java | 94 ---
.../com/cohere/api/types/ChatStreamEvent.java | 4 +-
.../ChatStreamRequestCitationQuality.java | 2 +-
.../ChatStreamRequestPromptOverride.java | 145 ++++
.../ChatStreamRequestPromptTruncation.java | 2 +-
.../types/ChatStreamRequestSearchOptions.java | 197 +++++
.../api/types/ChatStreamStartEvent.java | 12 +-
.../api/types/ChatTextGenerationEvent.java | 12 +-
...ExamplesItem.java => ClassifyExample.java} | 23 +-
.../api/types/ClassifyRequestTruncate.java | 2 +-
.../cohere/api/types/ClassifyResponse.java | 22 +-
.../ClassifyResponseClassificationsItem.java | 44 +-
...ClassificationsItemClassificationType.java | 2 +-
...esponseClassificationsItemLabelsValue.java | 6 +-
.../java/com/cohere/api/types/Connector.java | 54 +-
.../cohere/api/types/ConnectorAuthStatus.java | 2 +-
.../com/cohere/api/types/ConnectorOAuth.java | 166 ++++-
.../api/types/CreateConnectorOAuth.java | 147 ++--
...onse.java => CreateConnectorResponse.java} | 32 +-
.../api/types/CreateConnectorServiceAuth.java | 33 +-
...ponse.java => CreateEmbedJobResponse.java} | 87 ++-
.../java/com/cohere/api/types/Dataset.java | 495 +++++++++++++
.../com/cohere/api/types/DatasetPart.java | 328 ++++++++
.../com/cohere/api/types/DatasetType.java | 38 +
.../api/types/DatasetValidationStatus.java | 32 +
.../DetectLanguageResponseResultsItem.java | 118 ---
.../cohere/api/types/DetokenizeResponse.java | 16 +-
.../cohere/api/types/EmbedByTypeResponse.java | 24 +-
.../types/EmbedByTypeResponseEmbeddings.java | 6 +-
.../cohere/api/types/EmbedFloatsResponse.java | 28 +-
.../com/cohere/api/types/EmbedInputType.java | 28 +
.../java/com/cohere/api/types/EmbedJob.java | 398 ++++++++++
.../com/cohere/api/types/EmbedJobStatus.java | 30 +
.../cohere/api/types/EmbedJobTruncate.java | 24 +
.../types/EmbedRequestEmbeddingTypesItem.java | 30 +
.../api/types/EmbedRequestTruncate.java | 2 +-
.../com/cohere/api/types/EmbedResponse.java | 24 +-
.../com/cohere/api/types/FinishReason.java | 32 +
.../GenerateRequestReturnLikelihoods.java | 2 +-
.../api/types/GenerateRequestTruncate.java | 2 +-
.../cohere/api/types/GenerateStreamEnd.java | 159 ++++
.../api/types/GenerateStreamEndResponse.java | 164 ++++
.../cohere/api/types/GenerateStreamError.java | 197 +++++
.../cohere/api/types/GenerateStreamEvent.java | 32 +
...enerateStreamRequestReturnLikelihoods.java | 26 +
.../types/GenerateStreamRequestTruncate.java | 26 +
.../cohere/api/types/GenerateStreamText.java | 168 +++++
.../api/types/GenerateStreamedResponse.java | 263 +++++++
.../java/com/cohere/api/types/Generation.java | 26 +-
...esponse.java => GetConnectorResponse.java} | 32 +-
.../api/types/IGenerateStreamEvent.java | 6 +
...ponse.java => ListConnectorsResponse.java} | 53 +-
.../api/types/ListEmbedJobResponse.java | 96 +++
.../api/types/NonStreamedChatResponse.java | 160 +++-
.../api/types/OAuthAuthorizeResponse.java | 6 +-
.../java/com/cohere/api/types/ParseInfo.java | 118 +++
.../api/types/RerankRequestDocumentsItem.java | 8 +-
.../types/RerankRequestDocumentsItemText.java | 12 +-
.../com/cohere/api/types/RerankResponse.java | 6 +-
.../api/types/RerankResponseResultsItem.java | 18 +-
.../RerankResponseResultsItemDocument.java | 12 +-
.../api/types/SearchQueriesOnlyResponse.java | 105 ---
.../cohere/api/types/SingleGeneration.java | 26 +-
.../api/types/SingleGenerationInStream.java | 197 +++++
.../SingleGenerationTokenLikelihoodsItem.java | 14 +-
.../api/types/StreamedChatResponse.java | 56 +-
.../types/SummarizeRequestExtractiveness.java | 2 +-
.../api/types/SummarizeRequestFormat.java | 2 +-
.../api/types/SummarizeRequestLength.java | 2 +-
.../cohere/api/types/SummarizeResponse.java | 6 +-
.../cohere/api/types/TokenizeResponse.java | 6 +-
...onse.java => UpdateConnectorResponse.java} | 32 +-
125 files changed, 7892 insertions(+), 1627 deletions(-)
create mode 100644 src/main/java/com/cohere/api/core/MediaTypes.java
delete mode 100644 src/main/java/com/cohere/api/requests/DetectLanguageRequest.java
create mode 100644 src/main/java/com/cohere/api/requests/GenerateStreamRequest.java
create mode 100644 src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsOAuthAuthorizeRequest.java
rename src/main/java/com/cohere/api/resources/connectors/requests/{CreateRequest.java => CreateConnectorRequest.java} (91%)
rename src/main/java/com/cohere/api/resources/connectors/requests/{UpdateRequest.java => UpdateConnectorRequest.java} (93%)
create mode 100644 src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java
create mode 100644 src/main/java/com/cohere/api/resources/datasets/requests/DatasetsCreateRequest.java
create mode 100644 src/main/java/com/cohere/api/resources/datasets/requests/DatasetsListRequest.java
create mode 100644 src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponse.java
create mode 100644 src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetResponse.java
create mode 100644 src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetUsageResponse.java
create mode 100644 src/main/java/com/cohere/api/resources/datasets/types/DatasetsListResponse.java
create mode 100644 src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java
create mode 100644 src/main/java/com/cohere/api/resources/embedjobs/requests/CreateEmbedJobRequest.java
create mode 100644 src/main/java/com/cohere/api/resources/embedjobs/types/CreateEmbedJobRequestTruncate.java
rename src/main/java/com/cohere/api/types/{ApiMetaApiVersionBilledUnits.java => ApiMetaBilledUnits.java} (90%)
create mode 100644 src/main/java/com/cohere/api/types/AuthTokenType.java
create mode 100644 src/main/java/com/cohere/api/types/ChatRequestPromptOverride.java
create mode 100644 src/main/java/com/cohere/api/types/ChatRequestSearchOptions.java
create mode 100644 src/main/java/com/cohere/api/types/ChatSearchResultConnector.java
delete mode 100644 src/main/java/com/cohere/api/types/ChatStreamEndEventResponse.java
create mode 100644 src/main/java/com/cohere/api/types/ChatStreamRequestPromptOverride.java
create mode 100644 src/main/java/com/cohere/api/types/ChatStreamRequestSearchOptions.java
rename src/main/java/com/cohere/api/types/{ClassifyRequestExamplesItem.java => ClassifyExample.java} (80%)
rename src/main/java/com/cohere/api/types/{CreateResponse.java => CreateConnectorResponse.java} (72%)
rename src/main/java/com/cohere/api/types/{DetectLanguageResponse.java => CreateEmbedJobResponse.java} (52%)
create mode 100644 src/main/java/com/cohere/api/types/Dataset.java
create mode 100644 src/main/java/com/cohere/api/types/DatasetPart.java
create mode 100644 src/main/java/com/cohere/api/types/DatasetType.java
create mode 100644 src/main/java/com/cohere/api/types/DatasetValidationStatus.java
delete mode 100644 src/main/java/com/cohere/api/types/DetectLanguageResponseResultsItem.java
create mode 100644 src/main/java/com/cohere/api/types/EmbedInputType.java
create mode 100644 src/main/java/com/cohere/api/types/EmbedJob.java
create mode 100644 src/main/java/com/cohere/api/types/EmbedJobStatus.java
create mode 100644 src/main/java/com/cohere/api/types/EmbedJobTruncate.java
create mode 100644 src/main/java/com/cohere/api/types/EmbedRequestEmbeddingTypesItem.java
create mode 100644 src/main/java/com/cohere/api/types/FinishReason.java
create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamEnd.java
create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamEndResponse.java
create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamError.java
create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamEvent.java
create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamRequestReturnLikelihoods.java
create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamRequestTruncate.java
create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamText.java
create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamedResponse.java
rename src/main/java/com/cohere/api/types/{GetResponse.java => GetConnectorResponse.java} (73%)
create mode 100644 src/main/java/com/cohere/api/types/IGenerateStreamEvent.java
rename src/main/java/com/cohere/api/types/{ListResponse.java => ListConnectorsResponse.java} (60%)
create mode 100644 src/main/java/com/cohere/api/types/ListEmbedJobResponse.java
create mode 100644 src/main/java/com/cohere/api/types/ParseInfo.java
delete mode 100644 src/main/java/com/cohere/api/types/SearchQueriesOnlyResponse.java
create mode 100644 src/main/java/com/cohere/api/types/SingleGenerationInStream.java
rename src/main/java/com/cohere/api/types/{UpdateResponse.java => UpdateConnectorResponse.java} (72%)
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