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,9 +1,10 @@
{
"cliVersion": "3.50.1",
"cliVersion": "4.23.0",
"generatorName": "fernapi/fern-java-sdk",
"generatorVersion": "3.34.5",
"generatorVersion": "3.42.7",
"generatorConfig": {
"client-class-name": "Cohere"
},
"sdkVersion": "1.9.5"
"originGitCommit": "7ffcb80a5edaf952524b88ad8960151e148ff39b",
"sdkVersion": "1.8.0"
}
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: ci

on: [push]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
compile:
runs-on: ubuntu-latest
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ repositories {

dependencies {
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'
api 'com.fasterxml.jackson.core:jackson-databind:2.18.6'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.6'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.6'
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.5'
version = '1.8.0'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -78,7 +78,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.cohere'
artifactId = 'cohere-java'
version = '1.9.5'
version = '1.8.0'
from components.java
pom {
name = 'cohere'
Expand Down
77 changes: 72 additions & 5 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1572,11 +1572,31 @@ client.rerank(
.query("What is the capital of the United States?")
.documents(
Arrays.asList(
RerankRequestDocumentsItem.of(),
RerankRequestDocumentsItem.of(),
RerankRequestDocumentsItem.of(),
RerankRequestDocumentsItem.of(),
RerankRequestDocumentsItem.of()
RerankRequestDocumentsItem.of(
new HashMap<String, String>() {{
put("text", "Carson City is the capital city of the American state of Nevada.");
}}
),
RerankRequestDocumentsItem.of(
new HashMap<String, String>() {{
put("text", "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.");
}}
),
RerankRequestDocumentsItem.of(
new HashMap<String, String>() {{
put("text", "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.");
}}
),
RerankRequestDocumentsItem.of(
new HashMap<String, String>() {{
put("text", "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.");
}}
),
RerankRequestDocumentsItem.of(
new HashMap<String, String>() {{
put("text", "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.");
}}
)
)
)
.model("rerank-v4.0-pro")
Expand Down Expand Up @@ -5045,3 +5065,50 @@ Maximum number of results to be returned by the server. If 0, defaults to
</dd>
</dl>
</details>

## Audio Transcriptions
<details><summary><code>client.audio.transcriptions.create(request) -> AudioTranscriptionsCreateResponse</code></summary>
<dl>
<dd>

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

Transcribe an audio file.
</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```java
client.audio().transcriptions().create(
TranscriptionsCreateRequest
.builder()
.model("model")
.language("language")
.build()
);
```
</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>

8 changes: 8 additions & 0 deletions src/main/java/com/cohere/api/AsyncCohere.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.cohere.api.requests.RerankRequest;
import com.cohere.api.requests.SummarizeRequest;
import com.cohere.api.requests.TokenizeRequest;
import com.cohere.api.resources.audio.AsyncAudioClient;
import com.cohere.api.resources.batches.AsyncBatchesClient;
import com.cohere.api.resources.connectors.AsyncConnectorsClient;
import com.cohere.api.resources.datasets.AsyncDatasetsClient;
Expand Down Expand Up @@ -56,6 +57,8 @@ public class AsyncCohere {

protected final Supplier<AsyncFinetuningClient> finetuningClient;

protected final Supplier<AsyncAudioClient> audioClient;

public AsyncCohere(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawCohere(clientOptions);
Expand All @@ -66,6 +69,7 @@ public AsyncCohere(ClientOptions clientOptions) {
this.connectorsClient = Suppliers.memoize(() -> new AsyncConnectorsClient(clientOptions));
this.modelsClient = Suppliers.memoize(() -> new AsyncModelsClient(clientOptions));
this.finetuningClient = Suppliers.memoize(() -> new AsyncFinetuningClient(clientOptions));
this.audioClient = Suppliers.memoize(() -> new AsyncAudioClient(clientOptions));
}

/**
Expand Down Expand Up @@ -305,6 +309,10 @@ public AsyncFinetuningClient finetuning() {
return this.finetuningClient.get();
}

public AsyncAudioClient audio() {
return this.audioClient.get();
}

public static AsyncCohereBuilder builder() {
return new AsyncCohereBuilder();
}
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/cohere/api/AsyncCohereBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.cohere.api.core.ClientOptions;
import com.cohere.api.core.Environment;
import com.cohere.api.core.LogConfig;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
Expand All @@ -25,6 +26,8 @@ public class AsyncCohereBuilder {

private OkHttpClient httpClient;

private Optional<LogConfig> logging = Optional.empty();

/**
* Sets token.
* Defaults to the CO_API_KEY environment variable.
Expand Down Expand Up @@ -76,6 +79,14 @@ public AsyncCohereBuilder httpClient(OkHttpClient httpClient) {
return this;
}

/**
* Configure logging for the SDK. Silent by default — no log output unless explicitly configured.
*/
public AsyncCohereBuilder logging(LogConfig logging) {
this.logging = Optional.of(logging);
return this;
}

/**
* Add a custom header to be sent with all requests.
* For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead.
Expand All @@ -97,6 +108,7 @@ protected ClientOptions buildClientOptions() {
setHttpClient(builder);
setTimeouts(builder);
setRetries(builder);
setLogging(builder);
for (Map.Entry<String, String> header : this.customHeaders.entrySet()) {
builder.addHeader(header.getKey(), header.getValue());
}
Expand Down Expand Up @@ -192,6 +204,18 @@ protected void setHttpClient(ClientOptions.Builder builder) {
}
}

/**
* Sets the logging configuration for the SDK.
* Override this method to customize logging behavior.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setLogging(ClientOptions.Builder builder) {
if (this.logging.isPresent()) {
builder.logging(this.logging.get());
}
}

/**
* Override this method to add any additional configuration to the client.
* This method is called at the end of the configuration chain, allowing you to add
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/cohere/api/AsyncRawCohere.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
Expand Down Expand Up @@ -108,6 +109,7 @@ public CompletableFuture<CohereHttpResponse<Iterable<StreamedChatResponse>>> cha
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
client = client.newBuilder().callTimeout(0, TimeUnit.SECONDS).build();
CompletableFuture<CohereHttpResponse<Iterable<StreamedChatResponse>>> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
Expand Down Expand Up @@ -386,6 +388,7 @@ public CompletableFuture<CohereHttpResponse<Iterable<GenerateStreamedResponse>>>
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
client = client.newBuilder().callTimeout(0, TimeUnit.SECONDS).build();
CompletableFuture<CohereHttpResponse<Iterable<GenerateStreamedResponse>>> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/cohere/api/Cohere.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.cohere.api.requests.RerankRequest;
import com.cohere.api.requests.SummarizeRequest;
import com.cohere.api.requests.TokenizeRequest;
import com.cohere.api.resources.audio.AudioClient;
import com.cohere.api.resources.batches.BatchesClient;
import com.cohere.api.resources.connectors.ConnectorsClient;
import com.cohere.api.resources.datasets.DatasetsClient;
Expand Down Expand Up @@ -55,6 +56,8 @@ public class Cohere {

protected final Supplier<FinetuningClient> finetuningClient;

protected final Supplier<AudioClient> audioClient;

public Cohere(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawCohere(clientOptions);
Expand All @@ -65,6 +68,7 @@ public Cohere(ClientOptions clientOptions) {
this.connectorsClient = Suppliers.memoize(() -> new ConnectorsClient(clientOptions));
this.modelsClient = Suppliers.memoize(() -> new ModelsClient(clientOptions));
this.finetuningClient = Suppliers.memoize(() -> new FinetuningClient(clientOptions));
this.audioClient = Suppliers.memoize(() -> new AudioClient(clientOptions));
}

/**
Expand Down Expand Up @@ -303,6 +307,10 @@ public FinetuningClient finetuning() {
return this.finetuningClient.get();
}

public AudioClient audio() {
return this.audioClient.get();
}

public static CohereBuilder builder() {
return new CohereBuilder();
}
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/cohere/api/CohereBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.cohere.api.core.ClientOptions;
import com.cohere.api.core.Environment;
import com.cohere.api.core.LogConfig;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
Expand All @@ -25,6 +26,8 @@ public class CohereBuilder {

private OkHttpClient httpClient;

private Optional<LogConfig> logging = Optional.empty();

/**
* Sets token.
* Defaults to the CO_API_KEY environment variable.
Expand Down Expand Up @@ -76,6 +79,14 @@ public CohereBuilder httpClient(OkHttpClient httpClient) {
return this;
}

/**
* Configure logging for the SDK. Silent by default — no log output unless explicitly configured.
*/
public CohereBuilder logging(LogConfig logging) {
this.logging = Optional.of(logging);
return this;
}

/**
* Add a custom header to be sent with all requests.
* For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead.
Expand All @@ -97,6 +108,7 @@ protected ClientOptions buildClientOptions() {
setHttpClient(builder);
setTimeouts(builder);
setRetries(builder);
setLogging(builder);
for (Map.Entry<String, String> header : this.customHeaders.entrySet()) {
builder.addHeader(header.getKey(), header.getValue());
}
Expand Down Expand Up @@ -192,6 +204,18 @@ protected void setHttpClient(ClientOptions.Builder builder) {
}
}

/**
* Sets the logging configuration for the SDK.
* Override this method to customize logging behavior.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setLogging(ClientOptions.Builder builder) {
if (this.logging.isPresent()) {
builder.logging(this.logging.get());
}
}

/**
* Override this method to add any additional configuration to the client.
* This method is called at the end of the configuration chain, allowing you to add
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/cohere/api/RawCohere.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.cohere.api.types.TokenizeResponse;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
Expand Down Expand Up @@ -104,6 +105,7 @@ public CohereHttpResponse<Iterable<StreamedChatResponse>> chatStream(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
client = client.newBuilder().callTimeout(0, TimeUnit.SECONDS).build();
try {
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
Expand Down Expand Up @@ -305,6 +307,7 @@ public CohereHttpResponse<Iterable<GenerateStreamedResponse>> generateStream(
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
client = client.newBuilder().callTimeout(0, TimeUnit.SECONDS).build();
try {
Response response = client.newCall(okhttpRequest).execute();
ResponseBody responseBody = response.body();
Expand Down
Loading
Loading