Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed May 8, 2024
1 parent 8f16dec commit 72e0cd7
Show file tree
Hide file tree
Showing 16 changed files with 788 additions and 104 deletions.
1 change: 0 additions & 1 deletion CODEOWNERS

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.cohere'
artifactId = 'cohere-java'
version = '1.0.4'
version = '1.0.5'
from components.java
pom {
name = 'cohere'
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/cohere/api/Cohere.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.cohere.api.resources.embedjobs.EmbedJobsClient;
import com.cohere.api.resources.finetuning.FinetuningClient;
import com.cohere.api.resources.models.ModelsClient;
import com.cohere.api.types.CheckApiKeyResponse;
import com.cohere.api.types.ClassifyResponse;
import com.cohere.api.types.DetokenizeResponse;
import com.cohere.api.types.EmbedResponse;
Expand Down Expand Up @@ -553,6 +554,44 @@ public DetokenizeResponse detokenize(DetokenizeRequest request, RequestOptions r
}
}

/**
* Checks that the api key in the Authorization header is valid and active
*/
public CheckApiKeyResponse checkApiKey() {
return checkApiKey(null);
}

/**
* Checks that the api key in the Authorization header is valid and active
*/
public CheckApiKeyResponse checkApiKey(RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("check-api-key")
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", RequestBody.create("", null))
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.build();
try {
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
Response response = client.newCall(okhttpRequest).execute();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), CheckApiKeyResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public EmbedJobsClient embedJobs() {
return this.embedJobsClient.get();
}
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/com/cohere/api/CohereBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ public Cohere build() {
throw new RuntimeException("Please provide token or set the CO_API_KEY environment variable.");
}
this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token);
if (clientName == null) {
throw new RuntimeException("Please provide clientName");
}
this.clientOptionsBuilder.addHeader("X-Client-Name", this.clientName);
clientOptionsBuilder.environment(this.environment);
return new Cohere(clientOptionsBuilder.build());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cohere/api/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private ClientOptions(
"X-Fern-SDK-Name",
"com.cohere.fern:api-sdk",
"X-Fern-SDK-Version",
"1.0.4",
"1.0.5",
"X-Fern-Language",
"JAVA"));
this.headerSuppliers = headerSuppliers;
Expand Down
130 changes: 91 additions & 39 deletions src/main/java/com/cohere/api/requests/ChatRequest.java

Large diffs are not rendered by default.

130 changes: 91 additions & 39 deletions src/main/java/com/cohere/api/requests/ChatStreamRequest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public String getName() {
}

/**
* @return The dataset type, which is used to validate the data. Valid types are <code>embed-input</code>, <code>reranker-finetune-input</code>, <code>prompt-completion-finetune-input</code>, <code>single-label-classification-finetune-input</code>, <code>chat-finetune-input</code>, and <code>multi-label-classification-finetune-input</code>.
* @return The dataset type, which is used to validate the data. Valid types are <code>embed-input</code>, <code>reranker-finetune-input</code>, <code>single-label-classification-finetune-input</code>, <code>chat-finetune-input</code>, and <code>multi-label-classification-finetune-input</code>.
*/
@JsonProperty("type")
public DatasetType getType() {
Expand Down Expand Up @@ -275,7 +275,7 @@ public TypeStage name(String name) {
}

/**
* <p>The dataset type, which is used to validate the data. Valid types are <code>embed-input</code>, <code>reranker-finetune-input</code>, <code>prompt-completion-finetune-input</code>, <code>single-label-classification-finetune-input</code>, <code>chat-finetune-input</code>, and <code>multi-label-classification-finetune-input</code>.</p>
* <p>The dataset type, which is used to validate the data. Valid types are <code>embed-input</code>, <code>reranker-finetune-input</code>, <code>single-label-classification-finetune-input</code>, <code>chat-finetune-input</code>, and <code>multi-label-classification-finetune-input</code>.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.Optional;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonDeserialize(builder = DatasetsCreateResponseDatasetParts.Builder.class)
public final class DatasetsCreateResponseDatasetParts {
@JsonDeserialize(builder = DatasetsCreateResponseDatasetPartsItem.Builder.class)
public final class DatasetsCreateResponseDatasetPartsItem {
private final Optional<String> name;

private final Optional<Double> numRows;
Expand All @@ -31,7 +31,7 @@ public final class DatasetsCreateResponseDatasetParts {

private final Map<String, Object> additionalProperties;

private DatasetsCreateResponseDatasetParts(
private DatasetsCreateResponseDatasetPartsItem(
Optional<String> name,
Optional<Double> numRows,
Optional<List<String>> samples,
Expand Down Expand Up @@ -76,16 +76,16 @@ public Optional<String> getPartKind() {
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof DatasetsCreateResponseDatasetParts
&& equalTo((DatasetsCreateResponseDatasetParts) other);
return other instanceof DatasetsCreateResponseDatasetPartsItem
&& equalTo((DatasetsCreateResponseDatasetPartsItem) other);
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

private boolean equalTo(DatasetsCreateResponseDatasetParts other) {
private boolean equalTo(DatasetsCreateResponseDatasetPartsItem other) {
return name.equals(other.name)
&& numRows.equals(other.numRows)
&& samples.equals(other.samples)
Expand Down Expand Up @@ -121,7 +121,7 @@ public static final class Builder {

private Builder() {}

public Builder from(DatasetsCreateResponseDatasetParts other) {
public Builder from(DatasetsCreateResponseDatasetPartsItem other) {
name(other.getName());
numRows(other.getNumRows());
samples(other.getSamples());
Expand Down Expand Up @@ -173,8 +173,8 @@ public Builder partKind(String partKind) {
return this;
}

public DatasetsCreateResponseDatasetParts build() {
return new DatasetsCreateResponseDatasetParts(name, numRows, samples, partKind, additionalProperties);
public DatasetsCreateResponseDatasetPartsItem build() {
return new DatasetsCreateResponseDatasetPartsItem(name, numRows, samples, partKind, additionalProperties);
}
}
}
163 changes: 163 additions & 0 deletions src/main/java/com/cohere/api/types/CheckApiKeyResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/**
* 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 = CheckApiKeyResponse.Builder.class)
public final class CheckApiKeyResponse {
private final boolean valid;

private final Optional<String> organizationId;

private final Optional<String> ownerId;

private final Map<String, Object> additionalProperties;

private CheckApiKeyResponse(
boolean valid,
Optional<String> organizationId,
Optional<String> ownerId,
Map<String, Object> additionalProperties) {
this.valid = valid;
this.organizationId = organizationId;
this.ownerId = ownerId;
this.additionalProperties = additionalProperties;
}

@JsonProperty("valid")
public boolean getValid() {
return valid;
}

@JsonProperty("organization_id")
public Optional<String> getOrganizationId() {
return organizationId;
}

@JsonProperty("owner_id")
public Optional<String> getOwnerId() {
return ownerId;
}

@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof CheckApiKeyResponse && equalTo((CheckApiKeyResponse) other);
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

private boolean equalTo(CheckApiKeyResponse other) {
return valid == other.valid && organizationId.equals(other.organizationId) && ownerId.equals(other.ownerId);
}

@java.lang.Override
public int hashCode() {
return Objects.hash(this.valid, this.organizationId, this.ownerId);
}

@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}

public static ValidStage builder() {
return new Builder();
}

public interface ValidStage {
_FinalStage valid(boolean valid);

Builder from(CheckApiKeyResponse other);
}

public interface _FinalStage {
CheckApiKeyResponse build();

_FinalStage organizationId(Optional<String> organizationId);

_FinalStage organizationId(String organizationId);

_FinalStage ownerId(Optional<String> ownerId);

_FinalStage ownerId(String ownerId);
}

@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements ValidStage, _FinalStage {
private boolean valid;

private Optional<String> ownerId = Optional.empty();

private Optional<String> organizationId = Optional.empty();

@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();

private Builder() {}

@java.lang.Override
public Builder from(CheckApiKeyResponse other) {
valid(other.getValid());
organizationId(other.getOrganizationId());
ownerId(other.getOwnerId());
return this;
}

@java.lang.Override
@JsonSetter("valid")
public _FinalStage valid(boolean valid) {
this.valid = valid;
return this;
}

@java.lang.Override
public _FinalStage ownerId(String ownerId) {
this.ownerId = Optional.of(ownerId);
return this;
}

@java.lang.Override
@JsonSetter(value = "owner_id", nulls = Nulls.SKIP)
public _FinalStage ownerId(Optional<String> ownerId) {
this.ownerId = ownerId;
return this;
}

@java.lang.Override
public _FinalStage organizationId(String organizationId) {
this.organizationId = Optional.of(organizationId);
return this;
}

@java.lang.Override
@JsonSetter(value = "organization_id", nulls = Nulls.SKIP)
public _FinalStage organizationId(Optional<String> organizationId) {
this.organizationId = organizationId;
return this;
}

@java.lang.Override
public CheckApiKeyResponse build() {
return new CheckApiKeyResponse(valid, organizationId, ownerId, additionalProperties);
}
}
}
Loading

0 comments on commit 72e0cd7

Please sign in to comment.