Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"cliVersion": "0.112.1",
"cliVersion": "3.50.1",
"generatorName": "fernapi/fern-java-sdk",
"generatorVersion": "3.14.2",
"generatorVersion": "3.34.5",
"generatorConfig": {
"client-class-name": "Cohere"
}
},
"sdkVersion": "1.9.5"
}
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ repositories {
}

dependencies {
api 'com.squareup.okhttp3:okhttp:4.12.0'
api 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2'
api 'com.squareup.okhttp3:okhttp:5.2.1'
api 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
Expand Down Expand Up @@ -47,7 +47,7 @@ java {

group = 'com.cohere'

version = '1.9.4'
version = '1.9.5'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -78,7 +78,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.cohere'
artifactId = 'cohere-java'
version = '1.9.4'
version = '1.9.5'
from components.java
pom {
name = 'cohere'
Expand Down
22 changes: 8 additions & 14 deletions reference.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reference
<details><summary><code>client.chatStream(request) -> Optional&amp;lt;StreamedChatResponse&amp;gt;</code></summary>
<details><summary><code>client.chatStream(request) -> Iterable&amp;lt;StreamedChatResponse&amp;gt;</code></summary>
<dl>
<dd>

Expand Down Expand Up @@ -32,7 +32,6 @@ client.chatStream(
ChatStreamRequest
.builder()
.message("hello!")
.stream(true)
.model("command-a-03-2025")
.build()
);
Expand Down Expand Up @@ -488,7 +487,6 @@ client.chatStream(
ChatStreamRequest
.builder()
.message("Tell me about LLMs")
.stream(false)
.model("command-a-03-2025")
.build()
);
Expand Down Expand Up @@ -912,7 +910,7 @@ Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private D
</dl>
</details>

<details><summary><code>client.generateStream(request) -> Optional&amp;lt;GenerateStreamedResponse&amp;gt;</code></summary>
<details><summary><code>client.generateStream(request) -> Iterable&amp;lt;GenerateStreamedResponse&amp;gt;</code></summary>
<dl>
<dd>

Expand Down Expand Up @@ -946,7 +944,6 @@ client.generateStream(
GenerateStreamRequest
.builder()
.prompt("Please explain to me how LLMs work")
.stream(true)
.build()
);
```
Expand Down Expand Up @@ -1197,7 +1194,6 @@ client.generateStream(
GenerateStreamRequest
.builder()
.prompt("Please explain to me how LLMs work")
.stream(false)
.build()
);
```
Expand Down Expand Up @@ -1573,6 +1569,7 @@ This endpoint takes in a query and a list of texts and produces an ordered array
client.rerank(
RerankRequest
.builder()
.query("What is the capital of the United States?")
.documents(
Arrays.asList(
RerankRequestDocumentsItem.of(),
Expand All @@ -1582,9 +1579,8 @@ client.rerank(
RerankRequestDocumentsItem.of()
)
)
.query("What is the capital of the United States?")
.topN(3)
.model("rerank-v4.0-pro")
.topN(3)
.build()
);
```
Expand Down Expand Up @@ -2043,10 +2039,10 @@ This endpoint takes tokens using byte-pair encoding and returns their text repre
client.detokenize(
DetokenizeRequest
.builder()
.model("command")
.tokens(
Arrays.asList(10002, 2261, 2012, 8, 2792, 43)
)
.model("command")
.build()
);
```
Expand Down Expand Up @@ -2123,7 +2119,7 @@ client.checkApiKey();
</details>

## V2
<details><summary><code>client.v2.chatStream(request) -> Optional&amp;lt;V2ChatStreamResponse&amp;gt;</code></summary>
<details><summary><code>client.v2.chatStream(request) -> Iterable&amp;lt;V2ChatStreamResponse&amp;gt;</code></summary>
<dl>
<dd>

Expand Down Expand Up @@ -2168,7 +2164,6 @@ client.v2().chatStream(
)
)
)
.stream(true)
.build()
);
```
Expand Down Expand Up @@ -2460,7 +2455,6 @@ client.v2().chatStream(
)
)
)
.stream(false)
.build()
);
```
Expand Down Expand Up @@ -2907,11 +2901,11 @@ This endpoint takes in a query and a list of texts and produces an ordered array
client.v2().rerank(
V2RerankRequest
.builder()
.model("rerank-v4.0-pro")
.query("What is the capital of the United States?")
.documents(
Arrays.asList("Carson City is the capital city of the American state of Nevada.", "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.")
)
.query("What is the capital of the United States?")
.model("rerank-v4.0-pro")
.topN(3)
.build()
);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/cohere/api/AsyncCohere.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ public CompletableFuture<EmbedResponse> embed() {
return this.rawClient.embed().thenApply(response -> response.body());
}

/**
* This endpoint returns text and image embeddings. An embedding is a list of floating point numbers that captures semantic information about the content that it represents.
* <p>Embeddings can be used to create classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.</p>
* <p>If you want to learn more how to use the embedding model, have a look at the <a href="https://docs.cohere.com/docs/semantic-search">Semantic Search Guide</a>.</p>
*/
public CompletableFuture<EmbedResponse> embed(RequestOptions requestOptions) {
return this.rawClient.embed(requestOptions).thenApply(response -> response.body());
}

/**
* This endpoint returns text and image embeddings. An embedding is a list of floating point numbers that captures semantic information about the content that it represents.
* <p>Embeddings can be used to create classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.</p>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/cohere/api/AsyncCohereBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ protected void setAdditional(ClientOptions.Builder builder) {}
protected void validateConfiguration() {}

public AsyncCohere build() {
if (token == null) {
throw new RuntimeException("Please provide token or set the CO_API_KEY environment variable.");
}
validateConfiguration();
return new AsyncCohere(buildClientOptions());
}
Expand Down
Loading