Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌿 Fern Regeneration -- August 9, 2024 #24

Merged
merged 2 commits into from
Aug 9, 2024
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
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.1.0'
version = '1.2.0'
from components.java
pom {
name = 'cohere'
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/com/cohere/api/Cohere.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Iterable<StreamedChatResponse> chatStream(ChatStreamRequest request) {
public Iterable<StreamedChatResponse> chatStream(ChatStreamRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("chat")
.addPathSegments("v1/chat")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -132,7 +132,7 @@ public NonStreamedChatResponse chat(ChatRequest request) {
public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("chat")
.addPathSegments("v1/chat")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -188,7 +188,7 @@ public Iterable<GenerateStreamedResponse> generateStream(
GenerateStreamRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("generate")
.addPathSegments("v1/generate")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -244,7 +244,7 @@ public Generation generate(GenerateRequest request) {
public Generation generate(GenerateRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("generate")
.addPathSegments("v1/generate")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -295,7 +295,7 @@ public EmbedResponse embed(EmbedRequest request) {
public EmbedResponse embed(EmbedRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("embed")
.addPathSegments("v1/embed")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -342,7 +342,7 @@ public RerankResponse rerank(RerankRequest request) {
public RerankResponse rerank(RerankRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("rerank")
.addPathSegments("v1/rerank")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -391,7 +391,7 @@ public ClassifyResponse classify(ClassifyRequest request) {
public ClassifyResponse classify(ClassifyRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("classify")
.addPathSegments("v1/classify")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -446,7 +446,7 @@ public SummarizeResponse summarize(SummarizeRequest request) {
public SummarizeResponse summarize(SummarizeRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("summarize")
.addPathSegments("v1/summarize")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -493,7 +493,7 @@ public TokenizeResponse tokenize(TokenizeRequest request) {
public TokenizeResponse tokenize(TokenizeRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("tokenize")
.addPathSegments("v1/tokenize")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -540,7 +540,7 @@ public DetokenizeResponse detokenize(DetokenizeRequest request) {
public DetokenizeResponse detokenize(DetokenizeRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("detokenize")
.addPathSegments("v1/detokenize")
.build();
RequestBody body;
try {
Expand Down Expand Up @@ -587,7 +587,7 @@ public CheckApiKeyResponse checkApiKey() {
public CheckApiKeyResponse checkApiKey(RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("check-api-key")
.addPathSegments("v1/check-api-key")
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
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.1.0",
"1.2.0",
"X-Fern-Language",
"JAVA"));
this.headerSuppliers = headerSuppliers;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cohere/api/core/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package com.cohere.api.core;

public final class Environment {
public static final Environment PRODUCTION = new Environment("https://api.cohere.com/v1");
public static final Environment PRODUCTION = new Environment("https://api.cohere.com");

private final String url;

Expand Down
35 changes: 11 additions & 24 deletions src/main/java/com/cohere/api/requests/ChatRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.cohere.api.types.ChatConnector;
import com.cohere.api.types.ChatRequestCitationQuality;
import com.cohere.api.types.ChatRequestPromptTruncation;
import com.cohere.api.types.ChatRequestResponseFormat;
import com.cohere.api.types.Message;
import com.cohere.api.types.ResponseFormat;
import com.cohere.api.types.Tool;
import com.cohere.api.types.ToolResult;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
Expand Down Expand Up @@ -76,7 +76,7 @@ public final class ChatRequest {

private final Optional<Boolean> forceSingleStep;

private final Optional<ChatRequestResponseFormat> responseFormat;
private final Optional<ResponseFormat> responseFormat;

private final Map<String, Object> additionalProperties;

Expand Down Expand Up @@ -105,7 +105,7 @@ private ChatRequest(
Optional<List<Tool>> tools,
Optional<List<ToolResult>> toolResults,
Optional<Boolean> forceSingleStep,
Optional<ChatRequestResponseFormat> responseFormat,
Optional<ResponseFormat> responseFormat,
Map<String, Object> additionalProperties) {
this.message = message;
this.model = model;
Expand Down Expand Up @@ -211,7 +211,7 @@ public Optional<ChatRequestPromptTruncation> getPromptTruncation() {

/**
* @return Accepts <code>{&quot;id&quot;: &quot;web-search&quot;}</code>, and/or the <code>&quot;id&quot;</code> for a custom <a href="https://docs.cohere.com/docs/connectors">connector</a>, if you've <a href="https://docs.cohere.com/docs/creating-and-deploying-a-connector">created</a> one.
* <p>When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).
* <p>When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG).
* Compatible Deployments: Cohere Platform</p>
*/
@JsonProperty("connectors")
Expand Down Expand Up @@ -409,14 +409,8 @@ public Optional<Boolean> getForceSingleStep() {
return forceSingleStep;
}

/**
* @return Configuration for forcing the model output to adhere to the specified format. Supported on <a href="https://docs.cohere.com/docs/command-r">Command R</a>, <a href="https://docs.cohere.com/docs/command-r-plus">Command R+</a> and newer models.
* <p>The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting <code>{ &quot;type&quot;: &quot;json_object&quot; }</code>.</p>
* <p>A <a href="https://json-schema.org/">JSON Schema</a> can optionally be provided, to ensure a specific structure.</p>
* <p><strong>Note</strong>: When using <code>{ &quot;type&quot;: &quot;json_object&quot; }</code> your <code>message</code> should always explicitly instruct the model to generate a JSON (eg: <em>&quot;Generate a JSON ...&quot;</em>) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.</p>
*/
@JsonProperty("response_format")
public Optional<ChatRequestResponseFormat> getResponseFormat() {
public Optional<ResponseFormat> getResponseFormat() {
return responseFormat;
}

Expand Down Expand Up @@ -599,16 +593,16 @@ public interface _FinalStage {

_FinalStage forceSingleStep(Boolean forceSingleStep);

_FinalStage responseFormat(Optional<ChatRequestResponseFormat> responseFormat);
_FinalStage responseFormat(Optional<ResponseFormat> responseFormat);

_FinalStage responseFormat(ChatRequestResponseFormat responseFormat);
_FinalStage responseFormat(ResponseFormat responseFormat);
}

@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements MessageStage, _FinalStage {
private String message;

private Optional<ChatRequestResponseFormat> responseFormat = Optional.empty();
private Optional<ResponseFormat> responseFormat = Optional.empty();

private Optional<Boolean> forceSingleStep = Optional.empty();

Expand Down Expand Up @@ -703,22 +697,15 @@ public _FinalStage message(String message) {
return this;
}

/**
* <p>Configuration for forcing the model output to adhere to the specified format. Supported on <a href="https://docs.cohere.com/docs/command-r">Command R</a>, <a href="https://docs.cohere.com/docs/command-r-plus">Command R+</a> and newer models.</p>
* <p>The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting <code>{ &quot;type&quot;: &quot;json_object&quot; }</code>.</p>
* <p>A <a href="https://json-schema.org/">JSON Schema</a> can optionally be provided, to ensure a specific structure.</p>
* <p><strong>Note</strong>: When using <code>{ &quot;type&quot;: &quot;json_object&quot; }</code> your <code>message</code> should always explicitly instruct the model to generate a JSON (eg: <em>&quot;Generate a JSON ...&quot;</em>) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage responseFormat(ChatRequestResponseFormat responseFormat) {
public _FinalStage responseFormat(ResponseFormat responseFormat) {
this.responseFormat = Optional.of(responseFormat);
return this;
}

@java.lang.Override
@JsonSetter(value = "response_format", nulls = Nulls.SKIP)
public _FinalStage responseFormat(Optional<ChatRequestResponseFormat> responseFormat) {
public _FinalStage responseFormat(Optional<ResponseFormat> responseFormat) {
this.responseFormat = responseFormat;
return this;
}
Expand Down Expand Up @@ -1068,7 +1055,7 @@ public _FinalStage searchQueriesOnly(Optional<Boolean> searchQueriesOnly) {

/**
* <p>Accepts <code>{&quot;id&quot;: &quot;web-search&quot;}</code>, and/or the <code>&quot;id&quot;</code> for a custom <a href="https://docs.cohere.com/docs/connectors">connector</a>, if you've <a href="https://docs.cohere.com/docs/creating-and-deploying-a-connector">created</a> one.</p>
* <p>When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).
* <p>When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG).
* Compatible Deployments: Cohere Platform</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
Expand Down
35 changes: 11 additions & 24 deletions src/main/java/com/cohere/api/requests/ChatStreamRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.cohere.api.types.ChatConnector;
import com.cohere.api.types.ChatStreamRequestCitationQuality;
import com.cohere.api.types.ChatStreamRequestPromptTruncation;
import com.cohere.api.types.ChatStreamRequestResponseFormat;
import com.cohere.api.types.Message;
import com.cohere.api.types.ResponseFormat;
import com.cohere.api.types.Tool;
import com.cohere.api.types.ToolResult;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
Expand Down Expand Up @@ -76,7 +76,7 @@ public final class ChatStreamRequest {

private final Optional<Boolean> forceSingleStep;

private final Optional<ChatStreamRequestResponseFormat> responseFormat;
private final Optional<ResponseFormat> responseFormat;

private final Map<String, Object> additionalProperties;

Expand Down Expand Up @@ -105,7 +105,7 @@ private ChatStreamRequest(
Optional<List<Tool>> tools,
Optional<List<ToolResult>> toolResults,
Optional<Boolean> forceSingleStep,
Optional<ChatStreamRequestResponseFormat> responseFormat,
Optional<ResponseFormat> responseFormat,
Map<String, Object> additionalProperties) {
this.message = message;
this.model = model;
Expand Down Expand Up @@ -211,7 +211,7 @@ public Optional<ChatStreamRequestPromptTruncation> getPromptTruncation() {

/**
* @return Accepts <code>{&quot;id&quot;: &quot;web-search&quot;}</code>, and/or the <code>&quot;id&quot;</code> for a custom <a href="https://docs.cohere.com/docs/connectors">connector</a>, if you've <a href="https://docs.cohere.com/docs/creating-and-deploying-a-connector">created</a> one.
* <p>When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).
* <p>When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG).
* Compatible Deployments: Cohere Platform</p>
*/
@JsonProperty("connectors")
Expand Down Expand Up @@ -409,14 +409,8 @@ public Optional<Boolean> getForceSingleStep() {
return forceSingleStep;
}

/**
* @return Configuration for forcing the model output to adhere to the specified format. Supported on <a href="https://docs.cohere.com/docs/command-r">Command R</a>, <a href="https://docs.cohere.com/docs/command-r-plus">Command R+</a> and newer models.
* <p>The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting <code>{ &quot;type&quot;: &quot;json_object&quot; }</code>.</p>
* <p>A <a href="https://json-schema.org/">JSON Schema</a> can optionally be provided, to ensure a specific structure.</p>
* <p><strong>Note</strong>: When using <code>{ &quot;type&quot;: &quot;json_object&quot; }</code> your <code>message</code> should always explicitly instruct the model to generate a JSON (eg: <em>&quot;Generate a JSON ...&quot;</em>) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.</p>
*/
@JsonProperty("response_format")
public Optional<ChatStreamRequestResponseFormat> getResponseFormat() {
public Optional<ResponseFormat> getResponseFormat() {
return responseFormat;
}

Expand Down Expand Up @@ -599,16 +593,16 @@ public interface _FinalStage {

_FinalStage forceSingleStep(Boolean forceSingleStep);

_FinalStage responseFormat(Optional<ChatStreamRequestResponseFormat> responseFormat);
_FinalStage responseFormat(Optional<ResponseFormat> responseFormat);

_FinalStage responseFormat(ChatStreamRequestResponseFormat responseFormat);
_FinalStage responseFormat(ResponseFormat responseFormat);
}

@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements MessageStage, _FinalStage {
private String message;

private Optional<ChatStreamRequestResponseFormat> responseFormat = Optional.empty();
private Optional<ResponseFormat> responseFormat = Optional.empty();

private Optional<Boolean> forceSingleStep = Optional.empty();

Expand Down Expand Up @@ -703,22 +697,15 @@ public _FinalStage message(String message) {
return this;
}

/**
* <p>Configuration for forcing the model output to adhere to the specified format. Supported on <a href="https://docs.cohere.com/docs/command-r">Command R</a>, <a href="https://docs.cohere.com/docs/command-r-plus">Command R+</a> and newer models.</p>
* <p>The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting <code>{ &quot;type&quot;: &quot;json_object&quot; }</code>.</p>
* <p>A <a href="https://json-schema.org/">JSON Schema</a> can optionally be provided, to ensure a specific structure.</p>
* <p><strong>Note</strong>: When using <code>{ &quot;type&quot;: &quot;json_object&quot; }</code> your <code>message</code> should always explicitly instruct the model to generate a JSON (eg: <em>&quot;Generate a JSON ...&quot;</em>) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage responseFormat(ChatStreamRequestResponseFormat responseFormat) {
public _FinalStage responseFormat(ResponseFormat responseFormat) {
this.responseFormat = Optional.of(responseFormat);
return this;
}

@java.lang.Override
@JsonSetter(value = "response_format", nulls = Nulls.SKIP)
public _FinalStage responseFormat(Optional<ChatStreamRequestResponseFormat> responseFormat) {
public _FinalStage responseFormat(Optional<ResponseFormat> responseFormat) {
this.responseFormat = responseFormat;
return this;
}
Expand Down Expand Up @@ -1068,7 +1055,7 @@ public _FinalStage searchQueriesOnly(Optional<Boolean> searchQueriesOnly) {

/**
* <p>Accepts <code>{&quot;id&quot;: &quot;web-search&quot;}</code>, and/or the <code>&quot;id&quot;</code> for a custom <a href="https://docs.cohere.com/docs/connectors">connector</a>, if you've <a href="https://docs.cohere.com/docs/creating-and-deploying-a-connector">created</a> one.</p>
* <p>When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).
* <p>When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG).
* Compatible Deployments: Cohere Platform</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
Expand Down
Loading
Loading