Skip to content

Commit

Permalink
Merge pull request #14 from cohere-ai/fern-bot/04-22-2024-0144PM
Browse files Browse the repository at this point in the history
🌿 Fern Regeneration -- April 22, 2024
  • Loading branch information
billytrend-cohere authored Apr 22, 2024
2 parents 11fdde6 + 6f1badf commit a1760f4
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/"
MAVEN_PUBLISH_REGISTRY_URL: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
MAVEN_SIGNATURE_KID: ${{ secrets.MAVEN_SIGNATURE_KID }}
MAVEN_SIGNATURE_SECRET_KEY: ${{ secrets.MAVEN_SIGNATURE_SECRET_KEY }}
MAVEN_SIGNATURE_PASSWORD: ${{ secrets.MAVEN_SIGNATURE_PASSWORD }}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Cohere.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 8 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,17 @@ publishing {
from components.java
pom {
name = 'cohere'
description = 'The official SDK of cohere'
url = 'https://buildwithfern.com'
description = 'The official Java library for Cohere\'s API.'
url = 'https://docs.cohere.com'
licenses {
license {
name = 'MIT'
}
}
developers {
developer {
name = 'cohere'
email = 'developers@cohere.com'
email = 'platform@cohere.com'
}
}
scm {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
85 changes: 83 additions & 2 deletions src/main/java/com/cohere/api/requests/ChatRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.cohere.api.core.ObjectMappers;
import com.cohere.api.types.ChatConnector;
import com.cohere.api.types.ChatMessage;
import com.cohere.api.types.ChatRequestCitationQuality;
import com.cohere.api.types.ChatRequestPromptTruncation;
import com.cohere.api.types.ChatRequestToolResultsItem;
import com.cohere.api.types.Tool;
Expand Down Expand Up @@ -44,6 +45,8 @@ public final class ChatRequest {

private final Optional<List<Map<String, String>>> documents;

private final Optional<ChatRequestCitationQuality> citationQuality;

private final Optional<Double> temperature;

private final Optional<Integer> maxTokens;
Expand All @@ -64,6 +67,8 @@ public final class ChatRequest {

private final Optional<Boolean> rawPrompting;

private final Optional<Boolean> returnPrompt;

private final Optional<List<Tool>> tools;

private final Optional<List<ChatRequestToolResultsItem>> toolResults;
Expand All @@ -80,6 +85,7 @@ private ChatRequest(
Optional<List<ChatConnector>> connectors,
Optional<Boolean> searchQueriesOnly,
Optional<List<Map<String, String>>> documents,
Optional<ChatRequestCitationQuality> citationQuality,
Optional<Double> temperature,
Optional<Integer> maxTokens,
Optional<Integer> maxInputTokens,
Expand All @@ -90,6 +96,7 @@ private ChatRequest(
Optional<Double> frequencyPenalty,
Optional<Double> presencePenalty,
Optional<Boolean> rawPrompting,
Optional<Boolean> returnPrompt,
Optional<List<Tool>> tools,
Optional<List<ChatRequestToolResultsItem>> toolResults,
Map<String, Object> additionalProperties) {
Expand All @@ -102,6 +109,7 @@ private ChatRequest(
this.connectors = connectors;
this.searchQueriesOnly = searchQueriesOnly;
this.documents = documents;
this.citationQuality = citationQuality;
this.temperature = temperature;
this.maxTokens = maxTokens;
this.maxInputTokens = maxInputTokens;
Expand All @@ -112,6 +120,7 @@ private ChatRequest(
this.frequencyPenalty = frequencyPenalty;
this.presencePenalty = presencePenalty;
this.rawPrompting = rawPrompting;
this.returnPrompt = returnPrompt;
this.tools = tools;
this.toolResults = toolResults;
this.additionalProperties = additionalProperties;
Expand All @@ -126,7 +135,7 @@ public String getMessage() {
}

/**
* @return Defaults to <code>command-r</code>.
* @return Defaults to <code>command-r-plus</code>.
* <p>The name of a compatible <a href="https://docs.cohere.com/docs/models">Cohere model</a> or the ID of a <a href="https://docs.cohere.com/docs/chat-fine-tuning">fine-tuned</a> model.</p>
*/
@JsonProperty("model")
Expand Down Expand Up @@ -212,6 +221,15 @@ public Optional<List<Map<String, String>>> getDocuments() {
return documents;
}

/**
* @return Defaults to <code>&quot;accurate&quot;</code>.
* <p>Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want <code>&quot;accurate&quot;</code> results or <code>&quot;fast&quot;</code> results.</p>
*/
@JsonProperty("citation_quality")
public Optional<ChatRequestCitationQuality> getCitationQuality() {
return citationQuality;
}

/**
* @return Defaults to <code>0.3</code>.
* <p>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.</p>
Expand Down Expand Up @@ -299,6 +317,14 @@ public Optional<Boolean> getRawPrompting() {
return rawPrompting;
}

/**
* @return The prompt is returned in the <code>prompt</code> response field when this is enabled.
*/
@JsonProperty("return_prompt")
public Optional<Boolean> getReturnPrompt() {
return returnPrompt;
}

/**
* @return A list of available tools (functions) that the model may suggest invoking before producing a text response.
* <p>When <code>tools</code> is passed (without <code>tool_results</code>), the <code>text</code> field in the response will be <code>&quot;&quot;</code> and the <code>tool_calls</code> field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the <code>tool_calls</code> array will be empty.</p>
Expand Down Expand Up @@ -355,6 +381,7 @@ private boolean equalTo(ChatRequest other) {
&& connectors.equals(other.connectors)
&& searchQueriesOnly.equals(other.searchQueriesOnly)
&& documents.equals(other.documents)
&& citationQuality.equals(other.citationQuality)
&& temperature.equals(other.temperature)
&& maxTokens.equals(other.maxTokens)
&& maxInputTokens.equals(other.maxInputTokens)
Expand All @@ -365,6 +392,7 @@ private boolean equalTo(ChatRequest other) {
&& frequencyPenalty.equals(other.frequencyPenalty)
&& presencePenalty.equals(other.presencePenalty)
&& rawPrompting.equals(other.rawPrompting)
&& returnPrompt.equals(other.returnPrompt)
&& tools.equals(other.tools)
&& toolResults.equals(other.toolResults);
}
Expand All @@ -381,6 +409,7 @@ public int hashCode() {
this.connectors,
this.searchQueriesOnly,
this.documents,
this.citationQuality,
this.temperature,
this.maxTokens,
this.maxInputTokens,
Expand All @@ -391,6 +420,7 @@ public int hashCode() {
this.frequencyPenalty,
this.presencePenalty,
this.rawPrompting,
this.returnPrompt,
this.tools,
this.toolResults);
}
Expand Down Expand Up @@ -445,6 +475,10 @@ public interface _FinalStage {

_FinalStage documents(List<Map<String, String>> documents);

_FinalStage citationQuality(Optional<ChatRequestCitationQuality> citationQuality);

_FinalStage citationQuality(ChatRequestCitationQuality citationQuality);

_FinalStage temperature(Optional<Double> temperature);

_FinalStage temperature(Double temperature);
Expand Down Expand Up @@ -485,6 +519,10 @@ public interface _FinalStage {

_FinalStage rawPrompting(Boolean rawPrompting);

_FinalStage returnPrompt(Optional<Boolean> returnPrompt);

_FinalStage returnPrompt(Boolean returnPrompt);

_FinalStage tools(Optional<List<Tool>> tools);

_FinalStage tools(List<Tool> tools);
Expand All @@ -502,6 +540,8 @@ public static final class Builder implements MessageStage, _FinalStage {

private Optional<List<Tool>> tools = Optional.empty();

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

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

private Optional<Double> presencePenalty = Optional.empty();
Expand All @@ -522,6 +562,8 @@ public static final class Builder implements MessageStage, _FinalStage {

private Optional<Double> temperature = Optional.empty();

private Optional<ChatRequestCitationQuality> citationQuality = Optional.empty();

private Optional<List<Map<String, String>>> documents = Optional.empty();

private Optional<Boolean> searchQueriesOnly = Optional.empty();
Expand Down Expand Up @@ -554,6 +596,7 @@ public Builder from(ChatRequest other) {
connectors(other.getConnectors());
searchQueriesOnly(other.getSearchQueriesOnly());
documents(other.getDocuments());
citationQuality(other.getCitationQuality());
temperature(other.getTemperature());
maxTokens(other.getMaxTokens());
maxInputTokens(other.getMaxInputTokens());
Expand All @@ -564,6 +607,7 @@ public Builder from(ChatRequest other) {
frequencyPenalty(other.getFrequencyPenalty());
presencePenalty(other.getPresencePenalty());
rawPrompting(other.getRawPrompting());
returnPrompt(other.getReturnPrompt());
tools(other.getTools());
toolResults(other.getToolResults());
return this;
Expand Down Expand Up @@ -633,6 +677,23 @@ public _FinalStage tools(Optional<List<Tool>> tools) {
return this;
}

/**
* <p>The prompt is returned in the <code>prompt</code> response field when this is enabled.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage returnPrompt(Boolean returnPrompt) {
this.returnPrompt = Optional.of(returnPrompt);
return this;
}

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

/**
* <p>When enabled, the user's prompt will be sent to the model without any pre-processing.</p>
* @return Reference to {@code this} so that method calls can be chained together.
Expand Down Expand Up @@ -810,6 +871,24 @@ public _FinalStage temperature(Optional<Double> temperature) {
return this;
}

/**
* <p>Defaults to <code>&quot;accurate&quot;</code>.</p>
* <p>Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want <code>&quot;accurate&quot;</code> results or <code>&quot;fast&quot;</code> results.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
@java.lang.Override
public _FinalStage citationQuality(ChatRequestCitationQuality citationQuality) {
this.citationQuality = Optional.of(citationQuality);
return this;
}

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

/**
* <p>A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary.</p>
* <p>Example:
Expand Down Expand Up @@ -947,7 +1026,7 @@ public _FinalStage preamble(Optional<String> preamble) {
}

/**
* <p>Defaults to <code>command-r</code>.</p>
* <p>Defaults to <code>command-r-plus</code>.</p>
* <p>The name of a compatible <a href="https://docs.cohere.com/docs/models">Cohere model</a> or the ID of a <a href="https://docs.cohere.com/docs/chat-fine-tuning">fine-tuned</a> model.</p>
* @return Reference to {@code this} so that method calls can be chained together.
*/
Expand Down Expand Up @@ -976,6 +1055,7 @@ public ChatRequest build() {
connectors,
searchQueriesOnly,
documents,
citationQuality,
temperature,
maxTokens,
maxInputTokens,
Expand All @@ -986,6 +1066,7 @@ public ChatRequest build() {
frequencyPenalty,
presencePenalty,
rawPrompting,
returnPrompt,
tools,
toolResults,
additionalProperties);
Expand Down
Loading

0 comments on commit a1760f4

Please sign in to comment.