From 3a5d56b77908d304488accb09a7c310ea64a35b5 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:10:51 +0000 Subject: [PATCH] SDK regeneration --- .github/workflows/ci.yml | 6 +- .publish/prepare.sh | 8 + build.gradle | 26 +- gradle.properties | 0 gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew.bat | 20 +- src/main/java/com/cohere/api/Cohere.java | 257 ++++-- .../java/com/cohere/api/CohereBuilder.java | 26 +- .../java/com/cohere/api/core/ApiError.java | 2 +- .../com/cohere/api/core/ClientOptions.java | 16 +- .../java/com/cohere/api/core/MediaTypes.java | 13 + .../com/cohere/api/core/RequestOptions.java | 48 +- .../com/cohere/api/requests/ChatRequest.java | 714 +++++++++++++---- .../api/requests/ChatStreamRequest.java | 714 +++++++++++++---- .../cohere/api/requests/ClassifyRequest.java | 30 +- .../api/requests/DetectLanguageRequest.java | 132 ---- .../api/requests/DetokenizeRequest.java | 80 +- .../com/cohere/api/requests/EmbedRequest.java | 41 +- .../cohere/api/requests/GenerateRequest.java | 217 +++-- .../api/requests/GenerateStreamRequest.java | 738 ++++++++++++++++++ .../cohere/api/requests/RerankRequest.java | 85 +- .../cohere/api/requests/SummarizeRequest.java | 36 +- .../cohere/api/requests/TokenizeRequest.java | 46 +- .../connectors/ConnectorsClient.java | 155 ++-- .../requests/ConnectorsListRequest.java | 6 +- .../ConnectorsOAuthAuthorizeRequest.java | 99 +++ ...quest.java => CreateConnectorRequest.java} | 58 +- ...quest.java => UpdateConnectorRequest.java} | 22 +- .../resources/datasets/DatasetsClient.java | 292 +++++++ .../requests/DatasetsCreateRequest.java | 422 ++++++++++ .../requests/DatasetsListRequest.java | 209 +++++ .../types/DatasetsCreateResponse.java | 98 +++ .../DatasetsCreateResponseDatasetParts.java | 180 +++++ .../datasets/types/DatasetsGetResponse.java | 102 +++ .../types/DatasetsGetUsageResponse.java | 98 +++ .../datasets/types/DatasetsListResponse.java | 97 +++ .../resources/embedjobs/EmbedJobsClient.java | 190 +++++ .../requests/CreateEmbedJobRequest.java | 313 ++++++++ .../types/CreateEmbedJobRequestTruncate.java | 24 + .../finetuning/FinetuningClient.java | 329 ++++++++ .../finetuning/types/BaseModel.java | 223 ++++++ .../finetuning/finetuning/types/BaseType.java | 30 + .../types/CreateFinetunedModelResponse.java | 99 +++ .../finetuning/finetuning/types/Error.java | 98 +++ .../finetuning/finetuning/types/Event.java | 153 ++++ .../finetuning/types/FinetunedModel.java | 461 +++++++++++ .../types/GetFinetunedModelResponse.java | 99 +++ .../finetuning/types/Hyperparameters.java | 221 ++++++ .../finetuning/types/ListEventsResponse.java | 156 ++++ .../types/ListFinetunedModelsResponse.java | 156 ++++ .../ListTrainingStepMetricsResponse.java | 128 +++ .../finetuning/finetuning/types/Settings.java | 217 +++++ .../finetuning/finetuning/types/Status.java | 38 + .../finetuning/finetuning/types/Strategy.java | 26 + .../finetuning/types/TrainingStepMetrics.java | 155 ++++ .../types/UpdateFinetunedModelResponse.java | 99 +++ .../requests/FinetuningListEventsRequest.java | 158 ++++ .../FinetuningListFinetunedModelsRequest.java | 159 ++++ ...etuningListTrainingStepMetricsRequest.java | 125 +++ ...FinetuningUpdateFinetunedModelRequest.java | 425 ++++++++++ .../api/resources/models/ModelsClient.java | 122 +++ .../models/requests/ModelsListRequest.java | 183 +++++ .../java/com/cohere/api/types/ApiMeta.java | 61 +- .../cohere/api/types/ApiMetaApiVersion.java | 56 +- ...lledUnits.java => ApiMetaBilledUnits.java} | 22 +- .../com/cohere/api/types/ApiMetaTokens.java | 124 +++ .../com/cohere/api/types/AuthTokenType.java | 26 + .../com/cohere/api/types/ChatCitation.java | 22 +- .../types/ChatCitationGenerationEvent.java | 6 +- .../com/cohere/api/types/ChatConnector.java | 56 +- .../com/cohere/api/types/ChatDataMetrics.java | 154 ++++ .../com/cohere/api/types/ChatMessage.java | 67 +- .../com/cohere/api/types/ChatMessageRole.java | 4 +- .../api/types/ChatRequestCitationQuality.java | 2 +- .../ChatRequestConnectorsSearchOptions.java | 198 +++++ .../types/ChatRequestPromptTruncation.java | 6 +- .../api/types/ChatRequestToolResultsItem.java | 142 ++++ .../ChatSearchQueriesGenerationEvent.java | 6 +- .../com/cohere/api/types/ChatSearchQuery.java | 14 +- .../cohere/api/types/ChatSearchResult.java | 155 +++- .../api/types/ChatSearchResultConnector.java | 108 +++ .../api/types/ChatSearchResultsEvent.java | 52 +- .../cohere/api/types/ChatStreamEndEvent.java | 26 +- .../types/ChatStreamEndEventFinishReason.java | 2 +- .../api/types/ChatStreamEndEventResponse.java | 94 --- .../com/cohere/api/types/ChatStreamEvent.java | 4 +- .../ChatStreamRequestCitationQuality.java | 2 +- ...tStreamRequestConnectorsSearchOptions.java | 198 +++++ .../ChatStreamRequestPromptTruncation.java | 6 +- .../ChatStreamRequestToolResultsItem.java | 142 ++++ .../api/types/ChatStreamStartEvent.java | 12 +- .../api/types/ChatTextGenerationEvent.java | 12 +- ...java => ChatToolCallsGenerationEvent.java} | 59 +- .../cohere/api/types/ClassifyDataMetrics.java | 96 +++ ...ExamplesItem.java => ClassifyExample.java} | 23 +- .../api/types/ClassifyRequestTruncate.java | 2 +- .../cohere/api/types/ClassifyResponse.java | 22 +- .../ClassifyResponseClassificationsItem.java | 44 +- ...ClassificationsItemClassificationType.java | 2 +- ...esponseClassificationsItemLabelsValue.java | 6 +- .../cohere/api/types/CompatibleEndpoint.java | 34 + .../java/com/cohere/api/types/Connector.java | 54 +- .../cohere/api/types/ConnectorAuthStatus.java | 2 +- .../com/cohere/api/types/ConnectorOAuth.java | 166 +++- .../api/types/CreateConnectorOAuth.java | 147 ++-- ...onse.java => CreateConnectorResponse.java} | 32 +- .../api/types/CreateConnectorServiceAuth.java | 33 +- ...ponse.java => CreateEmbedJobResponse.java} | 87 ++- .../java/com/cohere/api/types/Dataset.java | 495 ++++++++++++ .../com/cohere/api/types/DatasetPart.java | 328 ++++++++ .../com/cohere/api/types/DatasetType.java | 38 + .../api/types/DatasetValidationStatus.java | 32 + .../DetectLanguageResponseResultsItem.java | 118 --- .../cohere/api/types/DetokenizeResponse.java | 16 +- .../cohere/api/types/EmbedByTypeResponse.java | 24 +- .../types/EmbedByTypeResponseEmbeddings.java | 54 +- .../cohere/api/types/EmbedFloatsResponse.java | 28 +- .../com/cohere/api/types/EmbedInputType.java | 28 + .../java/com/cohere/api/types/EmbedJob.java | 398 ++++++++++ .../com/cohere/api/types/EmbedJobStatus.java | 30 + .../cohere/api/types/EmbedJobTruncate.java | 24 + .../api/types/EmbedRequestTruncate.java | 2 +- .../com/cohere/api/types/EmbedResponse.java | 24 +- .../com/cohere/api/types/EmbeddingType.java | 30 + .../api/types/FinetuneDatasetMetrics.java | 248 ++++++ .../com/cohere/api/types/FinishReason.java | 32 + .../GenerateRequestReturnLikelihoods.java | 2 +- .../api/types/GenerateRequestTruncate.java | 2 +- .../cohere/api/types/GenerateStreamEnd.java | 159 ++++ .../api/types/GenerateStreamEndResponse.java | 164 ++++ .../cohere/api/types/GenerateStreamError.java | 197 +++++ .../cohere/api/types/GenerateStreamEvent.java | 32 + ...enerateStreamRequestReturnLikelihoods.java | 26 + .../types/GenerateStreamRequestTruncate.java | 26 + .../cohere/api/types/GenerateStreamText.java | 168 ++++ .../api/types/GenerateStreamedResponse.java | 263 +++++++ .../java/com/cohere/api/types/Generation.java | 26 +- ...esponse.java => GetConnectorResponse.java} | 32 +- .../cohere/api/types/GetModelResponse.java | 243 ++++++ .../api/types/IGenerateStreamEvent.java | 6 + .../com/cohere/api/types/LabelMetric.java | 153 ++++ ...ponse.java => ListConnectorsResponse.java} | 53 +- .../api/types/ListEmbedJobResponse.java | 96 +++ .../cohere/api/types/ListModelsResponse.java | 129 +++ .../java/com/cohere/api/types/Metrics.java | 95 +++ .../api/types/NonStreamedChatResponse.java | 257 +++++- .../api/types/OAuthAuthorizeResponse.java | 6 +- .../java/com/cohere/api/types/ParseInfo.java | 118 +++ .../api/types/RerankRequestDocumentsItem.java | 8 +- .../types/RerankRequestDocumentsItemText.java | 12 +- .../com/cohere/api/types/RerankResponse.java | 6 +- .../api/types/RerankResponseResultsItem.java | 18 +- .../RerankResponseResultsItemDocument.java | 12 +- .../cohere/api/types/RerankerDataMetrics.java | 248 ++++++ .../cohere/api/types/SingleGeneration.java | 26 +- .../api/types/SingleGenerationInStream.java | 197 +++++ .../SingleGenerationTokenLikelihoodsItem.java | 14 +- .../api/types/StreamedChatResponse.java | 112 ++- .../types/SummarizeRequestExtractiveness.java | 2 +- .../api/types/SummarizeRequestFormat.java | 2 +- .../api/types/SummarizeRequestLength.java | 2 +- .../cohere/api/types/SummarizeResponse.java | 6 +- .../cohere/api/types/TokenizeResponse.java | 6 +- src/main/java/com/cohere/api/types/Tool.java | 197 +++++ .../java/com/cohere/api/types/ToolCall.java | 158 ++++ .../types/ToolParameterDefinitionsValue.java | 184 +++++ ...onse.java => UpdateConnectorResponse.java} | 32 +- 167 files changed, 15615 insertions(+), 1899 deletions(-) create mode 100755 .publish/prepare.sh create mode 100644 gradle.properties create mode 100644 src/main/java/com/cohere/api/core/MediaTypes.java delete mode 100644 src/main/java/com/cohere/api/requests/DetectLanguageRequest.java create mode 100644 src/main/java/com/cohere/api/requests/GenerateStreamRequest.java create mode 100644 src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsOAuthAuthorizeRequest.java rename src/main/java/com/cohere/api/resources/connectors/requests/{CreateRequest.java => CreateConnectorRequest.java} (91%) rename src/main/java/com/cohere/api/resources/connectors/requests/{UpdateRequest.java => UpdateConnectorRequest.java} (93%) create mode 100644 src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java create mode 100644 src/main/java/com/cohere/api/resources/datasets/requests/DatasetsCreateRequest.java create mode 100644 src/main/java/com/cohere/api/resources/datasets/requests/DatasetsListRequest.java create mode 100644 src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponse.java create mode 100644 src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponseDatasetParts.java create mode 100644 src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetResponse.java create mode 100644 src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetUsageResponse.java create mode 100644 src/main/java/com/cohere/api/resources/datasets/types/DatasetsListResponse.java create mode 100644 src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java create mode 100644 src/main/java/com/cohere/api/resources/embedjobs/requests/CreateEmbedJobRequest.java create mode 100644 src/main/java/com/cohere/api/resources/embedjobs/types/CreateEmbedJobRequestTruncate.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/FinetuningClient.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/BaseModel.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/BaseType.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/CreateFinetunedModelResponse.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Error.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Event.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/FinetunedModel.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/GetFinetunedModelResponse.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Hyperparameters.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListEventsResponse.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListFinetunedModelsResponse.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListTrainingStepMetricsResponse.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Settings.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Status.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Strategy.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/TrainingStepMetrics.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/finetuning/types/UpdateFinetunedModelResponse.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListEventsRequest.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListFinetunedModelsRequest.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListTrainingStepMetricsRequest.java create mode 100644 src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningUpdateFinetunedModelRequest.java create mode 100644 src/main/java/com/cohere/api/resources/models/ModelsClient.java create mode 100644 src/main/java/com/cohere/api/resources/models/requests/ModelsListRequest.java rename src/main/java/com/cohere/api/types/{ApiMetaApiVersionBilledUnits.java => ApiMetaBilledUnits.java} (90%) create mode 100644 src/main/java/com/cohere/api/types/ApiMetaTokens.java create mode 100644 src/main/java/com/cohere/api/types/AuthTokenType.java create mode 100644 src/main/java/com/cohere/api/types/ChatDataMetrics.java create mode 100644 src/main/java/com/cohere/api/types/ChatRequestConnectorsSearchOptions.java create mode 100644 src/main/java/com/cohere/api/types/ChatRequestToolResultsItem.java create mode 100644 src/main/java/com/cohere/api/types/ChatSearchResultConnector.java delete mode 100644 src/main/java/com/cohere/api/types/ChatStreamEndEventResponse.java create mode 100644 src/main/java/com/cohere/api/types/ChatStreamRequestConnectorsSearchOptions.java create mode 100644 src/main/java/com/cohere/api/types/ChatStreamRequestToolResultsItem.java rename src/main/java/com/cohere/api/types/{SearchQueriesOnlyResponse.java => ChatToolCallsGenerationEvent.java} (50%) create mode 100644 src/main/java/com/cohere/api/types/ClassifyDataMetrics.java rename src/main/java/com/cohere/api/types/{ClassifyRequestExamplesItem.java => ClassifyExample.java} (80%) create mode 100644 src/main/java/com/cohere/api/types/CompatibleEndpoint.java rename src/main/java/com/cohere/api/types/{CreateResponse.java => CreateConnectorResponse.java} (72%) rename src/main/java/com/cohere/api/types/{DetectLanguageResponse.java => CreateEmbedJobResponse.java} (52%) create mode 100644 src/main/java/com/cohere/api/types/Dataset.java create mode 100644 src/main/java/com/cohere/api/types/DatasetPart.java create mode 100644 src/main/java/com/cohere/api/types/DatasetType.java create mode 100644 src/main/java/com/cohere/api/types/DatasetValidationStatus.java delete mode 100644 src/main/java/com/cohere/api/types/DetectLanguageResponseResultsItem.java create mode 100644 src/main/java/com/cohere/api/types/EmbedInputType.java create mode 100644 src/main/java/com/cohere/api/types/EmbedJob.java create mode 100644 src/main/java/com/cohere/api/types/EmbedJobStatus.java create mode 100644 src/main/java/com/cohere/api/types/EmbedJobTruncate.java create mode 100644 src/main/java/com/cohere/api/types/EmbeddingType.java create mode 100644 src/main/java/com/cohere/api/types/FinetuneDatasetMetrics.java create mode 100644 src/main/java/com/cohere/api/types/FinishReason.java create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamEnd.java create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamEndResponse.java create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamError.java create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamEvent.java create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamRequestReturnLikelihoods.java create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamRequestTruncate.java create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamText.java create mode 100644 src/main/java/com/cohere/api/types/GenerateStreamedResponse.java rename src/main/java/com/cohere/api/types/{GetResponse.java => GetConnectorResponse.java} (73%) create mode 100644 src/main/java/com/cohere/api/types/GetModelResponse.java create mode 100644 src/main/java/com/cohere/api/types/IGenerateStreamEvent.java create mode 100644 src/main/java/com/cohere/api/types/LabelMetric.java rename src/main/java/com/cohere/api/types/{ListResponse.java => ListConnectorsResponse.java} (60%) create mode 100644 src/main/java/com/cohere/api/types/ListEmbedJobResponse.java create mode 100644 src/main/java/com/cohere/api/types/ListModelsResponse.java create mode 100644 src/main/java/com/cohere/api/types/Metrics.java create mode 100644 src/main/java/com/cohere/api/types/ParseInfo.java create mode 100644 src/main/java/com/cohere/api/types/RerankerDataMetrics.java create mode 100644 src/main/java/com/cohere/api/types/SingleGenerationInStream.java create mode 100644 src/main/java/com/cohere/api/types/Tool.java create mode 100644 src/main/java/com/cohere/api/types/ToolCall.java create mode 100644 src/main/java/com/cohere/api/types/ToolParameterDefinitionsValue.java rename src/main/java/com/cohere/api/types/{UpdateResponse.java => UpdateConnectorResponse.java} (72%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0414818..812da11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,8 +54,12 @@ jobs: - name: Publish to maven run: | + ./.publish/prepare.sh ./gradlew publish env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/" \ No newline at end of file + MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/" + MAVEN_SIGNATURE_KID: ${{ secrets.MAVEN_SIGNATURE_KID }} + MAVEN_SIGNATURE_SECRET_KEY: ${{ secrets.MAVEN_SIGNATURE_SECRET_KEY }} + MAVEN_SIGNATURE_PASSWORD: ${{ secrets.MAVEN_SIGNATURE_PASSWORD }} diff --git a/.publish/prepare.sh b/.publish/prepare.sh new file mode 100755 index 0000000..df3948e --- /dev/null +++ b/.publish/prepare.sh @@ -0,0 +1,8 @@ +# Write key ring file +echo "$MAVEN_SIGNATURE_SECRET_KEY" > armored_key.asc +gpg -o publish_key.gpg --dearmor armored_key.asc + +# Generate gradle.properties file +echo "signing.keyId=$MAVEN_SIGNATURE_KID" > gradle.properties +echo "signing.secretKeyRingFile=publish_key.gpg" >> gradle.properties +echo "signing.password=$MAVEN_SIGNATURE_PASSWORD" >> gradle.properties diff --git a/build.gradle b/build.gradle index 4486d44..2de3cb1 100644 --- a/build.gradle +++ b/build.gradle @@ -2,17 +2,18 @@ plugins { id 'java-library' id 'maven-publish' id 'com.diffplug.spotless' version '6.11.0' + id 'signing' } repositories { mavenCentral() maven { - url 'https://s01.oss.sonatype.org/content/repositories/releases/' + url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' } } dependencies { - api 'com.squareup.okhttp3:okhttp:4.9.3' + api 'com.squareup.okhttp3:okhttp:4.12.0' api 'com.fasterxml.jackson.core:jackson-databind:2.13.0' api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.3' api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3' @@ -35,6 +36,9 @@ java { withJavadocJar() } +signing { + sign(publishing.publications) +} test { useJUnitPlatform() testLogging { @@ -46,8 +50,24 @@ publishing { maven(MavenPublication) { groupId = 'com.cohere' artifactId = 'cohere-java' - version = '1.0.3' + version = '1.0.4' from components.java + pom { + name = 'cohere' + description = 'The official SDK of cohere' + url = 'https://buildwithfern.com' + developers { + developer { + name = 'cohere' + email = 'developers@cohere.com' + } + } + scm { + connection = 'scm:git:git://github.com/cohere-ai/cohere-java.git' + developerConnection = 'scm:git:git://github.com/cohere-ai/cohere-java.git' + url = 'https://github.com/cohere-ai/cohere-java' + } + } } } repositories { diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e69de29 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e09..a80b22c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 6689b85..7101f8e 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/src/main/java/com/cohere/api/Cohere.java b/src/main/java/com/cohere/api/Cohere.java index 2ac98c3..cb4f4fe 100644 --- a/src/main/java/com/cohere/api/Cohere.java +++ b/src/main/java/com/cohere/api/Cohere.java @@ -5,6 +5,7 @@ import com.cohere.api.core.ApiError; import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.MediaTypes; import com.cohere.api.core.ObjectMappers; import com.cohere.api.core.RequestOptions; import com.cohere.api.core.Stream; @@ -12,18 +13,22 @@ import com.cohere.api.requests.ChatRequest; import com.cohere.api.requests.ChatStreamRequest; import com.cohere.api.requests.ClassifyRequest; -import com.cohere.api.requests.DetectLanguageRequest; import com.cohere.api.requests.DetokenizeRequest; import com.cohere.api.requests.EmbedRequest; import com.cohere.api.requests.GenerateRequest; +import com.cohere.api.requests.GenerateStreamRequest; import com.cohere.api.requests.RerankRequest; import com.cohere.api.requests.SummarizeRequest; import com.cohere.api.requests.TokenizeRequest; import com.cohere.api.resources.connectors.ConnectorsClient; +import com.cohere.api.resources.datasets.DatasetsClient; +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.ClassifyResponse; -import com.cohere.api.types.DetectLanguageResponse; import com.cohere.api.types.DetokenizeResponse; import com.cohere.api.types.EmbedResponse; +import com.cohere.api.types.GenerateStreamedResponse; import com.cohere.api.types.Generation; import com.cohere.api.types.NonStreamedChatResponse; import com.cohere.api.types.RerankResponse; @@ -34,7 +39,7 @@ import java.util.function.Supplier; import okhttp3.Headers; import okhttp3.HttpUrl; -import okhttp3.MediaType; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @@ -42,16 +47,36 @@ public class Cohere { protected final ClientOptions clientOptions; + protected final Supplier embedJobsClient; + + protected final Supplier datasetsClient; + protected final Supplier connectorsClient; + protected final Supplier modelsClient; + + protected final Supplier finetuningClient; + public Cohere(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.embedJobsClient = Suppliers.memoize(() -> new EmbedJobsClient(clientOptions)); + this.datasetsClient = Suppliers.memoize(() -> new DatasetsClient(clientOptions)); this.connectorsClient = Suppliers.memoize(() -> new ConnectorsClient(clientOptions)); + this.modelsClient = Suppliers.memoize(() -> new ModelsClient(clientOptions)); + this.finetuningClient = Suppliers.memoize(() -> new FinetuningClient(clientOptions)); } /** - * The chat endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the conversation_id parameter, or they can pass in their own conversation history using the chat_history parameter. - * The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". + * Generates a text response to a user message. + * To learn how to use Chat with Streaming and RAG follow this guide. + */ + public Iterable chatStream(ChatStreamRequest request) { + return chatStream(request, null); + } + + /** + * Generates a text response to a user message. + * To learn how to use Chat with Streaming and RAG follow this guide. */ public Iterable chatStream(ChatStreamRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -61,7 +86,7 @@ public Iterable chatStream(ChatStreamRequest request, Requ RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -72,8 +97,11 @@ public Iterable chatStream(ChatStreamRequest request, Requ .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + Response response = client.newCall(okhttpRequest).execute(); if (response.isSuccessful()) { return new Stream( StreamedChatResponse.class, response.body().charStream(), "\n"); @@ -87,16 +115,16 @@ public Iterable chatStream(ChatStreamRequest request, Requ } /** - * The chat endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the conversation_id parameter, or they can pass in their own conversation history using the chat_history parameter. - * The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". + * Generates a text response to a user message. + * To learn how to use Chat with Streaming and RAG follow this guide. */ - public Iterable chatStream(ChatStreamRequest request) { - return chatStream(request, null); + public NonStreamedChatResponse chat(ChatRequest request) { + return chat(request, null); } /** - * The chat endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the conversation_id parameter, or they can pass in their own conversation history using the chat_history parameter. - * The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". + * Generates a text response to a user message. + * To learn how to use Chat with Streaming and RAG follow this guide. */ public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -106,7 +134,7 @@ public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestO RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -117,8 +145,11 @@ public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestO .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), NonStreamedChatResponse.class); } @@ -131,17 +162,25 @@ public NonStreamedChatResponse chat(ChatRequest request, RequestOptions requestO } /** - * The chat endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the conversation_id parameter, or they can pass in their own conversation history using the chat_history parameter. - * The endpoint features additional parameters such as connectors and documents that enable conversations enriched by external knowledge. We call this "Retrieval Augmented Generation", or "RAG". + *
+ * 🚧 Warning + *

This API is marked as "Legacy" and is no longer maintained. Follow the migration guide to start using the Chat API.

+ *
+ *

Generates realistic text conditioned on a given input.

*/ - public NonStreamedChatResponse chat(ChatRequest request) { - return chat(request, null); + public Iterable generateStream(GenerateStreamRequest request) { + return generateStream(request, null); } /** - * This endpoint generates realistic text conditioned on a given input. + *
+ * 🚧 Warning + *

This API is marked as "Legacy" and is no longer maintained. Follow the migration guide to start using the Chat API.

+ *
+ *

Generates realistic text conditioned on a given input.

*/ - public Generation generate(GenerateRequest request, RequestOptions requestOptions) { + public Iterable generateStream( + GenerateStreamRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("generate") @@ -149,7 +188,7 @@ public Generation generate(GenerateRequest request, RequestOptions requestOption RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -160,10 +199,14 @@ public Generation generate(GenerateRequest request, RequestOptions requestOption .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), Generation.class); + return new Stream( + GenerateStreamedResponse.class, response.body().charStream(), "\n"); } throw new ApiError( response.code(), @@ -174,26 +217,32 @@ public Generation generate(GenerateRequest request, RequestOptions requestOption } /** - * This endpoint generates realistic text conditioned on a given input. + *
+ * 🚧 Warning + *

This API is marked as "Legacy" and is no longer maintained. Follow the migration guide to start using the Chat API.

+ *
+ *

Generates realistic text conditioned on a given input.

*/ public Generation generate(GenerateRequest request) { return generate(request, null); } /** - * This endpoint returns text embeddings. An embedding is a list of floating point numbers that captures semantic information about the text that it represents. - *

Embeddings can be used to create text classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.

- *

If you want to learn more how to use the embedding model, have a look at the Semantic Search Guide.

+ *
+ * 🚧 Warning + *

This API is marked as "Legacy" and is no longer maintained. Follow the migration guide to start using the Chat API.

+ *
+ *

Generates realistic text conditioned on a given input.

*/ - public EmbedResponse embed(EmbedRequest request, RequestOptions requestOptions) { + public Generation generate(GenerateRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("embed") + .addPathSegments("generate") .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -204,10 +253,13 @@ public EmbedResponse embed(EmbedRequest request, RequestOptions requestOptions) .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), EmbedResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Generation.class); } throw new ApiError( response.code(), @@ -227,17 +279,19 @@ public EmbedResponse embed(EmbedRequest request) { } /** - * This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score. + * This endpoint returns text embeddings. An embedding is a list of floating point numbers that captures semantic information about the text that it represents. + *

Embeddings can be used to create text classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.

+ *

If you want to learn more how to use the embedding model, have a look at the Semantic Search Guide.

*/ - public RerankResponse rerank(RerankRequest request, RequestOptions requestOptions) { + public EmbedResponse embed(EmbedRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("rerank") + .addPathSegments("embed") .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -248,10 +302,13 @@ public RerankResponse rerank(RerankRequest request, RequestOptions requestOption .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), RerankResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), EmbedResponse.class); } throw new ApiError( response.code(), @@ -269,18 +326,17 @@ public RerankResponse rerank(RerankRequest request) { } /** - * This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided examples of text + label pairs as a reference. - * Note: Custom Models trained on classification examples don't require the examples parameter to be passed in explicitly. + * This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score. */ - public ClassifyResponse classify(ClassifyRequest request, RequestOptions requestOptions) { + public RerankResponse rerank(RerankRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("classify") + .addPathSegments("rerank") .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -291,10 +347,13 @@ public ClassifyResponse classify(ClassifyRequest request, RequestOptions request .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), ClassifyResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), RerankResponse.class); } throw new ApiError( response.code(), @@ -306,24 +365,25 @@ public ClassifyResponse classify(ClassifyRequest request, RequestOptions request /** * This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided examples of text + label pairs as a reference. - * Note: Custom Models trained on classification examples don't require the examples parameter to be passed in explicitly. + * Note: Fine-tuned models trained on classification examples don't require the examples parameter to be passed in explicitly. */ public ClassifyResponse classify(ClassifyRequest request) { return classify(request, null); } /** - * This endpoint identifies which language each of the provided texts is written in. + * This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided examples of text + label pairs as a reference. + * Note: Fine-tuned models trained on classification examples don't require the examples parameter to be passed in explicitly. */ - public DetectLanguageResponse detectLanguage(DetectLanguageRequest request, RequestOptions requestOptions) { + public ClassifyResponse classify(ClassifyRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("detect-language") + .addPathSegments("classify") .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -334,10 +394,13 @@ public DetectLanguageResponse detectLanguage(DetectLanguageRequest request, Requ .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), DetectLanguageResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), ClassifyResponse.class); } throw new ApiError( response.code(), @@ -348,14 +411,22 @@ public DetectLanguageResponse detectLanguage(DetectLanguageRequest request, Requ } /** - * This endpoint identifies which language each of the provided texts is written in. + *
+ * 🚧 Warning + *

This API is marked as "Legacy" and is no longer maintained. Follow the migration guide to start using the Chat API.

+ *
+ *

Generates a summary in English for a given text.

*/ - public DetectLanguageResponse detectLanguage(DetectLanguageRequest request) { - return detectLanguage(request, null); + public SummarizeResponse summarize(SummarizeRequest request) { + return summarize(request, null); } /** - * This endpoint generates a summary in English for a given text. + *
+ * 🚧 Warning + *

This API is marked as "Legacy" and is no longer maintained. Follow the migration guide to start using the Chat API.

+ *
+ *

Generates a summary in English for a given text.

*/ public SummarizeResponse summarize(SummarizeRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -365,7 +436,7 @@ public SummarizeResponse summarize(SummarizeRequest request, RequestOptions requ RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -376,8 +447,11 @@ public SummarizeResponse summarize(SummarizeRequest request, RequestOptions requ .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), SummarizeResponse.class); } @@ -390,10 +464,10 @@ public SummarizeResponse summarize(SummarizeRequest request, RequestOptions requ } /** - * This endpoint generates a summary in English for a given text. + * This endpoint splits input text into smaller units called tokens using byte-pair encoding (BPE). To learn more about tokenization and byte pair encoding, see the tokens page. */ - public SummarizeResponse summarize(SummarizeRequest request) { - return summarize(request, null); + public TokenizeResponse tokenize(TokenizeRequest request) { + return tokenize(request, null); } /** @@ -407,7 +481,7 @@ public TokenizeResponse tokenize(TokenizeRequest request, RequestOptions request RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -418,8 +492,11 @@ public TokenizeResponse tokenize(TokenizeRequest request, RequestOptions request .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), TokenizeResponse.class); } @@ -432,10 +509,10 @@ public TokenizeResponse tokenize(TokenizeRequest request, RequestOptions request } /** - * This endpoint splits input text into smaller units called tokens using byte-pair encoding (BPE). To learn more about tokenization and byte pair encoding, see the tokens page. + * This endpoint takes tokens using byte-pair encoding and returns their text representation. To learn more about tokenization and byte pair encoding, see the tokens page. */ - public TokenizeResponse tokenize(TokenizeRequest request) { - return tokenize(request, null); + public DetokenizeResponse detokenize(DetokenizeRequest request) { + return detokenize(request, null); } /** @@ -449,7 +526,7 @@ public DetokenizeResponse detokenize(DetokenizeRequest request, RequestOptions r RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -460,8 +537,11 @@ public DetokenizeResponse detokenize(DetokenizeRequest request, RequestOptions r .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), DetokenizeResponse.class); } @@ -473,17 +553,26 @@ public DetokenizeResponse detokenize(DetokenizeRequest request, RequestOptions r } } - /** - * This endpoint takes tokens using byte-pair encoding and returns their text representation. To learn more about tokenization and byte pair encoding, see the tokens page. - */ - public DetokenizeResponse detokenize(DetokenizeRequest request) { - return detokenize(request, null); + public EmbedJobsClient embedJobs() { + return this.embedJobsClient.get(); + } + + public DatasetsClient datasets() { + return this.datasetsClient.get(); } public ConnectorsClient connectors() { return this.connectorsClient.get(); } + public ModelsClient models() { + return this.modelsClient.get(); + } + + public FinetuningClient finetuning() { + return this.finetuningClient.get(); + } + public static CohereBuilder builder() { return new CohereBuilder(); } diff --git a/src/main/java/com/cohere/api/CohereBuilder.java b/src/main/java/com/cohere/api/CohereBuilder.java index 325a94b..8d3f07d 100644 --- a/src/main/java/com/cohere/api/CohereBuilder.java +++ b/src/main/java/com/cohere/api/CohereBuilder.java @@ -9,10 +9,26 @@ public final class CohereBuilder { private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + private String token = System.getenv("CO_API_KEY"); + + private String clientName = null; + private Environment environment = Environment.PRODUCTION; + /** + * Sets token. + * Defaults to the CO_API_KEY environment variable. + */ public CohereBuilder token(String token) { - this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + token); + this.token = token; + return this; + } + + /** + * Sets clientName + */ + public CohereBuilder clientName(String clientName) { + this.clientName = clientName; return this; } @@ -27,6 +43,14 @@ public CohereBuilder url(String url) { } public Cohere build() { + if (token == null) { + 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()); } diff --git a/src/main/java/com/cohere/api/core/ApiError.java b/src/main/java/com/cohere/api/core/ApiError.java index a8f1d8b..3692156 100644 --- a/src/main/java/com/cohere/api/core/ApiError.java +++ b/src/main/java/com/cohere/api/core/ApiError.java @@ -21,7 +21,7 @@ public Object body() { return this.body; } - @Override + @java.lang.Override public String toString() { return "ApiError{" + "statusCode: " + statusCode + ", body: " + body + "}"; } diff --git a/src/main/java/com/cohere/api/core/ClientOptions.java b/src/main/java/com/cohere/api/core/ClientOptions.java index 17de257..746f68a 100644 --- a/src/main/java/com/cohere/api/core/ClientOptions.java +++ b/src/main/java/com/cohere/api/core/ClientOptions.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import okhttp3.OkHttpClient; @@ -29,7 +30,7 @@ private ClientOptions( "X-Fern-SDK-Name", "com.cohere.fern:api-sdk", "X-Fern-SDK-Version", - "1.0.3", + "1.0.4", "X-Fern-Language", "JAVA")); this.headerSuppliers = headerSuppliers; @@ -56,6 +57,19 @@ public OkHttpClient httpClient() { return this.httpClient; } + public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.httpClient; + } + return this.httpClient + .newBuilder() + .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .build(); + } + public static Builder builder() { return new Builder(); } diff --git a/src/main/java/com/cohere/api/core/MediaTypes.java b/src/main/java/com/cohere/api/core/MediaTypes.java new file mode 100644 index 0000000..44958be --- /dev/null +++ b/src/main/java/com/cohere/api/core/MediaTypes.java @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.core; + +import okhttp3.MediaType; + +public final class MediaTypes { + + public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); + + private MediaTypes() {} +} diff --git a/src/main/java/com/cohere/api/core/RequestOptions.java b/src/main/java/com/cohere/api/core/RequestOptions.java index 27c6fcc..414b7cf 100644 --- a/src/main/java/com/cohere/api/core/RequestOptions.java +++ b/src/main/java/com/cohere/api/core/RequestOptions.java @@ -5,12 +5,31 @@ import java.util.HashMap; import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; public final class RequestOptions { private final String token; - private RequestOptions(String token) { + private final String clientName; + + private final Optional timeout; + + private final TimeUnit timeoutTimeUnit; + + private RequestOptions(String token, String clientName, Optional timeout, TimeUnit timeoutTimeUnit) { this.token = token; + this.clientName = clientName; + this.timeout = timeout; + this.timeoutTimeUnit = timeoutTimeUnit; + } + + public Optional getTimeout() { + return timeout; + } + + public TimeUnit getTimeoutTimeUnit() { + return timeoutTimeUnit; } public Map getHeaders() { @@ -18,6 +37,9 @@ public Map getHeaders() { if (this.token != null) { headers.put("Authorization", "Bearer " + this.token); } + if (this.clientName != null) { + headers.put("X-Client-Name", this.clientName); + } return headers; } @@ -28,13 +50,35 @@ public static Builder builder() { public static final class Builder { private String token = null; + private String clientName = null; + + private Optional timeout = null; + + private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; + public Builder token(String token) { this.token = token; return this; } + public Builder clientName(String clientName) { + this.clientName = clientName; + return this; + } + + public Builder timeout(Integer timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { + this.timeout = Optional.of(timeout); + this.timeoutTimeUnit = timeoutTimeUnit; + return this; + } + public RequestOptions build() { - return new RequestOptions(token); + return new RequestOptions(token, clientName, timeout, timeoutTimeUnit); } } } diff --git a/src/main/java/com/cohere/api/requests/ChatRequest.java b/src/main/java/com/cohere/api/requests/ChatRequest.java index 03236cc..431adb1 100644 --- a/src/main/java/com/cohere/api/requests/ChatRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatRequest.java @@ -6,8 +6,9 @@ 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; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -29,9 +30,7 @@ public final class ChatRequest { private final Optional model; - private final Boolean stream; - - private final Optional preambleOverride; + private final Optional preamble; private final Optional> chatHistory; @@ -45,44 +44,81 @@ public final class ChatRequest { private final Optional>> documents; - private final Optional citationQuality; - private final Optional temperature; + private final Optional maxTokens; + + private final Optional maxInputTokens; + + private final Optional k; + + private final Optional p; + + private final Optional seed; + + private final Optional> stopSequences; + + private final Optional frequencyPenalty; + + private final Optional presencePenalty; + + private final Optional rawPrompting; + + private final Optional> tools; + + private final Optional> toolResults; + private final Map additionalProperties; private ChatRequest( String message, Optional model, - Boolean stream, - Optional preambleOverride, + Optional preamble, Optional> chatHistory, Optional conversationId, Optional promptTruncation, Optional> connectors, Optional searchQueriesOnly, Optional>> documents, - Optional citationQuality, Optional temperature, + Optional maxTokens, + Optional maxInputTokens, + Optional k, + Optional p, + Optional seed, + Optional> stopSequences, + Optional frequencyPenalty, + Optional presencePenalty, + Optional rawPrompting, + Optional> tools, + Optional> toolResults, Map additionalProperties) { this.message = message; this.model = model; - this.stream = stream; - this.preambleOverride = preambleOverride; + this.preamble = preamble; this.chatHistory = chatHistory; this.conversationId = conversationId; this.promptTruncation = promptTruncation; this.connectors = connectors; this.searchQueriesOnly = searchQueriesOnly; this.documents = documents; - this.citationQuality = citationQuality; this.temperature = temperature; + this.maxTokens = maxTokens; + this.maxInputTokens = maxInputTokens; + this.k = k; + this.p = p; + this.seed = seed; + this.stopSequences = stopSequences; + this.frequencyPenalty = frequencyPenalty; + this.presencePenalty = presencePenalty; + this.rawPrompting = rawPrompting; + this.tools = tools; + this.toolResults = toolResults; this.additionalProperties = additionalProperties; } /** - * @return Accepts a string. - * The chat message from the user to the model. + * @return Text input for the model to respond to. */ @JsonProperty("message") public String getMessage() { @@ -90,9 +126,8 @@ public String getMessage() { } /** - * @return Defaults to command. - * The identifier of the model, which can be one of the existing Cohere models or the full ID for a finetuned custom model. - * Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models. + * @return Defaults to command-r. + *

The name of a compatible Cohere model or the ID of a fine-tuned model.

*/ @JsonProperty("model") public Optional getModel() { @@ -101,19 +136,22 @@ public Optional getModel() { @JsonProperty("stream") public Boolean getStream() { - return stream; + return false; } /** - * @return When specified, the default Cohere preamble will be replaced with the provided one. + * @return When specified, the default Cohere preamble will be replaced with the provided one. Preambles are a part of the prompt used to adjust the model's overall behavior and conversation style, and use the SYSTEM role. + *

The SYSTEM role is also used for the contents of the optional chat_history= parameter. When used with the chat_history= parameter it adds content throughout a conversation. Conversely, when used with the preamble= parameter it adds content at the start of the conversation only.

*/ - @JsonProperty("preamble_override") - public Optional getPreambleOverride() { - return preambleOverride; + @JsonProperty("preamble") + public Optional getPreamble() { + return preamble; } /** - * @return A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message. + * @return A list of previous messages between the user and the model, giving the model conversational context for responding to the user's message. + *

Each item represents a single message in the chat history, excluding the current user turn. It has two properties: role and message. The role identifies the sender (CHATBOT, SYSTEM, or USER), while the message contains the text content.

+ *

The chat_history parameter should not be used for SYSTEM messages in most cases. Instead, to add a SYSTEM role message at the beginning of a conversation, the preamble parameter should be used.

*/ @JsonProperty("chat_history") public Optional> getChatHistory() { @@ -121,8 +159,8 @@ public Optional> getChatHistory() { } /** - * @return An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation. - * If a conversation with this id does not already exist, a new conversation will be created. + * @return An alternative to chat_history. + *

Providing a conversation_id creates or resumes a persisted conversation with the specified ID. The ID can be any non empty string.

*/ @JsonProperty("conversation_id") public Optional getConversationId() { @@ -131,9 +169,10 @@ public Optional getConversationId() { /** * @return Defaults to AUTO when connectors are specified and OFF in all other cases. - * Dictates how the prompt will be constructed. - * With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. - * With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned. + *

Dictates how the prompt will be constructed.

+ *

With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be changed and ranked by relevance.

+ *

With prompt_truncation set to "AUTO_PRESERVE_ORDER", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be preserved as they are inputted into the API.

+ *

With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

*/ @JsonProperty("prompt_truncation") public Optional getPromptTruncation() { @@ -142,7 +181,7 @@ public Optional getPromptTruncation() { /** * @return Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - * When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG). + *

When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).

*/ @JsonProperty("connectors") public Optional> getConnectors() { @@ -151,7 +190,7 @@ public Optional> getConnectors() { /** * @return Defaults to false. - * When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated. + *

When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

*/ @JsonProperty("search_queries_only") public Optional getSearchQueriesOnly() { @@ -159,7 +198,14 @@ public Optional getSearchQueriesOnly() { } /** - * @return A list of relevant documents that the model can use to enrich its reply. See 'Document Mode' in the guide for more information. + * @return A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary. + *

Example: + * [ { "title": "Tall penguins", "text": "Emperor penguins are the tallest." }, { "title": "Penguin habitats", "text": "Emperor penguins only live in Antarctica." }, ]

+ *

Keys and values from each document will be serialized to a string and passed to the model. The resulting generation will include citations that reference some of these documents.

+ *

Some suggested keys are "text", "author", and "date". For better generation quality, it is recommended to keep the total word count of the strings in the dictionary to under 300 words.

+ *

An id field (string) can be optionally supplied to identify the document in the citations. This field will not be passed to the model.

+ *

An _excludes field (array of strings) can be optionally supplied to omit some key-value pairs from being shown to the model. The omitted fields will still show up in the citation object. The "_excludes" field will not be passed to the model.

+ *

See 'Document Mode' in the guide for more information.

*/ @JsonProperty("documents") public Optional>> getDocuments() { @@ -167,24 +213,128 @@ public Optional>> getDocuments() { } /** - * @return Defaults to "accurate". - * Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results. + * @return Defaults to 0.3. + *

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.

+ *

Randomness can be further maximized by increasing the value of the p parameter.

*/ - @JsonProperty("citation_quality") - public Optional getCitationQuality() { - return citationQuality; + @JsonProperty("temperature") + public Optional getTemperature() { + return temperature; } /** - * @return Defaults to 0.3 - * 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. + * @return The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations. */ - @JsonProperty("temperature") - public Optional getTemperature() { - return temperature; + @JsonProperty("max_tokens") + public Optional getMaxTokens() { + return maxTokens; } - @Override + /** + * @return The maximum number of input tokens to send to the model. If not specified, max_input_tokens is the model's context length limit minus a small buffer. + *

Input will be truncated according to the prompt_truncation parameter.

+ */ + @JsonProperty("max_input_tokens") + public Optional getMaxInputTokens() { + return maxInputTokens; + } + + /** + * @return Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500. + */ + @JsonProperty("k") + public Optional getK() { + return k; + } + + /** + * @return Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99. + */ + @JsonProperty("p") + public Optional getP() { + return p; + } + + /** + * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinism cannot be totally guaranteed. + */ + @JsonProperty("seed") + public Optional getSeed() { + return seed; + } + + /** + * @return A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence. + */ + @JsonProperty("stop_sequences") + public Optional> getStopSequences() { + return stopSequences; + } + + /** + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. + *

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

+ */ + @JsonProperty("frequency_penalty") + public Optional getFrequencyPenalty() { + return frequencyPenalty; + } + + /** + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. + *

Used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

+ */ + @JsonProperty("presence_penalty") + public Optional getPresencePenalty() { + return presencePenalty; + } + + /** + * @return When enabled, the user's prompt will be sent to the model without any pre-processing. + */ + @JsonProperty("raw_prompting") + public Optional getRawPrompting() { + return rawPrompting; + } + + /** + * @return A list of available tools (functions) that the model may suggest invoking before producing a text response. + *

When tools is passed (without tool_results), the text field in the response will be "" and the tool_calls 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 tool_calls array will be empty.

+ */ + @JsonProperty("tools") + public Optional> getTools() { + return tools; + } + + /** + * @return A list of results from invoking tools recommended by the model in the previous chat turn. Results are used to produce a text response and will be referenced in citations. When using tool_results, tools must be passed as well. + * Each tool_result contains information about how it was invoked, as well as a list of outputs in the form of dictionaries. + *

Note: outputs must be a list of objects. If your tool returns a single object (eg {"status": 200}), make sure to wrap it in a list.

+ *
tool_results = [
+     *   {
+     *     "call": {
+     *       "name": <tool name>,
+     *       "parameters": {
+     *         <param name>: <param value>
+     *       }
+     *     },
+     *     "outputs": [{
+     *       <key>: <value>
+     *     }]
+     *   },
+     *   ...
+     * ]
+     * 
+ *

Note: Chat calls with tool_results should not be included in the Chat history to avoid duplication of the message text.

+ */ + @JsonProperty("tool_results") + public Optional> getToolResults() { + return toolResults; + } + + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatRequest && equalTo((ChatRequest) other); @@ -198,36 +348,54 @@ public Map getAdditionalProperties() { private boolean equalTo(ChatRequest other) { return message.equals(other.message) && model.equals(other.model) - && stream.equals(other.stream) - && preambleOverride.equals(other.preambleOverride) + && preamble.equals(other.preamble) && chatHistory.equals(other.chatHistory) && conversationId.equals(other.conversationId) && promptTruncation.equals(other.promptTruncation) && connectors.equals(other.connectors) && searchQueriesOnly.equals(other.searchQueriesOnly) && documents.equals(other.documents) - && citationQuality.equals(other.citationQuality) - && temperature.equals(other.temperature); + && temperature.equals(other.temperature) + && maxTokens.equals(other.maxTokens) + && maxInputTokens.equals(other.maxInputTokens) + && k.equals(other.k) + && p.equals(other.p) + && seed.equals(other.seed) + && stopSequences.equals(other.stopSequences) + && frequencyPenalty.equals(other.frequencyPenalty) + && presencePenalty.equals(other.presencePenalty) + && rawPrompting.equals(other.rawPrompting) + && tools.equals(other.tools) + && toolResults.equals(other.toolResults); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.message, this.model, - this.stream, - this.preambleOverride, + this.preamble, this.chatHistory, this.conversationId, this.promptTruncation, this.connectors, this.searchQueriesOnly, this.documents, - this.citationQuality, - this.temperature); + this.temperature, + this.maxTokens, + this.maxInputTokens, + this.k, + this.p, + this.seed, + this.stopSequences, + this.frequencyPenalty, + this.presencePenalty, + this.rawPrompting, + this.tools, + this.toolResults); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -237,15 +405,11 @@ public static MessageStage builder() { } public interface MessageStage { - StreamStage message(String message); + _FinalStage message(String message); Builder from(ChatRequest other); } - public interface StreamStage { - _FinalStage stream(Boolean stream); - } - public interface _FinalStage { ChatRequest build(); @@ -253,9 +417,9 @@ public interface _FinalStage { _FinalStage model(String model); - _FinalStage preambleOverride(Optional preambleOverride); + _FinalStage preamble(Optional preamble); - _FinalStage preambleOverride(String preambleOverride); + _FinalStage preamble(String preamble); _FinalStage chatHistory(Optional> chatHistory); @@ -281,24 +445,82 @@ public interface _FinalStage { _FinalStage documents(List> documents); - _FinalStage citationQuality(Optional citationQuality); - - _FinalStage citationQuality(ChatRequestCitationQuality citationQuality); - _FinalStage temperature(Optional temperature); _FinalStage temperature(Double temperature); + + _FinalStage maxTokens(Optional maxTokens); + + _FinalStage maxTokens(Integer maxTokens); + + _FinalStage maxInputTokens(Optional maxInputTokens); + + _FinalStage maxInputTokens(Integer maxInputTokens); + + _FinalStage k(Optional k); + + _FinalStage k(Integer k); + + _FinalStage p(Optional p); + + _FinalStage p(Double p); + + _FinalStage seed(Optional seed); + + _FinalStage seed(Double seed); + + _FinalStage stopSequences(Optional> stopSequences); + + _FinalStage stopSequences(List stopSequences); + + _FinalStage frequencyPenalty(Optional frequencyPenalty); + + _FinalStage frequencyPenalty(Double frequencyPenalty); + + _FinalStage presencePenalty(Optional presencePenalty); + + _FinalStage presencePenalty(Double presencePenalty); + + _FinalStage rawPrompting(Optional rawPrompting); + + _FinalStage rawPrompting(Boolean rawPrompting); + + _FinalStage tools(Optional> tools); + + _FinalStage tools(List tools); + + _FinalStage toolResults(Optional> toolResults); + + _FinalStage toolResults(List toolResults); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, StreamStage, _FinalStage { + public static final class Builder implements MessageStage, _FinalStage { private String message; - private Boolean stream; + private Optional> toolResults = Optional.empty(); - private Optional temperature = Optional.empty(); + private Optional> tools = Optional.empty(); + + private Optional rawPrompting = Optional.empty(); + + private Optional presencePenalty = Optional.empty(); + + private Optional frequencyPenalty = Optional.empty(); + + private Optional> stopSequences = Optional.empty(); + + private Optional seed = Optional.empty(); - private Optional citationQuality = Optional.empty(); + private Optional p = Optional.empty(); + + private Optional k = Optional.empty(); + + private Optional maxInputTokens = Optional.empty(); + + private Optional maxTokens = Optional.empty(); + + private Optional temperature = Optional.empty(); private Optional>> documents = Optional.empty(); @@ -312,7 +534,7 @@ public static final class Builder implements MessageStage, StreamStage, _FinalSt private Optional> chatHistory = Optional.empty(); - private Optional preambleOverride = Optional.empty(); + private Optional preamble = Optional.empty(); private Optional model = Optional.empty(); @@ -321,89 +543,291 @@ public static final class Builder implements MessageStage, StreamStage, _FinalSt private Builder() {} - @Override + @java.lang.Override public Builder from(ChatRequest other) { message(other.getMessage()); model(other.getModel()); - stream(other.getStream()); - preambleOverride(other.getPreambleOverride()); + preamble(other.getPreamble()); chatHistory(other.getChatHistory()); conversationId(other.getConversationId()); promptTruncation(other.getPromptTruncation()); connectors(other.getConnectors()); searchQueriesOnly(other.getSearchQueriesOnly()); documents(other.getDocuments()); - citationQuality(other.getCitationQuality()); temperature(other.getTemperature()); + maxTokens(other.getMaxTokens()); + maxInputTokens(other.getMaxInputTokens()); + k(other.getK()); + p(other.getP()); + seed(other.getSeed()); + stopSequences(other.getStopSequences()); + frequencyPenalty(other.getFrequencyPenalty()); + presencePenalty(other.getPresencePenalty()); + rawPrompting(other.getRawPrompting()); + tools(other.getTools()); + toolResults(other.getToolResults()); return this; } /** - *

Accepts a string. - * The chat message from the user to the model.

+ *

Text input for the model to respond to.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("message") - public StreamStage message(String message) { + public _FinalStage message(String message) { this.message = message; return this; } - @Override - @JsonSetter("stream") - public _FinalStage stream(Boolean stream) { - this.stream = stream; + /** + *

A list of results from invoking tools recommended by the model in the previous chat turn. Results are used to produce a text response and will be referenced in citations. When using tool_results, tools must be passed as well. + * Each tool_result contains information about how it was invoked, as well as a list of outputs in the form of dictionaries.

+ *

Note: outputs must be a list of objects. If your tool returns a single object (eg {"status": 200}), make sure to wrap it in a list.

+ *
tool_results = [
+         *   {
+         *     "call": {
+         *       "name": <tool name>,
+         *       "parameters": {
+         *         <param name>: <param value>
+         *       }
+         *     },
+         *     "outputs": [{
+         *       <key>: <value>
+         *     }]
+         *   },
+         *   ...
+         * ]
+         * 
+ *

Note: Chat calls with tool_results should not be included in the Chat history to avoid duplication of the message text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage toolResults(List toolResults) { + this.toolResults = Optional.of(toolResults); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tool_results", nulls = Nulls.SKIP) + public _FinalStage toolResults(Optional> toolResults) { + this.toolResults = toolResults; return this; } /** - *

Defaults to 0.3 - * 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.

+ *

A list of available tools (functions) that the model may suggest invoking before producing a text response.

+ *

When tools is passed (without tool_results), the text field in the response will be "" and the tool_calls 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 tool_calls array will be empty.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override - public _FinalStage temperature(Double temperature) { - this.temperature = Optional.of(temperature); + @java.lang.Override + public _FinalStage tools(List tools) { + this.tools = Optional.of(tools); return this; } - @Override - @JsonSetter(value = "temperature", nulls = Nulls.SKIP) - public _FinalStage temperature(Optional temperature) { - this.temperature = temperature; + @java.lang.Override + @JsonSetter(value = "tools", nulls = Nulls.SKIP) + public _FinalStage tools(Optional> tools) { + this.tools = tools; + return this; + } + + /** + *

When enabled, the user's prompt will be sent to the model without any pre-processing.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage rawPrompting(Boolean rawPrompting) { + this.rawPrompting = Optional.of(rawPrompting); + return this; + } + + @java.lang.Override + @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) + public _FinalStage rawPrompting(Optional rawPrompting) { + this.rawPrompting = rawPrompting; + return this; + } + + /** + *

Defaults to 0.0, min value of 0.0, max value of 1.0.

+ *

Used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage presencePenalty(Double presencePenalty) { + this.presencePenalty = Optional.of(presencePenalty); + return this; + } + + @java.lang.Override + @JsonSetter(value = "presence_penalty", nulls = Nulls.SKIP) + public _FinalStage presencePenalty(Optional presencePenalty) { + this.presencePenalty = presencePenalty; + return this; + } + + /** + *

Defaults to 0.0, min value of 0.0, max value of 1.0.

+ *

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage frequencyPenalty(Double frequencyPenalty) { + this.frequencyPenalty = Optional.of(frequencyPenalty); + return this; + } + + @java.lang.Override + @JsonSetter(value = "frequency_penalty", nulls = Nulls.SKIP) + public _FinalStage frequencyPenalty(Optional frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + return this; + } + + /** + *

A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage stopSequences(List stopSequences) { + this.stopSequences = Optional.of(stopSequences); + return this; + } + + @java.lang.Override + @JsonSetter(value = "stop_sequences", nulls = Nulls.SKIP) + public _FinalStage stopSequences(Optional> stopSequences) { + this.stopSequences = stopSequences; + return this; + } + + /** + *

If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinism cannot be totally guaranteed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage seed(Double seed) { + this.seed = Optional.of(seed); + return this; + } + + @java.lang.Override + @JsonSetter(value = "seed", nulls = Nulls.SKIP) + public _FinalStage seed(Optional seed) { + this.seed = seed; + return this; + } + + /** + *

Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage p(Double p) { + this.p = Optional.of(p); + return this; + } + + @java.lang.Override + @JsonSetter(value = "p", nulls = Nulls.SKIP) + public _FinalStage p(Optional p) { + this.p = p; + return this; + } + + /** + *

Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage k(Integer k) { + this.k = Optional.of(k); + return this; + } + + @java.lang.Override + @JsonSetter(value = "k", nulls = Nulls.SKIP) + public _FinalStage k(Optional k) { + this.k = k; + return this; + } + + /** + *

The maximum number of input tokens to send to the model. If not specified, max_input_tokens is the model's context length limit minus a small buffer.

+ *

Input will be truncated according to the prompt_truncation parameter.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage maxInputTokens(Integer maxInputTokens) { + this.maxInputTokens = Optional.of(maxInputTokens); + return this; + } + + @java.lang.Override + @JsonSetter(value = "max_input_tokens", nulls = Nulls.SKIP) + public _FinalStage maxInputTokens(Optional maxInputTokens) { + this.maxInputTokens = maxInputTokens; + return this; + } + + /** + *

The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage maxTokens(Integer maxTokens) { + this.maxTokens = Optional.of(maxTokens); + return this; + } + + @java.lang.Override + @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) + public _FinalStage maxTokens(Optional maxTokens) { + this.maxTokens = maxTokens; return this; } /** - *

Defaults to "accurate". - * Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results.

+ *

Defaults to 0.3.

+ *

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.

+ *

Randomness can be further maximized by increasing the value of the p parameter.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override - public _FinalStage citationQuality(ChatRequestCitationQuality citationQuality) { - this.citationQuality = Optional.of(citationQuality); + @java.lang.Override + public _FinalStage temperature(Double temperature) { + this.temperature = Optional.of(temperature); return this; } - @Override - @JsonSetter(value = "citation_quality", nulls = Nulls.SKIP) - public _FinalStage citationQuality(Optional citationQuality) { - this.citationQuality = citationQuality; + @java.lang.Override + @JsonSetter(value = "temperature", nulls = Nulls.SKIP) + public _FinalStage temperature(Optional temperature) { + this.temperature = temperature; return this; } /** - *

A list of relevant documents that the model can use to enrich its reply. See 'Document Mode' in the guide for more information.

+ *

A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary.

+ *

Example: + * [ { "title": "Tall penguins", "text": "Emperor penguins are the tallest." }, { "title": "Penguin habitats", "text": "Emperor penguins only live in Antarctica." }, ]

+ *

Keys and values from each document will be serialized to a string and passed to the model. The resulting generation will include citations that reference some of these documents.

+ *

Some suggested keys are "text", "author", and "date". For better generation quality, it is recommended to keep the total word count of the strings in the dictionary to under 300 words.

+ *

An id field (string) can be optionally supplied to identify the document in the citations. This field will not be passed to the model.

+ *

An _excludes field (array of strings) can be optionally supplied to omit some key-value pairs from being shown to the model. The omitted fields will still show up in the citation object. The "_excludes" field will not be passed to the model.

+ *

See 'Document Mode' in the guide for more information.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage documents(List> documents) { this.documents = Optional.of(documents); return this; } - @Override + @java.lang.Override @JsonSetter(value = "documents", nulls = Nulls.SKIP) public _FinalStage documents(Optional>> documents) { this.documents = documents; @@ -411,17 +835,17 @@ public _FinalStage documents(Optional>> documents) { } /** - *

Defaults to false. - * When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

+ *

Defaults to false.

+ *

When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage searchQueriesOnly(Boolean searchQueriesOnly) { this.searchQueriesOnly = Optional.of(searchQueriesOnly); return this; } - @Override + @java.lang.Override @JsonSetter(value = "search_queries_only", nulls = Nulls.SKIP) public _FinalStage searchQueriesOnly(Optional searchQueriesOnly) { this.searchQueriesOnly = searchQueriesOnly; @@ -429,17 +853,17 @@ public _FinalStage searchQueriesOnly(Optional searchQueriesOnly) { } /** - *

Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - * When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).

+ *

Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one.

+ *

When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage connectors(List connectors) { this.connectors = Optional.of(connectors); return this; } - @Override + @java.lang.Override @JsonSetter(value = "connectors", nulls = Nulls.SKIP) public _FinalStage connectors(Optional> connectors) { this.connectors = connectors; @@ -447,19 +871,20 @@ public _FinalStage connectors(Optional> connectors) { } /** - *

Defaults to AUTO when connectors are specified and OFF in all other cases. - * Dictates how the prompt will be constructed. - * With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. - * With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

+ *

Defaults to AUTO when connectors are specified and OFF in all other cases.

+ *

Dictates how the prompt will be constructed.

+ *

With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be changed and ranked by relevance.

+ *

With prompt_truncation set to "AUTO_PRESERVE_ORDER", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be preserved as they are inputted into the API.

+ *

With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage promptTruncation(ChatRequestPromptTruncation promptTruncation) { this.promptTruncation = Optional.of(promptTruncation); return this; } - @Override + @java.lang.Override @JsonSetter(value = "prompt_truncation", nulls = Nulls.SKIP) public _FinalStage promptTruncation(Optional promptTruncation) { this.promptTruncation = promptTruncation; @@ -467,17 +892,17 @@ public _FinalStage promptTruncation(Optional prompt } /** - *

An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation. - * If a conversation with this id does not already exist, a new conversation will be created.

+ *

An alternative to chat_history.

+ *

Providing a conversation_id creates or resumes a persisted conversation with the specified ID. The ID can be any non empty string.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage conversationId(String conversationId) { this.conversationId = Optional.of(conversationId); return this; } - @Override + @java.lang.Override @JsonSetter(value = "conversation_id", nulls = Nulls.SKIP) public _FinalStage conversationId(Optional conversationId) { this.conversationId = conversationId; @@ -485,16 +910,18 @@ public _FinalStage conversationId(Optional conversationId) { } /** - *

A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message.

+ *

A list of previous messages between the user and the model, giving the model conversational context for responding to the user's message.

+ *

Each item represents a single message in the chat history, excluding the current user turn. It has two properties: role and message. The role identifies the sender (CHATBOT, SYSTEM, or USER), while the message contains the text content.

+ *

The chat_history parameter should not be used for SYSTEM messages in most cases. Instead, to add a SYSTEM role message at the beginning of a conversation, the preamble parameter should be used.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage chatHistory(List chatHistory) { this.chatHistory = Optional.of(chatHistory); return this; } - @Override + @java.lang.Override @JsonSetter(value = "chat_history", nulls = Nulls.SKIP) public _FinalStage chatHistory(Optional> chatHistory) { this.chatHistory = chatHistory; @@ -502,56 +929,65 @@ public _FinalStage chatHistory(Optional> chatHistory) { } /** - *

When specified, the default Cohere preamble will be replaced with the provided one.

+ *

When specified, the default Cohere preamble will be replaced with the provided one. Preambles are a part of the prompt used to adjust the model's overall behavior and conversation style, and use the SYSTEM role.

+ *

The SYSTEM role is also used for the contents of the optional chat_history= parameter. When used with the chat_history= parameter it adds content throughout a conversation. Conversely, when used with the preamble= parameter it adds content at the start of the conversation only.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override - public _FinalStage preambleOverride(String preambleOverride) { - this.preambleOverride = Optional.of(preambleOverride); + @java.lang.Override + public _FinalStage preamble(String preamble) { + this.preamble = Optional.of(preamble); return this; } - @Override - @JsonSetter(value = "preamble_override", nulls = Nulls.SKIP) - public _FinalStage preambleOverride(Optional preambleOverride) { - this.preambleOverride = preambleOverride; + @java.lang.Override + @JsonSetter(value = "preamble", nulls = Nulls.SKIP) + public _FinalStage preamble(Optional preamble) { + this.preamble = preamble; return this; } /** - *

Defaults to command. - * The identifier of the model, which can be one of the existing Cohere models or the full ID for a finetuned custom model. - * Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models.

+ *

Defaults to command-r.

+ *

The name of a compatible Cohere model or the ID of a fine-tuned model.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public ChatRequest build() { return new ChatRequest( message, model, - stream, - preambleOverride, + preamble, chatHistory, conversationId, promptTruncation, connectors, searchQueriesOnly, documents, - citationQuality, temperature, + maxTokens, + maxInputTokens, + k, + p, + seed, + stopSequences, + frequencyPenalty, + presencePenalty, + rawPrompting, + tools, + toolResults, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java index 59bc69d..7c98eb8 100644 --- a/src/main/java/com/cohere/api/requests/ChatStreamRequest.java +++ b/src/main/java/com/cohere/api/requests/ChatStreamRequest.java @@ -6,8 +6,9 @@ import com.cohere.api.core.ObjectMappers; import com.cohere.api.types.ChatConnector; import com.cohere.api.types.ChatMessage; -import com.cohere.api.types.ChatStreamRequestCitationQuality; import com.cohere.api.types.ChatStreamRequestPromptTruncation; +import com.cohere.api.types.ChatStreamRequestToolResultsItem; +import com.cohere.api.types.Tool; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -29,9 +30,7 @@ public final class ChatStreamRequest { private final Optional model; - private final Boolean stream; - - private final Optional preambleOverride; + private final Optional preamble; private final Optional> chatHistory; @@ -45,44 +44,81 @@ public final class ChatStreamRequest { private final Optional>> documents; - private final Optional citationQuality; - private final Optional temperature; + private final Optional maxTokens; + + private final Optional maxInputTokens; + + private final Optional k; + + private final Optional p; + + private final Optional seed; + + private final Optional> stopSequences; + + private final Optional frequencyPenalty; + + private final Optional presencePenalty; + + private final Optional rawPrompting; + + private final Optional> tools; + + private final Optional> toolResults; + private final Map additionalProperties; private ChatStreamRequest( String message, Optional model, - Boolean stream, - Optional preambleOverride, + Optional preamble, Optional> chatHistory, Optional conversationId, Optional promptTruncation, Optional> connectors, Optional searchQueriesOnly, Optional>> documents, - Optional citationQuality, Optional temperature, + Optional maxTokens, + Optional maxInputTokens, + Optional k, + Optional p, + Optional seed, + Optional> stopSequences, + Optional frequencyPenalty, + Optional presencePenalty, + Optional rawPrompting, + Optional> tools, + Optional> toolResults, Map additionalProperties) { this.message = message; this.model = model; - this.stream = stream; - this.preambleOverride = preambleOverride; + this.preamble = preamble; this.chatHistory = chatHistory; this.conversationId = conversationId; this.promptTruncation = promptTruncation; this.connectors = connectors; this.searchQueriesOnly = searchQueriesOnly; this.documents = documents; - this.citationQuality = citationQuality; this.temperature = temperature; + this.maxTokens = maxTokens; + this.maxInputTokens = maxInputTokens; + this.k = k; + this.p = p; + this.seed = seed; + this.stopSequences = stopSequences; + this.frequencyPenalty = frequencyPenalty; + this.presencePenalty = presencePenalty; + this.rawPrompting = rawPrompting; + this.tools = tools; + this.toolResults = toolResults; this.additionalProperties = additionalProperties; } /** - * @return Accepts a string. - * The chat message from the user to the model. + * @return Text input for the model to respond to. */ @JsonProperty("message") public String getMessage() { @@ -90,9 +126,8 @@ public String getMessage() { } /** - * @return Defaults to command. - * The identifier of the model, which can be one of the existing Cohere models or the full ID for a finetuned custom model. - * Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models. + * @return Defaults to command-r. + *

The name of a compatible Cohere model or the ID of a fine-tuned model.

*/ @JsonProperty("model") public Optional getModel() { @@ -101,19 +136,22 @@ public Optional getModel() { @JsonProperty("stream") public Boolean getStream() { - return stream; + return true; } /** - * @return When specified, the default Cohere preamble will be replaced with the provided one. + * @return When specified, the default Cohere preamble will be replaced with the provided one. Preambles are a part of the prompt used to adjust the model's overall behavior and conversation style, and use the SYSTEM role. + *

The SYSTEM role is also used for the contents of the optional chat_history= parameter. When used with the chat_history= parameter it adds content throughout a conversation. Conversely, when used with the preamble= parameter it adds content at the start of the conversation only.

*/ - @JsonProperty("preamble_override") - public Optional getPreambleOverride() { - return preambleOverride; + @JsonProperty("preamble") + public Optional getPreamble() { + return preamble; } /** - * @return A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message. + * @return A list of previous messages between the user and the model, giving the model conversational context for responding to the user's message. + *

Each item represents a single message in the chat history, excluding the current user turn. It has two properties: role and message. The role identifies the sender (CHATBOT, SYSTEM, or USER), while the message contains the text content.

+ *

The chat_history parameter should not be used for SYSTEM messages in most cases. Instead, to add a SYSTEM role message at the beginning of a conversation, the preamble parameter should be used.

*/ @JsonProperty("chat_history") public Optional> getChatHistory() { @@ -121,8 +159,8 @@ public Optional> getChatHistory() { } /** - * @return An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation. - * If a conversation with this id does not already exist, a new conversation will be created. + * @return An alternative to chat_history. + *

Providing a conversation_id creates or resumes a persisted conversation with the specified ID. The ID can be any non empty string.

*/ @JsonProperty("conversation_id") public Optional getConversationId() { @@ -131,9 +169,10 @@ public Optional getConversationId() { /** * @return Defaults to AUTO when connectors are specified and OFF in all other cases. - * Dictates how the prompt will be constructed. - * With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. - * With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned. + *

Dictates how the prompt will be constructed.

+ *

With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be changed and ranked by relevance.

+ *

With prompt_truncation set to "AUTO_PRESERVE_ORDER", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be preserved as they are inputted into the API.

+ *

With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

*/ @JsonProperty("prompt_truncation") public Optional getPromptTruncation() { @@ -142,7 +181,7 @@ public Optional getPromptTruncation() { /** * @return Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - * When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG). + *

When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).

*/ @JsonProperty("connectors") public Optional> getConnectors() { @@ -151,7 +190,7 @@ public Optional> getConnectors() { /** * @return Defaults to false. - * When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated. + *

When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

*/ @JsonProperty("search_queries_only") public Optional getSearchQueriesOnly() { @@ -159,7 +198,14 @@ public Optional getSearchQueriesOnly() { } /** - * @return A list of relevant documents that the model can use to enrich its reply. See 'Document Mode' in the guide for more information. + * @return A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary. + *

Example: + * [ { "title": "Tall penguins", "text": "Emperor penguins are the tallest." }, { "title": "Penguin habitats", "text": "Emperor penguins only live in Antarctica." }, ]

+ *

Keys and values from each document will be serialized to a string and passed to the model. The resulting generation will include citations that reference some of these documents.

+ *

Some suggested keys are "text", "author", and "date". For better generation quality, it is recommended to keep the total word count of the strings in the dictionary to under 300 words.

+ *

An id field (string) can be optionally supplied to identify the document in the citations. This field will not be passed to the model.

+ *

An _excludes field (array of strings) can be optionally supplied to omit some key-value pairs from being shown to the model. The omitted fields will still show up in the citation object. The "_excludes" field will not be passed to the model.

+ *

See 'Document Mode' in the guide for more information.

*/ @JsonProperty("documents") public Optional>> getDocuments() { @@ -167,24 +213,128 @@ public Optional>> getDocuments() { } /** - * @return Defaults to "accurate". - * Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results. + * @return Defaults to 0.3. + *

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.

+ *

Randomness can be further maximized by increasing the value of the p parameter.

*/ - @JsonProperty("citation_quality") - public Optional getCitationQuality() { - return citationQuality; + @JsonProperty("temperature") + public Optional getTemperature() { + return temperature; } /** - * @return Defaults to 0.3 - * 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. + * @return The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations. */ - @JsonProperty("temperature") - public Optional getTemperature() { - return temperature; + @JsonProperty("max_tokens") + public Optional getMaxTokens() { + return maxTokens; } - @Override + /** + * @return The maximum number of input tokens to send to the model. If not specified, max_input_tokens is the model's context length limit minus a small buffer. + *

Input will be truncated according to the prompt_truncation parameter.

+ */ + @JsonProperty("max_input_tokens") + public Optional getMaxInputTokens() { + return maxInputTokens; + } + + /** + * @return Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500. + */ + @JsonProperty("k") + public Optional getK() { + return k; + } + + /** + * @return Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99. + */ + @JsonProperty("p") + public Optional getP() { + return p; + } + + /** + * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinism cannot be totally guaranteed. + */ + @JsonProperty("seed") + public Optional getSeed() { + return seed; + } + + /** + * @return A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence. + */ + @JsonProperty("stop_sequences") + public Optional> getStopSequences() { + return stopSequences; + } + + /** + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. + *

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

+ */ + @JsonProperty("frequency_penalty") + public Optional getFrequencyPenalty() { + return frequencyPenalty; + } + + /** + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. + *

Used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

+ */ + @JsonProperty("presence_penalty") + public Optional getPresencePenalty() { + return presencePenalty; + } + + /** + * @return When enabled, the user's prompt will be sent to the model without any pre-processing. + */ + @JsonProperty("raw_prompting") + public Optional getRawPrompting() { + return rawPrompting; + } + + /** + * @return A list of available tools (functions) that the model may suggest invoking before producing a text response. + *

When tools is passed (without tool_results), the text field in the response will be "" and the tool_calls 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 tool_calls array will be empty.

+ */ + @JsonProperty("tools") + public Optional> getTools() { + return tools; + } + + /** + * @return A list of results from invoking tools recommended by the model in the previous chat turn. Results are used to produce a text response and will be referenced in citations. When using tool_results, tools must be passed as well. + * Each tool_result contains information about how it was invoked, as well as a list of outputs in the form of dictionaries. + *

Note: outputs must be a list of objects. If your tool returns a single object (eg {"status": 200}), make sure to wrap it in a list.

+ *
tool_results = [
+     *   {
+     *     "call": {
+     *       "name": <tool name>,
+     *       "parameters": {
+     *         <param name>: <param value>
+     *       }
+     *     },
+     *     "outputs": [{
+     *       <key>: <value>
+     *     }]
+     *   },
+     *   ...
+     * ]
+     * 
+ *

Note: Chat calls with tool_results should not be included in the Chat history to avoid duplication of the message text.

+ */ + @JsonProperty("tool_results") + public Optional> getToolResults() { + return toolResults; + } + + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatStreamRequest && equalTo((ChatStreamRequest) other); @@ -198,36 +348,54 @@ public Map getAdditionalProperties() { private boolean equalTo(ChatStreamRequest other) { return message.equals(other.message) && model.equals(other.model) - && stream.equals(other.stream) - && preambleOverride.equals(other.preambleOverride) + && preamble.equals(other.preamble) && chatHistory.equals(other.chatHistory) && conversationId.equals(other.conversationId) && promptTruncation.equals(other.promptTruncation) && connectors.equals(other.connectors) && searchQueriesOnly.equals(other.searchQueriesOnly) && documents.equals(other.documents) - && citationQuality.equals(other.citationQuality) - && temperature.equals(other.temperature); + && temperature.equals(other.temperature) + && maxTokens.equals(other.maxTokens) + && maxInputTokens.equals(other.maxInputTokens) + && k.equals(other.k) + && p.equals(other.p) + && seed.equals(other.seed) + && stopSequences.equals(other.stopSequences) + && frequencyPenalty.equals(other.frequencyPenalty) + && presencePenalty.equals(other.presencePenalty) + && rawPrompting.equals(other.rawPrompting) + && tools.equals(other.tools) + && toolResults.equals(other.toolResults); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.message, this.model, - this.stream, - this.preambleOverride, + this.preamble, this.chatHistory, this.conversationId, this.promptTruncation, this.connectors, this.searchQueriesOnly, this.documents, - this.citationQuality, - this.temperature); + this.temperature, + this.maxTokens, + this.maxInputTokens, + this.k, + this.p, + this.seed, + this.stopSequences, + this.frequencyPenalty, + this.presencePenalty, + this.rawPrompting, + this.tools, + this.toolResults); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -237,15 +405,11 @@ public static MessageStage builder() { } public interface MessageStage { - StreamStage message(String message); + _FinalStage message(String message); Builder from(ChatStreamRequest other); } - public interface StreamStage { - _FinalStage stream(Boolean stream); - } - public interface _FinalStage { ChatStreamRequest build(); @@ -253,9 +417,9 @@ public interface _FinalStage { _FinalStage model(String model); - _FinalStage preambleOverride(Optional preambleOverride); + _FinalStage preamble(Optional preamble); - _FinalStage preambleOverride(String preambleOverride); + _FinalStage preamble(String preamble); _FinalStage chatHistory(Optional> chatHistory); @@ -281,24 +445,82 @@ public interface _FinalStage { _FinalStage documents(List> documents); - _FinalStage citationQuality(Optional citationQuality); - - _FinalStage citationQuality(ChatStreamRequestCitationQuality citationQuality); - _FinalStage temperature(Optional temperature); _FinalStage temperature(Double temperature); + + _FinalStage maxTokens(Optional maxTokens); + + _FinalStage maxTokens(Integer maxTokens); + + _FinalStage maxInputTokens(Optional maxInputTokens); + + _FinalStage maxInputTokens(Integer maxInputTokens); + + _FinalStage k(Optional k); + + _FinalStage k(Integer k); + + _FinalStage p(Optional p); + + _FinalStage p(Double p); + + _FinalStage seed(Optional seed); + + _FinalStage seed(Double seed); + + _FinalStage stopSequences(Optional> stopSequences); + + _FinalStage stopSequences(List stopSequences); + + _FinalStage frequencyPenalty(Optional frequencyPenalty); + + _FinalStage frequencyPenalty(Double frequencyPenalty); + + _FinalStage presencePenalty(Optional presencePenalty); + + _FinalStage presencePenalty(Double presencePenalty); + + _FinalStage rawPrompting(Optional rawPrompting); + + _FinalStage rawPrompting(Boolean rawPrompting); + + _FinalStage tools(Optional> tools); + + _FinalStage tools(List tools); + + _FinalStage toolResults(Optional> toolResults); + + _FinalStage toolResults(List toolResults); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, StreamStage, _FinalStage { + public static final class Builder implements MessageStage, _FinalStage { private String message; - private Boolean stream; + private Optional> toolResults = Optional.empty(); - private Optional temperature = Optional.empty(); + private Optional> tools = Optional.empty(); + + private Optional rawPrompting = Optional.empty(); + + private Optional presencePenalty = Optional.empty(); + + private Optional frequencyPenalty = Optional.empty(); + + private Optional> stopSequences = Optional.empty(); + + private Optional seed = Optional.empty(); - private Optional citationQuality = Optional.empty(); + private Optional p = Optional.empty(); + + private Optional k = Optional.empty(); + + private Optional maxInputTokens = Optional.empty(); + + private Optional maxTokens = Optional.empty(); + + private Optional temperature = Optional.empty(); private Optional>> documents = Optional.empty(); @@ -312,7 +534,7 @@ public static final class Builder implements MessageStage, StreamStage, _FinalSt private Optional> chatHistory = Optional.empty(); - private Optional preambleOverride = Optional.empty(); + private Optional preamble = Optional.empty(); private Optional model = Optional.empty(); @@ -321,89 +543,291 @@ public static final class Builder implements MessageStage, StreamStage, _FinalSt private Builder() {} - @Override + @java.lang.Override public Builder from(ChatStreamRequest other) { message(other.getMessage()); model(other.getModel()); - stream(other.getStream()); - preambleOverride(other.getPreambleOverride()); + preamble(other.getPreamble()); chatHistory(other.getChatHistory()); conversationId(other.getConversationId()); promptTruncation(other.getPromptTruncation()); connectors(other.getConnectors()); searchQueriesOnly(other.getSearchQueriesOnly()); documents(other.getDocuments()); - citationQuality(other.getCitationQuality()); temperature(other.getTemperature()); + maxTokens(other.getMaxTokens()); + maxInputTokens(other.getMaxInputTokens()); + k(other.getK()); + p(other.getP()); + seed(other.getSeed()); + stopSequences(other.getStopSequences()); + frequencyPenalty(other.getFrequencyPenalty()); + presencePenalty(other.getPresencePenalty()); + rawPrompting(other.getRawPrompting()); + tools(other.getTools()); + toolResults(other.getToolResults()); return this; } /** - *

Accepts a string. - * The chat message from the user to the model.

+ *

Text input for the model to respond to.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("message") - public StreamStage message(String message) { + public _FinalStage message(String message) { this.message = message; return this; } - @Override - @JsonSetter("stream") - public _FinalStage stream(Boolean stream) { - this.stream = stream; + /** + *

A list of results from invoking tools recommended by the model in the previous chat turn. Results are used to produce a text response and will be referenced in citations. When using tool_results, tools must be passed as well. + * Each tool_result contains information about how it was invoked, as well as a list of outputs in the form of dictionaries.

+ *

Note: outputs must be a list of objects. If your tool returns a single object (eg {"status": 200}), make sure to wrap it in a list.

+ *
tool_results = [
+         *   {
+         *     "call": {
+         *       "name": <tool name>,
+         *       "parameters": {
+         *         <param name>: <param value>
+         *       }
+         *     },
+         *     "outputs": [{
+         *       <key>: <value>
+         *     }]
+         *   },
+         *   ...
+         * ]
+         * 
+ *

Note: Chat calls with tool_results should not be included in the Chat history to avoid duplication of the message text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage toolResults(List toolResults) { + this.toolResults = Optional.of(toolResults); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tool_results", nulls = Nulls.SKIP) + public _FinalStage toolResults(Optional> toolResults) { + this.toolResults = toolResults; return this; } /** - *

Defaults to 0.3 - * 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.

+ *

A list of available tools (functions) that the model may suggest invoking before producing a text response.

+ *

When tools is passed (without tool_results), the text field in the response will be "" and the tool_calls 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 tool_calls array will be empty.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override - public _FinalStage temperature(Double temperature) { - this.temperature = Optional.of(temperature); + @java.lang.Override + public _FinalStage tools(List tools) { + this.tools = Optional.of(tools); return this; } - @Override - @JsonSetter(value = "temperature", nulls = Nulls.SKIP) - public _FinalStage temperature(Optional temperature) { - this.temperature = temperature; + @java.lang.Override + @JsonSetter(value = "tools", nulls = Nulls.SKIP) + public _FinalStage tools(Optional> tools) { + this.tools = tools; + return this; + } + + /** + *

When enabled, the user's prompt will be sent to the model without any pre-processing.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage rawPrompting(Boolean rawPrompting) { + this.rawPrompting = Optional.of(rawPrompting); + return this; + } + + @java.lang.Override + @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) + public _FinalStage rawPrompting(Optional rawPrompting) { + this.rawPrompting = rawPrompting; + return this; + } + + /** + *

Defaults to 0.0, min value of 0.0, max value of 1.0.

+ *

Used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage presencePenalty(Double presencePenalty) { + this.presencePenalty = Optional.of(presencePenalty); + return this; + } + + @java.lang.Override + @JsonSetter(value = "presence_penalty", nulls = Nulls.SKIP) + public _FinalStage presencePenalty(Optional presencePenalty) { + this.presencePenalty = presencePenalty; + return this; + } + + /** + *

Defaults to 0.0, min value of 0.0, max value of 1.0.

+ *

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage frequencyPenalty(Double frequencyPenalty) { + this.frequencyPenalty = Optional.of(frequencyPenalty); + return this; + } + + @java.lang.Override + @JsonSetter(value = "frequency_penalty", nulls = Nulls.SKIP) + public _FinalStage frequencyPenalty(Optional frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + return this; + } + + /** + *

A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage stopSequences(List stopSequences) { + this.stopSequences = Optional.of(stopSequences); + return this; + } + + @java.lang.Override + @JsonSetter(value = "stop_sequences", nulls = Nulls.SKIP) + public _FinalStage stopSequences(Optional> stopSequences) { + this.stopSequences = stopSequences; + return this; + } + + /** + *

If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinism cannot be totally guaranteed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage seed(Double seed) { + this.seed = Optional.of(seed); + return this; + } + + @java.lang.Override + @JsonSetter(value = "seed", nulls = Nulls.SKIP) + public _FinalStage seed(Optional seed) { + this.seed = seed; + return this; + } + + /** + *

Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage p(Double p) { + this.p = Optional.of(p); + return this; + } + + @java.lang.Override + @JsonSetter(value = "p", nulls = Nulls.SKIP) + public _FinalStage p(Optional p) { + this.p = p; + return this; + } + + /** + *

Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage k(Integer k) { + this.k = Optional.of(k); + return this; + } + + @java.lang.Override + @JsonSetter(value = "k", nulls = Nulls.SKIP) + public _FinalStage k(Optional k) { + this.k = k; + return this; + } + + /** + *

The maximum number of input tokens to send to the model. If not specified, max_input_tokens is the model's context length limit minus a small buffer.

+ *

Input will be truncated according to the prompt_truncation parameter.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage maxInputTokens(Integer maxInputTokens) { + this.maxInputTokens = Optional.of(maxInputTokens); + return this; + } + + @java.lang.Override + @JsonSetter(value = "max_input_tokens", nulls = Nulls.SKIP) + public _FinalStage maxInputTokens(Optional maxInputTokens) { + this.maxInputTokens = maxInputTokens; + return this; + } + + /** + *

The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage maxTokens(Integer maxTokens) { + this.maxTokens = Optional.of(maxTokens); + return this; + } + + @java.lang.Override + @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) + public _FinalStage maxTokens(Optional maxTokens) { + this.maxTokens = maxTokens; return this; } /** - *

Defaults to "accurate". - * Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want "accurate" results or "fast" results.

+ *

Defaults to 0.3.

+ *

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.

+ *

Randomness can be further maximized by increasing the value of the p parameter.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override - public _FinalStage citationQuality(ChatStreamRequestCitationQuality citationQuality) { - this.citationQuality = Optional.of(citationQuality); + @java.lang.Override + public _FinalStage temperature(Double temperature) { + this.temperature = Optional.of(temperature); return this; } - @Override - @JsonSetter(value = "citation_quality", nulls = Nulls.SKIP) - public _FinalStage citationQuality(Optional citationQuality) { - this.citationQuality = citationQuality; + @java.lang.Override + @JsonSetter(value = "temperature", nulls = Nulls.SKIP) + public _FinalStage temperature(Optional temperature) { + this.temperature = temperature; return this; } /** - *

A list of relevant documents that the model can use to enrich its reply. See 'Document Mode' in the guide for more information.

+ *

A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary.

+ *

Example: + * [ { "title": "Tall penguins", "text": "Emperor penguins are the tallest." }, { "title": "Penguin habitats", "text": "Emperor penguins only live in Antarctica." }, ]

+ *

Keys and values from each document will be serialized to a string and passed to the model. The resulting generation will include citations that reference some of these documents.

+ *

Some suggested keys are "text", "author", and "date". For better generation quality, it is recommended to keep the total word count of the strings in the dictionary to under 300 words.

+ *

An id field (string) can be optionally supplied to identify the document in the citations. This field will not be passed to the model.

+ *

An _excludes field (array of strings) can be optionally supplied to omit some key-value pairs from being shown to the model. The omitted fields will still show up in the citation object. The "_excludes" field will not be passed to the model.

+ *

See 'Document Mode' in the guide for more information.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage documents(List> documents) { this.documents = Optional.of(documents); return this; } - @Override + @java.lang.Override @JsonSetter(value = "documents", nulls = Nulls.SKIP) public _FinalStage documents(Optional>> documents) { this.documents = documents; @@ -411,17 +835,17 @@ public _FinalStage documents(Optional>> documents) { } /** - *

Defaults to false. - * When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

+ *

Defaults to false.

+ *

When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's message will be generated.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage searchQueriesOnly(Boolean searchQueriesOnly) { this.searchQueriesOnly = Optional.of(searchQueriesOnly); return this; } - @Override + @java.lang.Override @JsonSetter(value = "search_queries_only", nulls = Nulls.SKIP) public _FinalStage searchQueriesOnly(Optional searchQueriesOnly) { this.searchQueriesOnly = searchQueriesOnly; @@ -429,17 +853,17 @@ public _FinalStage searchQueriesOnly(Optional searchQueriesOnly) { } /** - *

Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one. - * When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).

+ *

Accepts {"id": "web-search"}, and/or the "id" for a custom connector, if you've created one.

+ *

When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG).

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage connectors(List connectors) { this.connectors = Optional.of(connectors); return this; } - @Override + @java.lang.Override @JsonSetter(value = "connectors", nulls = Nulls.SKIP) public _FinalStage connectors(Optional> connectors) { this.connectors = connectors; @@ -447,19 +871,20 @@ public _FinalStage connectors(Optional> connectors) { } /** - *

Defaults to AUTO when connectors are specified and OFF in all other cases. - * Dictates how the prompt will be constructed. - * With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. - * With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

+ *

Defaults to AUTO when connectors are specified and OFF in all other cases.

+ *

Dictates how the prompt will be constructed.

+ *

With prompt_truncation set to "AUTO", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be changed and ranked by relevance.

+ *

With prompt_truncation set to "AUTO_PRESERVE_ORDER", some elements from chat_history and documents will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be preserved as they are inputted into the API.

+ *

With prompt_truncation set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a TooManyTokens error will be returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage promptTruncation(ChatStreamRequestPromptTruncation promptTruncation) { this.promptTruncation = Optional.of(promptTruncation); return this; } - @Override + @java.lang.Override @JsonSetter(value = "prompt_truncation", nulls = Nulls.SKIP) public _FinalStage promptTruncation(Optional promptTruncation) { this.promptTruncation = promptTruncation; @@ -467,17 +892,17 @@ public _FinalStage promptTruncation(Optional } /** - *

An alternative to chat_history. Previous conversations can be resumed by providing the conversation's identifier. The contents of message and the model's response will be stored as part of this conversation. - * If a conversation with this id does not already exist, a new conversation will be created.

+ *

An alternative to chat_history.

+ *

Providing a conversation_id creates or resumes a persisted conversation with the specified ID. The ID can be any non empty string.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage conversationId(String conversationId) { this.conversationId = Optional.of(conversationId); return this; } - @Override + @java.lang.Override @JsonSetter(value = "conversation_id", nulls = Nulls.SKIP) public _FinalStage conversationId(Optional conversationId) { this.conversationId = conversationId; @@ -485,16 +910,18 @@ public _FinalStage conversationId(Optional conversationId) { } /** - *

A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message.

+ *

A list of previous messages between the user and the model, giving the model conversational context for responding to the user's message.

+ *

Each item represents a single message in the chat history, excluding the current user turn. It has two properties: role and message. The role identifies the sender (CHATBOT, SYSTEM, or USER), while the message contains the text content.

+ *

The chat_history parameter should not be used for SYSTEM messages in most cases. Instead, to add a SYSTEM role message at the beginning of a conversation, the preamble parameter should be used.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage chatHistory(List chatHistory) { this.chatHistory = Optional.of(chatHistory); return this; } - @Override + @java.lang.Override @JsonSetter(value = "chat_history", nulls = Nulls.SKIP) public _FinalStage chatHistory(Optional> chatHistory) { this.chatHistory = chatHistory; @@ -502,56 +929,65 @@ public _FinalStage chatHistory(Optional> chatHistory) { } /** - *

When specified, the default Cohere preamble will be replaced with the provided one.

+ *

When specified, the default Cohere preamble will be replaced with the provided one. Preambles are a part of the prompt used to adjust the model's overall behavior and conversation style, and use the SYSTEM role.

+ *

The SYSTEM role is also used for the contents of the optional chat_history= parameter. When used with the chat_history= parameter it adds content throughout a conversation. Conversely, when used with the preamble= parameter it adds content at the start of the conversation only.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override - public _FinalStage preambleOverride(String preambleOverride) { - this.preambleOverride = Optional.of(preambleOverride); + @java.lang.Override + public _FinalStage preamble(String preamble) { + this.preamble = Optional.of(preamble); return this; } - @Override - @JsonSetter(value = "preamble_override", nulls = Nulls.SKIP) - public _FinalStage preambleOverride(Optional preambleOverride) { - this.preambleOverride = preambleOverride; + @java.lang.Override + @JsonSetter(value = "preamble", nulls = Nulls.SKIP) + public _FinalStage preamble(Optional preamble) { + this.preamble = preamble; return this; } /** - *

Defaults to command. - * The identifier of the model, which can be one of the existing Cohere models or the full ID for a finetuned custom model. - * Compatible Cohere models are command and command-light as well as the experimental command-nightly and command-light-nightly variants. Read more about Cohere models.

+ *

Defaults to command-r.

+ *

The name of a compatible Cohere model or the ID of a fine-tuned model.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public ChatStreamRequest build() { return new ChatStreamRequest( message, model, - stream, - preambleOverride, + preamble, chatHistory, conversationId, promptTruncation, connectors, searchQueriesOnly, documents, - citationQuality, temperature, + maxTokens, + maxInputTokens, + k, + p, + seed, + stopSequences, + frequencyPenalty, + presencePenalty, + rawPrompting, + tools, + toolResults, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/requests/ClassifyRequest.java b/src/main/java/com/cohere/api/requests/ClassifyRequest.java index 437990a..28547a5 100644 --- a/src/main/java/com/cohere/api/requests/ClassifyRequest.java +++ b/src/main/java/com/cohere/api/requests/ClassifyRequest.java @@ -4,7 +4,7 @@ package com.cohere.api.requests; import com.cohere.api.core.ObjectMappers; -import com.cohere.api.types.ClassifyRequestExamplesItem; +import com.cohere.api.types.ClassifyExample; import com.cohere.api.types.ClassifyRequestTruncate; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -26,7 +26,7 @@ public final class ClassifyRequest { private final List inputs; - private final List examples; + private final List examples; private final Optional model; @@ -38,7 +38,7 @@ public final class ClassifyRequest { private ClassifyRequest( List inputs, - List examples, + List examples, Optional model, Optional preset, Optional truncate, @@ -52,7 +52,9 @@ private ClassifyRequest( } /** - * @return Represents a list of queries to be classified, each entry must not be empty. The maximum is 96 inputs. + * @return A list of up to 96 texts to be classified. Each one must be a non-empty string. + * There is, however, no consistent, universal limit to the length a particular input can be. We perform classification on the first x tokens of each input, and x varies depending on which underlying model is powering classification. The maximum token length for each model is listed in the "max tokens" column here. + * Note: by default the truncate parameter is set to END, so tokens exceeding the limit will be automatically dropped. This behavior can be disabled by setting truncate to NONE, which will result in validation errors for longer texts. */ @JsonProperty("inputs") public List getInputs() { @@ -61,15 +63,15 @@ public List getInputs() { /** * @return An array of examples to provide context to the model. Each example is a text string and its associated label/class. Each unique label requires at least 2 examples associated with it; the maximum number of examples is 2500, and each example has a maximum length of 512 tokens. The values should be structured as {text: "...",label: "..."}. - * Note: Custom Models trained on classification examples don't require the examples parameter to be passed in explicitly. + * Note: Fine-tuned Models trained on classification examples don't require the examples parameter to be passed in explicitly. */ @JsonProperty("examples") - public List getExamples() { + public List getExamples() { return examples; } /** - * @return The identifier of the model. Currently available models are embed-multilingual-v2.0, embed-english-light-v2.0, and embed-english-v2.0 (default). Smaller "light" models are faster, while larger models will perform better. Custom models can also be supplied with their full ID. + * @return The identifier of the model. Currently available models are embed-multilingual-v2.0, embed-english-light-v2.0, and embed-english-v2.0 (default). Smaller "light" models are faster, while larger models will perform better. Fine-tuned models can also be supplied with their full ID. */ @JsonProperty("model") public Optional getModel() { @@ -94,7 +96,7 @@ public Optional getTruncate() { return truncate; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ClassifyRequest && equalTo((ClassifyRequest) other); @@ -113,12 +115,12 @@ private boolean equalTo(ClassifyRequest other) { && truncate.equals(other.truncate); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.inputs, this.examples, this.model, this.preset, this.truncate); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -131,7 +133,7 @@ public static Builder builder() { public static final class Builder { private List inputs = new ArrayList<>(); - private List examples = new ArrayList<>(); + private List examples = new ArrayList<>(); private Optional model = Optional.empty(); @@ -171,18 +173,18 @@ public Builder addAllInputs(List inputs) { } @JsonSetter(value = "examples", nulls = Nulls.SKIP) - public Builder examples(List examples) { + public Builder examples(List examples) { this.examples.clear(); this.examples.addAll(examples); return this; } - public Builder addExamples(ClassifyRequestExamplesItem examples) { + public Builder addExamples(ClassifyExample examples) { this.examples.add(examples); return this; } - public Builder addAllExamples(List examples) { + public Builder addAllExamples(List examples) { this.examples.addAll(examples); return this; } diff --git a/src/main/java/com/cohere/api/requests/DetectLanguageRequest.java b/src/main/java/com/cohere/api/requests/DetectLanguageRequest.java deleted file mode 100644 index 0e3d471..0000000 --- a/src/main/java/com/cohere/api/requests/DetectLanguageRequest.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.cohere.api.requests; - -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.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = DetectLanguageRequest.Builder.class) -public final class DetectLanguageRequest { - private final List texts; - - private final Optional model; - - private final Map additionalProperties; - - private DetectLanguageRequest( - List texts, Optional model, Map additionalProperties) { - this.texts = texts; - this.model = model; - this.additionalProperties = additionalProperties; - } - - /** - * @return List of strings to run the detection on. - */ - @JsonProperty("texts") - public List getTexts() { - return texts; - } - - /** - * @return The identifier of the model to generate with. - */ - @JsonProperty("model") - public Optional getModel() { - return model; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DetectLanguageRequest && equalTo((DetectLanguageRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DetectLanguageRequest other) { - return texts.equals(other.texts) && model.equals(other.model); - } - - @Override - public int hashCode() { - return Objects.hash(this.texts, this.model); - } - - @Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List texts = new ArrayList<>(); - - private Optional model = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(DetectLanguageRequest other) { - texts(other.getTexts()); - model(other.getModel()); - return this; - } - - @JsonSetter(value = "texts", nulls = Nulls.SKIP) - public Builder texts(List texts) { - this.texts.clear(); - this.texts.addAll(texts); - return this; - } - - public Builder addTexts(String texts) { - this.texts.add(texts); - return this; - } - - public Builder addAllTexts(List texts) { - this.texts.addAll(texts); - return this; - } - - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public Builder model(Optional model) { - this.model = model; - return this; - } - - public Builder model(String model) { - this.model = Optional.of(model); - return this; - } - - public DetectLanguageRequest build() { - return new DetectLanguageRequest(texts, model, additionalProperties); - } - } -} diff --git a/src/main/java/com/cohere/api/requests/DetokenizeRequest.java b/src/main/java/com/cohere/api/requests/DetokenizeRequest.java index 1e8cbee..39301e1 100644 --- a/src/main/java/com/cohere/api/requests/DetokenizeRequest.java +++ b/src/main/java/com/cohere/api/requests/DetokenizeRequest.java @@ -17,18 +17,17 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = DetokenizeRequest.Builder.class) public final class DetokenizeRequest { private final List tokens; - private final Optional model; + private final String model; private final Map additionalProperties; - private DetokenizeRequest(List tokens, Optional model, Map additionalProperties) { + private DetokenizeRequest(List tokens, String model, Map additionalProperties) { this.tokens = tokens; this.model = model; this.additionalProperties = additionalProperties; @@ -46,11 +45,11 @@ public List getTokens() { * @return An optional parameter to provide the model name. This will ensure that the detokenization is done by the tokenizer used by that model. */ @JsonProperty("model") - public Optional getModel() { + public String getModel() { return model; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof DetokenizeRequest && equalTo((DetokenizeRequest) other); @@ -65,65 +64,94 @@ private boolean equalTo(DetokenizeRequest other) { return tokens.equals(other.tokens) && model.equals(other.model); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.tokens, this.model); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } - public static Builder builder() { + public static ModelStage builder() { return new Builder(); } + public interface ModelStage { + _FinalStage model(String model); + + Builder from(DetokenizeRequest other); + } + + public interface _FinalStage { + DetokenizeRequest build(); + + _FinalStage tokens(List tokens); + + _FinalStage addTokens(Integer tokens); + + _FinalStage addAllTokens(List tokens); + } + @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List tokens = new ArrayList<>(); + public static final class Builder implements ModelStage, _FinalStage { + private String model; - private Optional model = Optional.empty(); + private List tokens = new ArrayList<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} + @java.lang.Override public Builder from(DetokenizeRequest other) { tokens(other.getTokens()); model(other.getModel()); return this; } - @JsonSetter(value = "tokens", nulls = Nulls.SKIP) - public Builder tokens(List tokens) { - this.tokens.clear(); - this.tokens.addAll(tokens); - return this; - } - - public Builder addTokens(Integer tokens) { - this.tokens.add(tokens); + /** + *

An optional parameter to provide the model name. This will ensure that the detokenization is done by the tokenizer used by that model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("model") + public _FinalStage model(String model) { + this.model = model; return this; } - public Builder addAllTokens(List tokens) { + /** + *

The list of tokens to be detokenized.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAllTokens(List tokens) { this.tokens.addAll(tokens); return this; } - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public Builder model(Optional model) { - this.model = model; + /** + *

The list of tokens to be detokenized.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addTokens(Integer tokens) { + this.tokens.add(tokens); return this; } - public Builder model(String model) { - this.model = Optional.of(model); + @java.lang.Override + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public _FinalStage tokens(List tokens) { + this.tokens.clear(); + this.tokens.addAll(tokens); return this; } + @java.lang.Override public DetokenizeRequest build() { return new DetokenizeRequest(tokens, model, additionalProperties); } diff --git a/src/main/java/com/cohere/api/requests/EmbedRequest.java b/src/main/java/com/cohere/api/requests/EmbedRequest.java index a3c91ed..3a90448 100644 --- a/src/main/java/com/cohere/api/requests/EmbedRequest.java +++ b/src/main/java/com/cohere/api/requests/EmbedRequest.java @@ -4,7 +4,9 @@ package com.cohere.api.requests; import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.EmbedInputType; import com.cohere.api.types.EmbedRequestTruncate; +import com.cohere.api.types.EmbeddingType; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -27,9 +29,9 @@ public final class EmbedRequest { private final Optional model; - private final Optional inputType; + private final Optional inputType; - private final Optional> embeddingTypes; + private final Optional> embeddingTypes; private final Optional truncate; @@ -38,8 +40,8 @@ public final class EmbedRequest { private EmbedRequest( List texts, Optional model, - Optional inputType, - Optional> embeddingTypes, + Optional inputType, + Optional> embeddingTypes, Optional truncate, Map additionalProperties) { this.texts = texts; @@ -91,17 +93,8 @@ public Optional getModel() { return model; } - /** - * @return Specifies the type of input you're giving to the model. Not required for older versions of the embedding models (i.e. anything lower than v3), but is required for more recent versions (i.e. anything bigger than v2). - *
    - *
  • "search_document": Use this when you encode documents for embeddings that you store in a vector database for search use-cases.
  • - *
  • "search_query": Use this when you query your vector DB to find relevant documents.
  • - *
  • "classification": Use this when you use the embeddings as an input to a text classifier.
  • - *
  • "clustering": Use this when you want to cluster the embeddings.
  • - *
- */ @JsonProperty("input_type") - public Optional getInputType() { + public Optional getInputType() { return inputType; } @@ -116,7 +109,7 @@ public Optional getInputType() { * */ @JsonProperty("embedding_types") - public Optional> getEmbeddingTypes() { + public Optional> getEmbeddingTypes() { return embeddingTypes; } @@ -130,7 +123,7 @@ public Optional getTruncate() { return truncate; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbedRequest && equalTo((EmbedRequest) other); @@ -149,12 +142,12 @@ private boolean equalTo(EmbedRequest other) { && truncate.equals(other.truncate); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.texts, this.model, this.inputType, this.embeddingTypes, this.truncate); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -169,9 +162,9 @@ public static final class Builder { private Optional model = Optional.empty(); - private Optional inputType = Optional.empty(); + private Optional inputType = Optional.empty(); - private Optional> embeddingTypes = Optional.empty(); + private Optional> embeddingTypes = Optional.empty(); private Optional truncate = Optional.empty(); @@ -218,23 +211,23 @@ public Builder model(String model) { } @JsonSetter(value = "input_type", nulls = Nulls.SKIP) - public Builder inputType(Optional inputType) { + public Builder inputType(Optional inputType) { this.inputType = inputType; return this; } - public Builder inputType(String inputType) { + public Builder inputType(EmbedInputType inputType) { this.inputType = Optional.of(inputType); return this; } @JsonSetter(value = "embedding_types", nulls = Nulls.SKIP) - public Builder embeddingTypes(Optional> embeddingTypes) { + public Builder embeddingTypes(Optional> embeddingTypes) { this.embeddingTypes = embeddingTypes; return this; } - public Builder embeddingTypes(List embeddingTypes) { + public Builder embeddingTypes(List embeddingTypes) { this.embeddingTypes = Optional.of(embeddingTypes); return this; } diff --git a/src/main/java/com/cohere/api/requests/GenerateRequest.java b/src/main/java/com/cohere/api/requests/GenerateRequest.java index 3fdc366..a3be697 100644 --- a/src/main/java/com/cohere/api/requests/GenerateRequest.java +++ b/src/main/java/com/cohere/api/requests/GenerateRequest.java @@ -29,14 +29,14 @@ public final class GenerateRequest { private final Optional numGenerations; - private final Optional stream; - private final Optional maxTokens; private final Optional truncate; private final Optional temperature; + private final Optional seed; + private final Optional preset; private final Optional> endSequences; @@ -53,7 +53,7 @@ public final class GenerateRequest { private final Optional returnLikelihoods; - private final Optional> logitBias; + private final Optional rawPrompting; private final Map additionalProperties; @@ -61,10 +61,10 @@ private GenerateRequest( String prompt, Optional model, Optional numGenerations, - Optional stream, Optional maxTokens, Optional truncate, Optional temperature, + Optional seed, Optional preset, Optional> endSequences, Optional> stopSequences, @@ -73,15 +73,15 @@ private GenerateRequest( Optional frequencyPenalty, Optional presencePenalty, Optional returnLikelihoods, - Optional> logitBias, + Optional rawPrompting, Map additionalProperties) { this.prompt = prompt; this.model = model; this.numGenerations = numGenerations; - this.stream = stream; this.maxTokens = maxTokens; this.truncate = truncate; this.temperature = temperature; + this.seed = seed; this.preset = preset; this.endSequences = endSequences; this.stopSequences = stopSequences; @@ -90,7 +90,7 @@ private GenerateRequest( this.frequencyPenalty = frequencyPenalty; this.presencePenalty = presencePenalty; this.returnLikelihoods = returnLikelihoods; - this.logitBias = logitBias; + this.rawPrompting = rawPrompting; this.additionalProperties = additionalProperties; } @@ -120,19 +120,9 @@ public Optional getNumGenerations() { return numGenerations; } - /** - * @return When true, the response will be a JSON stream of events. Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated. - *

The final event will contain the complete response, and will contain an is_finished field set to true. The event will also contain a finish_reason, which can be one of the following:

- *
    - *
  • COMPLETE - the model sent back a finished reply
  • - *
  • MAX_TOKENS - the reply was cut off because the model reached the maximum number of tokens for its context length
  • - *
  • ERROR - something went wrong when generating the reply
  • - *
  • ERROR_TOXIC - the model generated a reply that was deemed toxic
  • - *
- */ @JsonProperty("stream") - public Optional getStream() { - return stream; + public Boolean getStream() { + return false; } /** @@ -164,6 +154,14 @@ public Optional getTemperature() { return temperature; } + /** + * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed. + */ + @JsonProperty("seed") + public Optional getSeed() { + return seed; + } + /** * @return Identifier of a custom preset. A preset is a combination of parameters, such as prompt, temperature etc. You can create presets in the playground. * When a preset is specified, the prompt parameter becomes optional, and any included parameters will override the preset's parameters. @@ -208,7 +206,8 @@ public Optional getP() { } /** - * @return Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.' + * @return Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

*/ @JsonProperty("frequency_penalty") public Optional getFrequencyPenalty() { @@ -216,7 +215,9 @@ public Optional getFrequencyPenalty() { } /** - * @return Defaults to 0.0, min value of 0.0, max value of 1.0. Can be used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. + *

Can be used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

*/ @JsonProperty("presence_penalty") public Optional getPresencePenalty() { @@ -234,16 +235,14 @@ public Optional getReturnLikelihoods() { } /** - * @return Used to prevent the model from generating unwanted tokens or to incentivize it to include desired tokens. The format is {token_id: bias} where bias is a float between -10 and 10. Tokens can be obtained from text using Tokenize. - *

For example, if the value {'11': -10} is provided, the model will be very unlikely to include the token 11 ("\n", the newline character) anywhere in the generated text. In contrast {'11': 10} will result in generations that nearly only contain that token. Values between -10 and 10 will proportionally affect the likelihood of the token appearing in the generated text.

- *

Note: logit bias may not be supported for all custom models.

+ * @return When enabled, the user's prompt will be sent to the model without any pre-processing. */ - @JsonProperty("logit_bias") - public Optional> getLogitBias() { - return logitBias; + @JsonProperty("raw_prompting") + public Optional getRawPrompting() { + return rawPrompting; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof GenerateRequest && equalTo((GenerateRequest) other); @@ -258,10 +257,10 @@ private boolean equalTo(GenerateRequest other) { return prompt.equals(other.prompt) && model.equals(other.model) && numGenerations.equals(other.numGenerations) - && stream.equals(other.stream) && maxTokens.equals(other.maxTokens) && truncate.equals(other.truncate) && temperature.equals(other.temperature) + && seed.equals(other.seed) && preset.equals(other.preset) && endSequences.equals(other.endSequences) && stopSequences.equals(other.stopSequences) @@ -270,19 +269,19 @@ private boolean equalTo(GenerateRequest other) { && frequencyPenalty.equals(other.frequencyPenalty) && presencePenalty.equals(other.presencePenalty) && returnLikelihoods.equals(other.returnLikelihoods) - && logitBias.equals(other.logitBias); + && rawPrompting.equals(other.rawPrompting); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.prompt, this.model, this.numGenerations, - this.stream, this.maxTokens, this.truncate, this.temperature, + this.seed, this.preset, this.endSequences, this.stopSequences, @@ -291,10 +290,10 @@ public int hashCode() { this.frequencyPenalty, this.presencePenalty, this.returnLikelihoods, - this.logitBias); + this.rawPrompting); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -320,10 +319,6 @@ public interface _FinalStage { _FinalStage numGenerations(Integer numGenerations); - _FinalStage stream(Optional stream); - - _FinalStage stream(Boolean stream); - _FinalStage maxTokens(Optional maxTokens); _FinalStage maxTokens(Integer maxTokens); @@ -336,6 +331,10 @@ public interface _FinalStage { _FinalStage temperature(Double temperature); + _FinalStage seed(Optional seed); + + _FinalStage seed(Double seed); + _FinalStage preset(Optional preset); _FinalStage preset(String preset); @@ -368,16 +367,16 @@ public interface _FinalStage { _FinalStage returnLikelihoods(GenerateRequestReturnLikelihoods returnLikelihoods); - _FinalStage logitBias(Optional> logitBias); + _FinalStage rawPrompting(Optional rawPrompting); - _FinalStage logitBias(Map logitBias); + _FinalStage rawPrompting(Boolean rawPrompting); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements PromptStage, _FinalStage { private String prompt; - private Optional> logitBias = Optional.empty(); + private Optional rawPrompting = Optional.empty(); private Optional returnLikelihoods = Optional.empty(); @@ -395,14 +394,14 @@ public static final class Builder implements PromptStage, _FinalStage { private Optional preset = Optional.empty(); + private Optional seed = Optional.empty(); + private Optional temperature = Optional.empty(); private Optional truncate = Optional.empty(); private Optional maxTokens = Optional.empty(); - private Optional stream = Optional.empty(); - private Optional numGenerations = Optional.empty(); private Optional model = Optional.empty(); @@ -412,15 +411,15 @@ public static final class Builder implements PromptStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(GenerateRequest other) { prompt(other.getPrompt()); model(other.getModel()); numGenerations(other.getNumGenerations()); - stream(other.getStream()); maxTokens(other.getMaxTokens()); truncate(other.getTruncate()); temperature(other.getTemperature()); + seed(other.getSeed()); preset(other.getPreset()); endSequences(other.getEndSequences()); stopSequences(other.getStopSequences()); @@ -429,7 +428,7 @@ public Builder from(GenerateRequest other) { frequencyPenalty(other.getFrequencyPenalty()); presencePenalty(other.getPresencePenalty()); returnLikelihoods(other.getReturnLikelihoods()); - logitBias(other.getLogitBias()); + rawPrompting(other.getRawPrompting()); return this; } @@ -438,7 +437,7 @@ public Builder from(GenerateRequest other) { * Note: The prompt will be pre-processed and modified before reaching the model.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("prompt") public _FinalStage prompt(String prompt) { this.prompt = prompt; @@ -446,21 +445,19 @@ public _FinalStage prompt(String prompt) { } /** - *

Used to prevent the model from generating unwanted tokens or to incentivize it to include desired tokens. The format is {token_id: bias} where bias is a float between -10 and 10. Tokens can be obtained from text using Tokenize.

- *

For example, if the value {'11': -10} is provided, the model will be very unlikely to include the token 11 ("\n", the newline character) anywhere in the generated text. In contrast {'11': 10} will result in generations that nearly only contain that token. Values between -10 and 10 will proportionally affect the likelihood of the token appearing in the generated text.

- *

Note: logit bias may not be supported for all custom models.

+ *

When enabled, the user's prompt will be sent to the model without any pre-processing.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override - public _FinalStage logitBias(Map logitBias) { - this.logitBias = Optional.of(logitBias); + @java.lang.Override + public _FinalStage rawPrompting(Boolean rawPrompting) { + this.rawPrompting = Optional.of(rawPrompting); return this; } - @Override - @JsonSetter(value = "logit_bias", nulls = Nulls.SKIP) - public _FinalStage logitBias(Optional> logitBias) { - this.logitBias = logitBias; + @java.lang.Override + @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) + public _FinalStage rawPrompting(Optional rawPrompting) { + this.rawPrompting = rawPrompting; return this; } @@ -470,13 +467,13 @@ public _FinalStage logitBias(Optional> logitBias) { *

If ALL is selected, the token likelihoods will be provided both for the prompt and the generated text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage returnLikelihoods(GenerateRequestReturnLikelihoods returnLikelihoods) { this.returnLikelihoods = Optional.of(returnLikelihoods); return this; } - @Override + @java.lang.Override @JsonSetter(value = "return_likelihoods", nulls = Nulls.SKIP) public _FinalStage returnLikelihoods(Optional returnLikelihoods) { this.returnLikelihoods = returnLikelihoods; @@ -484,16 +481,18 @@ public _FinalStage returnLikelihoods(Optional } /** - *

Defaults to 0.0, min value of 0.0, max value of 1.0. Can be used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

+ *

Defaults to 0.0, min value of 0.0, max value of 1.0.

+ *

Can be used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage presencePenalty(Double presencePenalty) { this.presencePenalty = Optional.of(presencePenalty); return this; } - @Override + @java.lang.Override @JsonSetter(value = "presence_penalty", nulls = Nulls.SKIP) public _FinalStage presencePenalty(Optional presencePenalty) { this.presencePenalty = presencePenalty; @@ -501,16 +500,17 @@ public _FinalStage presencePenalty(Optional presencePenalty) { } /** - *

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.'

+ *

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage frequencyPenalty(Double frequencyPenalty) { this.frequencyPenalty = Optional.of(frequencyPenalty); return this; } - @Override + @java.lang.Override @JsonSetter(value = "frequency_penalty", nulls = Nulls.SKIP) public _FinalStage frequencyPenalty(Optional frequencyPenalty) { this.frequencyPenalty = frequencyPenalty; @@ -522,13 +522,13 @@ public _FinalStage frequencyPenalty(Optional frequencyPenalty) { * Defaults to 0.75. min value of 0.01, max value of 0.99.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage p(Double p) { this.p = Optional.of(p); return this; } - @Override + @java.lang.Override @JsonSetter(value = "p", nulls = Nulls.SKIP) public _FinalStage p(Optional p) { this.p = p; @@ -540,13 +540,13 @@ public _FinalStage p(Optional p) { * Defaults to 0, min value of 0, max value of 500.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage k(Integer k) { this.k = Optional.of(k); return this; } - @Override + @java.lang.Override @JsonSetter(value = "k", nulls = Nulls.SKIP) public _FinalStage k(Optional k) { this.k = k; @@ -557,13 +557,13 @@ public _FinalStage k(Optional k) { *

The generated text will be cut at the end of the earliest occurrence of a stop sequence. The sequence will be included the text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage stopSequences(List stopSequences) { this.stopSequences = Optional.of(stopSequences); return this; } - @Override + @java.lang.Override @JsonSetter(value = "stop_sequences", nulls = Nulls.SKIP) public _FinalStage stopSequences(Optional> stopSequences) { this.stopSequences = stopSequences; @@ -574,13 +574,13 @@ public _FinalStage stopSequences(Optional> stopSequences) { *

The generated text will be cut at the beginning of the earliest occurrence of an end sequence. The sequence will be excluded from the text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage endSequences(List endSequences) { this.endSequences = Optional.of(endSequences); return this; } - @Override + @java.lang.Override @JsonSetter(value = "end_sequences", nulls = Nulls.SKIP) public _FinalStage endSequences(Optional> endSequences) { this.endSequences = endSequences; @@ -592,31 +592,48 @@ public _FinalStage endSequences(Optional> endSequences) { * When a preset is specified, the prompt parameter becomes optional, and any included parameters will override the preset's parameters.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage preset(String preset) { this.preset = Optional.of(preset); return this; } - @Override + @java.lang.Override @JsonSetter(value = "preset", nulls = Nulls.SKIP) public _FinalStage preset(Optional preset) { this.preset = preset; return this; } + /** + *

If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage seed(Double seed) { + this.seed = Optional.of(seed); + return this; + } + + @java.lang.Override + @JsonSetter(value = "seed", nulls = Nulls.SKIP) + public _FinalStage seed(Optional seed) { + this.seed = seed; + return this; + } + /** *

A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. See Temperature for more details. * Defaults to 0.75, min value of 0.0, max value of 5.0.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage temperature(Double temperature) { this.temperature = Optional.of(temperature); return this; } - @Override + @java.lang.Override @JsonSetter(value = "temperature", nulls = Nulls.SKIP) public _FinalStage temperature(Optional temperature) { this.temperature = temperature; @@ -629,13 +646,13 @@ public _FinalStage temperature(Optional temperature) { *

If NONE is selected, when the input exceeds the maximum input token length an error will be returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage truncate(GenerateRequestTruncate truncate) { this.truncate = Optional.of(truncate); return this; } - @Override + @java.lang.Override @JsonSetter(value = "truncate", nulls = Nulls.SKIP) public _FinalStage truncate(Optional truncate) { this.truncate = truncate; @@ -648,54 +665,30 @@ public _FinalStage truncate(Optional truncate) { *

Can only be set to 0 if return_likelihoods is set to ALL to get the likelihood of the prompt.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage maxTokens(Integer maxTokens) { this.maxTokens = Optional.of(maxTokens); return this; } - @Override + @java.lang.Override @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) public _FinalStage maxTokens(Optional maxTokens) { this.maxTokens = maxTokens; return this; } - /** - *

When true, the response will be a JSON stream of events. Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated.

- *

The final event will contain the complete response, and will contain an is_finished field set to true. The event will also contain a finish_reason, which can be one of the following:

- *
    - *
  • COMPLETE - the model sent back a finished reply
  • - *
  • MAX_TOKENS - the reply was cut off because the model reached the maximum number of tokens for its context length
  • - *
  • ERROR - something went wrong when generating the reply
  • - *
  • ERROR_TOXIC - the model generated a reply that was deemed toxic
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage stream(Boolean stream) { - this.stream = Optional.of(stream); - return this; - } - - @Override - @JsonSetter(value = "stream", nulls = Nulls.SKIP) - public _FinalStage stream(Optional stream) { - this.stream = stream; - return this; - } - /** *

The maximum number of generations that will be returned. Defaults to 1, min value of 1, max value of 5.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage numGenerations(Integer numGenerations) { this.numGenerations = Optional.of(numGenerations); return this; } - @Override + @java.lang.Override @JsonSetter(value = "num_generations", nulls = Nulls.SKIP) public _FinalStage numGenerations(Optional numGenerations) { this.numGenerations = numGenerations; @@ -707,29 +700,29 @@ public _FinalStage numGenerations(Optional numGenerations) { * Smaller, "light" models are faster, while larger models will perform better. Custom models can also be supplied with their full ID.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public GenerateRequest build() { return new GenerateRequest( prompt, model, numGenerations, - stream, maxTokens, truncate, temperature, + seed, preset, endSequences, stopSequences, @@ -738,7 +731,7 @@ public GenerateRequest build() { frequencyPenalty, presencePenalty, returnLikelihoods, - logitBias, + rawPrompting, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java b/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java new file mode 100644 index 0000000..4b247b6 --- /dev/null +++ b/src/main/java/com/cohere/api/requests/GenerateStreamRequest.java @@ -0,0 +1,738 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.requests; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.GenerateStreamRequestReturnLikelihoods; +import com.cohere.api.types.GenerateStreamRequestTruncate; +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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = GenerateStreamRequest.Builder.class) +public final class GenerateStreamRequest { + private final String prompt; + + private final Optional model; + + private final Optional numGenerations; + + private final Optional maxTokens; + + private final Optional truncate; + + private final Optional temperature; + + private final Optional seed; + + private final Optional preset; + + private final Optional> endSequences; + + private final Optional> stopSequences; + + private final Optional k; + + private final Optional p; + + private final Optional frequencyPenalty; + + private final Optional presencePenalty; + + private final Optional returnLikelihoods; + + private final Optional rawPrompting; + + private final Map additionalProperties; + + private GenerateStreamRequest( + String prompt, + Optional model, + Optional numGenerations, + Optional maxTokens, + Optional truncate, + Optional temperature, + Optional seed, + Optional preset, + Optional> endSequences, + Optional> stopSequences, + Optional k, + Optional p, + Optional frequencyPenalty, + Optional presencePenalty, + Optional returnLikelihoods, + Optional rawPrompting, + Map additionalProperties) { + this.prompt = prompt; + this.model = model; + this.numGenerations = numGenerations; + this.maxTokens = maxTokens; + this.truncate = truncate; + this.temperature = temperature; + this.seed = seed; + this.preset = preset; + this.endSequences = endSequences; + this.stopSequences = stopSequences; + this.k = k; + this.p = p; + this.frequencyPenalty = frequencyPenalty; + this.presencePenalty = presencePenalty; + this.returnLikelihoods = returnLikelihoods; + this.rawPrompting = rawPrompting; + this.additionalProperties = additionalProperties; + } + + /** + * @return The input text that serves as the starting point for generating the response. + * Note: The prompt will be pre-processed and modified before reaching the model. + */ + @JsonProperty("prompt") + public String getPrompt() { + return prompt; + } + + /** + * @return The identifier of the model to generate with. Currently available models are command (default), command-nightly (experimental), command-light, and command-light-nightly (experimental). + * Smaller, "light" models are faster, while larger models will perform better. Custom models can also be supplied with their full ID. + */ + @JsonProperty("model") + public Optional getModel() { + return model; + } + + /** + * @return The maximum number of generations that will be returned. Defaults to 1, min value of 1, max value of 5. + */ + @JsonProperty("num_generations") + public Optional getNumGenerations() { + return numGenerations; + } + + @JsonProperty("stream") + public Boolean getStream() { + return true; + } + + /** + * @return The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations. + *

This parameter is off by default, and if it's not specified, the model will continue generating until it emits an EOS completion token. See BPE Tokens for more details.

+ *

Can only be set to 0 if return_likelihoods is set to ALL to get the likelihood of the prompt.

+ */ + @JsonProperty("max_tokens") + public Optional getMaxTokens() { + return maxTokens; + } + + /** + * @return One of NONE|START|END to specify how the API will handle inputs longer than the maximum token length. + *

Passing START will discard the start of the input. END will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

+ *

If NONE is selected, when the input exceeds the maximum input token length an error will be returned.

+ */ + @JsonProperty("truncate") + public Optional getTruncate() { + return truncate; + } + + /** + * @return A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. See Temperature for more details. + * Defaults to 0.75, min value of 0.0, max value of 5.0. + */ + @JsonProperty("temperature") + public Optional getTemperature() { + return temperature; + } + + /** + * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed. + */ + @JsonProperty("seed") + public Optional getSeed() { + return seed; + } + + /** + * @return Identifier of a custom preset. A preset is a combination of parameters, such as prompt, temperature etc. You can create presets in the playground. + * When a preset is specified, the prompt parameter becomes optional, and any included parameters will override the preset's parameters. + */ + @JsonProperty("preset") + public Optional getPreset() { + return preset; + } + + /** + * @return The generated text will be cut at the beginning of the earliest occurrence of an end sequence. The sequence will be excluded from the text. + */ + @JsonProperty("end_sequences") + public Optional> getEndSequences() { + return endSequences; + } + + /** + * @return The generated text will be cut at the end of the earliest occurrence of a stop sequence. The sequence will be included the text. + */ + @JsonProperty("stop_sequences") + public Optional> getStopSequences() { + return stopSequences; + } + + /** + * @return Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500. + */ + @JsonProperty("k") + public Optional getK() { + return k; + } + + /** + * @return Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99. + */ + @JsonProperty("p") + public Optional getP() { + return p; + } + + /** + * @return Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

+ */ + @JsonProperty("frequency_penalty") + public Optional getFrequencyPenalty() { + return frequencyPenalty; + } + + /** + * @return Defaults to 0.0, min value of 0.0, max value of 1.0. + *

Can be used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

+ */ + @JsonProperty("presence_penalty") + public Optional getPresencePenalty() { + return presencePenalty; + } + + /** + * @return One of GENERATION|ALL|NONE to specify how and if the token likelihoods are returned with the response. Defaults to NONE. + *

If GENERATION is selected, the token likelihoods will only be provided for generated text.

+ *

If ALL is selected, the token likelihoods will be provided both for the prompt and the generated text.

+ */ + @JsonProperty("return_likelihoods") + public Optional getReturnLikelihoods() { + return returnLikelihoods; + } + + /** + * @return When enabled, the user's prompt will be sent to the model without any pre-processing. + */ + @JsonProperty("raw_prompting") + public Optional getRawPrompting() { + return rawPrompting; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamRequest && equalTo((GenerateStreamRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamRequest other) { + return prompt.equals(other.prompt) + && model.equals(other.model) + && numGenerations.equals(other.numGenerations) + && maxTokens.equals(other.maxTokens) + && truncate.equals(other.truncate) + && temperature.equals(other.temperature) + && seed.equals(other.seed) + && preset.equals(other.preset) + && endSequences.equals(other.endSequences) + && stopSequences.equals(other.stopSequences) + && k.equals(other.k) + && p.equals(other.p) + && frequencyPenalty.equals(other.frequencyPenalty) + && presencePenalty.equals(other.presencePenalty) + && returnLikelihoods.equals(other.returnLikelihoods) + && rawPrompting.equals(other.rawPrompting); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.prompt, + this.model, + this.numGenerations, + this.maxTokens, + this.truncate, + this.temperature, + this.seed, + this.preset, + this.endSequences, + this.stopSequences, + this.k, + this.p, + this.frequencyPenalty, + this.presencePenalty, + this.returnLikelihoods, + this.rawPrompting); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PromptStage builder() { + return new Builder(); + } + + public interface PromptStage { + _FinalStage prompt(String prompt); + + Builder from(GenerateStreamRequest other); + } + + public interface _FinalStage { + GenerateStreamRequest build(); + + _FinalStage model(Optional model); + + _FinalStage model(String model); + + _FinalStage numGenerations(Optional numGenerations); + + _FinalStage numGenerations(Integer numGenerations); + + _FinalStage maxTokens(Optional maxTokens); + + _FinalStage maxTokens(Integer maxTokens); + + _FinalStage truncate(Optional truncate); + + _FinalStage truncate(GenerateStreamRequestTruncate truncate); + + _FinalStage temperature(Optional temperature); + + _FinalStage temperature(Double temperature); + + _FinalStage seed(Optional seed); + + _FinalStage seed(Double seed); + + _FinalStage preset(Optional preset); + + _FinalStage preset(String preset); + + _FinalStage endSequences(Optional> endSequences); + + _FinalStage endSequences(List endSequences); + + _FinalStage stopSequences(Optional> stopSequences); + + _FinalStage stopSequences(List stopSequences); + + _FinalStage k(Optional k); + + _FinalStage k(Integer k); + + _FinalStage p(Optional p); + + _FinalStage p(Double p); + + _FinalStage frequencyPenalty(Optional frequencyPenalty); + + _FinalStage frequencyPenalty(Double frequencyPenalty); + + _FinalStage presencePenalty(Optional presencePenalty); + + _FinalStage presencePenalty(Double presencePenalty); + + _FinalStage returnLikelihoods(Optional returnLikelihoods); + + _FinalStage returnLikelihoods(GenerateStreamRequestReturnLikelihoods returnLikelihoods); + + _FinalStage rawPrompting(Optional rawPrompting); + + _FinalStage rawPrompting(Boolean rawPrompting); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PromptStage, _FinalStage { + private String prompt; + + private Optional rawPrompting = Optional.empty(); + + private Optional returnLikelihoods = Optional.empty(); + + private Optional presencePenalty = Optional.empty(); + + private Optional frequencyPenalty = Optional.empty(); + + private Optional p = Optional.empty(); + + private Optional k = Optional.empty(); + + private Optional> stopSequences = Optional.empty(); + + private Optional> endSequences = Optional.empty(); + + private Optional preset = Optional.empty(); + + private Optional seed = Optional.empty(); + + private Optional temperature = Optional.empty(); + + private Optional truncate = Optional.empty(); + + private Optional maxTokens = Optional.empty(); + + private Optional numGenerations = Optional.empty(); + + private Optional model = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamRequest other) { + prompt(other.getPrompt()); + model(other.getModel()); + numGenerations(other.getNumGenerations()); + maxTokens(other.getMaxTokens()); + truncate(other.getTruncate()); + temperature(other.getTemperature()); + seed(other.getSeed()); + preset(other.getPreset()); + endSequences(other.getEndSequences()); + stopSequences(other.getStopSequences()); + k(other.getK()); + p(other.getP()); + frequencyPenalty(other.getFrequencyPenalty()); + presencePenalty(other.getPresencePenalty()); + returnLikelihoods(other.getReturnLikelihoods()); + rawPrompting(other.getRawPrompting()); + return this; + } + + /** + *

The input text that serves as the starting point for generating the response. + * Note: The prompt will be pre-processed and modified before reaching the model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("prompt") + public _FinalStage prompt(String prompt) { + this.prompt = prompt; + return this; + } + + /** + *

When enabled, the user's prompt will be sent to the model without any pre-processing.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage rawPrompting(Boolean rawPrompting) { + this.rawPrompting = Optional.of(rawPrompting); + return this; + } + + @java.lang.Override + @JsonSetter(value = "raw_prompting", nulls = Nulls.SKIP) + public _FinalStage rawPrompting(Optional rawPrompting) { + this.rawPrompting = rawPrompting; + return this; + } + + /** + *

One of GENERATION|ALL|NONE to specify how and if the token likelihoods are returned with the response. Defaults to NONE.

+ *

If GENERATION is selected, the token likelihoods will only be provided for generated text.

+ *

If ALL is selected, the token likelihoods will be provided both for the prompt and the generated text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage returnLikelihoods(GenerateStreamRequestReturnLikelihoods returnLikelihoods) { + this.returnLikelihoods = Optional.of(returnLikelihoods); + return this; + } + + @java.lang.Override + @JsonSetter(value = "return_likelihoods", nulls = Nulls.SKIP) + public _FinalStage returnLikelihoods(Optional returnLikelihoods) { + this.returnLikelihoods = returnLikelihoods; + return this; + } + + /** + *

Defaults to 0.0, min value of 0.0, max value of 1.0.

+ *

Can be used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage presencePenalty(Double presencePenalty) { + this.presencePenalty = Optional.of(presencePenalty); + return this; + } + + @java.lang.Override + @JsonSetter(value = "presence_penalty", nulls = Nulls.SKIP) + public _FinalStage presencePenalty(Optional presencePenalty) { + this.presencePenalty = presencePenalty; + return this; + } + + /** + *

Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.

+ *

Using frequency_penalty in combination with presence_penalty is not supported on newer models.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage frequencyPenalty(Double frequencyPenalty) { + this.frequencyPenalty = Optional.of(frequencyPenalty); + return this; + } + + @java.lang.Override + @JsonSetter(value = "frequency_penalty", nulls = Nulls.SKIP) + public _FinalStage frequencyPenalty(Optional frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + return this; + } + + /** + *

Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k. + * Defaults to 0.75. min value of 0.01, max value of 0.99.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage p(Double p) { + this.p = Optional.of(p); + return this; + } + + @java.lang.Override + @JsonSetter(value = "p", nulls = Nulls.SKIP) + public _FinalStage p(Optional p) { + this.p = p; + return this; + } + + /** + *

Ensures only the top k most likely tokens are considered for generation at each step. + * Defaults to 0, min value of 0, max value of 500.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage k(Integer k) { + this.k = Optional.of(k); + return this; + } + + @java.lang.Override + @JsonSetter(value = "k", nulls = Nulls.SKIP) + public _FinalStage k(Optional k) { + this.k = k; + return this; + } + + /** + *

The generated text will be cut at the end of the earliest occurrence of a stop sequence. The sequence will be included the text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage stopSequences(List stopSequences) { + this.stopSequences = Optional.of(stopSequences); + return this; + } + + @java.lang.Override + @JsonSetter(value = "stop_sequences", nulls = Nulls.SKIP) + public _FinalStage stopSequences(Optional> stopSequences) { + this.stopSequences = stopSequences; + return this; + } + + /** + *

The generated text will be cut at the beginning of the earliest occurrence of an end sequence. The sequence will be excluded from the text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage endSequences(List endSequences) { + this.endSequences = Optional.of(endSequences); + return this; + } + + @java.lang.Override + @JsonSetter(value = "end_sequences", nulls = Nulls.SKIP) + public _FinalStage endSequences(Optional> endSequences) { + this.endSequences = endSequences; + return this; + } + + /** + *

Identifier of a custom preset. A preset is a combination of parameters, such as prompt, temperature etc. You can create presets in the playground. + * When a preset is specified, the prompt parameter becomes optional, and any included parameters will override the preset's parameters.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage preset(String preset) { + this.preset = Optional.of(preset); + return this; + } + + @java.lang.Override + @JsonSetter(value = "preset", nulls = Nulls.SKIP) + public _FinalStage preset(Optional preset) { + this.preset = preset; + return this; + } + + /** + *

If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage seed(Double seed) { + this.seed = Optional.of(seed); + return this; + } + + @java.lang.Override + @JsonSetter(value = "seed", nulls = Nulls.SKIP) + public _FinalStage seed(Optional seed) { + this.seed = seed; + return this; + } + + /** + *

A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. See Temperature for more details. + * Defaults to 0.75, min value of 0.0, max value of 5.0.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage temperature(Double temperature) { + this.temperature = Optional.of(temperature); + return this; + } + + @java.lang.Override + @JsonSetter(value = "temperature", nulls = Nulls.SKIP) + public _FinalStage temperature(Optional temperature) { + this.temperature = temperature; + return this; + } + + /** + *

One of NONE|START|END to specify how the API will handle inputs longer than the maximum token length.

+ *

Passing START will discard the start of the input. END will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

+ *

If NONE is selected, when the input exceeds the maximum input token length an error will be returned.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage truncate(GenerateStreamRequestTruncate truncate) { + this.truncate = Optional.of(truncate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "truncate", nulls = Nulls.SKIP) + public _FinalStage truncate(Optional truncate) { + this.truncate = truncate; + return this; + } + + /** + *

The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.

+ *

This parameter is off by default, and if it's not specified, the model will continue generating until it emits an EOS completion token. See BPE Tokens for more details.

+ *

Can only be set to 0 if return_likelihoods is set to ALL to get the likelihood of the prompt.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage maxTokens(Integer maxTokens) { + this.maxTokens = Optional.of(maxTokens); + return this; + } + + @java.lang.Override + @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) + public _FinalStage maxTokens(Optional maxTokens) { + this.maxTokens = maxTokens; + return this; + } + + /** + *

The maximum number of generations that will be returned. Defaults to 1, min value of 1, max value of 5.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage numGenerations(Integer numGenerations) { + this.numGenerations = Optional.of(numGenerations); + return this; + } + + @java.lang.Override + @JsonSetter(value = "num_generations", nulls = Nulls.SKIP) + public _FinalStage numGenerations(Optional numGenerations) { + this.numGenerations = numGenerations; + return this; + } + + /** + *

The identifier of the model to generate with. Currently available models are command (default), command-nightly (experimental), command-light, and command-light-nightly (experimental). + * Smaller, "light" models are faster, while larger models will perform better. Custom models can also be supplied with their full ID.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage model(String model) { + this.model = Optional.of(model); + return this; + } + + @java.lang.Override + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public _FinalStage model(Optional model) { + this.model = model; + return this; + } + + @java.lang.Override + public GenerateStreamRequest build() { + return new GenerateStreamRequest( + prompt, + model, + numGenerations, + maxTokens, + truncate, + temperature, + seed, + preset, + endSequences, + stopSequences, + k, + p, + frequencyPenalty, + presencePenalty, + returnLikelihoods, + rawPrompting, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/requests/RerankRequest.java b/src/main/java/com/cohere/api/requests/RerankRequest.java index cac0623..6bca227 100644 --- a/src/main/java/com/cohere/api/requests/RerankRequest.java +++ b/src/main/java/com/cohere/api/requests/RerankRequest.java @@ -31,6 +31,8 @@ public final class RerankRequest { private final Optional topN; + private final Optional> rankFields; + private final Optional returnDocuments; private final Optional maxChunksPerDoc; @@ -42,6 +44,7 @@ private RerankRequest( String query, List documents, Optional topN, + Optional> rankFields, Optional returnDocuments, Optional maxChunksPerDoc, Map additionalProperties) { @@ -49,13 +52,14 @@ private RerankRequest( this.query = query; this.documents = documents; this.topN = topN; + this.rankFields = rankFields; this.returnDocuments = returnDocuments; this.maxChunksPerDoc = maxChunksPerDoc; this.additionalProperties = additionalProperties; } /** - * @return The identifier of the model to use, one of : rerank-english-v2.0, rerank-multilingual-v2.0 + * @return The identifier of the model to use, one of : rerank-english-v3.0, rerank-multilingual-v3.0, rerank-english-v2.0, rerank-multilingual-v2.0 */ @JsonProperty("model") public Optional getModel() { @@ -89,6 +93,14 @@ public Optional getTopN() { return topN; } + /** + * @return If a JSON object is provided, you can specify which keys you would like to have considered for reranking. The model will rerank based on order of the fields passed in (i.e. rank_fields=['title','author','text'] will rerank using the values in title, author, text sequentially. If the length of title, author, and text exceeds the context length of the model, the chunking will not re-consider earlier fields). If not provided, the model will use the default text field for ranking. + */ + @JsonProperty("rank_fields") + public Optional> getRankFields() { + return rankFields; + } + /** * @return
    *
  • If false, returns results without the doc text - the api will return a list of {index, relevance score} where index is inferred from the list passed into the request.
  • @@ -108,7 +120,7 @@ public Optional getMaxChunksPerDoc() { return maxChunksPerDoc; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankRequest && equalTo((RerankRequest) other); @@ -124,17 +136,24 @@ private boolean equalTo(RerankRequest other) { && query.equals(other.query) && documents.equals(other.documents) && topN.equals(other.topN) + && rankFields.equals(other.rankFields) && returnDocuments.equals(other.returnDocuments) && maxChunksPerDoc.equals(other.maxChunksPerDoc); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( - this.model, this.query, this.documents, this.topN, this.returnDocuments, this.maxChunksPerDoc); + this.model, + this.query, + this.documents, + this.topN, + this.rankFields, + this.returnDocuments, + this.maxChunksPerDoc); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -166,6 +185,10 @@ public interface _FinalStage { _FinalStage topN(Integer topN); + _FinalStage rankFields(Optional> rankFields); + + _FinalStage rankFields(List rankFields); + _FinalStage returnDocuments(Optional returnDocuments); _FinalStage returnDocuments(Boolean returnDocuments); @@ -183,6 +206,8 @@ public static final class Builder implements QueryStage, _FinalStage { private Optional returnDocuments = Optional.empty(); + private Optional> rankFields = Optional.empty(); + private Optional topN = Optional.empty(); private List documents = new ArrayList<>(); @@ -194,12 +219,13 @@ public static final class Builder implements QueryStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(RerankRequest other) { model(other.getModel()); query(other.getQuery()); documents(other.getDocuments()); topN(other.getTopN()); + rankFields(other.getRankFields()); returnDocuments(other.getReturnDocuments()); maxChunksPerDoc(other.getMaxChunksPerDoc()); return this; @@ -209,7 +235,7 @@ public Builder from(RerankRequest other) { *

    The search query

    * @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("query") public _FinalStage query(String query) { this.query = query; @@ -220,13 +246,13 @@ public _FinalStage query(String query) { *

    The maximum number of chunks to produce internally from a document

    * @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage maxChunksPerDoc(Integer maxChunksPerDoc) { this.maxChunksPerDoc = Optional.of(maxChunksPerDoc); return this; } - @Override + @java.lang.Override @JsonSetter(value = "max_chunks_per_doc", nulls = Nulls.SKIP) public _FinalStage maxChunksPerDoc(Optional maxChunksPerDoc) { this.maxChunksPerDoc = maxChunksPerDoc; @@ -240,30 +266,47 @@ public _FinalStage maxChunksPerDoc(Optional maxChunksPerDoc) { *
* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage returnDocuments(Boolean returnDocuments) { this.returnDocuments = Optional.of(returnDocuments); return this; } - @Override + @java.lang.Override @JsonSetter(value = "return_documents", nulls = Nulls.SKIP) public _FinalStage returnDocuments(Optional returnDocuments) { this.returnDocuments = returnDocuments; return this; } + /** + *

If a JSON object is provided, you can specify which keys you would like to have considered for reranking. The model will rerank based on order of the fields passed in (i.e. rank_fields=['title','author','text'] will rerank using the values in title, author, text sequentially. If the length of title, author, and text exceeds the context length of the model, the chunking will not re-consider earlier fields). If not provided, the model will use the default text field for ranking.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage rankFields(List rankFields) { + this.rankFields = Optional.of(rankFields); + return this; + } + + @java.lang.Override + @JsonSetter(value = "rank_fields", nulls = Nulls.SKIP) + public _FinalStage rankFields(Optional> rankFields) { + this.rankFields = rankFields; + return this; + } + /** *

The number of most relevant documents or indices to return, defaults to the length of the documents

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage topN(Integer topN) { this.topN = Optional.of(topN); return this; } - @Override + @java.lang.Override @JsonSetter(value = "top_n", nulls = Nulls.SKIP) public _FinalStage topN(Optional topN) { this.topN = topN; @@ -277,7 +320,7 @@ public _FinalStage topN(Optional topN) { *

We recommend a maximum of 1,000 documents for optimal endpoint performance.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllDocuments(List documents) { this.documents.addAll(documents); return this; @@ -290,13 +333,13 @@ public _FinalStage addAllDocuments(List documents) { *

We recommend a maximum of 1,000 documents for optimal endpoint performance.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addDocuments(RerankRequestDocumentsItem documents) { this.documents.add(documents); return this; } - @Override + @java.lang.Override @JsonSetter(value = "documents", nulls = Nulls.SKIP) public _FinalStage documents(List documents) { this.documents.clear(); @@ -305,26 +348,26 @@ public _FinalStage documents(List documents) { } /** - *

The identifier of the model to use, one of : rerank-english-v2.0, rerank-multilingual-v2.0

+ *

The identifier of the model to use, one of : rerank-english-v3.0, rerank-multilingual-v3.0, rerank-english-v2.0, rerank-multilingual-v2.0

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public RerankRequest build() { return new RerankRequest( - model, query, documents, topN, returnDocuments, maxChunksPerDoc, additionalProperties); + model, query, documents, topN, rankFields, returnDocuments, maxChunksPerDoc, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/requests/SummarizeRequest.java b/src/main/java/com/cohere/api/requests/SummarizeRequest.java index bdbb6d5..1b173db 100644 --- a/src/main/java/com/cohere/api/requests/SummarizeRequest.java +++ b/src/main/java/com/cohere/api/requests/SummarizeRequest.java @@ -114,7 +114,7 @@ public Optional getAdditionalCommand() { return additionalCommand; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SummarizeRequest && equalTo((SummarizeRequest) other); @@ -135,7 +135,7 @@ private boolean equalTo(SummarizeRequest other) { && additionalCommand.equals(other.additionalCommand); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.text, @@ -147,7 +147,7 @@ public int hashCode() { this.additionalCommand); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -211,7 +211,7 @@ public static final class Builder implements TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(SummarizeRequest other) { text(other.getText()); length(other.getLength()); @@ -227,7 +227,7 @@ public Builder from(SummarizeRequest other) { *

The text to generate a summary for. Can be up to 100,000 characters long. Currently the only supported language is English.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; @@ -238,13 +238,13 @@ public _FinalStage text(String text) { *

A free-form instruction for modifying how the summaries get generated. Should complete the sentence "Generate a summary _". Eg. "focusing on the next steps" or "written by Yoda"

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage additionalCommand(String additionalCommand) { this.additionalCommand = Optional.of(additionalCommand); return this; } - @Override + @java.lang.Override @JsonSetter(value = "additional_command", nulls = Nulls.SKIP) public _FinalStage additionalCommand(Optional additionalCommand) { this.additionalCommand = additionalCommand; @@ -255,13 +255,13 @@ public _FinalStage additionalCommand(Optional additionalCommand) { *

Ranges from 0 to 5. Controls the randomness of the output. Lower values tend to generate more “predictable” output, while higher values tend to generate more “creative” output. The sweet spot is typically between 0 and 1.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage temperature(Double temperature) { this.temperature = Optional.of(temperature); return this; } - @Override + @java.lang.Override @JsonSetter(value = "temperature", nulls = Nulls.SKIP) public _FinalStage temperature(Optional temperature) { this.temperature = temperature; @@ -272,13 +272,13 @@ public _FinalStage temperature(Optional temperature) { *

One of low, medium, high, or auto, defaults to auto. Controls how close to the original text the summary is. high extractiveness summaries will lean towards reusing sentences verbatim, while low extractiveness summaries will tend to paraphrase more. If auto is selected, the best option will be picked based on the input text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage extractiveness(SummarizeRequestExtractiveness extractiveness) { this.extractiveness = Optional.of(extractiveness); return this; } - @Override + @java.lang.Override @JsonSetter(value = "extractiveness", nulls = Nulls.SKIP) public _FinalStage extractiveness(Optional extractiveness) { this.extractiveness = extractiveness; @@ -289,13 +289,13 @@ public _FinalStage extractiveness(Optional extra *

The identifier of the model to generate the summary with. Currently available models are command (default), command-nightly (experimental), command-light, and command-light-nightly (experimental). Smaller, "light" models are faster, while larger models will perform better.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage model(String model) { this.model = Optional.of(model); return this; } - @Override + @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { this.model = model; @@ -306,13 +306,13 @@ public _FinalStage model(Optional model) { *

One of paragraph, bullets, or auto, defaults to auto. Indicates the style in which the summary will be delivered - in a free form paragraph or in bullet points. If auto is selected, the best option will be picked based on the input text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage format(SummarizeRequestFormat format) { this.format = Optional.of(format); return this; } - @Override + @java.lang.Override @JsonSetter(value = "format", nulls = Nulls.SKIP) public _FinalStage format(Optional format) { this.format = format; @@ -323,20 +323,20 @@ public _FinalStage format(Optional format) { *

One of short, medium, long, or auto defaults to auto. Indicates the approximate length of the summary. If auto is selected, the best option will be picked based on the input text.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage length(SummarizeRequestLength length) { this.length = Optional.of(length); return this; } - @Override + @java.lang.Override @JsonSetter(value = "length", nulls = Nulls.SKIP) public _FinalStage length(Optional length) { this.length = length; return this; } - @Override + @java.lang.Override public SummarizeRequest build() { return new SummarizeRequest( text, length, format, model, extractiveness, temperature, additionalCommand, additionalProperties); diff --git a/src/main/java/com/cohere/api/requests/TokenizeRequest.java b/src/main/java/com/cohere/api/requests/TokenizeRequest.java index 9a55b4d..44ba956 100644 --- a/src/main/java/com/cohere/api/requests/TokenizeRequest.java +++ b/src/main/java/com/cohere/api/requests/TokenizeRequest.java @@ -10,23 +10,21 @@ 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 = TokenizeRequest.Builder.class) public final class TokenizeRequest { private final String text; - private final Optional model; + private final String model; private final Map additionalProperties; - private TokenizeRequest(String text, Optional model, Map additionalProperties) { + private TokenizeRequest(String text, String model, Map additionalProperties) { this.text = text; this.model = model; this.additionalProperties = additionalProperties; @@ -44,11 +42,11 @@ public String getText() { * @return An optional parameter to provide the model name. This will ensure that the tokenization uses the tokenizer used by that model. */ @JsonProperty("model") - public Optional getModel() { + public String getModel() { return model; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof TokenizeRequest && equalTo((TokenizeRequest) other); @@ -63,12 +61,12 @@ private boolean equalTo(TokenizeRequest other) { return text.equals(other.text) && model.equals(other.model); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text, this.model); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -78,31 +76,31 @@ public static TextStage builder() { } public interface TextStage { - _FinalStage text(String text); + ModelStage text(String text); Builder from(TokenizeRequest other); } + public interface ModelStage { + _FinalStage model(String model); + } + public interface _FinalStage { TokenizeRequest build(); - - _FinalStage model(Optional model); - - _FinalStage model(String model); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TextStage, _FinalStage { + public static final class Builder implements TextStage, ModelStage, _FinalStage { private String text; - private Optional model = Optional.empty(); + private String model; @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @Override + @java.lang.Override public Builder from(TokenizeRequest other) { text(other.getText()); model(other.getModel()); @@ -113,9 +111,9 @@ public Builder from(TokenizeRequest other) { *

The string to be tokenized, the minimum text length is 1 character, and the maximum text length is 65536 characters.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") - public _FinalStage text(String text) { + public ModelStage text(String text) { this.text = text; return this; } @@ -124,20 +122,14 @@ public _FinalStage text(String text) { *

An optional parameter to provide the model name. This will ensure that the tokenization uses the tokenizer used by that model.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override + @JsonSetter("model") public _FinalStage model(String model) { - this.model = Optional.of(model); - return this; - } - - @Override - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public _FinalStage model(Optional model) { this.model = model; return this; } - @Override + @java.lang.Override public TokenizeRequest build() { return new TokenizeRequest(text, model, additionalProperties); } diff --git a/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java b/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java index b259d60..9ca3e30 100644 --- a/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java +++ b/src/main/java/com/cohere/api/resources/connectors/ConnectorsClient.java @@ -5,22 +5,24 @@ import com.cohere.api.core.ApiError; import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.MediaTypes; import com.cohere.api.core.ObjectMappers; import com.cohere.api.core.RequestOptions; import com.cohere.api.resources.connectors.requests.ConnectorsListRequest; -import com.cohere.api.resources.connectors.requests.CreateRequest; -import com.cohere.api.resources.connectors.requests.UpdateRequest; -import com.cohere.api.types.CreateResponse; -import com.cohere.api.types.GetResponse; -import com.cohere.api.types.ListResponse; +import com.cohere.api.resources.connectors.requests.ConnectorsOAuthAuthorizeRequest; +import com.cohere.api.resources.connectors.requests.CreateConnectorRequest; +import com.cohere.api.resources.connectors.requests.UpdateConnectorRequest; +import com.cohere.api.types.CreateConnectorResponse; +import com.cohere.api.types.GetConnectorResponse; +import com.cohere.api.types.ListConnectorsResponse; import com.cohere.api.types.OAuthAuthorizeResponse; -import com.cohere.api.types.UpdateResponse; +import com.cohere.api.types.UpdateConnectorResponse; import com.fasterxml.jackson.core.type.TypeReference; import java.io.IOException; import java.util.Map; import okhttp3.Headers; import okhttp3.HttpUrl; -import okhttp3.MediaType; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @@ -35,14 +37,21 @@ public ConnectorsClient(ClientOptions clientOptions) { /** * Returns a list of connectors ordered by descending creation date (newer first). See 'Managing your Connector' for more information. */ - public ListResponse list() { + public ListConnectorsResponse list() { return list(ConnectorsListRequest.builder().build()); } /** * Returns a list of connectors ordered by descending creation date (newer first). See 'Managing your Connector' for more information. */ - public ListResponse list(ConnectorsListRequest request, RequestOptions requestOptions) { + public ListConnectorsResponse list(ConnectorsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of connectors ordered by descending creation date (newer first). See 'Managing your Connector' for more information. + */ + public ListConnectorsResponse list(ConnectorsListRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors"); @@ -59,10 +68,13 @@ public ListResponse list(ConnectorsListRequest request, RequestOptions requestOp .addHeader("Content-Type", "application/json"); Request okhttpRequest = _requestBuilder.build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), ListResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), ListConnectorsResponse.class); } throw new ApiError( response.code(), @@ -73,16 +85,16 @@ public ListResponse list(ConnectorsListRequest request, RequestOptions requestOp } /** - * Returns a list of connectors ordered by descending creation date (newer first). See 'Managing your Connector' for more information. + * Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See 'Creating and Deploying a Connector' for more information. */ - public ListResponse list(ConnectorsListRequest request) { - return list(request, null); + public CreateConnectorResponse create(CreateConnectorRequest request) { + return create(request, null); } /** * Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See 'Creating and Deploying a Connector' for more information. */ - public CreateResponse create(CreateRequest request, RequestOptions requestOptions) { + public CreateConnectorResponse create(CreateConnectorRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors") @@ -90,7 +102,7 @@ public CreateResponse create(CreateRequest request, RequestOptions requestOption RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -101,10 +113,13 @@ public CreateResponse create(CreateRequest request, RequestOptions requestOption .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), CreateResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), CreateConnectorResponse.class); } throw new ApiError( response.code(), @@ -115,16 +130,16 @@ public CreateResponse create(CreateRequest request, RequestOptions requestOption } /** - * Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See 'Creating and Deploying a Connector' for more information. + * Retrieve a connector by ID. See 'Connectors' for more information. */ - public CreateResponse create(CreateRequest request) { - return create(request, null); + public GetConnectorResponse get(String id) { + return get(id, null); } /** * Retrieve a connector by ID. See 'Connectors' for more information. */ - public GetResponse get(String id, RequestOptions requestOptions) { + public GetConnectorResponse get(String id, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors") @@ -137,10 +152,13 @@ public GetResponse get(String id, RequestOptions requestOptions) { .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), GetResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), GetConnectorResponse.class); } throw new ApiError( response.code(), @@ -151,10 +169,10 @@ public GetResponse get(String id, RequestOptions requestOptions) { } /** - * Retrieve a connector by ID. See 'Connectors' for more information. + * Delete a connector by ID. See 'Connectors' for more information. */ - public GetResponse get(String id) { - return get(id, null); + public Map delete(String id) { + return delete(id, null); } /** @@ -173,8 +191,11 @@ public Map delete(String id, RequestOptions requestOptions) { .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), new TypeReference>() {}); @@ -188,23 +209,23 @@ public Map delete(String id, RequestOptions requestOptions) { } /** - * Delete a connector by ID. See 'Connectors' for more information. + * Update a connector by ID. Omitted fields will not be updated. See 'Managing your Connector' for more information. */ - public Map delete(String id) { - return delete(id, null); + public UpdateConnectorResponse update(String id) { + return update(id, UpdateConnectorRequest.builder().build()); } /** * Update a connector by ID. Omitted fields will not be updated. See 'Managing your Connector' for more information. */ - public UpdateResponse update(String id) { - return update(id, UpdateRequest.builder().build()); + public UpdateConnectorResponse update(String id, UpdateConnectorRequest request) { + return update(id, request, null); } /** * Update a connector by ID. Omitted fields will not be updated. See 'Managing your Connector' for more information. */ - public UpdateResponse update(String id, UpdateRequest request, RequestOptions requestOptions) { + public UpdateConnectorResponse update(String id, UpdateConnectorRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors") @@ -213,7 +234,7 @@ public UpdateResponse update(String id, UpdateRequest request, RequestOptions re RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json")); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -224,10 +245,13 @@ public UpdateResponse update(String id, UpdateRequest request, RequestOptions re .addHeader("Content-Type", "application/json") .build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), UpdateResponse.class); + return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), UpdateConnectorResponse.class); } throw new ApiError( response.code(), @@ -238,31 +262,45 @@ public UpdateResponse update(String id, UpdateRequest request, RequestOptions re } /** - * Update a connector by ID. Omitted fields will not be updated. See 'Managing your Connector' for more information. + * Authorize the connector with the given ID for the connector oauth app. See 'Connector Authentication' for more information. */ - public UpdateResponse update(String id, UpdateRequest request) { - return update(id, request, null); + public OAuthAuthorizeResponse oAuthAuthorize(String id) { + return oAuthAuthorize(id, ConnectorsOAuthAuthorizeRequest.builder().build()); } /** * Authorize the connector with the given ID for the connector oauth app. See 'Connector Authentication' for more information. */ - public OAuthAuthorizeResponse oAuthAuthorize(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public OAuthAuthorizeResponse oAuthAuthorize(String id, ConnectorsOAuthAuthorizeRequest request) { + return oAuthAuthorize(id, request, null); + } + + /** + * Authorize the connector with the given ID for the connector oauth app. See 'Connector Authentication' for more information. + */ + public OAuthAuthorizeResponse oAuthAuthorize( + String id, ConnectorsOAuthAuthorizeRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("connectors") .addPathSegment(id) - .addPathSegments("oauth/authorize") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .addPathSegments("oauth/authorize"); + if (request.getAfterTokenRedirect().isPresent()) { + httpUrl.addQueryParameter( + "after_token_redirect", request.getAfterTokenRedirect().get()); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) .method("POST", RequestBody.create("", null)) .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.build(); try { - Response response = - clientOptions.httpClient().newCall(okhttpRequest).execute(); + 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(), OAuthAuthorizeResponse.class); } @@ -273,11 +311,4 @@ public OAuthAuthorizeResponse oAuthAuthorize(String id, RequestOptions requestOp throw new RuntimeException(e); } } - - /** - * Authorize the connector with the given ID for the connector oauth app. See 'Connector Authentication' for more information. - */ - public OAuthAuthorizeResponse oAuthAuthorize(String id) { - return oAuthAuthorize(id, null); - } } diff --git a/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsListRequest.java b/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsListRequest.java index 179db53..edc7478 100644 --- a/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsListRequest.java +++ b/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsListRequest.java @@ -49,7 +49,7 @@ public Optional getOffset() { return offset; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ConnectorsListRequest && equalTo((ConnectorsListRequest) other); @@ -64,12 +64,12 @@ private boolean equalTo(ConnectorsListRequest other) { return limit.equals(other.limit) && offset.equals(other.offset); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.limit, this.offset); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsOAuthAuthorizeRequest.java b/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsOAuthAuthorizeRequest.java new file mode 100644 index 0000000..e6c83be --- /dev/null +++ b/src/main/java/com/cohere/api/resources/connectors/requests/ConnectorsOAuthAuthorizeRequest.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.connectors.requests; + +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 = ConnectorsOAuthAuthorizeRequest.Builder.class) +public final class ConnectorsOAuthAuthorizeRequest { + private final Optional afterTokenRedirect; + + private final Map additionalProperties; + + private ConnectorsOAuthAuthorizeRequest( + Optional afterTokenRedirect, Map additionalProperties) { + this.afterTokenRedirect = afterTokenRedirect; + this.additionalProperties = additionalProperties; + } + + /** + * @return The URL to redirect to after the connector has been authorized. + */ + @JsonProperty("after_token_redirect") + public Optional getAfterTokenRedirect() { + return afterTokenRedirect; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConnectorsOAuthAuthorizeRequest && equalTo((ConnectorsOAuthAuthorizeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ConnectorsOAuthAuthorizeRequest other) { + return afterTokenRedirect.equals(other.afterTokenRedirect); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.afterTokenRedirect); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional afterTokenRedirect = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ConnectorsOAuthAuthorizeRequest other) { + afterTokenRedirect(other.getAfterTokenRedirect()); + return this; + } + + @JsonSetter(value = "after_token_redirect", nulls = Nulls.SKIP) + public Builder afterTokenRedirect(Optional afterTokenRedirect) { + this.afterTokenRedirect = afterTokenRedirect; + return this; + } + + public Builder afterTokenRedirect(String afterTokenRedirect) { + this.afterTokenRedirect = Optional.of(afterTokenRedirect); + return this; + } + + public ConnectorsOAuthAuthorizeRequest build() { + return new ConnectorsOAuthAuthorizeRequest(afterTokenRedirect, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/connectors/requests/CreateRequest.java b/src/main/java/com/cohere/api/resources/connectors/requests/CreateConnectorRequest.java similarity index 91% rename from src/main/java/com/cohere/api/resources/connectors/requests/CreateRequest.java rename to src/main/java/com/cohere/api/resources/connectors/requests/CreateConnectorRequest.java index 557d196..979d6fd 100644 --- a/src/main/java/com/cohere/api/resources/connectors/requests/CreateRequest.java +++ b/src/main/java/com/cohere/api/resources/connectors/requests/CreateConnectorRequest.java @@ -21,8 +21,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = CreateRequest.Builder.class) -public final class CreateRequest { +@JsonDeserialize(builder = CreateConnectorRequest.Builder.class) +public final class CreateConnectorRequest { private final String name; private final Optional description; @@ -41,7 +41,7 @@ public final class CreateRequest { private final Map additionalProperties; - private CreateRequest( + private CreateConnectorRequest( String name, Optional description, String url, @@ -126,10 +126,10 @@ public Optional getServiceAuth() { return serviceAuth; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof CreateRequest && equalTo((CreateRequest) other); + return other instanceof CreateConnectorRequest && equalTo((CreateConnectorRequest) other); } @JsonAnyGetter @@ -137,7 +137,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(CreateRequest other) { + private boolean equalTo(CreateConnectorRequest other) { return name.equals(other.name) && description.equals(other.description) && url.equals(other.url) @@ -148,7 +148,7 @@ private boolean equalTo(CreateRequest other) { && serviceAuth.equals(other.serviceAuth); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.name, @@ -161,7 +161,7 @@ public int hashCode() { this.serviceAuth); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -173,7 +173,7 @@ public static NameStage builder() { public interface NameStage { UrlStage name(String name); - Builder from(CreateRequest other); + Builder from(CreateConnectorRequest other); } public interface UrlStage { @@ -181,7 +181,7 @@ public interface UrlStage { } public interface _FinalStage { - CreateRequest build(); + CreateConnectorRequest build(); _FinalStage description(Optional description); @@ -231,8 +231,8 @@ public static final class Builder implements NameStage, UrlStage, _FinalStage { private Builder() {} - @Override - public Builder from(CreateRequest other) { + @java.lang.Override + public Builder from(CreateConnectorRequest other) { name(other.getName()); description(other.getDescription()); url(other.getUrl()); @@ -248,7 +248,7 @@ public Builder from(CreateRequest other) { *

A human-readable name for the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("name") public UrlStage name(String name) { this.name = name; @@ -259,7 +259,7 @@ public UrlStage name(String name) { *

The URL of the connector that will be used to search for documents.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("url") public _FinalStage url(String url) { this.url = url; @@ -270,13 +270,13 @@ public _FinalStage url(String url) { *

The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage serviceAuth(CreateConnectorServiceAuth serviceAuth) { this.serviceAuth = Optional.of(serviceAuth); return this; } - @Override + @java.lang.Override @JsonSetter(value = "service_auth", nulls = Nulls.SKIP) public _FinalStage serviceAuth(Optional serviceAuth) { this.serviceAuth = serviceAuth; @@ -287,13 +287,13 @@ public _FinalStage serviceAuth(Optional serviceAuth) *

Whether a chat request should continue or not if the request to this connector fails.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage continueOnFailure(Boolean continueOnFailure) { this.continueOnFailure = Optional.of(continueOnFailure); return this; } - @Override + @java.lang.Override @JsonSetter(value = "continue_on_failure", nulls = Nulls.SKIP) public _FinalStage continueOnFailure(Optional continueOnFailure) { this.continueOnFailure = continueOnFailure; @@ -304,13 +304,13 @@ public _FinalStage continueOnFailure(Optional continueOnFailure) { *

Whether the connector is active or not.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage active(Boolean active) { this.active = Optional.of(active); return this; } - @Override + @java.lang.Override @JsonSetter(value = "active", nulls = Nulls.SKIP) public _FinalStage active(Optional active) { this.active = active; @@ -321,13 +321,13 @@ public _FinalStage active(Optional active) { *

The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage oauth(CreateConnectorOAuth oauth) { this.oauth = Optional.of(oauth); return this; } - @Override + @java.lang.Override @JsonSetter(value = "oauth", nulls = Nulls.SKIP) public _FinalStage oauth(Optional oauth) { this.oauth = oauth; @@ -338,13 +338,13 @@ public _FinalStage oauth(Optional oauth) { *

A list of fields to exclude from the prompt (fields remain in the document).

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage excludes(List excludes) { this.excludes = Optional.of(excludes); return this; } - @Override + @java.lang.Override @JsonSetter(value = "excludes", nulls = Nulls.SKIP) public _FinalStage excludes(Optional> excludes) { this.excludes = excludes; @@ -355,22 +355,22 @@ public _FinalStage excludes(Optional> excludes) { *

A description of the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage description(String description) { this.description = Optional.of(description); return this; } - @Override + @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { this.description = description; return this; } - @Override - public CreateRequest build() { - return new CreateRequest( + @java.lang.Override + public CreateConnectorRequest build() { + return new CreateConnectorRequest( name, description, url, diff --git a/src/main/java/com/cohere/api/resources/connectors/requests/UpdateRequest.java b/src/main/java/com/cohere/api/resources/connectors/requests/UpdateConnectorRequest.java similarity index 93% rename from src/main/java/com/cohere/api/resources/connectors/requests/UpdateRequest.java rename to src/main/java/com/cohere/api/resources/connectors/requests/UpdateConnectorRequest.java index 19b9547..04028d3 100644 --- a/src/main/java/com/cohere/api/resources/connectors/requests/UpdateRequest.java +++ b/src/main/java/com/cohere/api/resources/connectors/requests/UpdateConnectorRequest.java @@ -21,8 +21,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UpdateRequest.Builder.class) -public final class UpdateRequest { +@JsonDeserialize(builder = UpdateConnectorRequest.Builder.class) +public final class UpdateConnectorRequest { private final Optional name; private final Optional url; @@ -39,7 +39,7 @@ public final class UpdateRequest { private final Map additionalProperties; - private UpdateRequest( + private UpdateConnectorRequest( Optional name, Optional url, Optional> excludes, @@ -108,10 +108,10 @@ public Optional getServiceAuth() { return serviceAuth; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof UpdateRequest && equalTo((UpdateRequest) other); + return other instanceof UpdateConnectorRequest && equalTo((UpdateConnectorRequest) other); } @JsonAnyGetter @@ -119,7 +119,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(UpdateRequest other) { + private boolean equalTo(UpdateConnectorRequest other) { return name.equals(other.name) && url.equals(other.url) && excludes.equals(other.excludes) @@ -129,13 +129,13 @@ private boolean equalTo(UpdateRequest other) { && serviceAuth.equals(other.serviceAuth); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.name, this.url, this.excludes, this.oauth, this.active, this.continueOnFailure, this.serviceAuth); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -165,7 +165,7 @@ public static final class Builder { private Builder() {} - public Builder from(UpdateRequest other) { + public Builder from(UpdateConnectorRequest other) { name(other.getName()); url(other.getUrl()); excludes(other.getExcludes()); @@ -253,8 +253,8 @@ public Builder serviceAuth(CreateConnectorServiceAuth serviceAuth) { return this; } - public UpdateRequest build() { - return new UpdateRequest( + public UpdateConnectorRequest build() { + return new UpdateConnectorRequest( name, url, excludes, oauth, active, continueOnFailure, serviceAuth, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java b/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java new file mode 100644 index 0000000..9a1dd2a --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/DatasetsClient.java @@ -0,0 +1,292 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets; + +import com.cohere.api.core.ApiError; +import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.core.RequestOptions; +import com.cohere.api.resources.datasets.requests.DatasetsCreateRequest; +import com.cohere.api.resources.datasets.requests.DatasetsListRequest; +import com.cohere.api.resources.datasets.types.DatasetsCreateResponse; +import com.cohere.api.resources.datasets.types.DatasetsGetResponse; +import com.cohere.api.resources.datasets.types.DatasetsGetUsageResponse; +import com.cohere.api.resources.datasets.types.DatasetsListResponse; +import com.fasterxml.jackson.core.type.TypeReference; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Map; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.MultipartBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class DatasetsClient { + protected final ClientOptions clientOptions; + + public DatasetsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List datasets that have been created. + */ + public DatasetsListResponse list() { + return list(DatasetsListRequest.builder().build()); + } + + /** + * List datasets that have been created. + */ + public DatasetsListResponse list(DatasetsListRequest request) { + return list(request, null); + } + + /** + * List datasets that have been created. + */ + public DatasetsListResponse list(DatasetsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets"); + if (request.getDatasetType().isPresent()) { + httpUrl.addQueryParameter("datasetType", request.getDatasetType().get()); + } + if (request.getBefore().isPresent()) { + httpUrl.addQueryParameter("before", request.getBefore().get().toString()); + } + if (request.getAfter().isPresent()) { + httpUrl.addQueryParameter("after", request.getAfter().get().toString()); + } + if (request.getLimit().isPresent()) { + httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); + } + if (request.getOffset().isPresent()) { + httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.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(), DatasetsListResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Create a dataset by uploading a file. See 'Dataset Creation' for more information. + */ + public DatasetsCreateResponse create(File data, Optional evalData, DatasetsCreateRequest request) { + return create(data, evalData, request, null); + } + + /** + * Create a dataset by uploading a file. See 'Dataset Creation' for more information. + */ + public DatasetsCreateResponse create( + File data, Optional evalData, DatasetsCreateRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets"); + httpUrl.addQueryParameter("name", request.getName()); + httpUrl.addQueryParameter("type", request.getType().toString()); + if (request.getKeepOriginalFile().isPresent()) { + httpUrl.addQueryParameter( + "keep_original_file", request.getKeepOriginalFile().get().toString()); + } + if (request.getSkipMalformedInput().isPresent()) { + httpUrl.addQueryParameter( + "skip_malformed_input", + request.getSkipMalformedInput().get().toString()); + } + if (request.getKeepFields().isPresent()) { + httpUrl.addQueryParameter("keep_fields", request.getKeepFields().get()); + } + if (request.getOptionalFields().isPresent()) { + httpUrl.addQueryParameter( + "optional_fields", request.getOptionalFields().get()); + } + if (request.getTextSeparator().isPresent()) { + httpUrl.addQueryParameter( + "text_separator", request.getTextSeparator().get()); + } + if (request.getCsvDelimiter().isPresent()) { + httpUrl.addQueryParameter("csv_delimiter", request.getCsvDelimiter().get()); + } + if (request.getDryRun().isPresent()) { + httpUrl.addQueryParameter("dry_run", request.getDryRun().get().toString()); + } + MultipartBody.Builder body = new MultipartBody.Builder().setType(MultipartBody.FORM); + try { + String dataMimeType = Files.probeContentType(data.toPath()); + MediaType dataMediaType = dataMimeType != null ? MediaType.parse(dataMimeType) : null; + body.addFormDataPart("data", data.getName(), RequestBody.create(dataMediaType, data)); + if (evalData.isPresent()) { + String evalDataMimeType = Files.probeContentType(evalData.get().toPath()); + MediaType evalDataMediaType = evalDataMimeType != null ? MediaType.parse(evalDataMimeType) : null; + body.addFormDataPart( + "eval_data", evalData.get().getName(), RequestBody.create(evalDataMediaType, evalData.get())); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body.build()) + .headers(Headers.of(clientOptions.headers(requestOptions))); + Request okhttpRequest = _requestBuilder.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(), DatasetsCreateResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * View the dataset storage usage for your Organization. Each Organization can have up to 10GB of storage across all their users. + */ + public DatasetsGetUsageResponse getUsage() { + return getUsage(null); + } + + /** + * View the dataset storage usage for your Organization. Each Organization can have up to 10GB of storage across all their users. + */ + public DatasetsGetUsageResponse getUsage(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets/usage") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", 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(), DatasetsGetUsageResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Retrieve a dataset by ID. See 'Datasets' for more information. + */ + public DatasetsGetResponse get(String id) { + return get(id, null); + } + + /** + * Retrieve a dataset by ID. See 'Datasets' for more information. + */ + public DatasetsGetResponse get(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", 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(), DatasetsGetResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually. + */ + public Map delete(String id) { + return delete(id, null); + } + + /** + * Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually. + */ + public Map delete(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("datasets") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", 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(), new TypeReference>() {}); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsCreateRequest.java b/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsCreateRequest.java new file mode 100644 index 0000000..088a858 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsCreateRequest.java @@ -0,0 +1,422 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.requests; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.DatasetType; +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 = DatasetsCreateRequest.Builder.class) +public final class DatasetsCreateRequest { + private final String name; + + private final DatasetType type; + + private final Optional keepOriginalFile; + + private final Optional skipMalformedInput; + + private final Optional keepFields; + + private final Optional optionalFields; + + private final Optional textSeparator; + + private final Optional csvDelimiter; + + private final Optional dryRun; + + private final Map additionalProperties; + + private DatasetsCreateRequest( + String name, + DatasetType type, + Optional keepOriginalFile, + Optional skipMalformedInput, + Optional keepFields, + Optional optionalFields, + Optional textSeparator, + Optional csvDelimiter, + Optional dryRun, + Map additionalProperties) { + this.name = name; + this.type = type; + this.keepOriginalFile = keepOriginalFile; + this.skipMalformedInput = skipMalformedInput; + this.keepFields = keepFields; + this.optionalFields = optionalFields; + this.textSeparator = textSeparator; + this.csvDelimiter = csvDelimiter; + this.dryRun = dryRun; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the uploaded dataset. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The dataset type, which is used to validate the data. Valid types are embed-input, reranker-finetune-input, prompt-completion-finetune-input, single-label-classification-finetune-input, chat-finetune-input, and multi-label-classification-finetune-input. + */ + @JsonProperty("type") + public DatasetType getType() { + return type; + } + + /** + * @return Indicates if the original file should be stored. + */ + @JsonProperty("keep_original_file") + public Optional getKeepOriginalFile() { + return keepOriginalFile; + } + + /** + * @return Indicates whether rows with malformed input should be dropped (instead of failing the validation check). Dropped rows will be returned in the warnings field. + */ + @JsonProperty("skip_malformed_input") + public Optional getSkipMalformedInput() { + return skipMalformedInput; + } + + /** + * @return List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the schema for the corresponding Dataset type. For example, datasets of type embed-input will drop all fields other than the required text field. If any of the fields in keep_fields are missing from the uploaded file, Dataset validation will fail. + */ + @JsonProperty("keep_fields") + public Optional getKeepFields() { + return keepFields; + } + + /** + * @return List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the schema for the corresponding Dataset type. For example, Datasets of type embed-input will drop all fields other than the required text field. If any of the fields in optional_fields are missing from the uploaded file, Dataset validation will pass. + */ + @JsonProperty("optional_fields") + public Optional getOptionalFields() { + return optionalFields; + } + + /** + * @return Raw .txt uploads will be split into entries using the text_separator value. + */ + @JsonProperty("text_separator") + public Optional getTextSeparator() { + return textSeparator; + } + + /** + * @return The delimiter used for .csv uploads. + */ + @JsonProperty("csv_delimiter") + public Optional getCsvDelimiter() { + return csvDelimiter; + } + + /** + * @return flag to enable dry_run mode + */ + @JsonProperty("dry_run") + public Optional getDryRun() { + return dryRun; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsCreateRequest && equalTo((DatasetsCreateRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsCreateRequest other) { + return name.equals(other.name) + && type.equals(other.type) + && keepOriginalFile.equals(other.keepOriginalFile) + && skipMalformedInput.equals(other.skipMalformedInput) + && keepFields.equals(other.keepFields) + && optionalFields.equals(other.optionalFields) + && textSeparator.equals(other.textSeparator) + && csvDelimiter.equals(other.csvDelimiter) + && dryRun.equals(other.dryRun); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.type, + this.keepOriginalFile, + this.skipMalformedInput, + this.keepFields, + this.optionalFields, + this.textSeparator, + this.csvDelimiter, + this.dryRun); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + TypeStage name(String name); + + Builder from(DatasetsCreateRequest other); + } + + public interface TypeStage { + _FinalStage type(DatasetType type); + } + + public interface _FinalStage { + DatasetsCreateRequest build(); + + _FinalStage keepOriginalFile(Optional keepOriginalFile); + + _FinalStage keepOriginalFile(Boolean keepOriginalFile); + + _FinalStage skipMalformedInput(Optional skipMalformedInput); + + _FinalStage skipMalformedInput(Boolean skipMalformedInput); + + _FinalStage keepFields(Optional keepFields); + + _FinalStage keepFields(String keepFields); + + _FinalStage optionalFields(Optional optionalFields); + + _FinalStage optionalFields(String optionalFields); + + _FinalStage textSeparator(Optional textSeparator); + + _FinalStage textSeparator(String textSeparator); + + _FinalStage csvDelimiter(Optional csvDelimiter); + + _FinalStage csvDelimiter(String csvDelimiter); + + _FinalStage dryRun(Optional dryRun); + + _FinalStage dryRun(Boolean dryRun); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, TypeStage, _FinalStage { + private String name; + + private DatasetType type; + + private Optional dryRun = Optional.empty(); + + private Optional csvDelimiter = Optional.empty(); + + private Optional textSeparator = Optional.empty(); + + private Optional optionalFields = Optional.empty(); + + private Optional keepFields = Optional.empty(); + + private Optional skipMalformedInput = Optional.empty(); + + private Optional keepOriginalFile = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DatasetsCreateRequest other) { + name(other.getName()); + type(other.getType()); + keepOriginalFile(other.getKeepOriginalFile()); + skipMalformedInput(other.getSkipMalformedInput()); + keepFields(other.getKeepFields()); + optionalFields(other.getOptionalFields()); + textSeparator(other.getTextSeparator()); + csvDelimiter(other.getCsvDelimiter()); + dryRun(other.getDryRun()); + return this; + } + + /** + *

The name of the uploaded dataset.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public TypeStage name(String name) { + this.name = name; + return this; + } + + /** + *

The dataset type, which is used to validate the data. Valid types are embed-input, reranker-finetune-input, prompt-completion-finetune-input, single-label-classification-finetune-input, chat-finetune-input, and multi-label-classification-finetune-input.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("type") + public _FinalStage type(DatasetType type) { + this.type = type; + return this; + } + + /** + *

flag to enable dry_run mode

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage dryRun(Boolean dryRun) { + this.dryRun = Optional.of(dryRun); + return this; + } + + @java.lang.Override + @JsonSetter(value = "dry_run", nulls = Nulls.SKIP) + public _FinalStage dryRun(Optional dryRun) { + this.dryRun = dryRun; + return this; + } + + /** + *

The delimiter used for .csv uploads.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage csvDelimiter(String csvDelimiter) { + this.csvDelimiter = Optional.of(csvDelimiter); + return this; + } + + @java.lang.Override + @JsonSetter(value = "csv_delimiter", nulls = Nulls.SKIP) + public _FinalStage csvDelimiter(Optional csvDelimiter) { + this.csvDelimiter = csvDelimiter; + return this; + } + + /** + *

Raw .txt uploads will be split into entries using the text_separator value.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage textSeparator(String textSeparator) { + this.textSeparator = Optional.of(textSeparator); + return this; + } + + @java.lang.Override + @JsonSetter(value = "text_separator", nulls = Nulls.SKIP) + public _FinalStage textSeparator(Optional textSeparator) { + this.textSeparator = textSeparator; + return this; + } + + /** + *

List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the schema for the corresponding Dataset type. For example, Datasets of type embed-input will drop all fields other than the required text field. If any of the fields in optional_fields are missing from the uploaded file, Dataset validation will pass.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage optionalFields(String optionalFields) { + this.optionalFields = Optional.of(optionalFields); + return this; + } + + @java.lang.Override + @JsonSetter(value = "optional_fields", nulls = Nulls.SKIP) + public _FinalStage optionalFields(Optional optionalFields) { + this.optionalFields = optionalFields; + return this; + } + + /** + *

List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the schema for the corresponding Dataset type. For example, datasets of type embed-input will drop all fields other than the required text field. If any of the fields in keep_fields are missing from the uploaded file, Dataset validation will fail.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keepFields(String keepFields) { + this.keepFields = Optional.of(keepFields); + return this; + } + + @java.lang.Override + @JsonSetter(value = "keep_fields", nulls = Nulls.SKIP) + public _FinalStage keepFields(Optional keepFields) { + this.keepFields = keepFields; + return this; + } + + /** + *

Indicates whether rows with malformed input should be dropped (instead of failing the validation check). Dropped rows will be returned in the warnings field.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage skipMalformedInput(Boolean skipMalformedInput) { + this.skipMalformedInput = Optional.of(skipMalformedInput); + return this; + } + + @java.lang.Override + @JsonSetter(value = "skip_malformed_input", nulls = Nulls.SKIP) + public _FinalStage skipMalformedInput(Optional skipMalformedInput) { + this.skipMalformedInput = skipMalformedInput; + return this; + } + + /** + *

Indicates if the original file should be stored.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keepOriginalFile(Boolean keepOriginalFile) { + this.keepOriginalFile = Optional.of(keepOriginalFile); + return this; + } + + @java.lang.Override + @JsonSetter(value = "keep_original_file", nulls = Nulls.SKIP) + public _FinalStage keepOriginalFile(Optional keepOriginalFile) { + this.keepOriginalFile = keepOriginalFile; + return this; + } + + @java.lang.Override + public DatasetsCreateRequest build() { + return new DatasetsCreateRequest( + name, + type, + keepOriginalFile, + skipMalformedInput, + keepFields, + optionalFields, + textSeparator, + csvDelimiter, + dryRun, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsListRequest.java b/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsListRequest.java new file mode 100644 index 0000000..fc13a51 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/requests/DatasetsListRequest.java @@ -0,0 +1,209 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.requests; + +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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = DatasetsListRequest.Builder.class) +public final class DatasetsListRequest { + private final Optional datasetType; + + private final Optional before; + + private final Optional after; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private DatasetsListRequest( + Optional datasetType, + Optional before, + Optional after, + Optional limit, + Optional offset, + Map additionalProperties) { + this.datasetType = datasetType; + this.before = before; + this.after = after; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + /** + * @return optional filter by dataset type + */ + @JsonProperty("datasetType") + public Optional getDatasetType() { + return datasetType; + } + + /** + * @return optional filter before a date + */ + @JsonProperty("before") + public Optional getBefore() { + return before; + } + + /** + * @return optional filter after a date + */ + @JsonProperty("after") + public Optional getAfter() { + return after; + } + + /** + * @return optional limit to number of results + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return optional offset to start of results + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsListRequest && equalTo((DatasetsListRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsListRequest other) { + return datasetType.equals(other.datasetType) + && before.equals(other.before) + && after.equals(other.after) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.datasetType, this.before, this.after, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional datasetType = Optional.empty(); + + private Optional before = Optional.empty(); + + private Optional after = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsListRequest other) { + datasetType(other.getDatasetType()); + before(other.getBefore()); + after(other.getAfter()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "datasetType", nulls = Nulls.SKIP) + public Builder datasetType(Optional datasetType) { + this.datasetType = datasetType; + return this; + } + + public Builder datasetType(String datasetType) { + this.datasetType = Optional.of(datasetType); + return this; + } + + @JsonSetter(value = "before", nulls = Nulls.SKIP) + public Builder before(Optional before) { + this.before = before; + return this; + } + + public Builder before(OffsetDateTime before) { + this.before = Optional.of(before); + return this; + } + + @JsonSetter(value = "after", nulls = Nulls.SKIP) + public Builder after(Optional after) { + this.after = after; + return this; + } + + public Builder after(OffsetDateTime after) { + this.after = Optional.of(after); + return this; + } + + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Double limit) { + this.limit = Optional.of(limit); + return this; + } + + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Double offset) { + this.offset = Optional.of(offset); + return this; + } + + public DatasetsListRequest build() { + return new DatasetsListRequest(datasetType, before, after, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponse.java b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponse.java new file mode 100644 index 0000000..72043dd --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponse.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.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 = DatasetsCreateResponse.Builder.class) +public final class DatasetsCreateResponse { + private final Optional id; + + private final Map additionalProperties; + + private DatasetsCreateResponse(Optional id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The dataset ID + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsCreateResponse && equalTo((DatasetsCreateResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsCreateResponse other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsCreateResponse other) { + id(other.getId()); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + public DatasetsCreateResponse build() { + return new DatasetsCreateResponse(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponseDatasetParts.java b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponseDatasetParts.java new file mode 100644 index 0000000..492f65c --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponseDatasetParts.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = DatasetsCreateResponseDatasetParts.Builder.class) +public final class DatasetsCreateResponseDatasetParts { + private final Optional name; + + private final Optional numRows; + + private final Optional> samples; + + private final Optional partKind; + + private final Map additionalProperties; + + private DatasetsCreateResponseDatasetParts( + Optional name, + Optional numRows, + Optional> samples, + Optional partKind, + Map additionalProperties) { + this.name = name; + this.numRows = numRows; + this.samples = samples; + this.partKind = partKind; + this.additionalProperties = additionalProperties; + } + + /** + * @return the name of the dataset part + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return the number of rows in the dataset part + */ + @JsonProperty("num_rows") + public Optional getNumRows() { + return numRows; + } + + @JsonProperty("samples") + public Optional> getSamples() { + return samples; + } + + /** + * @return the kind of dataset part + */ + @JsonProperty("part_kind") + public Optional getPartKind() { + return partKind; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsCreateResponseDatasetParts + && equalTo((DatasetsCreateResponseDatasetParts) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsCreateResponseDatasetParts other) { + return name.equals(other.name) + && numRows.equals(other.numRows) + && samples.equals(other.samples) + && partKind.equals(other.partKind); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.numRows, this.samples, this.partKind); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional name = Optional.empty(); + + private Optional numRows = Optional.empty(); + + private Optional> samples = Optional.empty(); + + private Optional partKind = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsCreateResponseDatasetParts other) { + name(other.getName()); + numRows(other.getNumRows()); + samples(other.getSamples()); + partKind(other.getPartKind()); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.of(name); + return this; + } + + @JsonSetter(value = "num_rows", nulls = Nulls.SKIP) + public Builder numRows(Optional numRows) { + this.numRows = numRows; + return this; + } + + public Builder numRows(Double numRows) { + this.numRows = Optional.of(numRows); + return this; + } + + @JsonSetter(value = "samples", nulls = Nulls.SKIP) + public Builder samples(Optional> samples) { + this.samples = samples; + return this; + } + + public Builder samples(List samples) { + this.samples = Optional.of(samples); + return this; + } + + @JsonSetter(value = "part_kind", nulls = Nulls.SKIP) + public Builder partKind(Optional partKind) { + this.partKind = partKind; + return this; + } + + public Builder partKind(String partKind) { + this.partKind = Optional.of(partKind); + return this; + } + + public DatasetsCreateResponseDatasetParts build() { + return new DatasetsCreateResponseDatasetParts(name, numRows, samples, partKind, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetResponse.java b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetResponse.java new file mode 100644 index 0000000..595d2f4 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetResponse.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.types; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.Dataset; +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.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = DatasetsGetResponse.Builder.class) +public final class DatasetsGetResponse { + private final Dataset dataset; + + private final Map additionalProperties; + + private DatasetsGetResponse(Dataset dataset, Map additionalProperties) { + this.dataset = dataset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("dataset") + public Dataset getDataset() { + return dataset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsGetResponse && equalTo((DatasetsGetResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsGetResponse other) { + return dataset.equals(other.dataset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.dataset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DatasetStage builder() { + return new Builder(); + } + + public interface DatasetStage { + _FinalStage dataset(Dataset dataset); + + Builder from(DatasetsGetResponse other); + } + + public interface _FinalStage { + DatasetsGetResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DatasetStage, _FinalStage { + private Dataset dataset; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DatasetsGetResponse other) { + dataset(other.getDataset()); + return this; + } + + @java.lang.Override + @JsonSetter("dataset") + public _FinalStage dataset(Dataset dataset) { + this.dataset = dataset; + return this; + } + + @java.lang.Override + public DatasetsGetResponse build() { + return new DatasetsGetResponse(dataset, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetUsageResponse.java b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetUsageResponse.java new file mode 100644 index 0000000..d0dbd5c --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsGetUsageResponse.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.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 = DatasetsGetUsageResponse.Builder.class) +public final class DatasetsGetUsageResponse { + private final Optional organizationUsage; + + private final Map additionalProperties; + + private DatasetsGetUsageResponse(Optional organizationUsage, Map additionalProperties) { + this.organizationUsage = organizationUsage; + this.additionalProperties = additionalProperties; + } + + /** + * @return The total number of bytes used by the organization. + */ + @JsonProperty("organization_usage") + public Optional getOrganizationUsage() { + return organizationUsage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsGetUsageResponse && equalTo((DatasetsGetUsageResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsGetUsageResponse other) { + return organizationUsage.equals(other.organizationUsage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.organizationUsage); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional organizationUsage = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsGetUsageResponse other) { + organizationUsage(other.getOrganizationUsage()); + return this; + } + + @JsonSetter(value = "organization_usage", nulls = Nulls.SKIP) + public Builder organizationUsage(Optional organizationUsage) { + this.organizationUsage = organizationUsage; + return this; + } + + public Builder organizationUsage(String organizationUsage) { + this.organizationUsage = Optional.of(organizationUsage); + return this; + } + + public DatasetsGetUsageResponse build() { + return new DatasetsGetUsageResponse(organizationUsage, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/datasets/types/DatasetsListResponse.java b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsListResponse.java new file mode 100644 index 0000000..4af6494 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/datasets/types/DatasetsListResponse.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.datasets.types; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.Dataset; +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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = DatasetsListResponse.Builder.class) +public final class DatasetsListResponse { + private final Optional> datasets; + + private final Map additionalProperties; + + private DatasetsListResponse(Optional> datasets, Map additionalProperties) { + this.datasets = datasets; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("datasets") + public Optional> getDatasets() { + return datasets; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetsListResponse && equalTo((DatasetsListResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetsListResponse other) { + return datasets.equals(other.datasets); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.datasets); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> datasets = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DatasetsListResponse other) { + datasets(other.getDatasets()); + return this; + } + + @JsonSetter(value = "datasets", nulls = Nulls.SKIP) + public Builder datasets(Optional> datasets) { + this.datasets = datasets; + return this; + } + + public Builder datasets(List datasets) { + this.datasets = Optional.of(datasets); + return this; + } + + public DatasetsListResponse build() { + return new DatasetsListResponse(datasets, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java b/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java new file mode 100644 index 0000000..8be3314 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/embedjobs/EmbedJobsClient.java @@ -0,0 +1,190 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.embedjobs; + +import com.cohere.api.core.ApiError; +import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.MediaTypes; +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.core.RequestOptions; +import com.cohere.api.resources.embedjobs.requests.CreateEmbedJobRequest; +import com.cohere.api.types.CreateEmbedJobResponse; +import com.cohere.api.types.EmbedJob; +import com.cohere.api.types.ListEmbedJobResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class EmbedJobsClient { + protected final ClientOptions clientOptions; + + public EmbedJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * The list embed job endpoint allows users to view all embed jobs history for that specific user. + */ + public ListEmbedJobResponse list() { + return list(null); + } + + /** + * The list embed job endpoint allows users to view all embed jobs history for that specific user. + */ + public ListEmbedJobResponse list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("embed-jobs") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", 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(), ListEmbedJobResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * This API launches an async Embed job for a Dataset of type embed-input. The result of a completed embed job is new Dataset of type embed-output, which contains the original text entries and the corresponding embeddings. + */ + public CreateEmbedJobResponse create(CreateEmbedJobRequest request) { + return create(request, null); + } + + /** + * This API launches an async Embed job for a Dataset of type embed-input. The result of a completed embed job is new Dataset of type embed-output, which contains the original text entries and the corresponding embeddings. + */ + public CreateEmbedJobResponse create(CreateEmbedJobRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("embed-jobs") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .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(), CreateEmbedJobResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * This API retrieves the details about an embed job started by the same user. + */ + public EmbedJob get(String id) { + return get(id, null); + } + + /** + * This API retrieves the details about an embed job started by the same user. + */ + public EmbedJob get(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("embed-jobs") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", 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(), EmbedJob.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * This API allows users to cancel an active embed job. Once invoked, the embedding process will be terminated, and users will be charged for the embeddings processed up to the cancellation point. It's important to note that partial results will not be available to users after cancellation. + */ + public void cancel(String id) { + cancel(id, null); + } + + /** + * This API allows users to cancel an active embed job. Once invoked, the embedding process will be terminated, and users will be charged for the embeddings processed up to the cancellation point. It's important to note that partial results will not be available to users after cancellation. + */ + public void cancel(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("embed-jobs") + .addPathSegment(id) + .addPathSegments("cancel") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .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; + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/embedjobs/requests/CreateEmbedJobRequest.java b/src/main/java/com/cohere/api/resources/embedjobs/requests/CreateEmbedJobRequest.java new file mode 100644 index 0000000..a64b4e7 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/embedjobs/requests/CreateEmbedJobRequest.java @@ -0,0 +1,313 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.embedjobs.requests; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.resources.embedjobs.types.CreateEmbedJobRequestTruncate; +import com.cohere.api.types.EmbedInputType; +import com.cohere.api.types.EmbeddingType; +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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = CreateEmbedJobRequest.Builder.class) +public final class CreateEmbedJobRequest { + private final String model; + + private final String datasetId; + + private final EmbedInputType inputType; + + private final Optional name; + + private final Optional> embeddingTypes; + + private final Optional truncate; + + private final Map additionalProperties; + + private CreateEmbedJobRequest( + String model, + String datasetId, + EmbedInputType inputType, + Optional name, + Optional> embeddingTypes, + Optional truncate, + Map additionalProperties) { + this.model = model; + this.datasetId = datasetId; + this.inputType = inputType; + this.name = name; + this.embeddingTypes = embeddingTypes; + this.truncate = truncate; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the embedding model. + *

Available models and corresponding embedding dimensions:

+ *
    + *
  • embed-english-v3.0 : 1024
  • + *
  • embed-multilingual-v3.0 : 1024
  • + *
  • embed-english-light-v3.0 : 384
  • + *
  • embed-multilingual-light-v3.0 : 384
  • + *
+ */ + @JsonProperty("model") + public String getModel() { + return model; + } + + /** + * @return ID of a Dataset. The Dataset must be of type embed-input and must have a validation status Validated + */ + @JsonProperty("dataset_id") + public String getDatasetId() { + return datasetId; + } + + @JsonProperty("input_type") + public EmbedInputType getInputType() { + return inputType; + } + + /** + * @return The name of the embed job. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return Specifies the types of embeddings you want to get back. Not required and default is None, which returns the Embed Floats response type. Can be one or more of the following types. + *
    + *
  • "float": Use this when you want to get back the default float embeddings. Valid for all models.
  • + *
  • "int8": Use this when you want to get back signed int8 embeddings. Valid for only v3 models.
  • + *
  • "uint8": Use this when you want to get back unsigned int8 embeddings. Valid for only v3 models.
  • + *
  • "binary": Use this when you want to get back signed binary embeddings. Valid for only v3 models.
  • + *
  • "ubinary": Use this when you want to get back unsigned binary embeddings. Valid for only v3 models.
  • + *
+ */ + @JsonProperty("embedding_types") + public Optional> getEmbeddingTypes() { + return embeddingTypes; + } + + /** + * @return One of START|END to specify how the API will handle inputs longer than the maximum token length. + *

Passing START will discard the start of the input. END will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

+ */ + @JsonProperty("truncate") + public Optional getTruncate() { + return truncate; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateEmbedJobRequest && equalTo((CreateEmbedJobRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateEmbedJobRequest other) { + return model.equals(other.model) + && datasetId.equals(other.datasetId) + && inputType.equals(other.inputType) + && name.equals(other.name) + && embeddingTypes.equals(other.embeddingTypes) + && truncate.equals(other.truncate); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.model, this.datasetId, this.inputType, this.name, this.embeddingTypes, this.truncate); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ModelStage builder() { + return new Builder(); + } + + public interface ModelStage { + DatasetIdStage model(String model); + + Builder from(CreateEmbedJobRequest other); + } + + public interface DatasetIdStage { + InputTypeStage datasetId(String datasetId); + } + + public interface InputTypeStage { + _FinalStage inputType(EmbedInputType inputType); + } + + public interface _FinalStage { + CreateEmbedJobRequest build(); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage embeddingTypes(Optional> embeddingTypes); + + _FinalStage embeddingTypes(List embeddingTypes); + + _FinalStage truncate(Optional truncate); + + _FinalStage truncate(CreateEmbedJobRequestTruncate truncate); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ModelStage, DatasetIdStage, InputTypeStage, _FinalStage { + private String model; + + private String datasetId; + + private EmbedInputType inputType; + + private Optional truncate = Optional.empty(); + + private Optional> embeddingTypes = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateEmbedJobRequest other) { + model(other.getModel()); + datasetId(other.getDatasetId()); + inputType(other.getInputType()); + name(other.getName()); + embeddingTypes(other.getEmbeddingTypes()); + truncate(other.getTruncate()); + return this; + } + + /** + *

ID of the embedding model.

+ *

Available models and corresponding embedding dimensions:

+ *
    + *
  • embed-english-v3.0 : 1024
  • + *
  • embed-multilingual-v3.0 : 1024
  • + *
  • embed-english-light-v3.0 : 384
  • + *
  • embed-multilingual-light-v3.0 : 384
  • + *
+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("model") + public DatasetIdStage model(String model) { + this.model = model; + return this; + } + + /** + *

ID of a Dataset. The Dataset must be of type embed-input and must have a validation status Validated

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("dataset_id") + public InputTypeStage datasetId(String datasetId) { + this.datasetId = datasetId; + return this; + } + + @java.lang.Override + @JsonSetter("input_type") + public _FinalStage inputType(EmbedInputType inputType) { + this.inputType = inputType; + return this; + } + + /** + *

One of START|END to specify how the API will handle inputs longer than the maximum token length.

+ *

Passing START will discard the start of the input. END will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage truncate(CreateEmbedJobRequestTruncate truncate) { + this.truncate = Optional.of(truncate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "truncate", nulls = Nulls.SKIP) + public _FinalStage truncate(Optional truncate) { + this.truncate = truncate; + return this; + } + + /** + *

Specifies the types of embeddings you want to get back. Not required and default is None, which returns the Embed Floats response type. Can be one or more of the following types.

+ *
    + *
  • "float": Use this when you want to get back the default float embeddings. Valid for all models.
  • + *
  • "int8": Use this when you want to get back signed int8 embeddings. Valid for only v3 models.
  • + *
  • "uint8": Use this when you want to get back unsigned int8 embeddings. Valid for only v3 models.
  • + *
  • "binary": Use this when you want to get back signed binary embeddings. Valid for only v3 models.
  • + *
  • "ubinary": Use this when you want to get back unsigned binary embeddings. Valid for only v3 models.
  • + *
+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage embeddingTypes(List embeddingTypes) { + this.embeddingTypes = Optional.of(embeddingTypes); + return this; + } + + @java.lang.Override + @JsonSetter(value = "embedding_types", nulls = Nulls.SKIP) + public _FinalStage embeddingTypes(Optional> embeddingTypes) { + this.embeddingTypes = embeddingTypes; + return this; + } + + /** + *

The name of the embed job.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.of(name); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public CreateEmbedJobRequest build() { + return new CreateEmbedJobRequest( + model, datasetId, inputType, name, embeddingTypes, truncate, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/embedjobs/types/CreateEmbedJobRequestTruncate.java b/src/main/java/com/cohere/api/resources/embedjobs/types/CreateEmbedJobRequestTruncate.java new file mode 100644 index 0000000..1c63e90 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/embedjobs/types/CreateEmbedJobRequestTruncate.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.embedjobs.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CreateEmbedJobRequestTruncate { + START("START"), + + END("END"); + + private final String value; + + CreateEmbedJobRequestTruncate(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/FinetuningClient.java b/src/main/java/com/cohere/api/resources/finetuning/FinetuningClient.java new file mode 100644 index 0000000..6064a3a --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/FinetuningClient.java @@ -0,0 +1,329 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning; + +import com.cohere.api.core.ApiError; +import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.MediaTypes; +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.core.RequestOptions; +import com.cohere.api.resources.finetuning.finetuning.types.CreateFinetunedModelResponse; +import com.cohere.api.resources.finetuning.finetuning.types.FinetunedModel; +import com.cohere.api.resources.finetuning.finetuning.types.GetFinetunedModelResponse; +import com.cohere.api.resources.finetuning.finetuning.types.ListEventsResponse; +import com.cohere.api.resources.finetuning.finetuning.types.ListFinetunedModelsResponse; +import com.cohere.api.resources.finetuning.finetuning.types.ListTrainingStepMetricsResponse; +import com.cohere.api.resources.finetuning.finetuning.types.UpdateFinetunedModelResponse; +import com.cohere.api.resources.finetuning.requests.FinetuningListEventsRequest; +import com.cohere.api.resources.finetuning.requests.FinetuningListFinetunedModelsRequest; +import com.cohere.api.resources.finetuning.requests.FinetuningListTrainingStepMetricsRequest; +import com.cohere.api.resources.finetuning.requests.FinetuningUpdateFinetunedModelRequest; +import com.fasterxml.jackson.core.type.TypeReference; +import java.io.IOException; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class FinetuningClient { + protected final ClientOptions clientOptions; + + public FinetuningClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public ListFinetunedModelsResponse listFinetunedModels() { + return listFinetunedModels( + FinetuningListFinetunedModelsRequest.builder().build()); + } + + public ListFinetunedModelsResponse listFinetunedModels(FinetuningListFinetunedModelsRequest request) { + return listFinetunedModels(request, null); + } + + public ListFinetunedModelsResponse listFinetunedModels( + FinetuningListFinetunedModelsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("finetuning/finetuned-models"); + if (request.getPageSize().isPresent()) { + httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); + } + if (request.getPageToken().isPresent()) { + httpUrl.addQueryParameter("page_token", request.getPageToken().get()); + } + if (request.getOrderBy().isPresent()) { + httpUrl.addQueryParameter("order_by", request.getOrderBy().get()); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.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(), ListFinetunedModelsResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public CreateFinetunedModelResponse createFinetunedModel(FinetunedModel request) { + return createFinetunedModel(request, null); + } + + public CreateFinetunedModelResponse createFinetunedModel(FinetunedModel request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("finetuning/finetuned-models") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .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(), CreateFinetunedModelResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public GetFinetunedModelResponse getFinetunedModel(String id) { + return getFinetunedModel(id, null); + } + + public GetFinetunedModelResponse getFinetunedModel(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("finetuning/finetuned-models") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", 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(), GetFinetunedModelResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public Map deleteFinetunedModel(String id) { + return deleteFinetunedModel(id, null); + } + + public Map deleteFinetunedModel(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("finetuning/finetuned-models") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", 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(), new TypeReference>() {}); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public UpdateFinetunedModelResponse updateFinetunedModel(String id, FinetuningUpdateFinetunedModelRequest request) { + return updateFinetunedModel(id, request, null); + } + + public UpdateFinetunedModelResponse updateFinetunedModel( + String id, FinetuningUpdateFinetunedModelRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("finetuning/finetuned-models") + .addPathSegment(id) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .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(), UpdateFinetunedModelResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public ListEventsResponse listEvents(String finetunedModelId) { + return listEvents( + finetunedModelId, FinetuningListEventsRequest.builder().build()); + } + + public ListEventsResponse listEvents(String finetunedModelId, FinetuningListEventsRequest request) { + return listEvents(finetunedModelId, request, null); + } + + public ListEventsResponse listEvents( + String finetunedModelId, FinetuningListEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("finetuning/finetuned-models") + .addPathSegment(finetunedModelId) + .addPathSegments("events"); + if (request.getPageSize().isPresent()) { + httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); + } + if (request.getPageToken().isPresent()) { + httpUrl.addQueryParameter("page_token", request.getPageToken().get()); + } + if (request.getOrderBy().isPresent()) { + httpUrl.addQueryParameter("order_by", request.getOrderBy().get()); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.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(), ListEventsResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public ListTrainingStepMetricsResponse listTrainingStepMetrics(String finetunedModelId) { + return listTrainingStepMetrics( + finetunedModelId, + FinetuningListTrainingStepMetricsRequest.builder().build()); + } + + public ListTrainingStepMetricsResponse listTrainingStepMetrics( + String finetunedModelId, FinetuningListTrainingStepMetricsRequest request) { + return listTrainingStepMetrics(finetunedModelId, request, null); + } + + public ListTrainingStepMetricsResponse listTrainingStepMetrics( + String finetunedModelId, FinetuningListTrainingStepMetricsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("finetuning/finetuned-models") + .addPathSegment(finetunedModelId) + .addPathSegments("metrics"); + if (request.getPageSize().isPresent()) { + httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); + } + if (request.getPageToken().isPresent()) { + httpUrl.addQueryParameter("page_token", request.getPageToken().get()); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.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(), ListTrainingStepMetricsResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/BaseModel.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/BaseModel.java new file mode 100644 index 0000000..a630881 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/BaseModel.java @@ -0,0 +1,223 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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 = BaseModel.Builder.class) +public final class BaseModel { + private final Optional name; + + private final Optional version; + + private final BaseType baseType; + + private final Optional strategy; + + private final Map additionalProperties; + + private BaseModel( + Optional name, + Optional version, + BaseType baseType, + Optional strategy, + Map additionalProperties) { + this.name = name; + this.version = version; + this.baseType = baseType; + this.strategy = strategy; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the base model. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return read-only. The version of the base model. + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + /** + * @return The type of the base model. + */ + @JsonProperty("base_type") + public BaseType getBaseType() { + return baseType; + } + + /** + * @return The fine-tuning strategy. + */ + @JsonProperty("strategy") + public Optional getStrategy() { + return strategy; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BaseModel && equalTo((BaseModel) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BaseModel other) { + return name.equals(other.name) + && version.equals(other.version) + && baseType.equals(other.baseType) + && strategy.equals(other.strategy); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.version, this.baseType, this.strategy); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BaseTypeStage builder() { + return new Builder(); + } + + public interface BaseTypeStage { + _FinalStage baseType(BaseType baseType); + + Builder from(BaseModel other); + } + + public interface _FinalStage { + BaseModel build(); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage version(Optional version); + + _FinalStage version(String version); + + _FinalStage strategy(Optional strategy); + + _FinalStage strategy(Strategy strategy); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements BaseTypeStage, _FinalStage { + private BaseType baseType; + + private Optional strategy = Optional.empty(); + + private Optional version = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BaseModel other) { + name(other.getName()); + version(other.getVersion()); + baseType(other.getBaseType()); + strategy(other.getStrategy()); + return this; + } + + /** + *

The type of the base model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("base_type") + public _FinalStage baseType(BaseType baseType) { + this.baseType = baseType; + return this; + } + + /** + *

The fine-tuning strategy.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage strategy(Strategy strategy) { + this.strategy = Optional.of(strategy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "strategy", nulls = Nulls.SKIP) + public _FinalStage strategy(Optional strategy) { + this.strategy = strategy; + return this; + } + + /** + *

read-only. The version of the base model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage version(String version) { + this.version = Optional.of(version); + return this; + } + + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + /** + *

The name of the base model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.of(name); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public BaseModel build() { + return new BaseModel(name, version, baseType, strategy, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/BaseType.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/BaseType.java new file mode 100644 index 0000000..015386d --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/BaseType.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum BaseType { + BASE_TYPE_UNSPECIFIED("BASE_TYPE_UNSPECIFIED"), + + BASE_TYPE_GENERATIVE("BASE_TYPE_GENERATIVE"), + + BASE_TYPE_CLASSIFICATION("BASE_TYPE_CLASSIFICATION"), + + BASE_TYPE_RERANK("BASE_TYPE_RERANK"), + + BASE_TYPE_CHAT("BASE_TYPE_CHAT"); + + private final String value; + + BaseType(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/CreateFinetunedModelResponse.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/CreateFinetunedModelResponse.java new file mode 100644 index 0000000..b2b365f --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/CreateFinetunedModelResponse.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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 = CreateFinetunedModelResponse.Builder.class) +public final class CreateFinetunedModelResponse { + private final Optional finetunedModel; + + private final Map additionalProperties; + + private CreateFinetunedModelResponse( + Optional finetunedModel, Map additionalProperties) { + this.finetunedModel = finetunedModel; + this.additionalProperties = additionalProperties; + } + + /** + * @return Information about the fine-tuned model. + */ + @JsonProperty("finetuned_model") + public Optional getFinetunedModel() { + return finetunedModel; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateFinetunedModelResponse && equalTo((CreateFinetunedModelResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateFinetunedModelResponse other) { + return finetunedModel.equals(other.finetunedModel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.finetunedModel); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional finetunedModel = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CreateFinetunedModelResponse other) { + finetunedModel(other.getFinetunedModel()); + return this; + } + + @JsonSetter(value = "finetuned_model", nulls = Nulls.SKIP) + public Builder finetunedModel(Optional finetunedModel) { + this.finetunedModel = finetunedModel; + return this; + } + + public Builder finetunedModel(FinetunedModel finetunedModel) { + this.finetunedModel = Optional.of(finetunedModel); + return this; + } + + public CreateFinetunedModelResponse build() { + return new CreateFinetunedModelResponse(finetunedModel, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Error.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Error.java new file mode 100644 index 0000000..23e8833 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Error.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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 = Error.Builder.class) +public final class Error { + private final Optional message; + + private final Map additionalProperties; + + private Error(Optional message, Map additionalProperties) { + this.message = message; + this.additionalProperties = additionalProperties; + } + + /** + * @return A developer-facing error message. + */ + @JsonProperty("message") + public Optional getMessage() { + return message; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Error && equalTo((Error) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Error other) { + return message.equals(other.message); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.message); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional message = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Error other) { + message(other.getMessage()); + return this; + } + + @JsonSetter(value = "message", nulls = Nulls.SKIP) + public Builder message(Optional message) { + this.message = message; + return this; + } + + public Builder message(String message) { + this.message = Optional.of(message); + return this; + } + + public Error build() { + return new Error(message, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Event.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Event.java new file mode 100644 index 0000000..9156164 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Event.java @@ -0,0 +1,153 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = Event.Builder.class) +public final class Event { + private final Optional userId; + + private final Optional status; + + private final Optional createdAt; + + private final Map additionalProperties; + + private Event( + Optional userId, + Optional status, + Optional createdAt, + Map additionalProperties) { + this.userId = userId; + this.status = status; + this.createdAt = createdAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the user who initiated the event. Empty if initiated by the system. + */ + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + /** + * @return Status of the fine-tuned model. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return Timestamp when the event happened. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Event && equalTo((Event) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Event other) { + return userId.equals(other.userId) && status.equals(other.status) && createdAt.equals(other.createdAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId, this.status, this.createdAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional userId = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Event other) { + userId(other.getUserId()); + status(other.getStatus()); + createdAt(other.getCreatedAt()); + return this; + } + + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public Builder userId(Optional userId) { + this.userId = userId; + return this; + } + + public Builder userId(String userId) { + this.userId = Optional.of(userId); + return this; + } + + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(Status status) { + this.status = Optional.of(status); + return this; + } + + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = Optional.of(createdAt); + return this; + } + + public Event build() { + return new Event(userId, status, createdAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/FinetunedModel.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/FinetunedModel.java new file mode 100644 index 0000000..de00577 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/FinetunedModel.java @@ -0,0 +1,461 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = FinetunedModel.Builder.class) +public final class FinetunedModel { + private final Optional id; + + private final String name; + + private final Optional creatorId; + + private final Optional organizationId; + + private final Settings settings; + + private final Optional status; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional completedAt; + + private final Optional lastUsed; + + private final Map additionalProperties; + + private FinetunedModel( + Optional id, + String name, + Optional creatorId, + Optional organizationId, + Settings settings, + Optional status, + Optional createdAt, + Optional updatedAt, + Optional completedAt, + Optional lastUsed, + Map additionalProperties) { + this.id = id; + this.name = name; + this.creatorId = creatorId; + this.organizationId = organizationId; + this.settings = settings; + this.status = status; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.completedAt = completedAt; + this.lastUsed = lastUsed; + this.additionalProperties = additionalProperties; + } + + /** + * @return read-only. FinetunedModel ID. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return FinetunedModel name (e.g. foobar). + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return read-only. User ID of the creator. + */ + @JsonProperty("creator_id") + public Optional getCreatorId() { + return creatorId; + } + + /** + * @return read-only. Organization ID. + */ + @JsonProperty("organization_id") + public Optional getOrganizationId() { + return organizationId; + } + + /** + * @return FinetunedModel settings such as dataset, hyperparameters... + */ + @JsonProperty("settings") + public Settings getSettings() { + return settings; + } + + /** + * @return read-only. Current stage in the life-cycle of the fine-tuned model. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return read-only. Creation timestamp. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return read-only. Latest update timestamp. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return read-only. Timestamp for the completed fine-tuning. + */ + @JsonProperty("completed_at") + public Optional getCompletedAt() { + return completedAt; + } + + /** + * @return read-only. Timestamp for the latest request to this fine-tuned model. + */ + @JsonProperty("last_used") + public Optional getLastUsed() { + return lastUsed; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FinetunedModel && equalTo((FinetunedModel) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FinetunedModel other) { + return id.equals(other.id) + && name.equals(other.name) + && creatorId.equals(other.creatorId) + && organizationId.equals(other.organizationId) + && settings.equals(other.settings) + && status.equals(other.status) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && completedAt.equals(other.completedAt) + && lastUsed.equals(other.lastUsed); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.name, + this.creatorId, + this.organizationId, + this.settings, + this.status, + this.createdAt, + this.updatedAt, + this.completedAt, + this.lastUsed); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + SettingsStage name(String name); + + Builder from(FinetunedModel other); + } + + public interface SettingsStage { + _FinalStage settings(Settings settings); + } + + public interface _FinalStage { + FinetunedModel build(); + + _FinalStage id(Optional id); + + _FinalStage id(String id); + + _FinalStage creatorId(Optional creatorId); + + _FinalStage creatorId(String creatorId); + + _FinalStage organizationId(Optional organizationId); + + _FinalStage organizationId(String organizationId); + + _FinalStage status(Optional status); + + _FinalStage status(Status status); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(OffsetDateTime createdAt); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(OffsetDateTime updatedAt); + + _FinalStage completedAt(Optional completedAt); + + _FinalStage completedAt(OffsetDateTime completedAt); + + _FinalStage lastUsed(Optional lastUsed); + + _FinalStage lastUsed(OffsetDateTime lastUsed); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, SettingsStage, _FinalStage { + private String name; + + private Settings settings; + + private Optional lastUsed = Optional.empty(); + + private Optional completedAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional organizationId = Optional.empty(); + + private Optional creatorId = Optional.empty(); + + private Optional id = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FinetunedModel other) { + id(other.getId()); + name(other.getName()); + creatorId(other.getCreatorId()); + organizationId(other.getOrganizationId()); + settings(other.getSettings()); + status(other.getStatus()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + completedAt(other.getCompletedAt()); + lastUsed(other.getLastUsed()); + return this; + } + + /** + *

FinetunedModel name (e.g. foobar).

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public SettingsStage name(String name) { + this.name = name; + return this; + } + + /** + *

FinetunedModel settings such as dataset, hyperparameters...

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("settings") + public _FinalStage settings(Settings settings) { + this.settings = settings; + return this; + } + + /** + *

read-only. Timestamp for the latest request to this fine-tuned model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage lastUsed(OffsetDateTime lastUsed) { + this.lastUsed = Optional.of(lastUsed); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_used", nulls = Nulls.SKIP) + public _FinalStage lastUsed(Optional lastUsed) { + this.lastUsed = lastUsed; + return this; + } + + /** + *

read-only. Timestamp for the completed fine-tuning.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage completedAt(OffsetDateTime completedAt) { + this.completedAt = Optional.of(completedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "completed_at", nulls = Nulls.SKIP) + public _FinalStage completedAt(Optional completedAt) { + this.completedAt = completedAt; + return this; + } + + /** + *

read-only. Latest update timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = Optional.of(updatedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + *

read-only. Creation timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAt(OffsetDateTime createdAt) { + this.createdAt = Optional.of(createdAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

read-only. Current stage in the life-cycle of the fine-tuned model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage status(Status status) { + this.status = Optional.of(status); + return this; + } + + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + /** + *

read-only. Organization ID.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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 organizationId) { + this.organizationId = organizationId; + return this; + } + + /** + *

read-only. User ID of the creator.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creatorId(String creatorId) { + this.creatorId = Optional.of(creatorId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "creator_id", nulls = Nulls.SKIP) + public _FinalStage creatorId(Optional creatorId) { + this.creatorId = creatorId; + return this; + } + + /** + *

read-only. FinetunedModel ID.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage id(String id) { + this.id = Optional.of(id); + return this; + } + + @java.lang.Override + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public _FinalStage id(Optional id) { + this.id = id; + return this; + } + + @java.lang.Override + public FinetunedModel build() { + return new FinetunedModel( + id, + name, + creatorId, + organizationId, + settings, + status, + createdAt, + updatedAt, + completedAt, + lastUsed, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/GetFinetunedModelResponse.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/GetFinetunedModelResponse.java new file mode 100644 index 0000000..2bf13a8 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/GetFinetunedModelResponse.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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 = GetFinetunedModelResponse.Builder.class) +public final class GetFinetunedModelResponse { + private final Optional finetunedModel; + + private final Map additionalProperties; + + private GetFinetunedModelResponse( + Optional finetunedModel, Map additionalProperties) { + this.finetunedModel = finetunedModel; + this.additionalProperties = additionalProperties; + } + + /** + * @return Information about the fine-tuned model. + */ + @JsonProperty("finetuned_model") + public Optional getFinetunedModel() { + return finetunedModel; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetFinetunedModelResponse && equalTo((GetFinetunedModelResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetFinetunedModelResponse other) { + return finetunedModel.equals(other.finetunedModel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.finetunedModel); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional finetunedModel = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetFinetunedModelResponse other) { + finetunedModel(other.getFinetunedModel()); + return this; + } + + @JsonSetter(value = "finetuned_model", nulls = Nulls.SKIP) + public Builder finetunedModel(Optional finetunedModel) { + this.finetunedModel = finetunedModel; + return this; + } + + public Builder finetunedModel(FinetunedModel finetunedModel) { + this.finetunedModel = Optional.of(finetunedModel); + return this; + } + + public GetFinetunedModelResponse build() { + return new GetFinetunedModelResponse(finetunedModel, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Hyperparameters.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Hyperparameters.java new file mode 100644 index 0000000..744ea5f --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Hyperparameters.java @@ -0,0 +1,221 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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 = Hyperparameters.Builder.class) +public final class Hyperparameters { + private final Optional earlyStoppingPatience; + + private final Optional earlyStoppingThreshold; + + private final Optional trainBatchSize; + + private final Optional trainEpochs; + + private final Optional learningRate; + + private final Map additionalProperties; + + private Hyperparameters( + Optional earlyStoppingPatience, + Optional earlyStoppingThreshold, + Optional trainBatchSize, + Optional trainEpochs, + Optional learningRate, + Map additionalProperties) { + this.earlyStoppingPatience = earlyStoppingPatience; + this.earlyStoppingThreshold = earlyStoppingThreshold; + this.trainBatchSize = trainBatchSize; + this.trainEpochs = trainEpochs; + this.learningRate = learningRate; + this.additionalProperties = additionalProperties; + } + + /** + * @return Stops training if the loss metric does not improve beyond the value of + * early_stopping_threshold after this many times of evaluation. + */ + @JsonProperty("early_stopping_patience") + public Optional getEarlyStoppingPatience() { + return earlyStoppingPatience; + } + + /** + * @return How much the loss must improve to prevent early stopping. + */ + @JsonProperty("early_stopping_threshold") + public Optional getEarlyStoppingThreshold() { + return earlyStoppingThreshold; + } + + /** + * @return The batch size is the number of training examples included in a single + * training pass. + */ + @JsonProperty("train_batch_size") + public Optional getTrainBatchSize() { + return trainBatchSize; + } + + /** + * @return The number of epochs to train for. + */ + @JsonProperty("train_epochs") + public Optional getTrainEpochs() { + return trainEpochs; + } + + /** + * @return The learning rate to be used during training. + */ + @JsonProperty("learning_rate") + public Optional getLearningRate() { + return learningRate; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Hyperparameters && equalTo((Hyperparameters) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Hyperparameters other) { + return earlyStoppingPatience.equals(other.earlyStoppingPatience) + && earlyStoppingThreshold.equals(other.earlyStoppingThreshold) + && trainBatchSize.equals(other.trainBatchSize) + && trainEpochs.equals(other.trainEpochs) + && learningRate.equals(other.learningRate); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.earlyStoppingPatience, + this.earlyStoppingThreshold, + this.trainBatchSize, + this.trainEpochs, + this.learningRate); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional earlyStoppingPatience = Optional.empty(); + + private Optional earlyStoppingThreshold = Optional.empty(); + + private Optional trainBatchSize = Optional.empty(); + + private Optional trainEpochs = Optional.empty(); + + private Optional learningRate = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Hyperparameters other) { + earlyStoppingPatience(other.getEarlyStoppingPatience()); + earlyStoppingThreshold(other.getEarlyStoppingThreshold()); + trainBatchSize(other.getTrainBatchSize()); + trainEpochs(other.getTrainEpochs()); + learningRate(other.getLearningRate()); + return this; + } + + @JsonSetter(value = "early_stopping_patience", nulls = Nulls.SKIP) + public Builder earlyStoppingPatience(Optional earlyStoppingPatience) { + this.earlyStoppingPatience = earlyStoppingPatience; + return this; + } + + public Builder earlyStoppingPatience(Integer earlyStoppingPatience) { + this.earlyStoppingPatience = Optional.of(earlyStoppingPatience); + return this; + } + + @JsonSetter(value = "early_stopping_threshold", nulls = Nulls.SKIP) + public Builder earlyStoppingThreshold(Optional earlyStoppingThreshold) { + this.earlyStoppingThreshold = earlyStoppingThreshold; + return this; + } + + public Builder earlyStoppingThreshold(Double earlyStoppingThreshold) { + this.earlyStoppingThreshold = Optional.of(earlyStoppingThreshold); + return this; + } + + @JsonSetter(value = "train_batch_size", nulls = Nulls.SKIP) + public Builder trainBatchSize(Optional trainBatchSize) { + this.trainBatchSize = trainBatchSize; + return this; + } + + public Builder trainBatchSize(Integer trainBatchSize) { + this.trainBatchSize = Optional.of(trainBatchSize); + return this; + } + + @JsonSetter(value = "train_epochs", nulls = Nulls.SKIP) + public Builder trainEpochs(Optional trainEpochs) { + this.trainEpochs = trainEpochs; + return this; + } + + public Builder trainEpochs(Integer trainEpochs) { + this.trainEpochs = Optional.of(trainEpochs); + return this; + } + + @JsonSetter(value = "learning_rate", nulls = Nulls.SKIP) + public Builder learningRate(Optional learningRate) { + this.learningRate = learningRate; + return this; + } + + public Builder learningRate(Double learningRate) { + this.learningRate = Optional.of(learningRate); + return this; + } + + public Hyperparameters build() { + return new Hyperparameters( + earlyStoppingPatience, + earlyStoppingThreshold, + trainBatchSize, + trainEpochs, + learningRate, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListEventsResponse.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListEventsResponse.java new file mode 100644 index 0000000..049c922 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListEventsResponse.java @@ -0,0 +1,156 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ListEventsResponse.Builder.class) +public final class ListEventsResponse { + private final Optional> events; + + private final Optional nextPageToken; + + private final Optional totalSize; + + private final Map additionalProperties; + + private ListEventsResponse( + Optional> events, + Optional nextPageToken, + Optional totalSize, + Map additionalProperties) { + this.events = events; + this.nextPageToken = nextPageToken; + this.totalSize = totalSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return List of events for the fine-tuned model. + */ + @JsonProperty("events") + public Optional> getEvents() { + return events; + } + + /** + * @return Pagination token to retrieve the next page of results. If the value is "", + * it means no further results for the request. + */ + @JsonProperty("next_page_token") + public Optional getNextPageToken() { + return nextPageToken; + } + + /** + * @return Total count of results. + */ + @JsonProperty("total_size") + public Optional getTotalSize() { + return totalSize; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListEventsResponse && equalTo((ListEventsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListEventsResponse other) { + return events.equals(other.events) + && nextPageToken.equals(other.nextPageToken) + && totalSize.equals(other.totalSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.events, this.nextPageToken, this.totalSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> events = Optional.empty(); + + private Optional nextPageToken = Optional.empty(); + + private Optional totalSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListEventsResponse other) { + events(other.getEvents()); + nextPageToken(other.getNextPageToken()); + totalSize(other.getTotalSize()); + return this; + } + + @JsonSetter(value = "events", nulls = Nulls.SKIP) + public Builder events(Optional> events) { + this.events = events; + return this; + } + + public Builder events(List events) { + this.events = Optional.of(events); + return this; + } + + @JsonSetter(value = "next_page_token", nulls = Nulls.SKIP) + public Builder nextPageToken(Optional nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + public Builder nextPageToken(String nextPageToken) { + this.nextPageToken = Optional.of(nextPageToken); + return this; + } + + @JsonSetter(value = "total_size", nulls = Nulls.SKIP) + public Builder totalSize(Optional totalSize) { + this.totalSize = totalSize; + return this; + } + + public Builder totalSize(Integer totalSize) { + this.totalSize = Optional.of(totalSize); + return this; + } + + public ListEventsResponse build() { + return new ListEventsResponse(events, nextPageToken, totalSize, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListFinetunedModelsResponse.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListFinetunedModelsResponse.java new file mode 100644 index 0000000..d85b722 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListFinetunedModelsResponse.java @@ -0,0 +1,156 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ListFinetunedModelsResponse.Builder.class) +public final class ListFinetunedModelsResponse { + private final Optional> finetunedModels; + + private final Optional nextPageToken; + + private final Optional totalSize; + + private final Map additionalProperties; + + private ListFinetunedModelsResponse( + Optional> finetunedModels, + Optional nextPageToken, + Optional totalSize, + Map additionalProperties) { + this.finetunedModels = finetunedModels; + this.nextPageToken = nextPageToken; + this.totalSize = totalSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return List of fine-tuned models matching the request. + */ + @JsonProperty("finetuned_models") + public Optional> getFinetunedModels() { + return finetunedModels; + } + + /** + * @return Pagination token to retrieve the next page of results. If the value is "", + * it means no further results for the request. + */ + @JsonProperty("next_page_token") + public Optional getNextPageToken() { + return nextPageToken; + } + + /** + * @return Total count of results. + */ + @JsonProperty("total_size") + public Optional getTotalSize() { + return totalSize; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListFinetunedModelsResponse && equalTo((ListFinetunedModelsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListFinetunedModelsResponse other) { + return finetunedModels.equals(other.finetunedModels) + && nextPageToken.equals(other.nextPageToken) + && totalSize.equals(other.totalSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.finetunedModels, this.nextPageToken, this.totalSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> finetunedModels = Optional.empty(); + + private Optional nextPageToken = Optional.empty(); + + private Optional totalSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListFinetunedModelsResponse other) { + finetunedModels(other.getFinetunedModels()); + nextPageToken(other.getNextPageToken()); + totalSize(other.getTotalSize()); + return this; + } + + @JsonSetter(value = "finetuned_models", nulls = Nulls.SKIP) + public Builder finetunedModels(Optional> finetunedModels) { + this.finetunedModels = finetunedModels; + return this; + } + + public Builder finetunedModels(List finetunedModels) { + this.finetunedModels = Optional.of(finetunedModels); + return this; + } + + @JsonSetter(value = "next_page_token", nulls = Nulls.SKIP) + public Builder nextPageToken(Optional nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + public Builder nextPageToken(String nextPageToken) { + this.nextPageToken = Optional.of(nextPageToken); + return this; + } + + @JsonSetter(value = "total_size", nulls = Nulls.SKIP) + public Builder totalSize(Optional totalSize) { + this.totalSize = totalSize; + return this; + } + + public Builder totalSize(Integer totalSize) { + this.totalSize = Optional.of(totalSize); + return this; + } + + public ListFinetunedModelsResponse build() { + return new ListFinetunedModelsResponse(finetunedModels, nextPageToken, totalSize, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListTrainingStepMetricsResponse.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListTrainingStepMetricsResponse.java new file mode 100644 index 0000000..4159607 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/ListTrainingStepMetricsResponse.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ListTrainingStepMetricsResponse.Builder.class) +public final class ListTrainingStepMetricsResponse { + private final Optional> stepMetrics; + + private final Optional nextPageToken; + + private final Map additionalProperties; + + private ListTrainingStepMetricsResponse( + Optional> stepMetrics, + Optional nextPageToken, + Map additionalProperties) { + this.stepMetrics = stepMetrics; + this.nextPageToken = nextPageToken; + this.additionalProperties = additionalProperties; + } + + /** + * @return The metrics for each step the evaluation was run on. + */ + @JsonProperty("step_metrics") + public Optional> getStepMetrics() { + return stepMetrics; + } + + /** + * @return Pagination token to retrieve the next page of results. If the value is "", + * it means no further results for the request. + */ + @JsonProperty("next_page_token") + public Optional getNextPageToken() { + return nextPageToken; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListTrainingStepMetricsResponse && equalTo((ListTrainingStepMetricsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListTrainingStepMetricsResponse other) { + return stepMetrics.equals(other.stepMetrics) && nextPageToken.equals(other.nextPageToken); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.stepMetrics, this.nextPageToken); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> stepMetrics = Optional.empty(); + + private Optional nextPageToken = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListTrainingStepMetricsResponse other) { + stepMetrics(other.getStepMetrics()); + nextPageToken(other.getNextPageToken()); + return this; + } + + @JsonSetter(value = "step_metrics", nulls = Nulls.SKIP) + public Builder stepMetrics(Optional> stepMetrics) { + this.stepMetrics = stepMetrics; + return this; + } + + public Builder stepMetrics(List stepMetrics) { + this.stepMetrics = Optional.of(stepMetrics); + return this; + } + + @JsonSetter(value = "next_page_token", nulls = Nulls.SKIP) + public Builder nextPageToken(Optional nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + public Builder nextPageToken(String nextPageToken) { + this.nextPageToken = Optional.of(nextPageToken); + return this; + } + + public ListTrainingStepMetricsResponse build() { + return new ListTrainingStepMetricsResponse(stepMetrics, nextPageToken, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Settings.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Settings.java new file mode 100644 index 0000000..a183909 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Settings.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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 = Settings.Builder.class) +public final class Settings { + private final BaseModel baseModel; + + private final String datasetId; + + private final Optional hyperparameters; + + private final Optional multiLabel; + + private final Map additionalProperties; + + private Settings( + BaseModel baseModel, + String datasetId, + Optional hyperparameters, + Optional multiLabel, + Map additionalProperties) { + this.baseModel = baseModel; + this.datasetId = datasetId; + this.hyperparameters = hyperparameters; + this.multiLabel = multiLabel; + this.additionalProperties = additionalProperties; + } + + /** + * @return The base model to fine-tune. + */ + @JsonProperty("base_model") + public BaseModel getBaseModel() { + return baseModel; + } + + /** + * @return The data used for training and evaluating the fine-tuned model. + */ + @JsonProperty("dataset_id") + public String getDatasetId() { + return datasetId; + } + + /** + * @return Fine-tuning hyper-parameters. + */ + @JsonProperty("hyperparameters") + public Optional getHyperparameters() { + return hyperparameters; + } + + /** + * @return read-only. Whether the model is single-label or multi-label (only for classification). + */ + @JsonProperty("multi_label") + public Optional getMultiLabel() { + return multiLabel; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Settings && equalTo((Settings) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Settings other) { + return baseModel.equals(other.baseModel) + && datasetId.equals(other.datasetId) + && hyperparameters.equals(other.hyperparameters) + && multiLabel.equals(other.multiLabel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.baseModel, this.datasetId, this.hyperparameters, this.multiLabel); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BaseModelStage builder() { + return new Builder(); + } + + public interface BaseModelStage { + DatasetIdStage baseModel(BaseModel baseModel); + + Builder from(Settings other); + } + + public interface DatasetIdStage { + _FinalStage datasetId(String datasetId); + } + + public interface _FinalStage { + Settings build(); + + _FinalStage hyperparameters(Optional hyperparameters); + + _FinalStage hyperparameters(Hyperparameters hyperparameters); + + _FinalStage multiLabel(Optional multiLabel); + + _FinalStage multiLabel(Boolean multiLabel); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements BaseModelStage, DatasetIdStage, _FinalStage { + private BaseModel baseModel; + + private String datasetId; + + private Optional multiLabel = Optional.empty(); + + private Optional hyperparameters = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Settings other) { + baseModel(other.getBaseModel()); + datasetId(other.getDatasetId()); + hyperparameters(other.getHyperparameters()); + multiLabel(other.getMultiLabel()); + return this; + } + + /** + *

The base model to fine-tune.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("base_model") + public DatasetIdStage baseModel(BaseModel baseModel) { + this.baseModel = baseModel; + return this; + } + + /** + *

The data used for training and evaluating the fine-tuned model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("dataset_id") + public _FinalStage datasetId(String datasetId) { + this.datasetId = datasetId; + return this; + } + + /** + *

read-only. Whether the model is single-label or multi-label (only for classification).

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage multiLabel(Boolean multiLabel) { + this.multiLabel = Optional.of(multiLabel); + return this; + } + + @java.lang.Override + @JsonSetter(value = "multi_label", nulls = Nulls.SKIP) + public _FinalStage multiLabel(Optional multiLabel) { + this.multiLabel = multiLabel; + return this; + } + + /** + *

Fine-tuning hyper-parameters.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage hyperparameters(Hyperparameters hyperparameters) { + this.hyperparameters = Optional.of(hyperparameters); + return this; + } + + @java.lang.Override + @JsonSetter(value = "hyperparameters", nulls = Nulls.SKIP) + public _FinalStage hyperparameters(Optional hyperparameters) { + this.hyperparameters = hyperparameters; + return this; + } + + @java.lang.Override + public Settings build() { + return new Settings(baseModel, datasetId, hyperparameters, multiLabel, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Status.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Status.java new file mode 100644 index 0000000..386fe0f --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Status.java @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum Status { + STATUS_UNSPECIFIED("STATUS_UNSPECIFIED"), + + STATUS_FINETUNING("STATUS_FINETUNING"), + + STATUS_DEPLOYING_API("STATUS_DEPLOYING_API"), + + STATUS_READY("STATUS_READY"), + + STATUS_FAILED("STATUS_FAILED"), + + STATUS_DELETED("STATUS_DELETED"), + + STATUS_TEMPORARILY_OFFLINE("STATUS_TEMPORARILY_OFFLINE"), + + STATUS_PAUSED("STATUS_PAUSED"), + + STATUS_QUEUED("STATUS_QUEUED"); + + private final String value; + + Status(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Strategy.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Strategy.java new file mode 100644 index 0000000..33f2cee --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Strategy.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum Strategy { + STRATEGY_UNSPECIFIED("STRATEGY_UNSPECIFIED"), + + STRATEGY_VANILLA("STRATEGY_VANILLA"), + + STRATEGY_TFEW("STRATEGY_TFEW"); + + private final String value; + + Strategy(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/TrainingStepMetrics.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/TrainingStepMetrics.java new file mode 100644 index 0000000..bb5e2f7 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/TrainingStepMetrics.java @@ -0,0 +1,155 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = TrainingStepMetrics.Builder.class) +public final class TrainingStepMetrics { + private final Optional createdAt; + + private final Optional stepNumber; + + private final Optional> metrics; + + private final Map additionalProperties; + + private TrainingStepMetrics( + Optional createdAt, + Optional stepNumber, + Optional> metrics, + Map additionalProperties) { + this.createdAt = createdAt; + this.stepNumber = stepNumber; + this.metrics = metrics; + this.additionalProperties = additionalProperties; + } + + /** + * @return Creation timestamp. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Step number. + */ + @JsonProperty("step_number") + public Optional getStepNumber() { + return stepNumber; + } + + /** + * @return Map of names and values for each evaluation metrics. + */ + @JsonProperty("metrics") + public Optional> getMetrics() { + return metrics; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TrainingStepMetrics && equalTo((TrainingStepMetrics) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TrainingStepMetrics other) { + return createdAt.equals(other.createdAt) + && stepNumber.equals(other.stepNumber) + && metrics.equals(other.metrics); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.createdAt, this.stepNumber, this.metrics); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional createdAt = Optional.empty(); + + private Optional stepNumber = Optional.empty(); + + private Optional> metrics = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TrainingStepMetrics other) { + createdAt(other.getCreatedAt()); + stepNumber(other.getStepNumber()); + metrics(other.getMetrics()); + return this; + } + + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = Optional.of(createdAt); + return this; + } + + @JsonSetter(value = "step_number", nulls = Nulls.SKIP) + public Builder stepNumber(Optional stepNumber) { + this.stepNumber = stepNumber; + return this; + } + + public Builder stepNumber(Integer stepNumber) { + this.stepNumber = Optional.of(stepNumber); + return this; + } + + @JsonSetter(value = "metrics", nulls = Nulls.SKIP) + public Builder metrics(Optional> metrics) { + this.metrics = metrics; + return this; + } + + public Builder metrics(Map metrics) { + this.metrics = Optional.of(metrics); + return this; + } + + public TrainingStepMetrics build() { + return new TrainingStepMetrics(createdAt, stepNumber, metrics, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/UpdateFinetunedModelResponse.java b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/UpdateFinetunedModelResponse.java new file mode 100644 index 0000000..5608f85 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/finetuning/types/UpdateFinetunedModelResponse.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.finetuning.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 = UpdateFinetunedModelResponse.Builder.class) +public final class UpdateFinetunedModelResponse { + private final Optional finetunedModel; + + private final Map additionalProperties; + + private UpdateFinetunedModelResponse( + Optional finetunedModel, Map additionalProperties) { + this.finetunedModel = finetunedModel; + this.additionalProperties = additionalProperties; + } + + /** + * @return Information about the fine-tuned model. + */ + @JsonProperty("finetuned_model") + public Optional getFinetunedModel() { + return finetunedModel; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateFinetunedModelResponse && equalTo((UpdateFinetunedModelResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateFinetunedModelResponse other) { + return finetunedModel.equals(other.finetunedModel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.finetunedModel); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional finetunedModel = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateFinetunedModelResponse other) { + finetunedModel(other.getFinetunedModel()); + return this; + } + + @JsonSetter(value = "finetuned_model", nulls = Nulls.SKIP) + public Builder finetunedModel(Optional finetunedModel) { + this.finetunedModel = finetunedModel; + return this; + } + + public Builder finetunedModel(FinetunedModel finetunedModel) { + this.finetunedModel = Optional.of(finetunedModel); + return this; + } + + public UpdateFinetunedModelResponse build() { + return new UpdateFinetunedModelResponse(finetunedModel, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListEventsRequest.java b/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListEventsRequest.java new file mode 100644 index 0000000..4b8846c --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListEventsRequest.java @@ -0,0 +1,158 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.requests; + +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 = FinetuningListEventsRequest.Builder.class) +public final class FinetuningListEventsRequest { + private final Optional pageSize; + + private final Optional pageToken; + + private final Optional orderBy; + + private final Map additionalProperties; + + private FinetuningListEventsRequest( + Optional pageSize, + Optional pageToken, + Optional orderBy, + Map additionalProperties) { + this.pageSize = pageSize; + this.pageToken = pageToken; + this.orderBy = orderBy; + this.additionalProperties = additionalProperties; + } + + /** + * @return Maximum number of results to be returned by the server. If 0, defaults to 50. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + /** + * @return Request a specific page of the list results. + */ + @JsonProperty("page_token") + public Optional getPageToken() { + return pageToken; + } + + /** + * @return Comma separated list of fields. For example: "created_at,name". The default + * sorting order is ascending. To specify descending order for a field, append + * " desc" to the field name. For example: "created_at desc,name". + *

Supported sorting fields:

+ *
    + *
  • created_at (default)
  • + *
+ */ + @JsonProperty("order_by") + public Optional getOrderBy() { + return orderBy; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FinetuningListEventsRequest && equalTo((FinetuningListEventsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FinetuningListEventsRequest other) { + return pageSize.equals(other.pageSize) && pageToken.equals(other.pageToken) && orderBy.equals(other.orderBy); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pageSize, this.pageToken, this.orderBy); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional pageSize = Optional.empty(); + + private Optional pageToken = Optional.empty(); + + private Optional orderBy = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(FinetuningListEventsRequest other) { + pageSize(other.getPageSize()); + pageToken(other.getPageToken()); + orderBy(other.getOrderBy()); + return this; + } + + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public Builder pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageSize(Integer pageSize) { + this.pageSize = Optional.of(pageSize); + return this; + } + + @JsonSetter(value = "page_token", nulls = Nulls.SKIP) + public Builder pageToken(Optional pageToken) { + this.pageToken = pageToken; + return this; + } + + public Builder pageToken(String pageToken) { + this.pageToken = Optional.of(pageToken); + return this; + } + + @JsonSetter(value = "order_by", nulls = Nulls.SKIP) + public Builder orderBy(Optional orderBy) { + this.orderBy = orderBy; + return this; + } + + public Builder orderBy(String orderBy) { + this.orderBy = Optional.of(orderBy); + return this; + } + + public FinetuningListEventsRequest build() { + return new FinetuningListEventsRequest(pageSize, pageToken, orderBy, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListFinetunedModelsRequest.java b/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListFinetunedModelsRequest.java new file mode 100644 index 0000000..b4d5ba5 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListFinetunedModelsRequest.java @@ -0,0 +1,159 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.requests; + +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 = FinetuningListFinetunedModelsRequest.Builder.class) +public final class FinetuningListFinetunedModelsRequest { + private final Optional pageSize; + + private final Optional pageToken; + + private final Optional orderBy; + + private final Map additionalProperties; + + private FinetuningListFinetunedModelsRequest( + Optional pageSize, + Optional pageToken, + Optional orderBy, + Map additionalProperties) { + this.pageSize = pageSize; + this.pageToken = pageToken; + this.orderBy = orderBy; + this.additionalProperties = additionalProperties; + } + + /** + * @return Maximum number of results to be returned by the server. If 0, defaults to 50. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + /** + * @return Request a specific page of the list results. + */ + @JsonProperty("page_token") + public Optional getPageToken() { + return pageToken; + } + + /** + * @return Comma separated list of fields. For example: "created_at,name". The default + * sorting order is ascending. To specify descending order for a field, append + * " desc" to the field name. For example: "created_at desc,name". + *

Supported sorting fields:

+ *
    + *
  • created_at (default)
  • + *
+ */ + @JsonProperty("order_by") + public Optional getOrderBy() { + return orderBy; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FinetuningListFinetunedModelsRequest + && equalTo((FinetuningListFinetunedModelsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FinetuningListFinetunedModelsRequest other) { + return pageSize.equals(other.pageSize) && pageToken.equals(other.pageToken) && orderBy.equals(other.orderBy); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pageSize, this.pageToken, this.orderBy); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional pageSize = Optional.empty(); + + private Optional pageToken = Optional.empty(); + + private Optional orderBy = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(FinetuningListFinetunedModelsRequest other) { + pageSize(other.getPageSize()); + pageToken(other.getPageToken()); + orderBy(other.getOrderBy()); + return this; + } + + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public Builder pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageSize(Integer pageSize) { + this.pageSize = Optional.of(pageSize); + return this; + } + + @JsonSetter(value = "page_token", nulls = Nulls.SKIP) + public Builder pageToken(Optional pageToken) { + this.pageToken = pageToken; + return this; + } + + public Builder pageToken(String pageToken) { + this.pageToken = Optional.of(pageToken); + return this; + } + + @JsonSetter(value = "order_by", nulls = Nulls.SKIP) + public Builder orderBy(Optional orderBy) { + this.orderBy = orderBy; + return this; + } + + public Builder orderBy(String orderBy) { + this.orderBy = Optional.of(orderBy); + return this; + } + + public FinetuningListFinetunedModelsRequest build() { + return new FinetuningListFinetunedModelsRequest(pageSize, pageToken, orderBy, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListTrainingStepMetricsRequest.java b/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListTrainingStepMetricsRequest.java new file mode 100644 index 0000000..b5597b1 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningListTrainingStepMetricsRequest.java @@ -0,0 +1,125 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.requests; + +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 = FinetuningListTrainingStepMetricsRequest.Builder.class) +public final class FinetuningListTrainingStepMetricsRequest { + private final Optional pageSize; + + private final Optional pageToken; + + private final Map additionalProperties; + + private FinetuningListTrainingStepMetricsRequest( + Optional pageSize, Optional pageToken, Map additionalProperties) { + this.pageSize = pageSize; + this.pageToken = pageToken; + this.additionalProperties = additionalProperties; + } + + /** + * @return Maximum number of results to be returned by the server. If 0, defaults to 50. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + /** + * @return Request a specific page of the list results. + */ + @JsonProperty("page_token") + public Optional getPageToken() { + return pageToken; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FinetuningListTrainingStepMetricsRequest + && equalTo((FinetuningListTrainingStepMetricsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FinetuningListTrainingStepMetricsRequest other) { + return pageSize.equals(other.pageSize) && pageToken.equals(other.pageToken); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pageSize, this.pageToken); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional pageSize = Optional.empty(); + + private Optional pageToken = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(FinetuningListTrainingStepMetricsRequest other) { + pageSize(other.getPageSize()); + pageToken(other.getPageToken()); + return this; + } + + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public Builder pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageSize(Integer pageSize) { + this.pageSize = Optional.of(pageSize); + return this; + } + + @JsonSetter(value = "page_token", nulls = Nulls.SKIP) + public Builder pageToken(Optional pageToken) { + this.pageToken = pageToken; + return this; + } + + public Builder pageToken(String pageToken) { + this.pageToken = Optional.of(pageToken); + return this; + } + + public FinetuningListTrainingStepMetricsRequest build() { + return new FinetuningListTrainingStepMetricsRequest(pageSize, pageToken, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningUpdateFinetunedModelRequest.java b/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningUpdateFinetunedModelRequest.java new file mode 100644 index 0000000..972c8ac --- /dev/null +++ b/src/main/java/com/cohere/api/resources/finetuning/requests/FinetuningUpdateFinetunedModelRequest.java @@ -0,0 +1,425 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.finetuning.requests; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.resources.finetuning.finetuning.types.Settings; +import com.cohere.api.resources.finetuning.finetuning.types.Status; +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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = FinetuningUpdateFinetunedModelRequest.Builder.class) +public final class FinetuningUpdateFinetunedModelRequest { + private final String name; + + private final Optional creatorId; + + private final Optional organizationId; + + private final Settings settings; + + private final Optional status; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional completedAt; + + private final Optional lastUsed; + + private final Map additionalProperties; + + private FinetuningUpdateFinetunedModelRequest( + String name, + Optional creatorId, + Optional organizationId, + Settings settings, + Optional status, + Optional createdAt, + Optional updatedAt, + Optional completedAt, + Optional lastUsed, + Map additionalProperties) { + this.name = name; + this.creatorId = creatorId; + this.organizationId = organizationId; + this.settings = settings; + this.status = status; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.completedAt = completedAt; + this.lastUsed = lastUsed; + this.additionalProperties = additionalProperties; + } + + /** + * @return FinetunedModel name (e.g. foobar). + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return User ID of the creator. + */ + @JsonProperty("creator_id") + public Optional getCreatorId() { + return creatorId; + } + + /** + * @return Organization ID. + */ + @JsonProperty("organization_id") + public Optional getOrganizationId() { + return organizationId; + } + + /** + * @return FinetunedModel settings such as dataset, hyperparameters... + */ + @JsonProperty("settings") + public Settings getSettings() { + return settings; + } + + /** + * @return Current stage in the life-cycle of the fine-tuned model. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return Creation timestamp. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Latest update timestamp. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return Timestamp for the completed fine-tuning. + */ + @JsonProperty("completed_at") + public Optional getCompletedAt() { + return completedAt; + } + + /** + * @return Timestamp for the latest request to this fine-tuned model. + */ + @JsonProperty("last_used") + public Optional getLastUsed() { + return lastUsed; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FinetuningUpdateFinetunedModelRequest + && equalTo((FinetuningUpdateFinetunedModelRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FinetuningUpdateFinetunedModelRequest other) { + return name.equals(other.name) + && creatorId.equals(other.creatorId) + && organizationId.equals(other.organizationId) + && settings.equals(other.settings) + && status.equals(other.status) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && completedAt.equals(other.completedAt) + && lastUsed.equals(other.lastUsed); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.creatorId, + this.organizationId, + this.settings, + this.status, + this.createdAt, + this.updatedAt, + this.completedAt, + this.lastUsed); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + SettingsStage name(String name); + + Builder from(FinetuningUpdateFinetunedModelRequest other); + } + + public interface SettingsStage { + _FinalStage settings(Settings settings); + } + + public interface _FinalStage { + FinetuningUpdateFinetunedModelRequest build(); + + _FinalStage creatorId(Optional creatorId); + + _FinalStage creatorId(String creatorId); + + _FinalStage organizationId(Optional organizationId); + + _FinalStage organizationId(String organizationId); + + _FinalStage status(Optional status); + + _FinalStage status(Status status); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(OffsetDateTime createdAt); + + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(OffsetDateTime updatedAt); + + _FinalStage completedAt(Optional completedAt); + + _FinalStage completedAt(OffsetDateTime completedAt); + + _FinalStage lastUsed(Optional lastUsed); + + _FinalStage lastUsed(OffsetDateTime lastUsed); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, SettingsStage, _FinalStage { + private String name; + + private Settings settings; + + private Optional lastUsed = Optional.empty(); + + private Optional completedAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional organizationId = Optional.empty(); + + private Optional creatorId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FinetuningUpdateFinetunedModelRequest other) { + name(other.getName()); + creatorId(other.getCreatorId()); + organizationId(other.getOrganizationId()); + settings(other.getSettings()); + status(other.getStatus()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + completedAt(other.getCompletedAt()); + lastUsed(other.getLastUsed()); + return this; + } + + /** + *

FinetunedModel name (e.g. foobar).

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public SettingsStage name(String name) { + this.name = name; + return this; + } + + /** + *

FinetunedModel settings such as dataset, hyperparameters...

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("settings") + public _FinalStage settings(Settings settings) { + this.settings = settings; + return this; + } + + /** + *

Timestamp for the latest request to this fine-tuned model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage lastUsed(OffsetDateTime lastUsed) { + this.lastUsed = Optional.of(lastUsed); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_used", nulls = Nulls.SKIP) + public _FinalStage lastUsed(Optional lastUsed) { + this.lastUsed = lastUsed; + return this; + } + + /** + *

Timestamp for the completed fine-tuning.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage completedAt(OffsetDateTime completedAt) { + this.completedAt = Optional.of(completedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "completed_at", nulls = Nulls.SKIP) + public _FinalStage completedAt(Optional completedAt) { + this.completedAt = completedAt; + return this; + } + + /** + *

Latest update timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = Optional.of(updatedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public _FinalStage updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + *

Creation timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAt(OffsetDateTime createdAt) { + this.createdAt = Optional.of(createdAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

Current stage in the life-cycle of the fine-tuned model.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage status(Status status) { + this.status = Optional.of(status); + return this; + } + + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + /** + *

Organization ID.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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 organizationId) { + this.organizationId = organizationId; + return this; + } + + /** + *

User ID of the creator.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creatorId(String creatorId) { + this.creatorId = Optional.of(creatorId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "creator_id", nulls = Nulls.SKIP) + public _FinalStage creatorId(Optional creatorId) { + this.creatorId = creatorId; + return this; + } + + @java.lang.Override + public FinetuningUpdateFinetunedModelRequest build() { + return new FinetuningUpdateFinetunedModelRequest( + name, + creatorId, + organizationId, + settings, + status, + createdAt, + updatedAt, + completedAt, + lastUsed, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/models/ModelsClient.java b/src/main/java/com/cohere/api/resources/models/ModelsClient.java new file mode 100644 index 0000000..3ae1328 --- /dev/null +++ b/src/main/java/com/cohere/api/resources/models/ModelsClient.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.models; + +import com.cohere.api.core.ApiError; +import com.cohere.api.core.ClientOptions; +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.core.RequestOptions; +import com.cohere.api.resources.models.requests.ModelsListRequest; +import com.cohere.api.types.GetModelResponse; +import com.cohere.api.types.ListModelsResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; + +public class ModelsClient { + protected final ClientOptions clientOptions; + + public ModelsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the details of a model, provided its name. + */ + public GetModelResponse get(String model) { + return get(model, null); + } + + /** + * Returns the details of a model, provided its name. + */ + public GetModelResponse get(String model, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("models") + .addPathSegment(model) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", 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(), GetModelResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Returns a list of models available for use. The list contains models from Cohere as well as your fine-tuned models. + */ + public ListModelsResponse list() { + return list(ModelsListRequest.builder().build()); + } + + /** + * Returns a list of models available for use. The list contains models from Cohere as well as your fine-tuned models. + */ + public ListModelsResponse list(ModelsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of models available for use. The list contains models from Cohere as well as your fine-tuned models. + */ + public ListModelsResponse list(ModelsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("models"); + if (request.getPageSize().isPresent()) { + httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); + } + if (request.getPageToken().isPresent()) { + httpUrl.addQueryParameter("page_token", request.getPageToken().get()); + } + if (request.getEndpoint().isPresent()) { + httpUrl.addQueryParameter("endpoint", request.getEndpoint().get().toString()); + } + if (request.getDefaultOnly().isPresent()) { + httpUrl.addQueryParameter( + "default_only", request.getDefaultOnly().get().toString()); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.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(), ListModelsResponse.class); + } + throw new ApiError( + response.code(), + ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/cohere/api/resources/models/requests/ModelsListRequest.java b/src/main/java/com/cohere/api/resources/models/requests/ModelsListRequest.java new file mode 100644 index 0000000..b8cd53c --- /dev/null +++ b/src/main/java/com/cohere/api/resources/models/requests/ModelsListRequest.java @@ -0,0 +1,183 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.resources.models.requests; + +import com.cohere.api.core.ObjectMappers; +import com.cohere.api.types.CompatibleEndpoint; +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 = ModelsListRequest.Builder.class) +public final class ModelsListRequest { + private final Optional pageSize; + + private final Optional pageToken; + + private final Optional endpoint; + + private final Optional defaultOnly; + + private final Map additionalProperties; + + private ModelsListRequest( + Optional pageSize, + Optional pageToken, + Optional endpoint, + Optional defaultOnly, + Map additionalProperties) { + this.pageSize = pageSize; + this.pageToken = pageToken; + this.endpoint = endpoint; + this.defaultOnly = defaultOnly; + this.additionalProperties = additionalProperties; + } + + /** + * @return Maximum number of models to include in a page + * Defaults to 20, min value of 1, max value of 1000. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + /** + * @return Page token provided in the next_page_token field of a previous response. + */ + @JsonProperty("page_token") + public Optional getPageToken() { + return pageToken; + } + + /** + * @return When provided, filters the list of models to only those that are compatible with the specified endpoint. + */ + @JsonProperty("endpoint") + public Optional getEndpoint() { + return endpoint; + } + + /** + * @return When provided, filters the list of models to only the default model to the endpoint. This parameter is only valid when endpoint is provided. + */ + @JsonProperty("default_only") + public Optional getDefaultOnly() { + return defaultOnly; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ModelsListRequest && equalTo((ModelsListRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ModelsListRequest other) { + return pageSize.equals(other.pageSize) + && pageToken.equals(other.pageToken) + && endpoint.equals(other.endpoint) + && defaultOnly.equals(other.defaultOnly); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pageSize, this.pageToken, this.endpoint, this.defaultOnly); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional pageSize = Optional.empty(); + + private Optional pageToken = Optional.empty(); + + private Optional endpoint = Optional.empty(); + + private Optional defaultOnly = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ModelsListRequest other) { + pageSize(other.getPageSize()); + pageToken(other.getPageToken()); + endpoint(other.getEndpoint()); + defaultOnly(other.getDefaultOnly()); + return this; + } + + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public Builder pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageSize(Double pageSize) { + this.pageSize = Optional.of(pageSize); + return this; + } + + @JsonSetter(value = "page_token", nulls = Nulls.SKIP) + public Builder pageToken(Optional pageToken) { + this.pageToken = pageToken; + return this; + } + + public Builder pageToken(String pageToken) { + this.pageToken = Optional.of(pageToken); + return this; + } + + @JsonSetter(value = "endpoint", nulls = Nulls.SKIP) + public Builder endpoint(Optional endpoint) { + this.endpoint = endpoint; + return this; + } + + public Builder endpoint(CompatibleEndpoint endpoint) { + this.endpoint = Optional.of(endpoint); + return this; + } + + @JsonSetter(value = "default_only", nulls = Nulls.SKIP) + public Builder defaultOnly(Optional defaultOnly) { + this.defaultOnly = defaultOnly; + return this; + } + + public Builder defaultOnly(Boolean defaultOnly) { + this.defaultOnly = Optional.of(defaultOnly); + return this; + } + + public ModelsListRequest build() { + return new ModelsListRequest(pageSize, pageToken, endpoint, defaultOnly, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ApiMeta.java b/src/main/java/com/cohere/api/types/ApiMeta.java index faaa8ba..74115ab 100644 --- a/src/main/java/com/cohere/api/types/ApiMeta.java +++ b/src/main/java/com/cohere/api/types/ApiMeta.java @@ -23,15 +23,23 @@ public final class ApiMeta { private final Optional apiVersion; + private final Optional billedUnits; + + private final Optional tokens; + private final Optional> warnings; private final Map additionalProperties; private ApiMeta( Optional apiVersion, + Optional billedUnits, + Optional tokens, Optional> warnings, Map additionalProperties) { this.apiVersion = apiVersion; + this.billedUnits = billedUnits; + this.tokens = tokens; this.warnings = warnings; this.additionalProperties = additionalProperties; } @@ -41,12 +49,22 @@ public Optional getApiVersion() { return apiVersion; } + @JsonProperty("billed_units") + public Optional getBilledUnits() { + return billedUnits; + } + + @JsonProperty("tokens") + public Optional getTokens() { + return tokens; + } + @JsonProperty("warnings") public Optional> getWarnings() { return warnings; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ApiMeta && equalTo((ApiMeta) other); @@ -58,15 +76,18 @@ public Map getAdditionalProperties() { } private boolean equalTo(ApiMeta other) { - return apiVersion.equals(other.apiVersion) && warnings.equals(other.warnings); + return apiVersion.equals(other.apiVersion) + && billedUnits.equals(other.billedUnits) + && tokens.equals(other.tokens) + && warnings.equals(other.warnings); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.apiVersion, this.warnings); + return Objects.hash(this.apiVersion, this.billedUnits, this.tokens, this.warnings); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -79,6 +100,10 @@ public static Builder builder() { public static final class Builder { private Optional apiVersion = Optional.empty(); + private Optional billedUnits = Optional.empty(); + + private Optional tokens = Optional.empty(); + private Optional> warnings = Optional.empty(); @JsonAnySetter @@ -88,6 +113,8 @@ private Builder() {} public Builder from(ApiMeta other) { apiVersion(other.getApiVersion()); + billedUnits(other.getBilledUnits()); + tokens(other.getTokens()); warnings(other.getWarnings()); return this; } @@ -103,6 +130,28 @@ public Builder apiVersion(ApiMetaApiVersion apiVersion) { return this; } + @JsonSetter(value = "billed_units", nulls = Nulls.SKIP) + public Builder billedUnits(Optional billedUnits) { + this.billedUnits = billedUnits; + return this; + } + + public Builder billedUnits(ApiMetaBilledUnits billedUnits) { + this.billedUnits = Optional.of(billedUnits); + return this; + } + + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(ApiMetaTokens tokens) { + this.tokens = Optional.of(tokens); + return this; + } + @JsonSetter(value = "warnings", nulls = Nulls.SKIP) public Builder warnings(Optional> warnings) { this.warnings = warnings; @@ -115,7 +164,7 @@ public Builder warnings(List warnings) { } public ApiMeta build() { - return new ApiMeta(apiVersion, warnings, additionalProperties); + return new ApiMeta(apiVersion, billedUnits, tokens, warnings, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ApiMetaApiVersion.java b/src/main/java/com/cohere/api/types/ApiMetaApiVersion.java index eacb5c0..e3defb3 100644 --- a/src/main/java/com/cohere/api/types/ApiMetaApiVersion.java +++ b/src/main/java/com/cohere/api/types/ApiMetaApiVersion.java @@ -26,20 +26,16 @@ public final class ApiMetaApiVersion { private final Optional isExperimental; - private final Optional billedUnits; - private final Map additionalProperties; private ApiMetaApiVersion( String version, Optional isDeprecated, Optional isExperimental, - Optional billedUnits, Map additionalProperties) { this.version = version; this.isDeprecated = isDeprecated; this.isExperimental = isExperimental; - this.billedUnits = billedUnits; this.additionalProperties = additionalProperties; } @@ -58,12 +54,7 @@ public Optional getIsExperimental() { return isExperimental; } - @JsonProperty("billed_units") - public Optional getBilledUnits() { - return billedUnits; - } - - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ApiMetaApiVersion && equalTo((ApiMetaApiVersion) other); @@ -77,16 +68,15 @@ public Map getAdditionalProperties() { private boolean equalTo(ApiMetaApiVersion other) { return version.equals(other.version) && isDeprecated.equals(other.isDeprecated) - && isExperimental.equals(other.isExperimental) - && billedUnits.equals(other.billedUnits); + && isExperimental.equals(other.isExperimental); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.version, this.isDeprecated, this.isExperimental, this.billedUnits); + return Objects.hash(this.version, this.isDeprecated, this.isExperimental); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -111,18 +101,12 @@ public interface _FinalStage { _FinalStage isExperimental(Optional isExperimental); _FinalStage isExperimental(Boolean isExperimental); - - _FinalStage billedUnits(Optional billedUnits); - - _FinalStage billedUnits(ApiMetaApiVersionBilledUnits billedUnits); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements VersionStage, _FinalStage { private String version; - private Optional billedUnits = Optional.empty(); - private Optional isExperimental = Optional.empty(); private Optional isDeprecated = Optional.empty(); @@ -132,64 +116,50 @@ public static final class Builder implements VersionStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ApiMetaApiVersion other) { version(other.getVersion()); isDeprecated(other.getIsDeprecated()); isExperimental(other.getIsExperimental()); - billedUnits(other.getBilledUnits()); return this; } - @Override + @java.lang.Override @JsonSetter("version") public _FinalStage version(String version) { this.version = version; return this; } - @Override - public _FinalStage billedUnits(ApiMetaApiVersionBilledUnits billedUnits) { - this.billedUnits = Optional.of(billedUnits); - return this; - } - - @Override - @JsonSetter(value = "billed_units", nulls = Nulls.SKIP) - public _FinalStage billedUnits(Optional billedUnits) { - this.billedUnits = billedUnits; - return this; - } - - @Override + @java.lang.Override public _FinalStage isExperimental(Boolean isExperimental) { this.isExperimental = Optional.of(isExperimental); return this; } - @Override + @java.lang.Override @JsonSetter(value = "is_experimental", nulls = Nulls.SKIP) public _FinalStage isExperimental(Optional isExperimental) { this.isExperimental = isExperimental; return this; } - @Override + @java.lang.Override public _FinalStage isDeprecated(Boolean isDeprecated) { this.isDeprecated = Optional.of(isDeprecated); return this; } - @Override + @java.lang.Override @JsonSetter(value = "is_deprecated", nulls = Nulls.SKIP) public _FinalStage isDeprecated(Optional isDeprecated) { this.isDeprecated = isDeprecated; return this; } - @Override + @java.lang.Override public ApiMetaApiVersion build() { - return new ApiMetaApiVersion(version, isDeprecated, isExperimental, billedUnits, additionalProperties); + return new ApiMetaApiVersion(version, isDeprecated, isExperimental, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ApiMetaApiVersionBilledUnits.java b/src/main/java/com/cohere/api/types/ApiMetaBilledUnits.java similarity index 90% rename from src/main/java/com/cohere/api/types/ApiMetaApiVersionBilledUnits.java rename to src/main/java/com/cohere/api/types/ApiMetaBilledUnits.java index 77ec04f..3c40206 100644 --- a/src/main/java/com/cohere/api/types/ApiMetaApiVersionBilledUnits.java +++ b/src/main/java/com/cohere/api/types/ApiMetaBilledUnits.java @@ -18,8 +18,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ApiMetaApiVersionBilledUnits.Builder.class) -public final class ApiMetaApiVersionBilledUnits { +@JsonDeserialize(builder = ApiMetaBilledUnits.Builder.class) +public final class ApiMetaBilledUnits { private final Optional inputTokens; private final Optional outputTokens; @@ -30,7 +30,7 @@ public final class ApiMetaApiVersionBilledUnits { private final Map additionalProperties; - private ApiMetaApiVersionBilledUnits( + private ApiMetaBilledUnits( Optional inputTokens, Optional outputTokens, Optional searchUnits, @@ -75,10 +75,10 @@ public Optional getClassifications() { return classifications; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ApiMetaApiVersionBilledUnits && equalTo((ApiMetaApiVersionBilledUnits) other); + return other instanceof ApiMetaBilledUnits && equalTo((ApiMetaBilledUnits) other); } @JsonAnyGetter @@ -86,19 +86,19 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ApiMetaApiVersionBilledUnits other) { + private boolean equalTo(ApiMetaBilledUnits other) { return inputTokens.equals(other.inputTokens) && outputTokens.equals(other.outputTokens) && searchUnits.equals(other.searchUnits) && classifications.equals(other.classifications); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.inputTokens, this.outputTokens, this.searchUnits, this.classifications); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -122,7 +122,7 @@ public static final class Builder { private Builder() {} - public Builder from(ApiMetaApiVersionBilledUnits other) { + public Builder from(ApiMetaBilledUnits other) { inputTokens(other.getInputTokens()); outputTokens(other.getOutputTokens()); searchUnits(other.getSearchUnits()); @@ -174,8 +174,8 @@ public Builder classifications(Double classifications) { return this; } - public ApiMetaApiVersionBilledUnits build() { - return new ApiMetaApiVersionBilledUnits( + public ApiMetaBilledUnits build() { + return new ApiMetaBilledUnits( inputTokens, outputTokens, searchUnits, classifications, additionalProperties); } } diff --git a/src/main/java/com/cohere/api/types/ApiMetaTokens.java b/src/main/java/com/cohere/api/types/ApiMetaTokens.java new file mode 100644 index 0000000..ca1fa90 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ApiMetaTokens.java @@ -0,0 +1,124 @@ +/** + * 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 = ApiMetaTokens.Builder.class) +public final class ApiMetaTokens { + private final Optional inputTokens; + + private final Optional outputTokens; + + private final Map additionalProperties; + + private ApiMetaTokens( + Optional inputTokens, Optional outputTokens, Map additionalProperties) { + this.inputTokens = inputTokens; + this.outputTokens = outputTokens; + this.additionalProperties = additionalProperties; + } + + /** + * @return The number of tokens used as input to the model. + */ + @JsonProperty("input_tokens") + public Optional getInputTokens() { + return inputTokens; + } + + /** + * @return The number of tokens produced by the model. + */ + @JsonProperty("output_tokens") + public Optional getOutputTokens() { + return outputTokens; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApiMetaTokens && equalTo((ApiMetaTokens) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ApiMetaTokens other) { + return inputTokens.equals(other.inputTokens) && outputTokens.equals(other.outputTokens); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.inputTokens, this.outputTokens); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional inputTokens = Optional.empty(); + + private Optional outputTokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ApiMetaTokens other) { + inputTokens(other.getInputTokens()); + outputTokens(other.getOutputTokens()); + return this; + } + + @JsonSetter(value = "input_tokens", nulls = Nulls.SKIP) + public Builder inputTokens(Optional inputTokens) { + this.inputTokens = inputTokens; + return this; + } + + public Builder inputTokens(Double inputTokens) { + this.inputTokens = Optional.of(inputTokens); + return this; + } + + @JsonSetter(value = "output_tokens", nulls = Nulls.SKIP) + public Builder outputTokens(Optional outputTokens) { + this.outputTokens = outputTokens; + return this; + } + + public Builder outputTokens(Double outputTokens) { + this.outputTokens = Optional.of(outputTokens); + return this; + } + + public ApiMetaTokens build() { + return new ApiMetaTokens(inputTokens, outputTokens, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/AuthTokenType.java b/src/main/java/com/cohere/api/types/AuthTokenType.java new file mode 100644 index 0000000..1b40260 --- /dev/null +++ b/src/main/java/com/cohere/api/types/AuthTokenType.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AuthTokenType { + BEARER("bearer"), + + BASIC("basic"), + + NOSCHEME("noscheme"); + + private final String value; + + AuthTokenType(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/ChatCitation.java b/src/main/java/com/cohere/api/types/ChatCitation.java index 9e83c67..af8c032 100644 --- a/src/main/java/com/cohere/api/types/ChatCitation.java +++ b/src/main/java/com/cohere/api/types/ChatCitation.java @@ -72,7 +72,7 @@ public List getDocumentIds() { return documentIds; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatCitation && equalTo((ChatCitation) other); @@ -90,12 +90,12 @@ private boolean equalTo(ChatCitation other) { && documentIds.equals(other.documentIds); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.start, this.end, this.text, this.documentIds); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -143,7 +143,7 @@ public static final class Builder implements StartStage, EndStage, TextStage, _F private Builder() {} - @Override + @java.lang.Override public Builder from(ChatCitation other) { start(other.getStart()); end(other.getEnd()); @@ -156,7 +156,7 @@ public Builder from(ChatCitation other) { *

The index of text that the citation starts at, counting from zero. For example, a generation of Hello, world! with a citation on world would have a start value of 7. This is because the citation starts at w, which is the seventh character.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("start") public EndStage start(int start) { this.start = start; @@ -167,7 +167,7 @@ public EndStage start(int start) { *

The index of text that the citation ends after, counting from zero. For example, a generation of Hello, world! with a citation on world would have an end value of 11. This is because the citation ends after d, which is the eleventh character.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("end") public TextStage end(int end) { this.end = end; @@ -178,7 +178,7 @@ public TextStage end(int end) { *

The text of the citation. For example, a generation of Hello, world! with a citation of world would have a text value of world.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; @@ -189,7 +189,7 @@ public _FinalStage text(String text) { *

Identifiers of documents cited by this section of the generated reply.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllDocumentIds(List documentIds) { this.documentIds.addAll(documentIds); return this; @@ -199,13 +199,13 @@ public _FinalStage addAllDocumentIds(List documentIds) { *

Identifiers of documents cited by this section of the generated reply.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addDocumentIds(String documentIds) { this.documentIds.add(documentIds); return this; } - @Override + @java.lang.Override @JsonSetter(value = "document_ids", nulls = Nulls.SKIP) public _FinalStage documentIds(List documentIds) { this.documentIds.clear(); @@ -213,7 +213,7 @@ public _FinalStage documentIds(List documentIds) { return this; } - @Override + @java.lang.Override public ChatCitation build() { return new ChatCitation(start, end, text, documentIds, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatCitationGenerationEvent.java b/src/main/java/com/cohere/api/types/ChatCitationGenerationEvent.java index b618b55..8125683 100644 --- a/src/main/java/com/cohere/api/types/ChatCitationGenerationEvent.java +++ b/src/main/java/com/cohere/api/types/ChatCitationGenerationEvent.java @@ -38,7 +38,7 @@ public List getCitations() { return citations; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatCitationGenerationEvent && equalTo((ChatCitationGenerationEvent) other); @@ -53,12 +53,12 @@ private boolean equalTo(ChatCitationGenerationEvent other) { return citations.equals(other.citations); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.citations); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/ChatConnector.java b/src/main/java/com/cohere/api/types/ChatConnector.java index 6e092aa..54642ff 100644 --- a/src/main/java/com/cohere/api/types/ChatConnector.java +++ b/src/main/java/com/cohere/api/types/ChatConnector.java @@ -44,7 +44,7 @@ private ChatConnector( } /** - * @return The identifier of the connector. Currently only 'web-search' is supported. + * @return The identifier of the connector. */ @JsonProperty("id") public String getId() { @@ -52,7 +52,7 @@ public String getId() { } /** - * @return An optional override to set the token that Cohere passes to the connector in the Authorization header. + * @return When specified, this user access token will be passed to the connector in the Authorization header instead of the Cohere generated one. */ @JsonProperty("user_access_token") public Optional getUserAccessToken() { @@ -60,7 +60,8 @@ public Optional getUserAccessToken() { } /** - * @return An optional override to set whether or not the request continues if this connector fails. + * @return Defaults to false. + *

When true, the request will continue if this connector returned an error.

*/ @JsonProperty("continue_on_failure") public Optional getContinueOnFailure() { @@ -69,21 +70,14 @@ public Optional getContinueOnFailure() { /** * @return Provides the connector with different settings at request time. The key/value pairs of this object are specific to each connector. - *

The supported options are:

- *

web-search

- *

site - The web search results will be restricted to this domain (and TLD) when specified. Only a single domain is specified, and subdomains are also accepted. - * Examples:

- *
    - *
  • {"options": {"site": "cohere.com"}} would restrict the results to all subdomains at cohere.com
  • - *
  • {"options": {"site": "txt.cohere.com"}} would restrict the results to txt.cohere.com
  • - *
+ *

For example, the connector web-search supports the site option, which limits search results to the specified domain.

*/ @JsonProperty("options") public Optional> getOptions() { return options; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatConnector && equalTo((ChatConnector) other); @@ -101,12 +95,12 @@ private boolean equalTo(ChatConnector other) { && options.equals(other.options); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.userAccessToken, this.continueOnFailure, this.options); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -152,7 +146,7 @@ public static final class Builder implements IdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ChatConnector other) { id(other.getId()); userAccessToken(other.getUserAccessToken()); @@ -162,10 +156,10 @@ public Builder from(ChatConnector other) { } /** - *

The identifier of the connector. Currently only 'web-search' is supported.

+ *

The identifier of the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("id") public _FinalStage id(String id) { this.id = id; @@ -174,23 +168,16 @@ public _FinalStage id(String id) { /** *

Provides the connector with different settings at request time. The key/value pairs of this object are specific to each connector.

- *

The supported options are:

- *

web-search

- *

site - The web search results will be restricted to this domain (and TLD) when specified. Only a single domain is specified, and subdomains are also accepted. - * Examples:

- *
    - *
  • {"options": {"site": "cohere.com"}} would restrict the results to all subdomains at cohere.com
  • - *
  • {"options": {"site": "txt.cohere.com"}} would restrict the results to txt.cohere.com
  • - *
+ *

For example, the connector web-search supports the site option, which limits search results to the specified domain.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage options(Map options) { this.options = Optional.of(options); return this; } - @Override + @java.lang.Override @JsonSetter(value = "options", nulls = Nulls.SKIP) public _FinalStage options(Optional> options) { this.options = options; @@ -198,16 +185,17 @@ public _FinalStage options(Optional> options) { } /** - *

An optional override to set whether or not the request continues if this connector fails.

+ *

Defaults to false.

+ *

When true, the request will continue if this connector returned an error.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage continueOnFailure(Boolean continueOnFailure) { this.continueOnFailure = Optional.of(continueOnFailure); return this; } - @Override + @java.lang.Override @JsonSetter(value = "continue_on_failure", nulls = Nulls.SKIP) public _FinalStage continueOnFailure(Optional continueOnFailure) { this.continueOnFailure = continueOnFailure; @@ -215,23 +203,23 @@ public _FinalStage continueOnFailure(Optional continueOnFailure) { } /** - *

An optional override to set the token that Cohere passes to the connector in the Authorization header.

+ *

When specified, this user access token will be passed to the connector in the Authorization header instead of the Cohere generated one.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage userAccessToken(String userAccessToken) { this.userAccessToken = Optional.of(userAccessToken); return this; } - @Override + @java.lang.Override @JsonSetter(value = "user_access_token", nulls = Nulls.SKIP) public _FinalStage userAccessToken(Optional userAccessToken) { this.userAccessToken = userAccessToken; return this; } - @Override + @java.lang.Override public ChatConnector build() { return new ChatConnector(id, userAccessToken, continueOnFailure, options, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatDataMetrics.java b/src/main/java/com/cohere/api/types/ChatDataMetrics.java new file mode 100644 index 0000000..df11ec4 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatDataMetrics.java @@ -0,0 +1,154 @@ +/** + * 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 = ChatDataMetrics.Builder.class) +public final class ChatDataMetrics { + private final Optional numTrainTurns; + + private final Optional numEvalTurns; + + private final Optional preamble; + + private final Map additionalProperties; + + private ChatDataMetrics( + Optional numTrainTurns, + Optional numEvalTurns, + Optional preamble, + Map additionalProperties) { + this.numTrainTurns = numTrainTurns; + this.numEvalTurns = numEvalTurns; + this.preamble = preamble; + this.additionalProperties = additionalProperties; + } + + /** + * @return The sum of all turns of valid train examples. + */ + @JsonProperty("num_train_turns") + public Optional getNumTrainTurns() { + return numTrainTurns; + } + + /** + * @return The sum of all turns of valid eval examples. + */ + @JsonProperty("num_eval_turns") + public Optional getNumEvalTurns() { + return numEvalTurns; + } + + /** + * @return The preamble of this dataset. + */ + @JsonProperty("preamble") + public Optional getPreamble() { + return preamble; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatDataMetrics && equalTo((ChatDataMetrics) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatDataMetrics other) { + return numTrainTurns.equals(other.numTrainTurns) + && numEvalTurns.equals(other.numEvalTurns) + && preamble.equals(other.preamble); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.numTrainTurns, this.numEvalTurns, this.preamble); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional numTrainTurns = Optional.empty(); + + private Optional numEvalTurns = Optional.empty(); + + private Optional preamble = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ChatDataMetrics other) { + numTrainTurns(other.getNumTrainTurns()); + numEvalTurns(other.getNumEvalTurns()); + preamble(other.getPreamble()); + return this; + } + + @JsonSetter(value = "num_train_turns", nulls = Nulls.SKIP) + public Builder numTrainTurns(Optional numTrainTurns) { + this.numTrainTurns = numTrainTurns; + return this; + } + + public Builder numTrainTurns(String numTrainTurns) { + this.numTrainTurns = Optional.of(numTrainTurns); + return this; + } + + @JsonSetter(value = "num_eval_turns", nulls = Nulls.SKIP) + public Builder numEvalTurns(Optional numEvalTurns) { + this.numEvalTurns = numEvalTurns; + return this; + } + + public Builder numEvalTurns(String numEvalTurns) { + this.numEvalTurns = Optional.of(numEvalTurns); + return this; + } + + @JsonSetter(value = "preamble", nulls = Nulls.SKIP) + public Builder preamble(Optional preamble) { + this.preamble = preamble; + return this; + } + + public Builder preamble(String preamble) { + this.preamble = Optional.of(preamble); + return this; + } + + public ChatDataMetrics build() { + return new ChatDataMetrics(numTrainTurns, numEvalTurns, preamble, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatMessage.java b/src/main/java/com/cohere/api/types/ChatMessage.java index ddd838b..8682606 100644 --- a/src/main/java/com/cohere/api/types/ChatMessage.java +++ b/src/main/java/com/cohere/api/types/ChatMessage.java @@ -10,12 +10,10 @@ 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 = ChatMessage.Builder.class) @@ -24,34 +22,31 @@ public final class ChatMessage { private final String message; - private final Optional userName; - private final Map additionalProperties; - private ChatMessage( - ChatMessageRole role, String message, Optional userName, Map additionalProperties) { + private ChatMessage(ChatMessageRole role, String message, Map additionalProperties) { this.role = role; this.message = message; - this.userName = userName; this.additionalProperties = additionalProperties; } + /** + * @return One of CHATBOT, SYSTEM, or USER to identify who the message is coming from. + */ @JsonProperty("role") public ChatMessageRole getRole() { return role; } + /** + * @return Contents of the chat message. + */ @JsonProperty("message") public String getMessage() { return message; } - @JsonProperty("user_name") - public Optional getUserName() { - return userName; - } - - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatMessage && equalTo((ChatMessage) other); @@ -63,15 +58,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(ChatMessage other) { - return role.equals(other.role) && message.equals(other.message) && userName.equals(other.userName); + return role.equals(other.role) && message.equals(other.message); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.role, this.message, this.userName); + return Objects.hash(this.role, this.message); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -92,10 +87,6 @@ public interface MessageStage { public interface _FinalStage { ChatMessage build(); - - _FinalStage userName(Optional userName); - - _FinalStage userName(String userName); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -104,51 +95,43 @@ public static final class Builder implements RoleStage, MessageStage, _FinalStag private String message; - private Optional userName = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @Override + @java.lang.Override public Builder from(ChatMessage other) { role(other.getRole()); message(other.getMessage()); - userName(other.getUserName()); return this; } - @Override + /** + *

One of CHATBOT, SYSTEM, or USER to identify who the message is coming from.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override @JsonSetter("role") public MessageStage role(ChatMessageRole role) { this.role = role; return this; } - @Override + /** + *

Contents of the chat message.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override @JsonSetter("message") public _FinalStage message(String message) { this.message = message; return this; } - @Override - public _FinalStage userName(String userName) { - this.userName = Optional.of(userName); - return this; - } - - @Override - @JsonSetter(value = "user_name", nulls = Nulls.SKIP) - public _FinalStage userName(Optional userName) { - this.userName = userName; - return this; - } - - @Override + @java.lang.Override public ChatMessage build() { - return new ChatMessage(role, message, userName, additionalProperties); + return new ChatMessage(role, message, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ChatMessageRole.java b/src/main/java/com/cohere/api/types/ChatMessageRole.java index 1bbd846..95c781b 100644 --- a/src/main/java/com/cohere/api/types/ChatMessageRole.java +++ b/src/main/java/com/cohere/api/types/ChatMessageRole.java @@ -8,6 +8,8 @@ public enum ChatMessageRole { CHATBOT("CHATBOT"), + SYSTEM("SYSTEM"), + USER("USER"); private final String value; @@ -17,7 +19,7 @@ public enum ChatMessageRole { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatRequestCitationQuality.java b/src/main/java/com/cohere/api/types/ChatRequestCitationQuality.java index 7917903..d2b6a1c 100644 --- a/src/main/java/com/cohere/api/types/ChatRequestCitationQuality.java +++ b/src/main/java/com/cohere/api/types/ChatRequestCitationQuality.java @@ -17,7 +17,7 @@ public enum ChatRequestCitationQuality { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatRequestConnectorsSearchOptions.java b/src/main/java/com/cohere/api/types/ChatRequestConnectorsSearchOptions.java new file mode 100644 index 0000000..23d2541 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatRequestConnectorsSearchOptions.java @@ -0,0 +1,198 @@ +/** + * 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 = ChatRequestConnectorsSearchOptions.Builder.class) +public final class ChatRequestConnectorsSearchOptions { + private final Optional model; + + private final Optional temperature; + + private final Optional maxTokens; + + private final Optional preamble; + + private final Optional seed; + + private final Map additionalProperties; + + private ChatRequestConnectorsSearchOptions( + Optional model, + Optional temperature, + Optional maxTokens, + Optional preamble, + Optional seed, + Map additionalProperties) { + this.model = model; + this.temperature = temperature; + this.maxTokens = maxTokens; + this.preamble = preamble; + this.seed = seed; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("model") + public Optional getModel() { + return model; + } + + @JsonProperty("temperature") + public Optional getTemperature() { + return temperature; + } + + @JsonProperty("max_tokens") + public Optional getMaxTokens() { + return maxTokens; + } + + @JsonProperty("preamble") + public Optional getPreamble() { + return preamble; + } + + /** + * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed. + */ + @JsonProperty("seed") + public Optional getSeed() { + return seed; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatRequestConnectorsSearchOptions + && equalTo((ChatRequestConnectorsSearchOptions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatRequestConnectorsSearchOptions other) { + return model.equals(other.model) + && temperature.equals(other.temperature) + && maxTokens.equals(other.maxTokens) + && preamble.equals(other.preamble) + && seed.equals(other.seed); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.model, this.temperature, this.maxTokens, this.preamble, this.seed); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional model = Optional.empty(); + + private Optional temperature = Optional.empty(); + + private Optional maxTokens = Optional.empty(); + + private Optional preamble = Optional.empty(); + + private Optional seed = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ChatRequestConnectorsSearchOptions other) { + model(other.getModel()); + temperature(other.getTemperature()); + maxTokens(other.getMaxTokens()); + preamble(other.getPreamble()); + seed(other.getSeed()); + return this; + } + + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public Builder model(Optional model) { + this.model = model; + return this; + } + + public Builder model(Object model) { + this.model = Optional.of(model); + return this; + } + + @JsonSetter(value = "temperature", nulls = Nulls.SKIP) + public Builder temperature(Optional temperature) { + this.temperature = temperature; + return this; + } + + public Builder temperature(Object temperature) { + this.temperature = Optional.of(temperature); + return this; + } + + @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) + public Builder maxTokens(Optional maxTokens) { + this.maxTokens = maxTokens; + return this; + } + + public Builder maxTokens(Object maxTokens) { + this.maxTokens = Optional.of(maxTokens); + return this; + } + + @JsonSetter(value = "preamble", nulls = Nulls.SKIP) + public Builder preamble(Optional preamble) { + this.preamble = preamble; + return this; + } + + public Builder preamble(Object preamble) { + this.preamble = Optional.of(preamble); + return this; + } + + @JsonSetter(value = "seed", nulls = Nulls.SKIP) + public Builder seed(Optional seed) { + this.seed = seed; + return this; + } + + public Builder seed(Double seed) { + this.seed = Optional.of(seed); + return this; + } + + public ChatRequestConnectorsSearchOptions build() { + return new ChatRequestConnectorsSearchOptions( + model, temperature, maxTokens, preamble, seed, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatRequestPromptTruncation.java b/src/main/java/com/cohere/api/types/ChatRequestPromptTruncation.java index 4d9065b..4c58859 100644 --- a/src/main/java/com/cohere/api/types/ChatRequestPromptTruncation.java +++ b/src/main/java/com/cohere/api/types/ChatRequestPromptTruncation.java @@ -8,7 +8,9 @@ public enum ChatRequestPromptTruncation { OFF("OFF"), - AUTO("AUTO"); + AUTO("AUTO"), + + AUTO_PRESERVE_ORDER("AUTO_PRESERVE_ORDER"); private final String value; @@ -17,7 +19,7 @@ public enum ChatRequestPromptTruncation { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatRequestToolResultsItem.java b/src/main/java/com/cohere/api/types/ChatRequestToolResultsItem.java new file mode 100644 index 0000000..4bee1be --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatRequestToolResultsItem.java @@ -0,0 +1,142 @@ +/** + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ChatRequestToolResultsItem.Builder.class) +public final class ChatRequestToolResultsItem { + private final ToolCall call; + + private final List> outputs; + + private final Map additionalProperties; + + private ChatRequestToolResultsItem( + ToolCall call, List> outputs, Map additionalProperties) { + this.call = call; + this.outputs = outputs; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("call") + public ToolCall getCall() { + return call; + } + + @JsonProperty("outputs") + public List> getOutputs() { + return outputs; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatRequestToolResultsItem && equalTo((ChatRequestToolResultsItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatRequestToolResultsItem other) { + return call.equals(other.call) && outputs.equals(other.outputs); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.call, this.outputs); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CallStage builder() { + return new Builder(); + } + + public interface CallStage { + _FinalStage call(ToolCall call); + + Builder from(ChatRequestToolResultsItem other); + } + + public interface _FinalStage { + ChatRequestToolResultsItem build(); + + _FinalStage outputs(List> outputs); + + _FinalStage addOutputs(Map outputs); + + _FinalStage addAllOutputs(List> outputs); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CallStage, _FinalStage { + private ToolCall call; + + private List> outputs = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ChatRequestToolResultsItem other) { + call(other.getCall()); + outputs(other.getOutputs()); + return this; + } + + @java.lang.Override + @JsonSetter("call") + public _FinalStage call(ToolCall call) { + this.call = call; + return this; + } + + @java.lang.Override + public _FinalStage addAllOutputs(List> outputs) { + this.outputs.addAll(outputs); + return this; + } + + @java.lang.Override + public _FinalStage addOutputs(Map outputs) { + this.outputs.add(outputs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "outputs", nulls = Nulls.SKIP) + public _FinalStage outputs(List> outputs) { + this.outputs.clear(); + this.outputs.addAll(outputs); + return this; + } + + @java.lang.Override + public ChatRequestToolResultsItem build() { + return new ChatRequestToolResultsItem(call, outputs, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatSearchQueriesGenerationEvent.java b/src/main/java/com/cohere/api/types/ChatSearchQueriesGenerationEvent.java index 61f837d..12d193a 100644 --- a/src/main/java/com/cohere/api/types/ChatSearchQueriesGenerationEvent.java +++ b/src/main/java/com/cohere/api/types/ChatSearchQueriesGenerationEvent.java @@ -39,7 +39,7 @@ public List getSearchQueries() { return searchQueries; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatSearchQueriesGenerationEvent && equalTo((ChatSearchQueriesGenerationEvent) other); @@ -54,12 +54,12 @@ private boolean equalTo(ChatSearchQueriesGenerationEvent other) { return searchQueries.equals(other.searchQueries); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.searchQueries); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/ChatSearchQuery.java b/src/main/java/com/cohere/api/types/ChatSearchQuery.java index a9f5711..eb89352 100644 --- a/src/main/java/com/cohere/api/types/ChatSearchQuery.java +++ b/src/main/java/com/cohere/api/types/ChatSearchQuery.java @@ -46,7 +46,7 @@ public String getGenerationId() { return generationId; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatSearchQuery && equalTo((ChatSearchQuery) other); @@ -61,12 +61,12 @@ private boolean equalTo(ChatSearchQuery other) { return text.equals(other.text) && generationId.equals(other.generationId); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text, this.generationId); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -100,7 +100,7 @@ public static final class Builder implements TextStage, GenerationIdStage, _Fina private Builder() {} - @Override + @java.lang.Override public Builder from(ChatSearchQuery other) { text(other.getText()); generationId(other.getGenerationId()); @@ -111,7 +111,7 @@ public Builder from(ChatSearchQuery other) { *

The text of the search query.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public GenerationIdStage text(String text) { this.text = text; @@ -122,14 +122,14 @@ public GenerationIdStage text(String text) { *

Unique identifier for the generated search query. Useful for submitting feedback.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("generation_id") public _FinalStage generationId(String generationId) { this.generationId = generationId; return this; } - @Override + @java.lang.Override public ChatSearchQuery build() { return new ChatSearchQuery(text, generationId, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatSearchResult.java b/src/main/java/com/cohere/api/types/ChatSearchResult.java index ad8d8a9..25303c2 100644 --- a/src/main/java/com/cohere/api/types/ChatSearchResult.java +++ b/src/main/java/com/cohere/api/types/ChatSearchResult.java @@ -17,31 +17,40 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = ChatSearchResult.Builder.class) public final class ChatSearchResult { - private final ChatSearchQuery searchQuery; + private final Optional searchQuery; - private final ChatConnector connector; + private final ChatSearchResultConnector connector; private final List documentIds; + private final Optional errorMessage; + + private final Optional continueOnFailure; + private final Map additionalProperties; private ChatSearchResult( - ChatSearchQuery searchQuery, - ChatConnector connector, + Optional searchQuery, + ChatSearchResultConnector connector, List documentIds, + Optional errorMessage, + Optional continueOnFailure, Map additionalProperties) { this.searchQuery = searchQuery; this.connector = connector; this.documentIds = documentIds; + this.errorMessage = errorMessage; + this.continueOnFailure = continueOnFailure; this.additionalProperties = additionalProperties; } @JsonProperty("search_query") - public ChatSearchQuery getSearchQuery() { + public Optional getSearchQuery() { return searchQuery; } @@ -49,7 +58,7 @@ public ChatSearchQuery getSearchQuery() { * @return The connector from which this result comes from. */ @JsonProperty("connector") - public ChatConnector getConnector() { + public ChatSearchResultConnector getConnector() { return connector; } @@ -61,7 +70,23 @@ public List getDocumentIds() { return documentIds; } - @Override + /** + * @return An error message if the search failed. + */ + @JsonProperty("error_message") + public Optional getErrorMessage() { + return errorMessage; + } + + /** + * @return Whether a chat request should continue or not if the request to this connector fails. + */ + @JsonProperty("continue_on_failure") + public Optional getContinueOnFailure() { + return continueOnFailure; + } + + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatSearchResult && equalTo((ChatSearchResult) other); @@ -75,68 +100,78 @@ public Map getAdditionalProperties() { private boolean equalTo(ChatSearchResult other) { return searchQuery.equals(other.searchQuery) && connector.equals(other.connector) - && documentIds.equals(other.documentIds); + && documentIds.equals(other.documentIds) + && errorMessage.equals(other.errorMessage) + && continueOnFailure.equals(other.continueOnFailure); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.searchQuery, this.connector, this.documentIds); + return Objects.hash( + this.searchQuery, this.connector, this.documentIds, this.errorMessage, this.continueOnFailure); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } - public static SearchQueryStage builder() { + public static ConnectorStage builder() { return new Builder(); } - public interface SearchQueryStage { - ConnectorStage searchQuery(ChatSearchQuery searchQuery); + public interface ConnectorStage { + _FinalStage connector(ChatSearchResultConnector connector); Builder from(ChatSearchResult other); } - public interface ConnectorStage { - _FinalStage connector(ChatConnector connector); - } - public interface _FinalStage { ChatSearchResult build(); + _FinalStage searchQuery(Optional searchQuery); + + _FinalStage searchQuery(ChatSearchQuery searchQuery); + _FinalStage documentIds(List documentIds); _FinalStage addDocumentIds(String documentIds); _FinalStage addAllDocumentIds(List documentIds); + + _FinalStage errorMessage(Optional errorMessage); + + _FinalStage errorMessage(String errorMessage); + + _FinalStage continueOnFailure(Optional continueOnFailure); + + _FinalStage continueOnFailure(Boolean continueOnFailure); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements SearchQueryStage, ConnectorStage, _FinalStage { - private ChatSearchQuery searchQuery; + public static final class Builder implements ConnectorStage, _FinalStage { + private ChatSearchResultConnector connector; - private ChatConnector connector; + private Optional continueOnFailure = Optional.empty(); + + private Optional errorMessage = Optional.empty(); private List documentIds = new ArrayList<>(); + private Optional searchQuery = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @Override + @java.lang.Override public Builder from(ChatSearchResult other) { searchQuery(other.getSearchQuery()); connector(other.getConnector()); documentIds(other.getDocumentIds()); - return this; - } - - @Override - @JsonSetter("search_query") - public ConnectorStage searchQuery(ChatSearchQuery searchQuery) { - this.searchQuery = searchQuery; + errorMessage(other.getErrorMessage()); + continueOnFailure(other.getContinueOnFailure()); return this; } @@ -144,18 +179,52 @@ public ConnectorStage searchQuery(ChatSearchQuery searchQuery) { *

The connector from which this result comes from.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("connector") - public _FinalStage connector(ChatConnector connector) { + public _FinalStage connector(ChatSearchResultConnector connector) { this.connector = connector; return this; } + /** + *

Whether a chat request should continue or not if the request to this connector fails.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage continueOnFailure(Boolean continueOnFailure) { + this.continueOnFailure = Optional.of(continueOnFailure); + return this; + } + + @java.lang.Override + @JsonSetter(value = "continue_on_failure", nulls = Nulls.SKIP) + public _FinalStage continueOnFailure(Optional continueOnFailure) { + this.continueOnFailure = continueOnFailure; + return this; + } + + /** + *

An error message if the search failed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage errorMessage(String errorMessage) { + this.errorMessage = Optional.of(errorMessage); + return this; + } + + @java.lang.Override + @JsonSetter(value = "error_message", nulls = Nulls.SKIP) + public _FinalStage errorMessage(Optional errorMessage) { + this.errorMessage = errorMessage; + return this; + } + /** *

Identifiers of documents found by this search query.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllDocumentIds(List documentIds) { this.documentIds.addAll(documentIds); return this; @@ -165,13 +234,13 @@ public _FinalStage addAllDocumentIds(List documentIds) { *

Identifiers of documents found by this search query.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addDocumentIds(String documentIds) { this.documentIds.add(documentIds); return this; } - @Override + @java.lang.Override @JsonSetter(value = "document_ids", nulls = Nulls.SKIP) public _FinalStage documentIds(List documentIds) { this.documentIds.clear(); @@ -179,9 +248,23 @@ public _FinalStage documentIds(List documentIds) { return this; } - @Override + @java.lang.Override + public _FinalStage searchQuery(ChatSearchQuery searchQuery) { + this.searchQuery = Optional.of(searchQuery); + return this; + } + + @java.lang.Override + @JsonSetter(value = "search_query", nulls = Nulls.SKIP) + public _FinalStage searchQuery(Optional searchQuery) { + this.searchQuery = searchQuery; + return this; + } + + @java.lang.Override public ChatSearchResult build() { - return new ChatSearchResult(searchQuery, connector, documentIds, additionalProperties); + return new ChatSearchResult( + searchQuery, connector, documentIds, errorMessage, continueOnFailure, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ChatSearchResultConnector.java b/src/main/java/com/cohere/api/types/ChatSearchResultConnector.java new file mode 100644 index 0000000..cc969cb --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatSearchResultConnector.java @@ -0,0 +1,108 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ChatSearchResultConnector.Builder.class) +public final class ChatSearchResultConnector { + private final String id; + + private final Map additionalProperties; + + private ChatSearchResultConnector(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier of the connector. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatSearchResultConnector && equalTo((ChatSearchResultConnector) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatSearchResultConnector other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + _FinalStage id(String id); + + Builder from(ChatSearchResultConnector other); + } + + public interface _FinalStage { + ChatSearchResultConnector build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ChatSearchResultConnector other) { + id(other.getId()); + return this; + } + + /** + *

The identifier of the connector.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(String id) { + this.id = id; + return this; + } + + @java.lang.Override + public ChatSearchResultConnector build() { + return new ChatSearchResultConnector(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatSearchResultsEvent.java b/src/main/java/com/cohere/api/types/ChatSearchResultsEvent.java index e3a1524..4eb002b 100644 --- a/src/main/java/com/cohere/api/types/ChatSearchResultsEvent.java +++ b/src/main/java/com/cohere/api/types/ChatSearchResultsEvent.java @@ -12,24 +12,24 @@ import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = ChatSearchResultsEvent.Builder.class) public final class ChatSearchResultsEvent implements IChatStreamEvent { - private final List searchResults; + private final Optional> searchResults; - private final List> documents; + private final Optional>> documents; private final Map additionalProperties; private ChatSearchResultsEvent( - List searchResults, - List> documents, + Optional> searchResults, + Optional>> documents, Map additionalProperties) { this.searchResults = searchResults; this.documents = documents; @@ -40,7 +40,7 @@ private ChatSearchResultsEvent( * @return Conducted searches and the ids of documents retrieved from each of them. */ @JsonProperty("search_results") - public List getSearchResults() { + public Optional> getSearchResults() { return searchResults; } @@ -48,11 +48,11 @@ public List getSearchResults() { * @return Documents fetched from searches or provided by the user. */ @JsonProperty("documents") - public List> getDocuments() { + public Optional>> getDocuments() { return documents; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatSearchResultsEvent && equalTo((ChatSearchResultsEvent) other); @@ -67,12 +67,12 @@ private boolean equalTo(ChatSearchResultsEvent other) { return searchResults.equals(other.searchResults) && documents.equals(other.documents); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.searchResults, this.documents); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -83,9 +83,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List searchResults = new ArrayList<>(); + private Optional> searchResults = Optional.empty(); - private List> documents = new ArrayList<>(); + private Optional>> documents = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -99,36 +99,24 @@ public Builder from(ChatSearchResultsEvent other) { } @JsonSetter(value = "search_results", nulls = Nulls.SKIP) - public Builder searchResults(List searchResults) { - this.searchResults.clear(); - this.searchResults.addAll(searchResults); + public Builder searchResults(Optional> searchResults) { + this.searchResults = searchResults; return this; } - public Builder addSearchResults(ChatSearchResult searchResults) { - this.searchResults.add(searchResults); - return this; - } - - public Builder addAllSearchResults(List searchResults) { - this.searchResults.addAll(searchResults); + public Builder searchResults(List searchResults) { + this.searchResults = Optional.of(searchResults); return this; } @JsonSetter(value = "documents", nulls = Nulls.SKIP) - public Builder documents(List> documents) { - this.documents.clear(); - this.documents.addAll(documents); + public Builder documents(Optional>> documents) { + this.documents = documents; return this; } - public Builder addDocuments(Map documents) { - this.documents.add(documents); - return this; - } - - public Builder addAllDocuments(List> documents) { - this.documents.addAll(documents); + public Builder documents(List> documents) { + this.documents = Optional.of(documents); return this; } diff --git a/src/main/java/com/cohere/api/types/ChatStreamEndEvent.java b/src/main/java/com/cohere/api/types/ChatStreamEndEvent.java index eeb547d..6f34855 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamEndEvent.java +++ b/src/main/java/com/cohere/api/types/ChatStreamEndEvent.java @@ -20,13 +20,13 @@ public final class ChatStreamEndEvent implements IChatStreamEvent { private final ChatStreamEndEventFinishReason finishReason; - private final ChatStreamEndEventResponse response; + private final NonStreamedChatResponse response; private final Map additionalProperties; private ChatStreamEndEvent( ChatStreamEndEventFinishReason finishReason, - ChatStreamEndEventResponse response, + NonStreamedChatResponse response, Map additionalProperties) { this.finishReason = finishReason; this.response = response; @@ -51,11 +51,11 @@ public ChatStreamEndEventFinishReason getFinishReason() { * @return The consolidated response from the model. Contains the generated reply and all the other information streamed back in the previous events. */ @JsonProperty("response") - public ChatStreamEndEventResponse getResponse() { + public NonStreamedChatResponse getResponse() { return response; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatStreamEndEvent && equalTo((ChatStreamEndEvent) other); @@ -70,12 +70,12 @@ private boolean equalTo(ChatStreamEndEvent other) { return finishReason.equals(other.finishReason) && response.equals(other.response); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.finishReason, this.response); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -91,7 +91,7 @@ public interface FinishReasonStage { } public interface ResponseStage { - _FinalStage response(ChatStreamEndEventResponse response); + _FinalStage response(NonStreamedChatResponse response); } public interface _FinalStage { @@ -102,14 +102,14 @@ public interface _FinalStage { public static final class Builder implements FinishReasonStage, ResponseStage, _FinalStage { private ChatStreamEndEventFinishReason finishReason; - private ChatStreamEndEventResponse response; + private NonStreamedChatResponse response; @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @Override + @java.lang.Override public Builder from(ChatStreamEndEvent other) { finishReason(other.getFinishReason()); response(other.getResponse()); @@ -126,7 +126,7 @@ public Builder from(ChatStreamEndEvent other) { * * @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("finish_reason") public ResponseStage finishReason(ChatStreamEndEventFinishReason finishReason) { this.finishReason = finishReason; @@ -137,14 +137,14 @@ public ResponseStage finishReason(ChatStreamEndEventFinishReason finishReason) { *

The consolidated response from the model. Contains the generated reply and all the other information streamed back in the previous events.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("response") - public _FinalStage response(ChatStreamEndEventResponse response) { + public _FinalStage response(NonStreamedChatResponse response) { this.response = response; return this; } - @Override + @java.lang.Override public ChatStreamEndEvent build() { return new ChatStreamEndEvent(finishReason, response, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatStreamEndEventFinishReason.java b/src/main/java/com/cohere/api/types/ChatStreamEndEventFinishReason.java index 861df09..1dd7b70 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamEndEventFinishReason.java +++ b/src/main/java/com/cohere/api/types/ChatStreamEndEventFinishReason.java @@ -23,7 +23,7 @@ public enum ChatStreamEndEventFinishReason { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatStreamEndEventResponse.java b/src/main/java/com/cohere/api/types/ChatStreamEndEventResponse.java deleted file mode 100644 index 8ec8a26..0000000 --- a/src/main/java/com/cohere/api/types/ChatStreamEndEventResponse.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * 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.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ChatStreamEndEventResponse.Deserializer.class) -public final class ChatStreamEndEventResponse { - private final Object value; - - private final int type; - - private ChatStreamEndEventResponse(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((NonStreamedChatResponse) this.value); - } else if (this.type == 1) { - return visitor.visit((SearchQueriesOnlyResponse) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ChatStreamEndEventResponse && equalTo((ChatStreamEndEventResponse) other); - } - - private boolean equalTo(ChatStreamEndEventResponse other) { - return value.equals(other.value); - } - - @Override - public int hashCode() { - return Objects.hash(this.value); - } - - @Override - public String toString() { - return this.value.toString(); - } - - public static ChatStreamEndEventResponse of(NonStreamedChatResponse value) { - return new ChatStreamEndEventResponse(value, 0); - } - - public static ChatStreamEndEventResponse of(SearchQueriesOnlyResponse value) { - return new ChatStreamEndEventResponse(value, 1); - } - - public interface Visitor { - T visit(NonStreamedChatResponse value); - - T visit(SearchQueriesOnlyResponse value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ChatStreamEndEventResponse.class); - } - - @Override - public ChatStreamEndEventResponse deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, NonStreamedChatResponse.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SearchQueriesOnlyResponse.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/cohere/api/types/ChatStreamEvent.java b/src/main/java/com/cohere/api/types/ChatStreamEvent.java index 3671afb..b9d7f22 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamEvent.java +++ b/src/main/java/com/cohere/api/types/ChatStreamEvent.java @@ -14,7 +14,7 @@ private ChatStreamEvent(Map additionalProperties) { this.additionalProperties = additionalProperties; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatStreamEvent; @@ -25,7 +25,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestCitationQuality.java b/src/main/java/com/cohere/api/types/ChatStreamRequestCitationQuality.java index 356f24d..ff2d4ba 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamRequestCitationQuality.java +++ b/src/main/java/com/cohere/api/types/ChatStreamRequestCitationQuality.java @@ -17,7 +17,7 @@ public enum ChatStreamRequestCitationQuality { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestConnectorsSearchOptions.java b/src/main/java/com/cohere/api/types/ChatStreamRequestConnectorsSearchOptions.java new file mode 100644 index 0000000..5d446b4 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatStreamRequestConnectorsSearchOptions.java @@ -0,0 +1,198 @@ +/** + * 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 = ChatStreamRequestConnectorsSearchOptions.Builder.class) +public final class ChatStreamRequestConnectorsSearchOptions { + private final Optional model; + + private final Optional temperature; + + private final Optional maxTokens; + + private final Optional preamble; + + private final Optional seed; + + private final Map additionalProperties; + + private ChatStreamRequestConnectorsSearchOptions( + Optional model, + Optional temperature, + Optional maxTokens, + Optional preamble, + Optional seed, + Map additionalProperties) { + this.model = model; + this.temperature = temperature; + this.maxTokens = maxTokens; + this.preamble = preamble; + this.seed = seed; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("model") + public Optional getModel() { + return model; + } + + @JsonProperty("temperature") + public Optional getTemperature() { + return temperature; + } + + @JsonProperty("max_tokens") + public Optional getMaxTokens() { + return maxTokens; + } + + @JsonProperty("preamble") + public Optional getPreamble() { + return preamble; + } + + /** + * @return If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinsim cannot be totally guaranteed. + */ + @JsonProperty("seed") + public Optional getSeed() { + return seed; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatStreamRequestConnectorsSearchOptions + && equalTo((ChatStreamRequestConnectorsSearchOptions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatStreamRequestConnectorsSearchOptions other) { + return model.equals(other.model) + && temperature.equals(other.temperature) + && maxTokens.equals(other.maxTokens) + && preamble.equals(other.preamble) + && seed.equals(other.seed); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.model, this.temperature, this.maxTokens, this.preamble, this.seed); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional model = Optional.empty(); + + private Optional temperature = Optional.empty(); + + private Optional maxTokens = Optional.empty(); + + private Optional preamble = Optional.empty(); + + private Optional seed = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ChatStreamRequestConnectorsSearchOptions other) { + model(other.getModel()); + temperature(other.getTemperature()); + maxTokens(other.getMaxTokens()); + preamble(other.getPreamble()); + seed(other.getSeed()); + return this; + } + + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public Builder model(Optional model) { + this.model = model; + return this; + } + + public Builder model(Object model) { + this.model = Optional.of(model); + return this; + } + + @JsonSetter(value = "temperature", nulls = Nulls.SKIP) + public Builder temperature(Optional temperature) { + this.temperature = temperature; + return this; + } + + public Builder temperature(Object temperature) { + this.temperature = Optional.of(temperature); + return this; + } + + @JsonSetter(value = "max_tokens", nulls = Nulls.SKIP) + public Builder maxTokens(Optional maxTokens) { + this.maxTokens = maxTokens; + return this; + } + + public Builder maxTokens(Object maxTokens) { + this.maxTokens = Optional.of(maxTokens); + return this; + } + + @JsonSetter(value = "preamble", nulls = Nulls.SKIP) + public Builder preamble(Optional preamble) { + this.preamble = preamble; + return this; + } + + public Builder preamble(Object preamble) { + this.preamble = Optional.of(preamble); + return this; + } + + @JsonSetter(value = "seed", nulls = Nulls.SKIP) + public Builder seed(Optional seed) { + this.seed = seed; + return this; + } + + public Builder seed(Double seed) { + this.seed = Optional.of(seed); + return this; + } + + public ChatStreamRequestConnectorsSearchOptions build() { + return new ChatStreamRequestConnectorsSearchOptions( + model, temperature, maxTokens, preamble, seed, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestPromptTruncation.java b/src/main/java/com/cohere/api/types/ChatStreamRequestPromptTruncation.java index 4874d27..0e9f8e9 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamRequestPromptTruncation.java +++ b/src/main/java/com/cohere/api/types/ChatStreamRequestPromptTruncation.java @@ -8,7 +8,9 @@ public enum ChatStreamRequestPromptTruncation { OFF("OFF"), - AUTO("AUTO"); + AUTO("AUTO"), + + AUTO_PRESERVE_ORDER("AUTO_PRESERVE_ORDER"); private final String value; @@ -17,7 +19,7 @@ public enum ChatStreamRequestPromptTruncation { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ChatStreamRequestToolResultsItem.java b/src/main/java/com/cohere/api/types/ChatStreamRequestToolResultsItem.java new file mode 100644 index 0000000..fb87422 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ChatStreamRequestToolResultsItem.java @@ -0,0 +1,142 @@ +/** + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ChatStreamRequestToolResultsItem.Builder.class) +public final class ChatStreamRequestToolResultsItem { + private final ToolCall call; + + private final List> outputs; + + private final Map additionalProperties; + + private ChatStreamRequestToolResultsItem( + ToolCall call, List> outputs, Map additionalProperties) { + this.call = call; + this.outputs = outputs; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("call") + public ToolCall getCall() { + return call; + } + + @JsonProperty("outputs") + public List> getOutputs() { + return outputs; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ChatStreamRequestToolResultsItem && equalTo((ChatStreamRequestToolResultsItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ChatStreamRequestToolResultsItem other) { + return call.equals(other.call) && outputs.equals(other.outputs); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.call, this.outputs); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CallStage builder() { + return new Builder(); + } + + public interface CallStage { + _FinalStage call(ToolCall call); + + Builder from(ChatStreamRequestToolResultsItem other); + } + + public interface _FinalStage { + ChatStreamRequestToolResultsItem build(); + + _FinalStage outputs(List> outputs); + + _FinalStage addOutputs(Map outputs); + + _FinalStage addAllOutputs(List> outputs); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CallStage, _FinalStage { + private ToolCall call; + + private List> outputs = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ChatStreamRequestToolResultsItem other) { + call(other.getCall()); + outputs(other.getOutputs()); + return this; + } + + @java.lang.Override + @JsonSetter("call") + public _FinalStage call(ToolCall call) { + this.call = call; + return this; + } + + @java.lang.Override + public _FinalStage addAllOutputs(List> outputs) { + this.outputs.addAll(outputs); + return this; + } + + @java.lang.Override + public _FinalStage addOutputs(Map outputs) { + this.outputs.add(outputs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "outputs", nulls = Nulls.SKIP) + public _FinalStage outputs(List> outputs) { + this.outputs.clear(); + this.outputs.addAll(outputs); + return this; + } + + @java.lang.Override + public ChatStreamRequestToolResultsItem build() { + return new ChatStreamRequestToolResultsItem(call, outputs, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ChatStreamStartEvent.java b/src/main/java/com/cohere/api/types/ChatStreamStartEvent.java index c0afa5c..0e69d98 100644 --- a/src/main/java/com/cohere/api/types/ChatStreamStartEvent.java +++ b/src/main/java/com/cohere/api/types/ChatStreamStartEvent.java @@ -35,7 +35,7 @@ public String getGenerationId() { return generationId; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatStreamStartEvent && equalTo((ChatStreamStartEvent) other); @@ -50,12 +50,12 @@ private boolean equalTo(ChatStreamStartEvent other) { return generationId.equals(other.generationId); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.generationId); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -83,7 +83,7 @@ public static final class Builder implements GenerationIdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ChatStreamStartEvent other) { generationId(other.getGenerationId()); return this; @@ -93,14 +93,14 @@ public Builder from(ChatStreamStartEvent other) { *

Unique identifier for the generated reply. Useful for submitting feedback.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("generation_id") public _FinalStage generationId(String generationId) { this.generationId = generationId; return this; } - @Override + @java.lang.Override public ChatStreamStartEvent build() { return new ChatStreamStartEvent(generationId, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ChatTextGenerationEvent.java b/src/main/java/com/cohere/api/types/ChatTextGenerationEvent.java index 55e8acd..39f953e 100644 --- a/src/main/java/com/cohere/api/types/ChatTextGenerationEvent.java +++ b/src/main/java/com/cohere/api/types/ChatTextGenerationEvent.java @@ -35,7 +35,7 @@ public String getText() { return text; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ChatTextGenerationEvent && equalTo((ChatTextGenerationEvent) other); @@ -50,12 +50,12 @@ private boolean equalTo(ChatTextGenerationEvent other) { return text.equals(other.text); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -83,7 +83,7 @@ public static final class Builder implements TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ChatTextGenerationEvent other) { text(other.getText()); return this; @@ -93,14 +93,14 @@ public Builder from(ChatTextGenerationEvent other) { *

The next batch of text generated by the model.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; return this; } - @Override + @java.lang.Override public ChatTextGenerationEvent build() { return new ChatTextGenerationEvent(text, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/SearchQueriesOnlyResponse.java b/src/main/java/com/cohere/api/types/ChatToolCallsGenerationEvent.java similarity index 50% rename from src/main/java/com/cohere/api/types/SearchQueriesOnlyResponse.java rename to src/main/java/com/cohere/api/types/ChatToolCallsGenerationEvent.java index 735e470..e6097bc 100644 --- a/src/main/java/com/cohere/api/types/SearchQueriesOnlyResponse.java +++ b/src/main/java/com/cohere/api/types/ChatToolCallsGenerationEvent.java @@ -19,29 +19,26 @@ import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SearchQueriesOnlyResponse.Builder.class) -public final class SearchQueriesOnlyResponse { - private final List searchQueries; +@JsonDeserialize(builder = ChatToolCallsGenerationEvent.Builder.class) +public final class ChatToolCallsGenerationEvent implements IChatStreamEvent { + private final List toolCalls; private final Map additionalProperties; - private SearchQueriesOnlyResponse(List searchQueries, Map additionalProperties) { - this.searchQueries = searchQueries; + private ChatToolCallsGenerationEvent(List toolCalls, Map additionalProperties) { + this.toolCalls = toolCalls; this.additionalProperties = additionalProperties; } - /** - * @return Generated search queries, meant to be used as part of the RAG flow. - */ - @JsonProperty("search_queries") - public List getSearchQueries() { - return searchQueries; + @JsonProperty("tool_calls") + public List getToolCalls() { + return toolCalls; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SearchQueriesOnlyResponse && equalTo((SearchQueriesOnlyResponse) other); + return other instanceof ChatToolCallsGenerationEvent && equalTo((ChatToolCallsGenerationEvent) other); } @JsonAnyGetter @@ -49,16 +46,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(SearchQueriesOnlyResponse other) { - return searchQueries.equals(other.searchQueries); + private boolean equalTo(ChatToolCallsGenerationEvent other) { + return toolCalls.equals(other.toolCalls); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.searchQueries); + return Objects.hash(this.toolCalls); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -69,37 +66,37 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List searchQueries = new ArrayList<>(); + private List toolCalls = new ArrayList<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(SearchQueriesOnlyResponse other) { - searchQueries(other.getSearchQueries()); + public Builder from(ChatToolCallsGenerationEvent other) { + toolCalls(other.getToolCalls()); return this; } - @JsonSetter(value = "search_queries", nulls = Nulls.SKIP) - public Builder searchQueries(List searchQueries) { - this.searchQueries.clear(); - this.searchQueries.addAll(searchQueries); + @JsonSetter(value = "tool_calls", nulls = Nulls.SKIP) + public Builder toolCalls(List toolCalls) { + this.toolCalls.clear(); + this.toolCalls.addAll(toolCalls); return this; } - public Builder addSearchQueries(ChatSearchQuery searchQueries) { - this.searchQueries.add(searchQueries); + public Builder addToolCalls(ToolCall toolCalls) { + this.toolCalls.add(toolCalls); return this; } - public Builder addAllSearchQueries(List searchQueries) { - this.searchQueries.addAll(searchQueries); + public Builder addAllToolCalls(List toolCalls) { + this.toolCalls.addAll(toolCalls); return this; } - public SearchQueriesOnlyResponse build() { - return new SearchQueriesOnlyResponse(searchQueries, additionalProperties); + public ChatToolCallsGenerationEvent build() { + return new ChatToolCallsGenerationEvent(toolCalls, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ClassifyDataMetrics.java b/src/main/java/com/cohere/api/types/ClassifyDataMetrics.java new file mode 100644 index 0000000..b65ee80 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ClassifyDataMetrics.java @@ -0,0 +1,96 @@ +/** + * 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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassifyDataMetrics.Builder.class) +public final class ClassifyDataMetrics { + private final Optional> labelMetrics; + + private final Map additionalProperties; + + private ClassifyDataMetrics(Optional> labelMetrics, Map additionalProperties) { + this.labelMetrics = labelMetrics; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("label_metrics") + public Optional> getLabelMetrics() { + return labelMetrics; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassifyDataMetrics && equalTo((ClassifyDataMetrics) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ClassifyDataMetrics other) { + return labelMetrics.equals(other.labelMetrics); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.labelMetrics); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> labelMetrics = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ClassifyDataMetrics other) { + labelMetrics(other.getLabelMetrics()); + return this; + } + + @JsonSetter(value = "label_metrics", nulls = Nulls.SKIP) + public Builder labelMetrics(Optional> labelMetrics) { + this.labelMetrics = labelMetrics; + return this; + } + + public Builder labelMetrics(List labelMetrics) { + this.labelMetrics = Optional.of(labelMetrics); + return this; + } + + public ClassifyDataMetrics build() { + return new ClassifyDataMetrics(labelMetrics, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ClassifyRequestExamplesItem.java b/src/main/java/com/cohere/api/types/ClassifyExample.java similarity index 80% rename from src/main/java/com/cohere/api/types/ClassifyRequestExamplesItem.java rename to src/main/java/com/cohere/api/types/ClassifyExample.java index 708454c..ddff171 100644 --- a/src/main/java/com/cohere/api/types/ClassifyRequestExamplesItem.java +++ b/src/main/java/com/cohere/api/types/ClassifyExample.java @@ -18,16 +18,15 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ClassifyRequestExamplesItem.Builder.class) -public final class ClassifyRequestExamplesItem { +@JsonDeserialize(builder = ClassifyExample.Builder.class) +public final class ClassifyExample { private final Optional text; private final Optional label; private final Map additionalProperties; - private ClassifyRequestExamplesItem( - Optional text, Optional label, Map additionalProperties) { + private ClassifyExample(Optional text, Optional label, Map additionalProperties) { this.text = text; this.label = label; this.additionalProperties = additionalProperties; @@ -43,10 +42,10 @@ public Optional getLabel() { return label; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ClassifyRequestExamplesItem && equalTo((ClassifyRequestExamplesItem) other); + return other instanceof ClassifyExample && equalTo((ClassifyExample) other); } @JsonAnyGetter @@ -54,16 +53,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ClassifyRequestExamplesItem other) { + private boolean equalTo(ClassifyExample other) { return text.equals(other.text) && label.equals(other.label); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text, this.label); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -83,7 +82,7 @@ public static final class Builder { private Builder() {} - public Builder from(ClassifyRequestExamplesItem other) { + public Builder from(ClassifyExample other) { text(other.getText()); label(other.getLabel()); return this; @@ -111,8 +110,8 @@ public Builder label(String label) { return this; } - public ClassifyRequestExamplesItem build() { - return new ClassifyRequestExamplesItem(text, label, additionalProperties); + public ClassifyExample build() { + return new ClassifyExample(text, label, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ClassifyRequestTruncate.java b/src/main/java/com/cohere/api/types/ClassifyRequestTruncate.java index f83d07f..0065233 100644 --- a/src/main/java/com/cohere/api/types/ClassifyRequestTruncate.java +++ b/src/main/java/com/cohere/api/types/ClassifyRequestTruncate.java @@ -19,7 +19,7 @@ public enum ClassifyRequestTruncate { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ClassifyResponse.java b/src/main/java/com/cohere/api/types/ClassifyResponse.java index 6281fe5..76fb1fa 100644 --- a/src/main/java/com/cohere/api/types/ClassifyResponse.java +++ b/src/main/java/com/cohere/api/types/ClassifyResponse.java @@ -56,7 +56,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ClassifyResponse && equalTo((ClassifyResponse) other); @@ -71,12 +71,12 @@ private boolean equalTo(ClassifyResponse other) { return id.equals(other.id) && classifications.equals(other.classifications) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.classifications, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -118,7 +118,7 @@ public static final class Builder implements IdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(ClassifyResponse other) { id(other.getId()); classifications(other.getClassifications()); @@ -126,39 +126,39 @@ public Builder from(ClassifyResponse other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public _FinalStage id(String id) { this.id = id; return this; } - @Override + @java.lang.Override public _FinalStage meta(ApiMeta meta) { this.meta = Optional.of(meta); return this; } - @Override + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Optional meta) { this.meta = meta; return this; } - @Override + @java.lang.Override public _FinalStage addAllClassifications(List classifications) { this.classifications.addAll(classifications); return this; } - @Override + @java.lang.Override public _FinalStage addClassifications(ClassifyResponseClassificationsItem classifications) { this.classifications.add(classifications); return this; } - @Override + @java.lang.Override @JsonSetter(value = "classifications", nulls = Nulls.SKIP) public _FinalStage classifications(List classifications) { this.classifications.clear(); @@ -166,7 +166,7 @@ public _FinalStage classifications(List cla return this; } - @Override + @java.lang.Override public ClassifyResponse build() { return new ClassifyResponse(id, classifications, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItem.java b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItem.java index 206d667..9ca9573 100644 --- a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItem.java +++ b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItem.java @@ -123,7 +123,7 @@ public ClassifyResponseClassificationsItemClassificationType getClassificationTy return classificationType; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ClassifyResponseClassificationsItem @@ -146,7 +146,7 @@ private boolean equalTo(ClassifyResponseClassificationsItem other) { && classificationType.equals(other.classificationType); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.id, @@ -159,7 +159,7 @@ public int hashCode() { this.classificationType); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -235,7 +235,7 @@ public static final class Builder implements IdStage, ClassificationTypeStage, _ private Builder() {} - @Override + @java.lang.Override public Builder from(ClassifyResponseClassificationsItem other) { id(other.getId()); input(other.getInput()); @@ -248,7 +248,7 @@ public Builder from(ClassifyResponseClassificationsItem other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public ClassificationTypeStage id(String id) { this.id = id; @@ -259,7 +259,7 @@ public ClassificationTypeStage id(String id) { *

The type of classification performed

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("classification_type") public _FinalStage classificationType( ClassifyResponseClassificationsItemClassificationType classificationType) { @@ -271,7 +271,7 @@ public _FinalStage classificationType( *

A map containing each label and its confidence score according to the classifier. All the confidence scores add up to 1 for single-label classification. For multi-label classification the label confidences are independent of each other, so they don't have to sum up to 1.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage labels(String key, ClassifyResponseClassificationsItemLabelsValue value) { this.labels.put(key, value); return this; @@ -281,13 +281,13 @@ public _FinalStage labels(String key, ClassifyResponseClassificationsItemLabelsV *

A map containing each label and its confidence score according to the classifier. All the confidence scores add up to 1 for single-label classification. For multi-label classification the label confidences are independent of each other, so they don't have to sum up to 1.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage putAllLabels(Map labels) { this.labels.putAll(labels); return this; } - @Override + @java.lang.Override @JsonSetter(value = "labels", nulls = Nulls.SKIP) public _FinalStage labels(Map labels) { this.labels.clear(); @@ -299,7 +299,7 @@ public _FinalStage labels(MapAn array containing the confidence scores of all the predictions in the same order

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllConfidences(List confidences) { this.confidences.addAll(confidences); return this; @@ -309,13 +309,13 @@ public _FinalStage addAllConfidences(List confidences) { *

An array containing the confidence scores of all the predictions in the same order

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addConfidences(Double confidences) { this.confidences.add(confidences); return this; } - @Override + @java.lang.Override @JsonSetter(value = "confidences", nulls = Nulls.SKIP) public _FinalStage confidences(List confidences) { this.confidences.clear(); @@ -327,13 +327,13 @@ public _FinalStage confidences(List confidences) { *

The confidence score for the top predicted class (only filled for single-label classification)

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage confidence(Double confidence) { this.confidence = Optional.of(confidence); return this; } - @Override + @java.lang.Override @JsonSetter(value = "confidence", nulls = Nulls.SKIP) public _FinalStage confidence(Optional confidence) { this.confidence = confidence; @@ -344,7 +344,7 @@ public _FinalStage confidence(Optional confidence) { *

An array containing the predicted labels for the associated query (only filled for single-label classification)

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllPredictions(List predictions) { this.predictions.addAll(predictions); return this; @@ -354,13 +354,13 @@ public _FinalStage addAllPredictions(List predictions) { *

An array containing the predicted labels for the associated query (only filled for single-label classification)

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addPredictions(String predictions) { this.predictions.add(predictions); return this; } - @Override + @java.lang.Override @JsonSetter(value = "predictions", nulls = Nulls.SKIP) public _FinalStage predictions(List predictions) { this.predictions.clear(); @@ -372,13 +372,13 @@ public _FinalStage predictions(List predictions) { *

The predicted label for the associated query (only filled for single-label models)

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage prediction(String prediction) { this.prediction = Optional.of(prediction); return this; } - @Override + @java.lang.Override @JsonSetter(value = "prediction", nulls = Nulls.SKIP) public _FinalStage prediction(Optional prediction) { this.prediction = prediction; @@ -389,20 +389,20 @@ public _FinalStage prediction(Optional prediction) { *

The input text that was classified

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage input(String input) { this.input = Optional.of(input); return this; } - @Override + @java.lang.Override @JsonSetter(value = "input", nulls = Nulls.SKIP) public _FinalStage input(Optional input) { this.input = input; return this; } - @Override + @java.lang.Override public ClassifyResponseClassificationsItem build() { return new ClassifyResponseClassificationsItem( id, diff --git a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemClassificationType.java b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemClassificationType.java index e4f847f..3ffff13 100644 --- a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemClassificationType.java +++ b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemClassificationType.java @@ -17,7 +17,7 @@ public enum ClassifyResponseClassificationsItemClassificationType { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemLabelsValue.java b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemLabelsValue.java index 66f858d..417ed76 100644 --- a/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemLabelsValue.java +++ b/src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemLabelsValue.java @@ -35,7 +35,7 @@ public Optional getConfidence() { return confidence; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ClassifyResponseClassificationsItemLabelsValue @@ -51,12 +51,12 @@ private boolean equalTo(ClassifyResponseClassificationsItemLabelsValue other) { return confidence.equals(other.confidence); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.confidence); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/CompatibleEndpoint.java b/src/main/java/com/cohere/api/types/CompatibleEndpoint.java new file mode 100644 index 0000000..215e96c --- /dev/null +++ b/src/main/java/com/cohere/api/types/CompatibleEndpoint.java @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CompatibleEndpoint { + CHAT("chat"), + + EMBED("embed"), + + CLASSIFY("classify"), + + SUMMARIZE("summarize"), + + RERANK("rerank"), + + RATE("rate"), + + GENERATE("generate"); + + private final String value; + + CompatibleEndpoint(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/Connector.java b/src/main/java/com/cohere/api/types/Connector.java index 978ca83..9ae6670 100644 --- a/src/main/java/com/cohere/api/types/Connector.java +++ b/src/main/java/com/cohere/api/types/Connector.java @@ -187,7 +187,7 @@ public Optional getContinueOnFailure() { return continueOnFailure; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof Connector && equalTo((Connector) other); @@ -214,7 +214,7 @@ private boolean equalTo(Connector other) { && continueOnFailure.equals(other.continueOnFailure); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.id, @@ -232,7 +232,7 @@ public int hashCode() { this.continueOnFailure); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -332,7 +332,7 @@ public static final class Builder implements IdStage, NameStage, CreatedAtStage, private Builder() {} - @Override + @java.lang.Override public Builder from(Connector other) { id(other.getId()); organizationId(other.getOrganizationId()); @@ -355,7 +355,7 @@ public Builder from(Connector other) { * This is automatically created from the name of the connector upon registration.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("id") public NameStage id(String id) { this.id = id; @@ -366,7 +366,7 @@ public NameStage id(String id) { *

A human-readable name for the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("name") public CreatedAtStage name(String name) { this.name = name; @@ -377,7 +377,7 @@ public CreatedAtStage name(String name) { *

The UTC time at which the connector was created.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("created_at") public UpdatedAtStage createdAt(OffsetDateTime createdAt) { this.createdAt = createdAt; @@ -388,7 +388,7 @@ public UpdatedAtStage createdAt(OffsetDateTime createdAt) { *

The UTC time at which the connector was last updated.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("updated_at") public _FinalStage updatedAt(OffsetDateTime updatedAt) { this.updatedAt = updatedAt; @@ -399,13 +399,13 @@ public _FinalStage updatedAt(OffsetDateTime updatedAt) { *

Whether a chat request should continue or not if the request to this connector fails.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage continueOnFailure(Boolean continueOnFailure) { this.continueOnFailure = Optional.of(continueOnFailure); return this; } - @Override + @java.lang.Override @JsonSetter(value = "continue_on_failure", nulls = Nulls.SKIP) public _FinalStage continueOnFailure(Optional continueOnFailure) { this.continueOnFailure = continueOnFailure; @@ -416,13 +416,13 @@ public _FinalStage continueOnFailure(Optional continueOnFailure) { *

Whether the connector is active or not.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage active(Boolean active) { this.active = Optional.of(active); return this; } - @Override + @java.lang.Override @JsonSetter(value = "active", nulls = Nulls.SKIP) public _FinalStage active(Optional active) { this.active = active; @@ -433,13 +433,13 @@ public _FinalStage active(Optional active) { *

The OAuth status for the user making the request. One of ["valid", "expired", ""]. Empty string (field is omitted) means the user has not authorized the connector yet.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage authStatus(ConnectorAuthStatus authStatus) { this.authStatus = Optional.of(authStatus); return this; } - @Override + @java.lang.Override @JsonSetter(value = "auth_status", nulls = Nulls.SKIP) public _FinalStage authStatus(Optional authStatus) { this.authStatus = authStatus; @@ -450,13 +450,13 @@ public _FinalStage authStatus(Optional authStatus) { *

The OAuth 2.0 configuration for the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage oauth(ConnectorOAuth oauth) { this.oauth = Optional.of(oauth); return this; } - @Override + @java.lang.Override @JsonSetter(value = "oauth", nulls = Nulls.SKIP) public _FinalStage oauth(Optional oauth) { this.oauth = oauth; @@ -467,13 +467,13 @@ public _FinalStage oauth(Optional oauth) { *

The type of authentication/authorization used by the connector. Possible values: [oauth, service_auth]

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage authType(String authType) { this.authType = Optional.of(authType); return this; } - @Override + @java.lang.Override @JsonSetter(value = "auth_type", nulls = Nulls.SKIP) public _FinalStage authType(Optional authType) { this.authType = authType; @@ -484,13 +484,13 @@ public _FinalStage authType(Optional authType) { *

A list of fields to exclude from the prompt (fields remain in the document).

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage excludes(List excludes) { this.excludes = Optional.of(excludes); return this; } - @Override + @java.lang.Override @JsonSetter(value = "excludes", nulls = Nulls.SKIP) public _FinalStage excludes(Optional> excludes) { this.excludes = excludes; @@ -501,13 +501,13 @@ public _FinalStage excludes(Optional> excludes) { *

The URL of the connector that will be used to search for documents.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage url(String url) { this.url = Optional.of(url); return this; } - @Override + @java.lang.Override @JsonSetter(value = "url", nulls = Nulls.SKIP) public _FinalStage url(Optional url) { this.url = url; @@ -518,13 +518,13 @@ public _FinalStage url(Optional url) { *

A description of the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage description(String description) { this.description = Optional.of(description); return this; } - @Override + @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { this.description = description; @@ -536,20 +536,20 @@ public _FinalStage description(Optional description) { * the organization of the user who created the connector.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage organizationId(String organizationId) { this.organizationId = Optional.of(organizationId); return this; } - @Override + @java.lang.Override @JsonSetter(value = "organization_id", nulls = Nulls.SKIP) public _FinalStage organizationId(Optional organizationId) { this.organizationId = organizationId; return this; } - @Override + @java.lang.Override public Connector build() { return new Connector( id, diff --git a/src/main/java/com/cohere/api/types/ConnectorAuthStatus.java b/src/main/java/com/cohere/api/types/ConnectorAuthStatus.java index 63b8e32..2f0a4f1 100644 --- a/src/main/java/com/cohere/api/types/ConnectorAuthStatus.java +++ b/src/main/java/com/cohere/api/types/ConnectorAuthStatus.java @@ -17,7 +17,7 @@ public enum ConnectorAuthStatus { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/ConnectorOAuth.java b/src/main/java/com/cohere/api/types/ConnectorOAuth.java index b9e4340..ffe974c 100644 --- a/src/main/java/com/cohere/api/types/ConnectorOAuth.java +++ b/src/main/java/com/cohere/api/types/ConnectorOAuth.java @@ -20,38 +20,62 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = ConnectorOAuth.Builder.class) public final class ConnectorOAuth { - private final Optional authorizeUrl; + private final Optional clientId; - private final Optional tokenUrl; + private final Optional clientSecret; + + private final String authorizeUrl; + + private final String tokenUrl; private final Optional scope; private final Map additionalProperties; private ConnectorOAuth( - Optional authorizeUrl, - Optional tokenUrl, + Optional clientId, + Optional clientSecret, + String authorizeUrl, + String tokenUrl, Optional scope, Map additionalProperties) { + this.clientId = clientId; + this.clientSecret = clientSecret; this.authorizeUrl = authorizeUrl; this.tokenUrl = tokenUrl; this.scope = scope; this.additionalProperties = additionalProperties; } + /** + * @return The OAuth 2.0 client ID. This field is encrypted at rest. + */ + @JsonProperty("client_id") + public Optional getClientId() { + return clientId; + } + + /** + * @return The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response. + */ + @JsonProperty("client_secret") + public Optional getClientSecret() { + return clientSecret; + } + /** * @return The OAuth 2.0 /authorize endpoint to use when users authorize the connector. */ - @JsonProperty("authorizeUrl") - public Optional getAuthorizeUrl() { + @JsonProperty("authorize_url") + public String getAuthorizeUrl() { return authorizeUrl; } /** * @return The OAuth 2.0 /token endpoint to use when users authorize the connector. */ - @JsonProperty("tokenUrl") - public Optional getTokenUrl() { + @JsonProperty("token_url") + public String getTokenUrl() { return tokenUrl; } @@ -63,7 +87,7 @@ public Optional getScope() { return scope; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof ConnectorOAuth && equalTo((ConnectorOAuth) other); @@ -75,78 +99,156 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConnectorOAuth other) { - return authorizeUrl.equals(other.authorizeUrl) && tokenUrl.equals(other.tokenUrl) && scope.equals(other.scope); + return clientId.equals(other.clientId) + && clientSecret.equals(other.clientSecret) + && authorizeUrl.equals(other.authorizeUrl) + && tokenUrl.equals(other.tokenUrl) + && scope.equals(other.scope); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.authorizeUrl, this.tokenUrl, this.scope); + return Objects.hash(this.clientId, this.clientSecret, this.authorizeUrl, this.tokenUrl, this.scope); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } - public static Builder builder() { + public static AuthorizeUrlStage builder() { return new Builder(); } + public interface AuthorizeUrlStage { + TokenUrlStage authorizeUrl(String authorizeUrl); + + Builder from(ConnectorOAuth other); + } + + public interface TokenUrlStage { + _FinalStage tokenUrl(String tokenUrl); + } + + public interface _FinalStage { + ConnectorOAuth build(); + + _FinalStage clientId(Optional clientId); + + _FinalStage clientId(String clientId); + + _FinalStage clientSecret(Optional clientSecret); + + _FinalStage clientSecret(String clientSecret); + + _FinalStage scope(Optional scope); + + _FinalStage scope(String scope); + } + @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional authorizeUrl = Optional.empty(); + public static final class Builder implements AuthorizeUrlStage, TokenUrlStage, _FinalStage { + private String authorizeUrl; - private Optional tokenUrl = Optional.empty(); + private String tokenUrl; private Optional scope = Optional.empty(); + private Optional clientSecret = Optional.empty(); + + private Optional clientId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} + @java.lang.Override public Builder from(ConnectorOAuth other) { + clientId(other.getClientId()); + clientSecret(other.getClientSecret()); authorizeUrl(other.getAuthorizeUrl()); tokenUrl(other.getTokenUrl()); scope(other.getScope()); return this; } - @JsonSetter(value = "authorizeUrl", nulls = Nulls.SKIP) - public Builder authorizeUrl(Optional authorizeUrl) { + /** + *

The OAuth 2.0 /authorize endpoint to use when users authorize the connector.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("authorize_url") + public TokenUrlStage authorizeUrl(String authorizeUrl) { this.authorizeUrl = authorizeUrl; return this; } - public Builder authorizeUrl(String authorizeUrl) { - this.authorizeUrl = Optional.of(authorizeUrl); - return this; - } - - @JsonSetter(value = "tokenUrl", nulls = Nulls.SKIP) - public Builder tokenUrl(Optional tokenUrl) { + /** + *

The OAuth 2.0 /token endpoint to use when users authorize the connector.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("token_url") + public _FinalStage tokenUrl(String tokenUrl) { this.tokenUrl = tokenUrl; return this; } - public Builder tokenUrl(String tokenUrl) { - this.tokenUrl = Optional.of(tokenUrl); + /** + *

The OAuth scopes to request when users authorize the connector.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage scope(String scope) { + this.scope = Optional.of(scope); return this; } + @java.lang.Override @JsonSetter(value = "scope", nulls = Nulls.SKIP) - public Builder scope(Optional scope) { + public _FinalStage scope(Optional scope) { this.scope = scope; return this; } - public Builder scope(String scope) { - this.scope = Optional.of(scope); + /** + *

The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage clientSecret(String clientSecret) { + this.clientSecret = Optional.of(clientSecret); + return this; + } + + @java.lang.Override + @JsonSetter(value = "client_secret", nulls = Nulls.SKIP) + public _FinalStage clientSecret(Optional clientSecret) { + this.clientSecret = clientSecret; + return this; + } + + /** + *

The OAuth 2.0 client ID. This field is encrypted at rest.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage clientId(String clientId) { + this.clientId = Optional.of(clientId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "client_id", nulls = Nulls.SKIP) + public _FinalStage clientId(Optional clientId) { + this.clientId = clientId; return this; } + @java.lang.Override public ConnectorOAuth build() { - return new ConnectorOAuth(authorizeUrl, tokenUrl, scope, additionalProperties); + return new ConnectorOAuth(clientId, clientSecret, authorizeUrl, tokenUrl, scope, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/CreateConnectorOAuth.java b/src/main/java/com/cohere/api/types/CreateConnectorOAuth.java index 4762e89..329eb3d 100644 --- a/src/main/java/com/cohere/api/types/CreateConnectorOAuth.java +++ b/src/main/java/com/cohere/api/types/CreateConnectorOAuth.java @@ -20,23 +20,23 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = CreateConnectorOAuth.Builder.class) public final class CreateConnectorOAuth { - private final String clientId; + private final Optional clientId; - private final String clientSecret; + private final Optional clientSecret; - private final String authorizeUrl; + private final Optional authorizeUrl; - private final String tokenUrl; + private final Optional tokenUrl; private final Optional scope; private final Map additionalProperties; private CreateConnectorOAuth( - String clientId, - String clientSecret, - String authorizeUrl, - String tokenUrl, + Optional clientId, + Optional clientSecret, + Optional authorizeUrl, + Optional tokenUrl, Optional scope, Map additionalProperties) { this.clientId = clientId; @@ -50,32 +50,32 @@ private CreateConnectorOAuth( /** * @return The OAuth 2.0 client ID. This fields is encrypted at rest. */ - @JsonProperty("clientId") - public String getClientId() { + @JsonProperty("client_id") + public Optional getClientId() { return clientId; } /** * @return The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response. */ - @JsonProperty("clientSecret") - public String getClientSecret() { + @JsonProperty("client_secret") + public Optional getClientSecret() { return clientSecret; } /** * @return The OAuth 2.0 /authorize endpoint to use when users authorize the connector. */ - @JsonProperty("authorizeUrl") - public String getAuthorizeUrl() { + @JsonProperty("authorize_url") + public Optional getAuthorizeUrl() { return authorizeUrl; } /** * @return The OAuth 2.0 /token endpoint to use when users authorize the connector. */ - @JsonProperty("tokenUrl") - public String getTokenUrl() { + @JsonProperty("token_url") + public Optional getTokenUrl() { return tokenUrl; } @@ -87,7 +87,7 @@ public Optional getScope() { return scope; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof CreateConnectorOAuth && equalTo((CreateConnectorOAuth) other); @@ -106,56 +106,29 @@ private boolean equalTo(CreateConnectorOAuth other) { && scope.equals(other.scope); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.clientId, this.clientSecret, this.authorizeUrl, this.tokenUrl, this.scope); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } - public static ClientIdStage builder() { + public static Builder builder() { return new Builder(); } - public interface ClientIdStage { - ClientSecretStage clientId(String clientId); - - Builder from(CreateConnectorOAuth other); - } - - public interface ClientSecretStage { - AuthorizeUrlStage clientSecret(String clientSecret); - } - - public interface AuthorizeUrlStage { - TokenUrlStage authorizeUrl(String authorizeUrl); - } - - public interface TokenUrlStage { - _FinalStage tokenUrl(String tokenUrl); - } - - public interface _FinalStage { - CreateConnectorOAuth build(); - - _FinalStage scope(Optional scope); - - _FinalStage scope(String scope); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements ClientIdStage, ClientSecretStage, AuthorizeUrlStage, TokenUrlStage, _FinalStage { - private String clientId; + public static final class Builder { + private Optional clientId = Optional.empty(); - private String clientSecret; + private Optional clientSecret = Optional.empty(); - private String authorizeUrl; + private Optional authorizeUrl = Optional.empty(); - private String tokenUrl; + private Optional tokenUrl = Optional.empty(); private Optional scope = Optional.empty(); @@ -164,7 +137,6 @@ public static final class Builder private Builder() {} - @Override public Builder from(CreateConnectorOAuth other) { clientId(other.getClientId()); clientSecret(other.getClientSecret()); @@ -174,68 +146,61 @@ public Builder from(CreateConnectorOAuth other) { return this; } - /** - *

The OAuth 2.0 client ID. This fields is encrypted at rest.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("clientId") - public ClientSecretStage clientId(String clientId) { + @JsonSetter(value = "client_id", nulls = Nulls.SKIP) + public Builder clientId(Optional clientId) { this.clientId = clientId; return this; } - /** - *

The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("clientSecret") - public AuthorizeUrlStage clientSecret(String clientSecret) { + public Builder clientId(String clientId) { + this.clientId = Optional.of(clientId); + return this; + } + + @JsonSetter(value = "client_secret", nulls = Nulls.SKIP) + public Builder clientSecret(Optional clientSecret) { this.clientSecret = clientSecret; return this; } - /** - *

The OAuth 2.0 /authorize endpoint to use when users authorize the connector.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("authorizeUrl") - public TokenUrlStage authorizeUrl(String authorizeUrl) { + public Builder clientSecret(String clientSecret) { + this.clientSecret = Optional.of(clientSecret); + return this; + } + + @JsonSetter(value = "authorize_url", nulls = Nulls.SKIP) + public Builder authorizeUrl(Optional authorizeUrl) { this.authorizeUrl = authorizeUrl; return this; } - /** - *

The OAuth 2.0 /token endpoint to use when users authorize the connector.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("tokenUrl") - public _FinalStage tokenUrl(String tokenUrl) { + public Builder authorizeUrl(String authorizeUrl) { + this.authorizeUrl = Optional.of(authorizeUrl); + return this; + } + + @JsonSetter(value = "token_url", nulls = Nulls.SKIP) + public Builder tokenUrl(Optional tokenUrl) { this.tokenUrl = tokenUrl; return this; } - /** - *

The OAuth scopes to request when users authorize the connector.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage scope(String scope) { - this.scope = Optional.of(scope); + public Builder tokenUrl(String tokenUrl) { + this.tokenUrl = Optional.of(tokenUrl); return this; } - @Override @JsonSetter(value = "scope", nulls = Nulls.SKIP) - public _FinalStage scope(Optional scope) { + public Builder scope(Optional scope) { this.scope = scope; return this; } - @Override + public Builder scope(String scope) { + this.scope = Optional.of(scope); + return this; + } + public CreateConnectorOAuth build() { return new CreateConnectorOAuth( clientId, clientSecret, authorizeUrl, tokenUrl, scope, additionalProperties); diff --git a/src/main/java/com/cohere/api/types/CreateResponse.java b/src/main/java/com/cohere/api/types/CreateConnectorResponse.java similarity index 72% rename from src/main/java/com/cohere/api/types/CreateResponse.java rename to src/main/java/com/cohere/api/types/CreateConnectorResponse.java index e00fdae..3766fbe 100644 --- a/src/main/java/com/cohere/api/types/CreateResponse.java +++ b/src/main/java/com/cohere/api/types/CreateConnectorResponse.java @@ -16,13 +16,13 @@ import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = CreateResponse.Builder.class) -public final class CreateResponse { +@JsonDeserialize(builder = CreateConnectorResponse.Builder.class) +public final class CreateConnectorResponse { private final Connector connector; private final Map additionalProperties; - private CreateResponse(Connector connector, Map additionalProperties) { + private CreateConnectorResponse(Connector connector, Map additionalProperties) { this.connector = connector; this.additionalProperties = additionalProperties; } @@ -32,10 +32,10 @@ public Connector getConnector() { return connector; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof CreateResponse && equalTo((CreateResponse) other); + return other instanceof CreateConnectorResponse && equalTo((CreateConnectorResponse) other); } @JsonAnyGetter @@ -43,16 +43,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(CreateResponse other) { + private boolean equalTo(CreateConnectorResponse other) { return connector.equals(other.connector); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.connector); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -64,11 +64,11 @@ public static ConnectorStage builder() { public interface ConnectorStage { _FinalStage connector(Connector connector); - Builder from(CreateResponse other); + Builder from(CreateConnectorResponse other); } public interface _FinalStage { - CreateResponse build(); + CreateConnectorResponse build(); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -80,22 +80,22 @@ public static final class Builder implements ConnectorStage, _FinalStage { private Builder() {} - @Override - public Builder from(CreateResponse other) { + @java.lang.Override + public Builder from(CreateConnectorResponse other) { connector(other.getConnector()); return this; } - @Override + @java.lang.Override @JsonSetter("connector") public _FinalStage connector(Connector connector) { this.connector = connector; return this; } - @Override - public CreateResponse build() { - return new CreateResponse(connector, additionalProperties); + @java.lang.Override + public CreateConnectorResponse build() { + return new CreateConnectorResponse(connector, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/CreateConnectorServiceAuth.java b/src/main/java/com/cohere/api/types/CreateConnectorServiceAuth.java index 58d7068..6c91370 100644 --- a/src/main/java/com/cohere/api/types/CreateConnectorServiceAuth.java +++ b/src/main/java/com/cohere/api/types/CreateConnectorServiceAuth.java @@ -18,23 +18,20 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonDeserialize(builder = CreateConnectorServiceAuth.Builder.class) public final class CreateConnectorServiceAuth { - private final String type; + private final AuthTokenType type; private final String token; private final Map additionalProperties; - private CreateConnectorServiceAuth(String type, String token, Map additionalProperties) { + private CreateConnectorServiceAuth(AuthTokenType type, String token, Map additionalProperties) { this.type = type; this.token = token; this.additionalProperties = additionalProperties; } - /** - * @return The token_type specifies the way the token is passed in the Authorization header. Valid values are "bearer", "basic", and "noscheme". - */ @JsonProperty("type") - public String getType() { + public AuthTokenType getType() { return type; } @@ -46,7 +43,7 @@ public String getToken() { return token; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof CreateConnectorServiceAuth && equalTo((CreateConnectorServiceAuth) other); @@ -61,12 +58,12 @@ private boolean equalTo(CreateConnectorServiceAuth other) { return type.equals(other.type) && token.equals(other.token); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.type, this.token); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -76,7 +73,7 @@ public static TypeStage builder() { } public interface TypeStage { - TokenStage type(String type); + TokenStage type(AuthTokenType type); Builder from(CreateConnectorServiceAuth other); } @@ -91,7 +88,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements TypeStage, TokenStage, _FinalStage { - private String type; + private AuthTokenType type; private String token; @@ -100,20 +97,16 @@ public static final class Builder implements TypeStage, TokenStage, _FinalStage private Builder() {} - @Override + @java.lang.Override public Builder from(CreateConnectorServiceAuth other) { type(other.getType()); token(other.getToken()); return this; } - /** - *

The token_type specifies the way the token is passed in the Authorization header. Valid values are "bearer", "basic", and "noscheme".

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override + @java.lang.Override @JsonSetter("type") - public TokenStage type(String type) { + public TokenStage type(AuthTokenType type) { this.type = type; return this; } @@ -122,14 +115,14 @@ public TokenStage type(String type) { *

The token that will be used in the HTTP Authorization header when making requests to the connector. This field is encrypted at rest and never returned in a response.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("token") public _FinalStage token(String token) { this.token = token; return this; } - @Override + @java.lang.Override public CreateConnectorServiceAuth build() { return new CreateConnectorServiceAuth(type, token, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/DetectLanguageResponse.java b/src/main/java/com/cohere/api/types/CreateEmbedJobResponse.java similarity index 52% rename from src/main/java/com/cohere/api/types/DetectLanguageResponse.java rename to src/main/java/com/cohere/api/types/CreateEmbedJobResponse.java index 90af909..ce919ca 100644 --- a/src/main/java/com/cohere/api/types/DetectLanguageResponse.java +++ b/src/main/java/com/cohere/api/types/CreateEmbedJobResponse.java @@ -13,35 +13,28 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = DetectLanguageResponse.Builder.class) -public final class DetectLanguageResponse { - private final Optional> results; +@JsonDeserialize(builder = CreateEmbedJobResponse.Builder.class) +public final class CreateEmbedJobResponse { + private final String jobId; private final Optional meta; private final Map additionalProperties; - private DetectLanguageResponse( - Optional> results, - Optional meta, - Map additionalProperties) { - this.results = results; + private CreateEmbedJobResponse(String jobId, Optional meta, Map additionalProperties) { + this.jobId = jobId; this.meta = meta; this.additionalProperties = additionalProperties; } - /** - * @return List of languages, one per input text - */ - @JsonProperty("results") - public Optional> getResults() { - return results; + @JsonProperty("job_id") + public String getJobId() { + return jobId; } @JsonProperty("meta") @@ -49,10 +42,10 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof DetectLanguageResponse && equalTo((DetectLanguageResponse) other); + return other instanceof CreateEmbedJobResponse && equalTo((CreateEmbedJobResponse) other); } @JsonAnyGetter @@ -60,27 +53,41 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(DetectLanguageResponse other) { - return results.equals(other.results) && meta.equals(other.meta); + private boolean equalTo(CreateEmbedJobResponse other) { + return jobId.equals(other.jobId) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.results, this.meta); + return Objects.hash(this.jobId, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } - public static Builder builder() { + public static JobIdStage builder() { return new Builder(); } + public interface JobIdStage { + _FinalStage jobId(String jobId); + + Builder from(CreateEmbedJobResponse other); + } + + public interface _FinalStage { + CreateEmbedJobResponse build(); + + _FinalStage meta(Optional meta); + + _FinalStage meta(ApiMeta meta); + } + @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> results = Optional.empty(); + public static final class Builder implements JobIdStage, _FinalStage { + private String jobId; private Optional meta = Optional.empty(); @@ -89,36 +96,36 @@ public static final class Builder { private Builder() {} - public Builder from(DetectLanguageResponse other) { - results(other.getResults()); + @java.lang.Override + public Builder from(CreateEmbedJobResponse other) { + jobId(other.getJobId()); meta(other.getMeta()); return this; } - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public Builder results(Optional> results) { - this.results = results; + @java.lang.Override + @JsonSetter("job_id") + public _FinalStage jobId(String jobId) { + this.jobId = jobId; return this; } - public Builder results(List results) { - this.results = Optional.of(results); + @java.lang.Override + public _FinalStage meta(ApiMeta meta) { + this.meta = Optional.of(meta); return this; } + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) - public Builder meta(Optional meta) { + public _FinalStage meta(Optional meta) { this.meta = meta; return this; } - public Builder meta(ApiMeta meta) { - this.meta = Optional.of(meta); - return this; - } - - public DetectLanguageResponse build() { - return new DetectLanguageResponse(results, meta, additionalProperties); + @java.lang.Override + public CreateEmbedJobResponse build() { + return new CreateEmbedJobResponse(jobId, meta, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/Dataset.java b/src/main/java/com/cohere/api/types/Dataset.java new file mode 100644 index 0000000..7c6652a --- /dev/null +++ b/src/main/java/com/cohere/api/types/Dataset.java @@ -0,0 +1,495 @@ +/** + * 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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = Dataset.Builder.class) +public final class Dataset { + private final String id; + + private final String name; + + private final OffsetDateTime createdAt; + + private final OffsetDateTime updatedAt; + + private final DatasetType datasetType; + + private final DatasetValidationStatus validationStatus; + + private final Optional validationError; + + private final Optional schema; + + private final Optional> requiredFields; + + private final Optional> preserveFields; + + private final Optional> datasetParts; + + private final Optional> validationWarnings; + + private final Map additionalProperties; + + private Dataset( + String id, + String name, + OffsetDateTime createdAt, + OffsetDateTime updatedAt, + DatasetType datasetType, + DatasetValidationStatus validationStatus, + Optional validationError, + Optional schema, + Optional> requiredFields, + Optional> preserveFields, + Optional> datasetParts, + Optional> validationWarnings, + Map additionalProperties) { + this.id = id; + this.name = name; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.datasetType = datasetType; + this.validationStatus = validationStatus; + this.validationError = validationError; + this.schema = schema; + this.requiredFields = requiredFields; + this.preserveFields = preserveFields; + this.datasetParts = datasetParts; + this.validationWarnings = validationWarnings; + this.additionalProperties = additionalProperties; + } + + /** + * @return The dataset ID + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the dataset + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The creation date + */ + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * @return The last update date + */ + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("dataset_type") + public DatasetType getDatasetType() { + return datasetType; + } + + @JsonProperty("validation_status") + public DatasetValidationStatus getValidationStatus() { + return validationStatus; + } + + /** + * @return Errors found during validation + */ + @JsonProperty("validation_error") + public Optional getValidationError() { + return validationError; + } + + /** + * @return the avro schema of the dataset + */ + @JsonProperty("schema") + public Optional getSchema() { + return schema; + } + + @JsonProperty("required_fields") + public Optional> getRequiredFields() { + return requiredFields; + } + + @JsonProperty("preserve_fields") + public Optional> getPreserveFields() { + return preserveFields; + } + + /** + * @return the underlying files that make up the dataset + */ + @JsonProperty("dataset_parts") + public Optional> getDatasetParts() { + return datasetParts; + } + + /** + * @return warnings found during validation + */ + @JsonProperty("validation_warnings") + public Optional> getValidationWarnings() { + return validationWarnings; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Dataset && equalTo((Dataset) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Dataset other) { + return id.equals(other.id) + && name.equals(other.name) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && datasetType.equals(other.datasetType) + && validationStatus.equals(other.validationStatus) + && validationError.equals(other.validationError) + && schema.equals(other.schema) + && requiredFields.equals(other.requiredFields) + && preserveFields.equals(other.preserveFields) + && datasetParts.equals(other.datasetParts) + && validationWarnings.equals(other.validationWarnings); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.name, + this.createdAt, + this.updatedAt, + this.datasetType, + this.validationStatus, + this.validationError, + this.schema, + this.requiredFields, + this.preserveFields, + this.datasetParts, + this.validationWarnings); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(String id); + + Builder from(Dataset other); + } + + public interface NameStage { + CreatedAtStage name(String name); + } + + public interface CreatedAtStage { + UpdatedAtStage createdAt(OffsetDateTime createdAt); + } + + public interface UpdatedAtStage { + DatasetTypeStage updatedAt(OffsetDateTime updatedAt); + } + + public interface DatasetTypeStage { + ValidationStatusStage datasetType(DatasetType datasetType); + } + + public interface ValidationStatusStage { + _FinalStage validationStatus(DatasetValidationStatus validationStatus); + } + + public interface _FinalStage { + Dataset build(); + + _FinalStage validationError(Optional validationError); + + _FinalStage validationError(String validationError); + + _FinalStage schema(Optional schema); + + _FinalStage schema(String schema); + + _FinalStage requiredFields(Optional> requiredFields); + + _FinalStage requiredFields(List requiredFields); + + _FinalStage preserveFields(Optional> preserveFields); + + _FinalStage preserveFields(List preserveFields); + + _FinalStage datasetParts(Optional> datasetParts); + + _FinalStage datasetParts(List datasetParts); + + _FinalStage validationWarnings(Optional> validationWarnings); + + _FinalStage validationWarnings(List validationWarnings); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + NameStage, + CreatedAtStage, + UpdatedAtStage, + DatasetTypeStage, + ValidationStatusStage, + _FinalStage { + private String id; + + private String name; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + private DatasetType datasetType; + + private DatasetValidationStatus validationStatus; + + private Optional> validationWarnings = Optional.empty(); + + private Optional> datasetParts = Optional.empty(); + + private Optional> preserveFields = Optional.empty(); + + private Optional> requiredFields = Optional.empty(); + + private Optional schema = Optional.empty(); + + private Optional validationError = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Dataset other) { + id(other.getId()); + name(other.getName()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + datasetType(other.getDatasetType()); + validationStatus(other.getValidationStatus()); + validationError(other.getValidationError()); + schema(other.getSchema()); + requiredFields(other.getRequiredFields()); + preserveFields(other.getPreserveFields()); + datasetParts(other.getDatasetParts()); + validationWarnings(other.getValidationWarnings()); + return this; + } + + /** + *

The dataset ID

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public NameStage id(String id) { + this.id = id; + return this; + } + + /** + *

The name of the dataset

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public CreatedAtStage name(String name) { + this.name = name; + return this; + } + + /** + *

The creation date

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public UpdatedAtStage createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

The last update date

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public DatasetTypeStage updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + @JsonSetter("dataset_type") + public ValidationStatusStage datasetType(DatasetType datasetType) { + this.datasetType = datasetType; + return this; + } + + @java.lang.Override + @JsonSetter("validation_status") + public _FinalStage validationStatus(DatasetValidationStatus validationStatus) { + this.validationStatus = validationStatus; + return this; + } + + /** + *

warnings found during validation

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage validationWarnings(List validationWarnings) { + this.validationWarnings = Optional.of(validationWarnings); + return this; + } + + @java.lang.Override + @JsonSetter(value = "validation_warnings", nulls = Nulls.SKIP) + public _FinalStage validationWarnings(Optional> validationWarnings) { + this.validationWarnings = validationWarnings; + return this; + } + + /** + *

the underlying files that make up the dataset

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage datasetParts(List datasetParts) { + this.datasetParts = Optional.of(datasetParts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "dataset_parts", nulls = Nulls.SKIP) + public _FinalStage datasetParts(Optional> datasetParts) { + this.datasetParts = datasetParts; + return this; + } + + @java.lang.Override + public _FinalStage preserveFields(List preserveFields) { + this.preserveFields = Optional.of(preserveFields); + return this; + } + + @java.lang.Override + @JsonSetter(value = "preserve_fields", nulls = Nulls.SKIP) + public _FinalStage preserveFields(Optional> preserveFields) { + this.preserveFields = preserveFields; + return this; + } + + @java.lang.Override + public _FinalStage requiredFields(List requiredFields) { + this.requiredFields = Optional.of(requiredFields); + return this; + } + + @java.lang.Override + @JsonSetter(value = "required_fields", nulls = Nulls.SKIP) + public _FinalStage requiredFields(Optional> requiredFields) { + this.requiredFields = requiredFields; + return this; + } + + /** + *

the avro schema of the dataset

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage schema(String schema) { + this.schema = Optional.of(schema); + return this; + } + + @java.lang.Override + @JsonSetter(value = "schema", nulls = Nulls.SKIP) + public _FinalStage schema(Optional schema) { + this.schema = schema; + return this; + } + + /** + *

Errors found during validation

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage validationError(String validationError) { + this.validationError = Optional.of(validationError); + return this; + } + + @java.lang.Override + @JsonSetter(value = "validation_error", nulls = Nulls.SKIP) + public _FinalStage validationError(Optional validationError) { + this.validationError = validationError; + return this; + } + + @java.lang.Override + public Dataset build() { + return new Dataset( + id, + name, + createdAt, + updatedAt, + datasetType, + validationStatus, + validationError, + schema, + requiredFields, + preserveFields, + datasetParts, + validationWarnings, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/DatasetPart.java b/src/main/java/com/cohere/api/types/DatasetPart.java new file mode 100644 index 0000000..fd06846 --- /dev/null +++ b/src/main/java/com/cohere/api/types/DatasetPart.java @@ -0,0 +1,328 @@ +/** + * 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 = DatasetPart.Builder.class) +public final class DatasetPart { + private final String id; + + private final String name; + + private final Optional url; + + private final Optional index; + + private final Optional sizeBytes; + + private final Optional numRows; + + private final Optional originalUrl; + + private final Map additionalProperties; + + private DatasetPart( + String id, + String name, + Optional url, + Optional index, + Optional sizeBytes, + Optional numRows, + Optional originalUrl, + Map additionalProperties) { + this.id = id; + this.name = name; + this.url = url; + this.index = index; + this.sizeBytes = sizeBytes; + this.numRows = numRows; + this.originalUrl = originalUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The dataset part ID + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The name of the dataset part + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The download url of the file + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The index of the file + */ + @JsonProperty("index") + public Optional getIndex() { + return index; + } + + /** + * @return The size of the file in bytes + */ + @JsonProperty("size_bytes") + public Optional getSizeBytes() { + return sizeBytes; + } + + /** + * @return The number of rows in the file + */ + @JsonProperty("num_rows") + public Optional getNumRows() { + return numRows; + } + + /** + * @return The download url of the original file + */ + @JsonProperty("original_url") + public Optional getOriginalUrl() { + return originalUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DatasetPart && equalTo((DatasetPart) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DatasetPart other) { + return id.equals(other.id) + && name.equals(other.name) + && url.equals(other.url) + && index.equals(other.index) + && sizeBytes.equals(other.sizeBytes) + && numRows.equals(other.numRows) + && originalUrl.equals(other.originalUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.url, this.index, this.sizeBytes, this.numRows, this.originalUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(String id); + + Builder from(DatasetPart other); + } + + public interface NameStage { + _FinalStage name(String name); + } + + public interface _FinalStage { + DatasetPart build(); + + _FinalStage url(Optional url); + + _FinalStage url(String url); + + _FinalStage index(Optional index); + + _FinalStage index(Integer index); + + _FinalStage sizeBytes(Optional sizeBytes); + + _FinalStage sizeBytes(Integer sizeBytes); + + _FinalStage numRows(Optional numRows); + + _FinalStage numRows(Integer numRows); + + _FinalStage originalUrl(Optional originalUrl); + + _FinalStage originalUrl(String originalUrl); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, _FinalStage { + private String id; + + private String name; + + private Optional originalUrl = Optional.empty(); + + private Optional numRows = Optional.empty(); + + private Optional sizeBytes = Optional.empty(); + + private Optional index = Optional.empty(); + + private Optional url = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DatasetPart other) { + id(other.getId()); + name(other.getName()); + url(other.getUrl()); + index(other.getIndex()); + sizeBytes(other.getSizeBytes()); + numRows(other.getNumRows()); + originalUrl(other.getOriginalUrl()); + return this; + } + + /** + *

The dataset part ID

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public NameStage id(String id) { + this.id = id; + return this; + } + + /** + *

The name of the dataset part

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(String name) { + this.name = name; + return this; + } + + /** + *

The download url of the original file

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage originalUrl(String originalUrl) { + this.originalUrl = Optional.of(originalUrl); + return this; + } + + @java.lang.Override + @JsonSetter(value = "original_url", nulls = Nulls.SKIP) + public _FinalStage originalUrl(Optional originalUrl) { + this.originalUrl = originalUrl; + return this; + } + + /** + *

The number of rows in the file

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage numRows(Integer numRows) { + this.numRows = Optional.of(numRows); + return this; + } + + @java.lang.Override + @JsonSetter(value = "num_rows", nulls = Nulls.SKIP) + public _FinalStage numRows(Optional numRows) { + this.numRows = numRows; + return this; + } + + /** + *

The size of the file in bytes

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage sizeBytes(Integer sizeBytes) { + this.sizeBytes = Optional.of(sizeBytes); + return this; + } + + @java.lang.Override + @JsonSetter(value = "size_bytes", nulls = Nulls.SKIP) + public _FinalStage sizeBytes(Optional sizeBytes) { + this.sizeBytes = sizeBytes; + return this; + } + + /** + *

The index of the file

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage index(Integer index) { + this.index = Optional.of(index); + return this; + } + + @java.lang.Override + @JsonSetter(value = "index", nulls = Nulls.SKIP) + public _FinalStage index(Optional index) { + this.index = index; + return this; + } + + /** + *

The download url of the file

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage url(String url) { + this.url = Optional.of(url); + return this; + } + + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + @java.lang.Override + public DatasetPart build() { + return new DatasetPart(id, name, url, index, sizeBytes, numRows, originalUrl, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/DatasetType.java b/src/main/java/com/cohere/api/types/DatasetType.java new file mode 100644 index 0000000..7cf2beb --- /dev/null +++ b/src/main/java/com/cohere/api/types/DatasetType.java @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DatasetType { + EMBED_INPUT("embed-input"), + + EMBED_RESULT("embed-result"), + + CLUSTER_RESULT("cluster-result"), + + CLUSTER_OUTLIERS("cluster-outliers"), + + RERANKER_FINETUNE_INPUT("reranker-finetune-input"), + + PROMPT_COMPLETION_FINETUNE_INPUT("prompt-completion-finetune-input"), + + SINGLE_LABEL_CLASSIFICATION_FINETUNE_INPUT("single-label-classification-finetune-input"), + + CHAT_FINETUNE_INPUT("chat-finetune-input"), + + MULTI_LABEL_CLASSIFICATION_FINETUNE_INPUT("multi-label-classification-finetune-input"); + + private final String value; + + DatasetType(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/DatasetValidationStatus.java b/src/main/java/com/cohere/api/types/DatasetValidationStatus.java new file mode 100644 index 0000000..5b041aa --- /dev/null +++ b/src/main/java/com/cohere/api/types/DatasetValidationStatus.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DatasetValidationStatus { + UNKNOWN("unknown"), + + QUEUED("queued"), + + PROCESSING("processing"), + + FAILED("failed"), + + VALIDATED("validated"), + + SKIPPED("skipped"); + + private final String value; + + DatasetValidationStatus(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/DetectLanguageResponseResultsItem.java b/src/main/java/com/cohere/api/types/DetectLanguageResponseResultsItem.java deleted file mode 100644 index e204466..0000000 --- a/src/main/java/com/cohere/api/types/DetectLanguageResponseResultsItem.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * 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 = DetectLanguageResponseResultsItem.Builder.class) -public final class DetectLanguageResponseResultsItem { - private final Optional languageName; - - private final Optional languageCode; - - private final Map additionalProperties; - - private DetectLanguageResponseResultsItem( - Optional languageName, Optional languageCode, Map additionalProperties) { - this.languageName = languageName; - this.languageCode = languageCode; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("language_name") - public Optional getLanguageName() { - return languageName; - } - - @JsonProperty("language_code") - public Optional getLanguageCode() { - return languageCode; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DetectLanguageResponseResultsItem && equalTo((DetectLanguageResponseResultsItem) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DetectLanguageResponseResultsItem other) { - return languageName.equals(other.languageName) && languageCode.equals(other.languageCode); - } - - @Override - public int hashCode() { - return Objects.hash(this.languageName, this.languageCode); - } - - @Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional languageName = Optional.empty(); - - private Optional languageCode = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(DetectLanguageResponseResultsItem other) { - languageName(other.getLanguageName()); - languageCode(other.getLanguageCode()); - return this; - } - - @JsonSetter(value = "language_name", nulls = Nulls.SKIP) - public Builder languageName(Optional languageName) { - this.languageName = languageName; - return this; - } - - public Builder languageName(String languageName) { - this.languageName = Optional.of(languageName); - return this; - } - - @JsonSetter(value = "language_code", nulls = Nulls.SKIP) - public Builder languageCode(Optional languageCode) { - this.languageCode = languageCode; - return this; - } - - public Builder languageCode(String languageCode) { - this.languageCode = Optional.of(languageCode); - return this; - } - - public DetectLanguageResponseResultsItem build() { - return new DetectLanguageResponseResultsItem(languageName, languageCode, additionalProperties); - } - } -} diff --git a/src/main/java/com/cohere/api/types/DetokenizeResponse.java b/src/main/java/com/cohere/api/types/DetokenizeResponse.java index 3b36745..80273f4 100644 --- a/src/main/java/com/cohere/api/types/DetokenizeResponse.java +++ b/src/main/java/com/cohere/api/types/DetokenizeResponse.java @@ -45,7 +45,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof DetokenizeResponse && equalTo((DetokenizeResponse) other); @@ -60,12 +60,12 @@ private boolean equalTo(DetokenizeResponse other) { return text.equals(other.text) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -99,7 +99,7 @@ public static final class Builder implements TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(DetokenizeResponse other) { text(other.getText()); meta(other.getMeta()); @@ -110,27 +110,27 @@ public Builder from(DetokenizeResponse other) { *

A string representing the list of tokens.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; return this; } - @Override + @java.lang.Override public _FinalStage meta(ApiMeta meta) { this.meta = Optional.of(meta); return this; } - @Override + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Optional meta) { this.meta = meta; return this; } - @Override + @java.lang.Override public DetokenizeResponse build() { return new DetokenizeResponse(text, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/EmbedByTypeResponse.java b/src/main/java/com/cohere/api/types/EmbedByTypeResponse.java index 79ea844..8dee976 100644 --- a/src/main/java/com/cohere/api/types/EmbedByTypeResponse.java +++ b/src/main/java/com/cohere/api/types/EmbedByTypeResponse.java @@ -71,7 +71,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbedByTypeResponse && equalTo((EmbedByTypeResponse) other); @@ -89,12 +89,12 @@ private boolean equalTo(EmbedByTypeResponse other) { && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.embeddings, this.texts, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -142,7 +142,7 @@ public static final class Builder implements IdStage, EmbeddingsStage, _FinalSta private Builder() {} - @Override + @java.lang.Override public Builder from(EmbedByTypeResponse other) { id(other.getId()); embeddings(other.getEmbeddings()); @@ -151,7 +151,7 @@ public Builder from(EmbedByTypeResponse other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public EmbeddingsStage id(String id) { this.id = id; @@ -162,20 +162,20 @@ public EmbeddingsStage id(String id) { *

An object with different embedding types. The length of each embedding type array will be the same as the length of the original texts array.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("embeddings") public _FinalStage embeddings(EmbedByTypeResponseEmbeddings embeddings) { this.embeddings = embeddings; return this; } - @Override + @java.lang.Override public _FinalStage meta(ApiMeta meta) { this.meta = Optional.of(meta); return this; } - @Override + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Optional meta) { this.meta = meta; @@ -186,7 +186,7 @@ public _FinalStage meta(Optional meta) { *

The text entries for which embeddings were returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllTexts(List texts) { this.texts.addAll(texts); return this; @@ -196,13 +196,13 @@ public _FinalStage addAllTexts(List texts) { *

The text entries for which embeddings were returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addTexts(String texts) { this.texts.add(texts); return this; } - @Override + @java.lang.Override @JsonSetter(value = "texts", nulls = Nulls.SKIP) public _FinalStage texts(List texts) { this.texts.clear(); @@ -210,7 +210,7 @@ public _FinalStage texts(List texts) { return this; } - @Override + @java.lang.Override public EmbedByTypeResponse build() { return new EmbedByTypeResponse(id, embeddings, texts, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java b/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java index 566a0f2..6ba639c 100644 --- a/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java +++ b/src/main/java/com/cohere/api/types/EmbedByTypeResponseEmbeddings.java @@ -23,22 +23,22 @@ public final class EmbedByTypeResponseEmbeddings { private final Optional>> float_; - private final Optional>> int8; + private final Optional>> int8; - private final Optional>> uint8; + private final Optional>> uint8; - private final Optional>> binary; + private final Optional>> binary; - private final Optional>> ubinary; + private final Optional>> ubinary; private final Map additionalProperties; private EmbedByTypeResponseEmbeddings( Optional>> float_, - Optional>> int8, - Optional>> uint8, - Optional>> binary, - Optional>> ubinary, + Optional>> int8, + Optional>> uint8, + Optional>> binary, + Optional>> ubinary, Map additionalProperties) { this.float_ = float_; this.int8 = int8; @@ -60,7 +60,7 @@ public Optional>> getFloat() { * @return An array of signed int8 embeddings. Each value is between -128 and 127. */ @JsonProperty("int8") - public Optional>> getInt8() { + public Optional>> getInt8() { return int8; } @@ -68,7 +68,7 @@ public Optional>> getInt8() { * @return An array of unsigned int8 embeddings. Each value is between 0 and 255. */ @JsonProperty("uint8") - public Optional>> getUint8() { + public Optional>> getUint8() { return uint8; } @@ -76,7 +76,7 @@ public Optional>> getUint8() { * @return An array of packed signed binary embeddings. The length of each binary embedding is 1/8 the length of the float embeddings of the provided model. Each value is between -128 and 127. */ @JsonProperty("binary") - public Optional>> getBinary() { + public Optional>> getBinary() { return binary; } @@ -84,11 +84,11 @@ public Optional>> getBinary() { * @return An array of packed unsigned binary embeddings. The length of each binary embedding is 1/8 the length of the float embeddings of the provided model. Each value is between 0 and 255. */ @JsonProperty("ubinary") - public Optional>> getUbinary() { + public Optional>> getUbinary() { return ubinary; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbedByTypeResponseEmbeddings && equalTo((EmbedByTypeResponseEmbeddings) other); @@ -107,12 +107,12 @@ private boolean equalTo(EmbedByTypeResponseEmbeddings other) { && ubinary.equals(other.ubinary); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.float_, this.int8, this.uint8, this.binary, this.ubinary); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -125,13 +125,13 @@ public static Builder builder() { public static final class Builder { private Optional>> float_ = Optional.empty(); - private Optional>> int8 = Optional.empty(); + private Optional>> int8 = Optional.empty(); - private Optional>> uint8 = Optional.empty(); + private Optional>> uint8 = Optional.empty(); - private Optional>> binary = Optional.empty(); + private Optional>> binary = Optional.empty(); - private Optional>> ubinary = Optional.empty(); + private Optional>> ubinary = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -159,45 +159,45 @@ public Builder float_(List> float_) { } @JsonSetter(value = "int8", nulls = Nulls.SKIP) - public Builder int8(Optional>> int8) { + public Builder int8(Optional>> int8) { this.int8 = int8; return this; } - public Builder int8(List> int8) { + public Builder int8(List> int8) { this.int8 = Optional.of(int8); return this; } @JsonSetter(value = "uint8", nulls = Nulls.SKIP) - public Builder uint8(Optional>> uint8) { + public Builder uint8(Optional>> uint8) { this.uint8 = uint8; return this; } - public Builder uint8(List> uint8) { + public Builder uint8(List> uint8) { this.uint8 = Optional.of(uint8); return this; } @JsonSetter(value = "binary", nulls = Nulls.SKIP) - public Builder binary(Optional>> binary) { + public Builder binary(Optional>> binary) { this.binary = binary; return this; } - public Builder binary(List> binary) { + public Builder binary(List> binary) { this.binary = Optional.of(binary); return this; } @JsonSetter(value = "ubinary", nulls = Nulls.SKIP) - public Builder ubinary(Optional>> ubinary) { + public Builder ubinary(Optional>> ubinary) { this.ubinary = ubinary; return this; } - public Builder ubinary(List> ubinary) { + public Builder ubinary(List> ubinary) { this.ubinary = Optional.of(ubinary); return this; } diff --git a/src/main/java/com/cohere/api/types/EmbedFloatsResponse.java b/src/main/java/com/cohere/api/types/EmbedFloatsResponse.java index 7f3970d..8969319 100644 --- a/src/main/java/com/cohere/api/types/EmbedFloatsResponse.java +++ b/src/main/java/com/cohere/api/types/EmbedFloatsResponse.java @@ -71,7 +71,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbedFloatsResponse && equalTo((EmbedFloatsResponse) other); @@ -89,12 +89,12 @@ private boolean equalTo(EmbedFloatsResponse other) { && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.embeddings, this.texts, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -144,7 +144,7 @@ public static final class Builder implements IdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(EmbedFloatsResponse other) { id(other.getId()); embeddings(other.getEmbeddings()); @@ -153,20 +153,20 @@ public Builder from(EmbedFloatsResponse other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public _FinalStage id(String id) { this.id = id; return this; } - @Override + @java.lang.Override public _FinalStage meta(ApiMeta meta) { this.meta = Optional.of(meta); return this; } - @Override + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Optional meta) { this.meta = meta; @@ -177,7 +177,7 @@ public _FinalStage meta(Optional meta) { *

The text entries for which embeddings were returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllTexts(List texts) { this.texts.addAll(texts); return this; @@ -187,13 +187,13 @@ public _FinalStage addAllTexts(List texts) { *

The text entries for which embeddings were returned.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addTexts(String texts) { this.texts.add(texts); return this; } - @Override + @java.lang.Override @JsonSetter(value = "texts", nulls = Nulls.SKIP) public _FinalStage texts(List texts) { this.texts.clear(); @@ -205,7 +205,7 @@ public _FinalStage texts(List texts) { *

An array of embeddings, where each embedding is an array of floats. The length of the embeddings array will be the same as the length of the original texts array.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllEmbeddings(List> embeddings) { this.embeddings.addAll(embeddings); return this; @@ -215,13 +215,13 @@ public _FinalStage addAllEmbeddings(List> embeddings) { *

An array of embeddings, where each embedding is an array of floats. The length of the embeddings array will be the same as the length of the original texts array.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addEmbeddings(List embeddings) { this.embeddings.add(embeddings); return this; } - @Override + @java.lang.Override @JsonSetter(value = "embeddings", nulls = Nulls.SKIP) public _FinalStage embeddings(List> embeddings) { this.embeddings.clear(); @@ -229,7 +229,7 @@ public _FinalStage embeddings(List> embeddings) { return this; } - @Override + @java.lang.Override public EmbedFloatsResponse build() { return new EmbedFloatsResponse(id, embeddings, texts, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/EmbedInputType.java b/src/main/java/com/cohere/api/types/EmbedInputType.java new file mode 100644 index 0000000..0e507cf --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbedInputType.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmbedInputType { + SEARCH_DOCUMENT("search_document"), + + SEARCH_QUERY("search_query"), + + CLASSIFICATION("classification"), + + CLUSTERING("clustering"); + + private final String value; + + EmbedInputType(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedJob.java b/src/main/java/com/cohere/api/types/EmbedJob.java new file mode 100644 index 0000000..8e17be9 --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbedJob.java @@ -0,0 +1,398 @@ +/** + * 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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = EmbedJob.Builder.class) +public final class EmbedJob { + private final String jobId; + + private final Optional name; + + private final EmbedJobStatus status; + + private final OffsetDateTime createdAt; + + private final String inputDatasetId; + + private final Optional outputDatasetId; + + private final String model; + + private final EmbedJobTruncate truncate; + + private final Optional meta; + + private final Map additionalProperties; + + private EmbedJob( + String jobId, + Optional name, + EmbedJobStatus status, + OffsetDateTime createdAt, + String inputDatasetId, + Optional outputDatasetId, + String model, + EmbedJobTruncate truncate, + Optional meta, + Map additionalProperties) { + this.jobId = jobId; + this.name = name; + this.status = status; + this.createdAt = createdAt; + this.inputDatasetId = inputDatasetId; + this.outputDatasetId = outputDatasetId; + this.model = model; + this.truncate = truncate; + this.meta = meta; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the embed job + */ + @JsonProperty("job_id") + public String getJobId() { + return jobId; + } + + /** + * @return The name of the embed job + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The status of the embed job + */ + @JsonProperty("status") + public EmbedJobStatus getStatus() { + return status; + } + + /** + * @return The creation date of the embed job + */ + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * @return ID of the input dataset + */ + @JsonProperty("input_dataset_id") + public String getInputDatasetId() { + return inputDatasetId; + } + + /** + * @return ID of the resulting output dataset + */ + @JsonProperty("output_dataset_id") + public Optional getOutputDatasetId() { + return outputDatasetId; + } + + /** + * @return ID of the model used to embed + */ + @JsonProperty("model") + public String getModel() { + return model; + } + + /** + * @return The truncation option used + */ + @JsonProperty("truncate") + public EmbedJobTruncate getTruncate() { + return truncate; + } + + @JsonProperty("meta") + public Optional getMeta() { + return meta; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EmbedJob && equalTo((EmbedJob) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EmbedJob other) { + return jobId.equals(other.jobId) + && name.equals(other.name) + && status.equals(other.status) + && createdAt.equals(other.createdAt) + && inputDatasetId.equals(other.inputDatasetId) + && outputDatasetId.equals(other.outputDatasetId) + && model.equals(other.model) + && truncate.equals(other.truncate) + && meta.equals(other.meta); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.jobId, + this.name, + this.status, + this.createdAt, + this.inputDatasetId, + this.outputDatasetId, + this.model, + this.truncate, + this.meta); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdStage builder() { + return new Builder(); + } + + public interface JobIdStage { + StatusStage jobId(String jobId); + + Builder from(EmbedJob other); + } + + public interface StatusStage { + CreatedAtStage status(EmbedJobStatus status); + } + + public interface CreatedAtStage { + InputDatasetIdStage createdAt(OffsetDateTime createdAt); + } + + public interface InputDatasetIdStage { + ModelStage inputDatasetId(String inputDatasetId); + } + + public interface ModelStage { + TruncateStage model(String model); + } + + public interface TruncateStage { + _FinalStage truncate(EmbedJobTruncate truncate); + } + + public interface _FinalStage { + EmbedJob build(); + + _FinalStage name(Optional name); + + _FinalStage name(String name); + + _FinalStage outputDatasetId(Optional outputDatasetId); + + _FinalStage outputDatasetId(String outputDatasetId); + + _FinalStage meta(Optional meta); + + _FinalStage meta(ApiMeta meta); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements JobIdStage, + StatusStage, + CreatedAtStage, + InputDatasetIdStage, + ModelStage, + TruncateStage, + _FinalStage { + private String jobId; + + private EmbedJobStatus status; + + private OffsetDateTime createdAt; + + private String inputDatasetId; + + private String model; + + private EmbedJobTruncate truncate; + + private Optional meta = Optional.empty(); + + private Optional outputDatasetId = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(EmbedJob other) { + jobId(other.getJobId()); + name(other.getName()); + status(other.getStatus()); + createdAt(other.getCreatedAt()); + inputDatasetId(other.getInputDatasetId()); + outputDatasetId(other.getOutputDatasetId()); + model(other.getModel()); + truncate(other.getTruncate()); + meta(other.getMeta()); + return this; + } + + /** + *

ID of the embed job

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_id") + public StatusStage jobId(String jobId) { + this.jobId = jobId; + return this; + } + + /** + *

The status of the embed job

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("status") + public CreatedAtStage status(EmbedJobStatus status) { + this.status = status; + return this; + } + + /** + *

The creation date of the embed job

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public InputDatasetIdStage createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

ID of the input dataset

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("input_dataset_id") + public ModelStage inputDatasetId(String inputDatasetId) { + this.inputDatasetId = inputDatasetId; + return this; + } + + /** + *

ID of the model used to embed

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("model") + public TruncateStage model(String model) { + this.model = model; + return this; + } + + /** + *

The truncation option used

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("truncate") + public _FinalStage truncate(EmbedJobTruncate truncate) { + this.truncate = truncate; + return this; + } + + @java.lang.Override + public _FinalStage meta(ApiMeta meta) { + this.meta = Optional.of(meta); + return this; + } + + @java.lang.Override + @JsonSetter(value = "meta", nulls = Nulls.SKIP) + public _FinalStage meta(Optional meta) { + this.meta = meta; + return this; + } + + /** + *

ID of the resulting output dataset

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage outputDatasetId(String outputDatasetId) { + this.outputDatasetId = Optional.of(outputDatasetId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "output_dataset_id", nulls = Nulls.SKIP) + public _FinalStage outputDatasetId(Optional outputDatasetId) { + this.outputDatasetId = outputDatasetId; + return this; + } + + /** + *

The name of the embed job

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.of(name); + return this; + } + + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public EmbedJob build() { + return new EmbedJob( + jobId, + name, + status, + createdAt, + inputDatasetId, + outputDatasetId, + model, + truncate, + meta, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedJobStatus.java b/src/main/java/com/cohere/api/types/EmbedJobStatus.java new file mode 100644 index 0000000..b24b7f1 --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbedJobStatus.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmbedJobStatus { + PROCESSING("processing"), + + COMPLETE("complete"), + + CANCELLING("cancelling"), + + CANCELLED("cancelled"), + + FAILED("failed"); + + private final String value; + + EmbedJobStatus(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedJobTruncate.java b/src/main/java/com/cohere/api/types/EmbedJobTruncate.java new file mode 100644 index 0000000..8309552 --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbedJobTruncate.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmbedJobTruncate { + START("START"), + + END("END"); + + private final String value; + + EmbedJobTruncate(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/EmbedRequestTruncate.java b/src/main/java/com/cohere/api/types/EmbedRequestTruncate.java index 0d146cd..9475444 100644 --- a/src/main/java/com/cohere/api/types/EmbedRequestTruncate.java +++ b/src/main/java/com/cohere/api/types/EmbedRequestTruncate.java @@ -19,7 +19,7 @@ public enum EmbedRequestTruncate { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/EmbedResponse.java b/src/main/java/com/cohere/api/types/EmbedResponse.java index 6720e90..052ac33 100644 --- a/src/main/java/com/cohere/api/types/EmbedResponse.java +++ b/src/main/java/com/cohere/api/types/EmbedResponse.java @@ -103,12 +103,12 @@ private EmbeddingsFloatsValue(EmbedFloatsResponse value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitEmbeddingsFloats(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbeddingsFloatsValue && equalTo((EmbeddingsFloatsValue) other); @@ -118,12 +118,12 @@ private boolean equalTo(EmbeddingsFloatsValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "EmbedResponse{" + "value: " + value + "}"; } @@ -141,12 +141,12 @@ private EmbeddingsByTypeValue(EmbedByTypeResponse value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitEmbeddingsByType(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof EmbeddingsByTypeValue && equalTo((EmbeddingsByTypeValue) other); @@ -156,12 +156,12 @@ private boolean equalTo(EmbeddingsByTypeValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "EmbedResponse{" + "value: " + value + "}"; } @@ -176,12 +176,12 @@ private static final class _UnknownValue implements Value { @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) private _UnknownValue(@JsonProperty("value") Object value) {} - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor._visitUnknown(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof _UnknownValue && equalTo((_UnknownValue) other); @@ -191,12 +191,12 @@ private boolean equalTo(_UnknownValue other) { return type.equals(other.type) && value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.type, this.value); } - @Override + @java.lang.Override public String toString() { return "EmbedResponse{" + "type: " + type + ", value: " + value + "}"; } diff --git a/src/main/java/com/cohere/api/types/EmbeddingType.java b/src/main/java/com/cohere/api/types/EmbeddingType.java new file mode 100644 index 0000000..63e8883 --- /dev/null +++ b/src/main/java/com/cohere/api/types/EmbeddingType.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmbeddingType { + FLOAT("float"), + + INT_8("int8"), + + UINT_8("uint8"), + + BINARY("binary"), + + UBINARY("ubinary"); + + private final String value; + + EmbeddingType(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/FinetuneDatasetMetrics.java b/src/main/java/com/cohere/api/types/FinetuneDatasetMetrics.java new file mode 100644 index 0000000..f759ca9 --- /dev/null +++ b/src/main/java/com/cohere/api/types/FinetuneDatasetMetrics.java @@ -0,0 +1,248 @@ +/** + * 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 = FinetuneDatasetMetrics.Builder.class) +public final class FinetuneDatasetMetrics { + private final Optional trainableTokenCount; + + private final Optional totalExamples; + + private final Optional trainExamples; + + private final Optional trainSizeBytes; + + private final Optional evalExamples; + + private final Optional evalSizeBytes; + + private final Map additionalProperties; + + private FinetuneDatasetMetrics( + Optional trainableTokenCount, + Optional totalExamples, + Optional trainExamples, + Optional trainSizeBytes, + Optional evalExamples, + Optional evalSizeBytes, + Map additionalProperties) { + this.trainableTokenCount = trainableTokenCount; + this.totalExamples = totalExamples; + this.trainExamples = trainExamples; + this.trainSizeBytes = trainSizeBytes; + this.evalExamples = evalExamples; + this.evalSizeBytes = evalSizeBytes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The number of tokens of valid examples that can be used for training. + */ + @JsonProperty("trainable_token_count") + public Optional getTrainableTokenCount() { + return trainableTokenCount; + } + + /** + * @return The overall number of examples. + */ + @JsonProperty("total_examples") + public Optional getTotalExamples() { + return totalExamples; + } + + /** + * @return The number of training examples. + */ + @JsonProperty("train_examples") + public Optional getTrainExamples() { + return trainExamples; + } + + /** + * @return The size in bytes of all training examples. + */ + @JsonProperty("train_size_bytes") + public Optional getTrainSizeBytes() { + return trainSizeBytes; + } + + /** + * @return Number of evaluation examples. + */ + @JsonProperty("eval_examples") + public Optional getEvalExamples() { + return evalExamples; + } + + /** + * @return The size in bytes of all eval examples. + */ + @JsonProperty("eval_size_bytes") + public Optional getEvalSizeBytes() { + return evalSizeBytes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FinetuneDatasetMetrics && equalTo((FinetuneDatasetMetrics) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FinetuneDatasetMetrics other) { + return trainableTokenCount.equals(other.trainableTokenCount) + && totalExamples.equals(other.totalExamples) + && trainExamples.equals(other.trainExamples) + && trainSizeBytes.equals(other.trainSizeBytes) + && evalExamples.equals(other.evalExamples) + && evalSizeBytes.equals(other.evalSizeBytes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.trainableTokenCount, + this.totalExamples, + this.trainExamples, + this.trainSizeBytes, + this.evalExamples, + this.evalSizeBytes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional trainableTokenCount = Optional.empty(); + + private Optional totalExamples = Optional.empty(); + + private Optional trainExamples = Optional.empty(); + + private Optional trainSizeBytes = Optional.empty(); + + private Optional evalExamples = Optional.empty(); + + private Optional evalSizeBytes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(FinetuneDatasetMetrics other) { + trainableTokenCount(other.getTrainableTokenCount()); + totalExamples(other.getTotalExamples()); + trainExamples(other.getTrainExamples()); + trainSizeBytes(other.getTrainSizeBytes()); + evalExamples(other.getEvalExamples()); + evalSizeBytes(other.getEvalSizeBytes()); + return this; + } + + @JsonSetter(value = "trainable_token_count", nulls = Nulls.SKIP) + public Builder trainableTokenCount(Optional trainableTokenCount) { + this.trainableTokenCount = trainableTokenCount; + return this; + } + + public Builder trainableTokenCount(String trainableTokenCount) { + this.trainableTokenCount = Optional.of(trainableTokenCount); + return this; + } + + @JsonSetter(value = "total_examples", nulls = Nulls.SKIP) + public Builder totalExamples(Optional totalExamples) { + this.totalExamples = totalExamples; + return this; + } + + public Builder totalExamples(String totalExamples) { + this.totalExamples = Optional.of(totalExamples); + return this; + } + + @JsonSetter(value = "train_examples", nulls = Nulls.SKIP) + public Builder trainExamples(Optional trainExamples) { + this.trainExamples = trainExamples; + return this; + } + + public Builder trainExamples(String trainExamples) { + this.trainExamples = Optional.of(trainExamples); + return this; + } + + @JsonSetter(value = "train_size_bytes", nulls = Nulls.SKIP) + public Builder trainSizeBytes(Optional trainSizeBytes) { + this.trainSizeBytes = trainSizeBytes; + return this; + } + + public Builder trainSizeBytes(String trainSizeBytes) { + this.trainSizeBytes = Optional.of(trainSizeBytes); + return this; + } + + @JsonSetter(value = "eval_examples", nulls = Nulls.SKIP) + public Builder evalExamples(Optional evalExamples) { + this.evalExamples = evalExamples; + return this; + } + + public Builder evalExamples(String evalExamples) { + this.evalExamples = Optional.of(evalExamples); + return this; + } + + @JsonSetter(value = "eval_size_bytes", nulls = Nulls.SKIP) + public Builder evalSizeBytes(Optional evalSizeBytes) { + this.evalSizeBytes = evalSizeBytes; + return this; + } + + public Builder evalSizeBytes(String evalSizeBytes) { + this.evalSizeBytes = Optional.of(evalSizeBytes); + return this; + } + + public FinetuneDatasetMetrics build() { + return new FinetuneDatasetMetrics( + trainableTokenCount, + totalExamples, + trainExamples, + trainSizeBytes, + evalExamples, + evalSizeBytes, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/FinishReason.java b/src/main/java/com/cohere/api/types/FinishReason.java new file mode 100644 index 0000000..67713cc --- /dev/null +++ b/src/main/java/com/cohere/api/types/FinishReason.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum FinishReason { + COMPLETE("COMPLETE"), + + ERROR("ERROR"), + + ERROR_TOXIC("ERROR_TOXIC"), + + ERROR_LIMIT("ERROR_LIMIT"), + + USER_CANCEL("USER_CANCEL"), + + MAX_TOKENS("MAX_TOKENS"); + + private final String value; + + FinishReason(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateRequestReturnLikelihoods.java b/src/main/java/com/cohere/api/types/GenerateRequestReturnLikelihoods.java index cb88cb9..1e1f986 100644 --- a/src/main/java/com/cohere/api/types/GenerateRequestReturnLikelihoods.java +++ b/src/main/java/com/cohere/api/types/GenerateRequestReturnLikelihoods.java @@ -19,7 +19,7 @@ public enum GenerateRequestReturnLikelihoods { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/GenerateRequestTruncate.java b/src/main/java/com/cohere/api/types/GenerateRequestTruncate.java index 6227dbd..2e1dc45 100644 --- a/src/main/java/com/cohere/api/types/GenerateRequestTruncate.java +++ b/src/main/java/com/cohere/api/types/GenerateRequestTruncate.java @@ -19,7 +19,7 @@ public enum GenerateRequestTruncate { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/GenerateStreamEnd.java b/src/main/java/com/cohere/api/types/GenerateStreamEnd.java new file mode 100644 index 0000000..ec5dd34 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamEnd.java @@ -0,0 +1,159 @@ +/** + * 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 = GenerateStreamEnd.Builder.class) +public final class GenerateStreamEnd implements IGenerateStreamEvent { + private final boolean isFinished; + + private final Optional finishReason; + + private final GenerateStreamEndResponse response; + + private final Map additionalProperties; + + private GenerateStreamEnd( + boolean isFinished, + Optional finishReason, + GenerateStreamEndResponse response, + Map additionalProperties) { + this.isFinished = isFinished; + this.finishReason = finishReason; + this.response = response; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("is_finished") + public boolean getIsFinished() { + return isFinished; + } + + @JsonProperty("finish_reason") + public Optional getFinishReason() { + return finishReason; + } + + @JsonProperty("response") + public GenerateStreamEndResponse getResponse() { + return response; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamEnd && equalTo((GenerateStreamEnd) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamEnd other) { + return isFinished == other.isFinished + && finishReason.equals(other.finishReason) + && response.equals(other.response); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.isFinished, this.finishReason, this.response); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IsFinishedStage builder() { + return new Builder(); + } + + public interface IsFinishedStage { + ResponseStage isFinished(boolean isFinished); + + Builder from(GenerateStreamEnd other); + } + + public interface ResponseStage { + _FinalStage response(GenerateStreamEndResponse response); + } + + public interface _FinalStage { + GenerateStreamEnd build(); + + _FinalStage finishReason(Optional finishReason); + + _FinalStage finishReason(FinishReason finishReason); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IsFinishedStage, ResponseStage, _FinalStage { + private boolean isFinished; + + private GenerateStreamEndResponse response; + + private Optional finishReason = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamEnd other) { + isFinished(other.getIsFinished()); + finishReason(other.getFinishReason()); + response(other.getResponse()); + return this; + } + + @java.lang.Override + @JsonSetter("is_finished") + public ResponseStage isFinished(boolean isFinished) { + this.isFinished = isFinished; + return this; + } + + @java.lang.Override + @JsonSetter("response") + public _FinalStage response(GenerateStreamEndResponse response) { + this.response = response; + return this; + } + + @java.lang.Override + public _FinalStage finishReason(FinishReason finishReason) { + this.finishReason = Optional.of(finishReason); + return this; + } + + @java.lang.Override + @JsonSetter(value = "finish_reason", nulls = Nulls.SKIP) + public _FinalStage finishReason(Optional finishReason) { + this.finishReason = finishReason; + return this; + } + + @java.lang.Override + public GenerateStreamEnd build() { + return new GenerateStreamEnd(isFinished, finishReason, response, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamEndResponse.java b/src/main/java/com/cohere/api/types/GenerateStreamEndResponse.java new file mode 100644 index 0000000..3df4226 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamEndResponse.java @@ -0,0 +1,164 @@ +/** + * 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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = GenerateStreamEndResponse.Builder.class) +public final class GenerateStreamEndResponse { + private final String id; + + private final Optional prompt; + + private final Optional> generations; + + private final Map additionalProperties; + + private GenerateStreamEndResponse( + String id, + Optional prompt, + Optional> generations, + Map additionalProperties) { + this.id = id; + this.prompt = prompt; + this.generations = generations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("prompt") + public Optional getPrompt() { + return prompt; + } + + @JsonProperty("generations") + public Optional> getGenerations() { + return generations; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamEndResponse && equalTo((GenerateStreamEndResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamEndResponse other) { + return id.equals(other.id) && prompt.equals(other.prompt) && generations.equals(other.generations); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.prompt, this.generations); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + _FinalStage id(String id); + + Builder from(GenerateStreamEndResponse other); + } + + public interface _FinalStage { + GenerateStreamEndResponse build(); + + _FinalStage prompt(Optional prompt); + + _FinalStage prompt(String prompt); + + _FinalStage generations(Optional> generations); + + _FinalStage generations(List generations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + private Optional> generations = Optional.empty(); + + private Optional prompt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamEndResponse other) { + id(other.getId()); + prompt(other.getPrompt()); + generations(other.getGenerations()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(String id) { + this.id = id; + return this; + } + + @java.lang.Override + public _FinalStage generations(List generations) { + this.generations = Optional.of(generations); + return this; + } + + @java.lang.Override + @JsonSetter(value = "generations", nulls = Nulls.SKIP) + public _FinalStage generations(Optional> generations) { + this.generations = generations; + return this; + } + + @java.lang.Override + public _FinalStage prompt(String prompt) { + this.prompt = Optional.of(prompt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "prompt", nulls = Nulls.SKIP) + public _FinalStage prompt(Optional prompt) { + this.prompt = prompt; + return this; + } + + @java.lang.Override + public GenerateStreamEndResponse build() { + return new GenerateStreamEndResponse(id, prompt, generations, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamError.java b/src/main/java/com/cohere/api/types/GenerateStreamError.java new file mode 100644 index 0000000..55c6ac8 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamError.java @@ -0,0 +1,197 @@ +/** + * 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 = GenerateStreamError.Builder.class) +public final class GenerateStreamError implements IGenerateStreamEvent { + private final Optional index; + + private final boolean isFinished; + + private final FinishReason finishReason; + + private final String err; + + private final Map additionalProperties; + + private GenerateStreamError( + Optional index, + boolean isFinished, + FinishReason finishReason, + String err, + Map additionalProperties) { + this.index = index; + this.isFinished = isFinished; + this.finishReason = finishReason; + this.err = err; + this.additionalProperties = additionalProperties; + } + + /** + * @return Refers to the nth generation. Only present when num_generations is greater than zero. + */ + @JsonProperty("index") + public Optional getIndex() { + return index; + } + + @JsonProperty("is_finished") + public boolean getIsFinished() { + return isFinished; + } + + @JsonProperty("finish_reason") + public FinishReason getFinishReason() { + return finishReason; + } + + /** + * @return Error message + */ + @JsonProperty("err") + public String getErr() { + return err; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamError && equalTo((GenerateStreamError) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamError other) { + return index.equals(other.index) + && isFinished == other.isFinished + && finishReason.equals(other.finishReason) + && err.equals(other.err); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.index, this.isFinished, this.finishReason, this.err); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IsFinishedStage builder() { + return new Builder(); + } + + public interface IsFinishedStage { + FinishReasonStage isFinished(boolean isFinished); + + Builder from(GenerateStreamError other); + } + + public interface FinishReasonStage { + ErrStage finishReason(FinishReason finishReason); + } + + public interface ErrStage { + _FinalStage err(String err); + } + + public interface _FinalStage { + GenerateStreamError build(); + + _FinalStage index(Optional index); + + _FinalStage index(Integer index); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IsFinishedStage, FinishReasonStage, ErrStage, _FinalStage { + private boolean isFinished; + + private FinishReason finishReason; + + private String err; + + private Optional index = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamError other) { + index(other.getIndex()); + isFinished(other.getIsFinished()); + finishReason(other.getFinishReason()); + err(other.getErr()); + return this; + } + + @java.lang.Override + @JsonSetter("is_finished") + public FinishReasonStage isFinished(boolean isFinished) { + this.isFinished = isFinished; + return this; + } + + @java.lang.Override + @JsonSetter("finish_reason") + public ErrStage finishReason(FinishReason finishReason) { + this.finishReason = finishReason; + return this; + } + + /** + *

Error message

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("err") + public _FinalStage err(String err) { + this.err = err; + return this; + } + + /** + *

Refers to the nth generation. Only present when num_generations is greater than zero.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage index(Integer index) { + this.index = Optional.of(index); + return this; + } + + @java.lang.Override + @JsonSetter(value = "index", nulls = Nulls.SKIP) + public _FinalStage index(Optional index) { + this.index = index; + return this; + } + + @java.lang.Override + public GenerateStreamError build() { + return new GenerateStreamError(index, isFinished, finishReason, err, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamEvent.java b/src/main/java/com/cohere/api/types/GenerateStreamEvent.java new file mode 100644 index 0000000..cd36550 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamEvent.java @@ -0,0 +1,32 @@ +/** + * 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 java.util.Map; + +public final class GenerateStreamEvent implements IGenerateStreamEvent { + private final Map additionalProperties; + + private GenerateStreamEvent(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamEvent; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamRequestReturnLikelihoods.java b/src/main/java/com/cohere/api/types/GenerateStreamRequestReturnLikelihoods.java new file mode 100644 index 0000000..face700 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamRequestReturnLikelihoods.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum GenerateStreamRequestReturnLikelihoods { + GENERATION("GENERATION"), + + ALL("ALL"), + + NONE("NONE"); + + private final String value; + + GenerateStreamRequestReturnLikelihoods(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamRequestTruncate.java b/src/main/java/com/cohere/api/types/GenerateStreamRequestTruncate.java new file mode 100644 index 0000000..cefed5a --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamRequestTruncate.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum GenerateStreamRequestTruncate { + NONE("NONE"), + + START("START"), + + END("END"); + + private final String value; + + GenerateStreamRequestTruncate(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamText.java b/src/main/java/com/cohere/api/types/GenerateStreamText.java new file mode 100644 index 0000000..cdd1414 --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamText.java @@ -0,0 +1,168 @@ +/** + * 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 = GenerateStreamText.Builder.class) +public final class GenerateStreamText implements IGenerateStreamEvent { + private final String text; + + private final Optional index; + + private final boolean isFinished; + + private final Map additionalProperties; + + private GenerateStreamText( + String text, Optional index, boolean isFinished, Map additionalProperties) { + this.text = text; + this.index = index; + this.isFinished = isFinished; + this.additionalProperties = additionalProperties; + } + + /** + * @return A segment of text of the generation. + */ + @JsonProperty("text") + public String getText() { + return text; + } + + /** + * @return Refers to the nth generation. Only present when num_generations is greater than zero, and only when text responses are being streamed. + */ + @JsonProperty("index") + public Optional getIndex() { + return index; + } + + @JsonProperty("is_finished") + public boolean getIsFinished() { + return isFinished; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GenerateStreamText && equalTo((GenerateStreamText) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GenerateStreamText other) { + return text.equals(other.text) && index.equals(other.index) && isFinished == other.isFinished; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.text, this.index, this.isFinished); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TextStage builder() { + return new Builder(); + } + + public interface TextStage { + IsFinishedStage text(String text); + + Builder from(GenerateStreamText other); + } + + public interface IsFinishedStage { + _FinalStage isFinished(boolean isFinished); + } + + public interface _FinalStage { + GenerateStreamText build(); + + _FinalStage index(Optional index); + + _FinalStage index(Integer index); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TextStage, IsFinishedStage, _FinalStage { + private String text; + + private boolean isFinished; + + private Optional index = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GenerateStreamText other) { + text(other.getText()); + index(other.getIndex()); + isFinished(other.getIsFinished()); + return this; + } + + /** + *

A segment of text of the generation.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("text") + public IsFinishedStage text(String text) { + this.text = text; + return this; + } + + @java.lang.Override + @JsonSetter("is_finished") + public _FinalStage isFinished(boolean isFinished) { + this.isFinished = isFinished; + return this; + } + + /** + *

Refers to the nth generation. Only present when num_generations is greater than zero, and only when text responses are being streamed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage index(Integer index) { + this.index = Optional.of(index); + return this; + } + + @java.lang.Override + @JsonSetter(value = "index", nulls = Nulls.SKIP) + public _FinalStage index(Optional index) { + this.index = index; + return this; + } + + @java.lang.Override + public GenerateStreamText build() { + return new GenerateStreamText(text, index, isFinished, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/GenerateStreamedResponse.java b/src/main/java/com/cohere/api/types/GenerateStreamedResponse.java new file mode 100644 index 0000000..96a238e --- /dev/null +++ b/src/main/java/com/cohere/api/types/GenerateStreamedResponse.java @@ -0,0 +1,263 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class GenerateStreamedResponse { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private GenerateStreamedResponse(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static GenerateStreamedResponse textGeneration(GenerateStreamText value) { + return new GenerateStreamedResponse(new TextGenerationValue(value)); + } + + public static GenerateStreamedResponse streamEnd(GenerateStreamEnd value) { + return new GenerateStreamedResponse(new StreamEndValue(value)); + } + + public static GenerateStreamedResponse streamError(GenerateStreamError value) { + return new GenerateStreamedResponse(new StreamErrorValue(value)); + } + + public boolean isTextGeneration() { + return value instanceof TextGenerationValue; + } + + public boolean isStreamEnd() { + return value instanceof StreamEndValue; + } + + public boolean isStreamError() { + return value instanceof StreamErrorValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getTextGeneration() { + if (isTextGeneration()) { + return Optional.of(((TextGenerationValue) value).value); + } + return Optional.empty(); + } + + public Optional getStreamEnd() { + if (isStreamEnd()) { + return Optional.of(((StreamEndValue) value).value); + } + return Optional.empty(); + } + + public Optional getStreamError() { + if (isStreamError()) { + return Optional.of(((StreamErrorValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitTextGeneration(GenerateStreamText textGeneration); + + T visitStreamEnd(GenerateStreamEnd streamEnd); + + T visitStreamError(GenerateStreamError streamError); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "event_type", + visible = true, + defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(TextGenerationValue.class), + @JsonSubTypes.Type(StreamEndValue.class), + @JsonSubTypes.Type(StreamErrorValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("text-generation") + private static final class TextGenerationValue implements Value { + @JsonUnwrapped + private GenerateStreamText value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private TextGenerationValue() {} + + private TextGenerationValue(GenerateStreamText value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitTextGeneration(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TextGenerationValue && equalTo((TextGenerationValue) other); + } + + private boolean equalTo(TextGenerationValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "GenerateStreamedResponse{" + "value: " + value + "}"; + } + } + + @JsonTypeName("stream-end") + private static final class StreamEndValue implements Value { + @JsonUnwrapped + private GenerateStreamEnd value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private StreamEndValue() {} + + private StreamEndValue(GenerateStreamEnd value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitStreamEnd(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StreamEndValue && equalTo((StreamEndValue) other); + } + + private boolean equalTo(StreamEndValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "GenerateStreamedResponse{" + "value: " + value + "}"; + } + } + + @JsonTypeName("stream-error") + private static final class StreamErrorValue implements Value { + @JsonUnwrapped + private GenerateStreamError value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private StreamErrorValue() {} + + private StreamErrorValue(GenerateStreamError value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitStreamError(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StreamErrorValue && equalTo((StreamErrorValue) other); + } + + private boolean equalTo(StreamErrorValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "GenerateStreamedResponse{" + "value: " + value + "}"; + } + } + + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "GenerateStreamedResponse{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/cohere/api/types/Generation.java b/src/main/java/com/cohere/api/types/Generation.java index eb20a39..16d548f 100644 --- a/src/main/java/com/cohere/api/types/Generation.java +++ b/src/main/java/com/cohere/api/types/Generation.java @@ -71,7 +71,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof Generation && equalTo((Generation) other); @@ -89,12 +89,12 @@ private boolean equalTo(Generation other) { && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.prompt, this.generations, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -142,7 +142,7 @@ public static final class Builder implements IdStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(Generation other) { id(other.getId()); prompt(other.getPrompt()); @@ -151,20 +151,20 @@ public Builder from(Generation other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public _FinalStage id(String id) { this.id = id; return this; } - @Override + @java.lang.Override public _FinalStage meta(ApiMeta meta) { this.meta = Optional.of(meta); return this; } - @Override + @java.lang.Override @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Optional meta) { this.meta = meta; @@ -175,7 +175,7 @@ public _FinalStage meta(Optional meta) { *

List of generated results

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addAllGenerations(List generations) { this.generations.addAll(generations); return this; @@ -185,13 +185,13 @@ public _FinalStage addAllGenerations(List generations) { *

List of generated results

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage addGenerations(SingleGeneration generations) { this.generations.add(generations); return this; } - @Override + @java.lang.Override @JsonSetter(value = "generations", nulls = Nulls.SKIP) public _FinalStage generations(List generations) { this.generations.clear(); @@ -203,20 +203,20 @@ public _FinalStage generations(List generations) { *

Prompt used for generations.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage prompt(String prompt) { this.prompt = Optional.of(prompt); return this; } - @Override + @java.lang.Override @JsonSetter(value = "prompt", nulls = Nulls.SKIP) public _FinalStage prompt(Optional prompt) { this.prompt = prompt; return this; } - @Override + @java.lang.Override public Generation build() { return new Generation(id, prompt, generations, meta, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/GetResponse.java b/src/main/java/com/cohere/api/types/GetConnectorResponse.java similarity index 73% rename from src/main/java/com/cohere/api/types/GetResponse.java rename to src/main/java/com/cohere/api/types/GetConnectorResponse.java index 5b2e7fa..3727064 100644 --- a/src/main/java/com/cohere/api/types/GetResponse.java +++ b/src/main/java/com/cohere/api/types/GetConnectorResponse.java @@ -16,13 +16,13 @@ import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetResponse.Builder.class) -public final class GetResponse { +@JsonDeserialize(builder = GetConnectorResponse.Builder.class) +public final class GetConnectorResponse { private final Connector connector; private final Map additionalProperties; - private GetResponse(Connector connector, Map additionalProperties) { + private GetConnectorResponse(Connector connector, Map additionalProperties) { this.connector = connector; this.additionalProperties = additionalProperties; } @@ -32,10 +32,10 @@ public Connector getConnector() { return connector; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof GetResponse && equalTo((GetResponse) other); + return other instanceof GetConnectorResponse && equalTo((GetConnectorResponse) other); } @JsonAnyGetter @@ -43,16 +43,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(GetResponse other) { + private boolean equalTo(GetConnectorResponse other) { return connector.equals(other.connector); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.connector); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -64,11 +64,11 @@ public static ConnectorStage builder() { public interface ConnectorStage { _FinalStage connector(Connector connector); - Builder from(GetResponse other); + Builder from(GetConnectorResponse other); } public interface _FinalStage { - GetResponse build(); + GetConnectorResponse build(); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -80,22 +80,22 @@ public static final class Builder implements ConnectorStage, _FinalStage { private Builder() {} - @Override - public Builder from(GetResponse other) { + @java.lang.Override + public Builder from(GetConnectorResponse other) { connector(other.getConnector()); return this; } - @Override + @java.lang.Override @JsonSetter("connector") public _FinalStage connector(Connector connector) { this.connector = connector; return this; } - @Override - public GetResponse build() { - return new GetResponse(connector, additionalProperties); + @java.lang.Override + public GetConnectorResponse build() { + return new GetConnectorResponse(connector, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/GetModelResponse.java b/src/main/java/com/cohere/api/types/GetModelResponse.java new file mode 100644 index 0000000..824655b --- /dev/null +++ b/src/main/java/com/cohere/api/types/GetModelResponse.java @@ -0,0 +1,243 @@ +/** + * 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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = GetModelResponse.Builder.class) +public final class GetModelResponse { + private final Optional name; + + private final Optional> endpoints; + + private final Optional finetuned; + + private final Optional contextLength; + + private final Optional tokenizerUrl; + + private final Optional> defaultEndpoints; + + private final Map additionalProperties; + + private GetModelResponse( + Optional name, + Optional> endpoints, + Optional finetuned, + Optional contextLength, + Optional tokenizerUrl, + Optional> defaultEndpoints, + Map additionalProperties) { + this.name = name; + this.endpoints = endpoints; + this.finetuned = finetuned; + this.contextLength = contextLength; + this.tokenizerUrl = tokenizerUrl; + this.defaultEndpoints = defaultEndpoints; + this.additionalProperties = additionalProperties; + } + + /** + * @return Specify this name in the model parameter of API requests to use your chosen model. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The API endpoints that the model is compatible with. + */ + @JsonProperty("endpoints") + public Optional> getEndpoints() { + return endpoints; + } + + /** + * @return Whether the model has been fine-tuned or not. + */ + @JsonProperty("finetuned") + public Optional getFinetuned() { + return finetuned; + } + + /** + * @return The maximum number of tokens that the model can process in a single request. Note that not all of these tokens are always available due to special tokens and preambles that Cohere has added by default. + */ + @JsonProperty("context_length") + public Optional getContextLength() { + return contextLength; + } + + /** + * @return Public URL to the tokenizer's configuration file. + */ + @JsonProperty("tokenizer_url") + public Optional getTokenizerUrl() { + return tokenizerUrl; + } + + /** + * @return The API endpoints that the model is default to. + */ + @JsonProperty("default_endpoints") + public Optional> getDefaultEndpoints() { + return defaultEndpoints; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetModelResponse && equalTo((GetModelResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetModelResponse other) { + return name.equals(other.name) + && endpoints.equals(other.endpoints) + && finetuned.equals(other.finetuned) + && contextLength.equals(other.contextLength) + && tokenizerUrl.equals(other.tokenizerUrl) + && defaultEndpoints.equals(other.defaultEndpoints); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.endpoints, + this.finetuned, + this.contextLength, + this.tokenizerUrl, + this.defaultEndpoints); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional name = Optional.empty(); + + private Optional> endpoints = Optional.empty(); + + private Optional finetuned = Optional.empty(); + + private Optional contextLength = Optional.empty(); + + private Optional tokenizerUrl = Optional.empty(); + + private Optional> defaultEndpoints = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetModelResponse other) { + name(other.getName()); + endpoints(other.getEndpoints()); + finetuned(other.getFinetuned()); + contextLength(other.getContextLength()); + tokenizerUrl(other.getTokenizerUrl()); + defaultEndpoints(other.getDefaultEndpoints()); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.of(name); + return this; + } + + @JsonSetter(value = "endpoints", nulls = Nulls.SKIP) + public Builder endpoints(Optional> endpoints) { + this.endpoints = endpoints; + return this; + } + + public Builder endpoints(List endpoints) { + this.endpoints = Optional.of(endpoints); + return this; + } + + @JsonSetter(value = "finetuned", nulls = Nulls.SKIP) + public Builder finetuned(Optional finetuned) { + this.finetuned = finetuned; + return this; + } + + public Builder finetuned(Boolean finetuned) { + this.finetuned = Optional.of(finetuned); + return this; + } + + @JsonSetter(value = "context_length", nulls = Nulls.SKIP) + public Builder contextLength(Optional contextLength) { + this.contextLength = contextLength; + return this; + } + + public Builder contextLength(Double contextLength) { + this.contextLength = Optional.of(contextLength); + return this; + } + + @JsonSetter(value = "tokenizer_url", nulls = Nulls.SKIP) + public Builder tokenizerUrl(Optional tokenizerUrl) { + this.tokenizerUrl = tokenizerUrl; + return this; + } + + public Builder tokenizerUrl(String tokenizerUrl) { + this.tokenizerUrl = Optional.of(tokenizerUrl); + return this; + } + + @JsonSetter(value = "default_endpoints", nulls = Nulls.SKIP) + public Builder defaultEndpoints(Optional> defaultEndpoints) { + this.defaultEndpoints = defaultEndpoints; + return this; + } + + public Builder defaultEndpoints(List defaultEndpoints) { + this.defaultEndpoints = Optional.of(defaultEndpoints); + return this; + } + + public GetModelResponse build() { + return new GetModelResponse( + name, endpoints, finetuned, contextLength, tokenizerUrl, defaultEndpoints, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/IGenerateStreamEvent.java b/src/main/java/com/cohere/api/types/IGenerateStreamEvent.java new file mode 100644 index 0000000..d78cc89 --- /dev/null +++ b/src/main/java/com/cohere/api/types/IGenerateStreamEvent.java @@ -0,0 +1,6 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.cohere.api.types; + +public interface IGenerateStreamEvent {} diff --git a/src/main/java/com/cohere/api/types/LabelMetric.java b/src/main/java/com/cohere/api/types/LabelMetric.java new file mode 100644 index 0000000..fa9c91a --- /dev/null +++ b/src/main/java/com/cohere/api/types/LabelMetric.java @@ -0,0 +1,153 @@ +/** + * 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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = LabelMetric.Builder.class) +public final class LabelMetric { + private final Optional totalExamples; + + private final Optional label; + + private final Optional> samples; + + private final Map additionalProperties; + + private LabelMetric( + Optional totalExamples, + Optional label, + Optional> samples, + Map additionalProperties) { + this.totalExamples = totalExamples; + this.label = label; + this.samples = samples; + this.additionalProperties = additionalProperties; + } + + /** + * @return Total number of examples for this label + */ + @JsonProperty("total_examples") + public Optional getTotalExamples() { + return totalExamples; + } + + /** + * @return value of the label + */ + @JsonProperty("label") + public Optional getLabel() { + return label; + } + + /** + * @return samples for this label + */ + @JsonProperty("samples") + public Optional> getSamples() { + return samples; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LabelMetric && equalTo((LabelMetric) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LabelMetric other) { + return totalExamples.equals(other.totalExamples) && label.equals(other.label) && samples.equals(other.samples); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.totalExamples, this.label, this.samples); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional totalExamples = Optional.empty(); + + private Optional label = Optional.empty(); + + private Optional> samples = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(LabelMetric other) { + totalExamples(other.getTotalExamples()); + label(other.getLabel()); + samples(other.getSamples()); + return this; + } + + @JsonSetter(value = "total_examples", nulls = Nulls.SKIP) + public Builder totalExamples(Optional totalExamples) { + this.totalExamples = totalExamples; + return this; + } + + public Builder totalExamples(String totalExamples) { + this.totalExamples = Optional.of(totalExamples); + return this; + } + + @JsonSetter(value = "label", nulls = Nulls.SKIP) + public Builder label(Optional label) { + this.label = label; + return this; + } + + public Builder label(String label) { + this.label = Optional.of(label); + return this; + } + + @JsonSetter(value = "samples", nulls = Nulls.SKIP) + public Builder samples(Optional> samples) { + this.samples = samples; + return this; + } + + public Builder samples(List samples) { + this.samples = Optional.of(samples); + return this; + } + + public LabelMetric build() { + return new LabelMetric(totalExamples, label, samples, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ListResponse.java b/src/main/java/com/cohere/api/types/ListConnectorsResponse.java similarity index 60% rename from src/main/java/com/cohere/api/types/ListResponse.java rename to src/main/java/com/cohere/api/types/ListConnectorsResponse.java index 63fce2b..b441f1a 100644 --- a/src/main/java/com/cohere/api/types/ListResponse.java +++ b/src/main/java/com/cohere/api/types/ListConnectorsResponse.java @@ -17,16 +17,21 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListResponse.Builder.class) -public final class ListResponse { +@JsonDeserialize(builder = ListConnectorsResponse.Builder.class) +public final class ListConnectorsResponse { private final List connectors; + private final Optional totalCount; + private final Map additionalProperties; - private ListResponse(List connectors, Map additionalProperties) { + private ListConnectorsResponse( + List connectors, Optional totalCount, Map additionalProperties) { this.connectors = connectors; + this.totalCount = totalCount; this.additionalProperties = additionalProperties; } @@ -35,10 +40,18 @@ public List getConnectors() { return connectors; } - @Override + /** + * @return Total number of connectors. + */ + @JsonProperty("total_count") + public Optional getTotalCount() { + return totalCount; + } + + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ListResponse && equalTo((ListResponse) other); + return other instanceof ListConnectorsResponse && equalTo((ListConnectorsResponse) other); } @JsonAnyGetter @@ -46,16 +59,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ListResponse other) { - return connectors.equals(other.connectors); + private boolean equalTo(ListConnectorsResponse other) { + return connectors.equals(other.connectors) && totalCount.equals(other.totalCount); } - @Override + @java.lang.Override public int hashCode() { - return Objects.hash(this.connectors); + return Objects.hash(this.connectors, this.totalCount); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -68,13 +81,16 @@ public static Builder builder() { public static final class Builder { private List connectors = new ArrayList<>(); + private Optional totalCount = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(ListResponse other) { + public Builder from(ListConnectorsResponse other) { connectors(other.getConnectors()); + totalCount(other.getTotalCount()); return this; } @@ -95,8 +111,19 @@ public Builder addAllConnectors(List connectors) { return this; } - public ListResponse build() { - return new ListResponse(connectors, additionalProperties); + @JsonSetter(value = "total_count", nulls = Nulls.SKIP) + public Builder totalCount(Optional totalCount) { + this.totalCount = totalCount; + return this; + } + + public Builder totalCount(Double totalCount) { + this.totalCount = Optional.of(totalCount); + return this; + } + + public ListConnectorsResponse build() { + return new ListConnectorsResponse(connectors, totalCount, additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/ListEmbedJobResponse.java b/src/main/java/com/cohere/api/types/ListEmbedJobResponse.java new file mode 100644 index 0000000..be125fc --- /dev/null +++ b/src/main/java/com/cohere/api/types/ListEmbedJobResponse.java @@ -0,0 +1,96 @@ +/** + * 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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ListEmbedJobResponse.Builder.class) +public final class ListEmbedJobResponse { + private final Optional> embedJobs; + + private final Map additionalProperties; + + private ListEmbedJobResponse(Optional> embedJobs, Map additionalProperties) { + this.embedJobs = embedJobs; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("embed_jobs") + public Optional> getEmbedJobs() { + return embedJobs; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListEmbedJobResponse && equalTo((ListEmbedJobResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListEmbedJobResponse other) { + return embedJobs.equals(other.embedJobs); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.embedJobs); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> embedJobs = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListEmbedJobResponse other) { + embedJobs(other.getEmbedJobs()); + return this; + } + + @JsonSetter(value = "embed_jobs", nulls = Nulls.SKIP) + public Builder embedJobs(Optional> embedJobs) { + this.embedJobs = embedJobs; + return this; + } + + public Builder embedJobs(List embedJobs) { + this.embedJobs = Optional.of(embedJobs); + return this; + } + + public ListEmbedJobResponse build() { + return new ListEmbedJobResponse(embedJobs, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ListModelsResponse.java b/src/main/java/com/cohere/api/types/ListModelsResponse.java new file mode 100644 index 0000000..bbeb74c --- /dev/null +++ b/src/main/java/com/cohere/api/types/ListModelsResponse.java @@ -0,0 +1,129 @@ +/** + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ListModelsResponse.Builder.class) +public final class ListModelsResponse { + private final List models; + + private final Optional nextPageToken; + + private final Map additionalProperties; + + private ListModelsResponse( + List models, Optional nextPageToken, Map additionalProperties) { + this.models = models; + this.nextPageToken = nextPageToken; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("models") + public List getModels() { + return models; + } + + /** + * @return A token to retrieve the next page of results. Provide in the page_token parameter of the next request. + */ + @JsonProperty("next_page_token") + public Optional getNextPageToken() { + return nextPageToken; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListModelsResponse && equalTo((ListModelsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListModelsResponse other) { + return models.equals(other.models) && nextPageToken.equals(other.nextPageToken); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.models, this.nextPageToken); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private List models = new ArrayList<>(); + + private Optional nextPageToken = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListModelsResponse other) { + models(other.getModels()); + nextPageToken(other.getNextPageToken()); + return this; + } + + @JsonSetter(value = "models", nulls = Nulls.SKIP) + public Builder models(List models) { + this.models.clear(); + this.models.addAll(models); + return this; + } + + public Builder addModels(GetModelResponse models) { + this.models.add(models); + return this; + } + + public Builder addAllModels(List models) { + this.models.addAll(models); + return this; + } + + @JsonSetter(value = "next_page_token", nulls = Nulls.SKIP) + public Builder nextPageToken(Optional nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + public Builder nextPageToken(String nextPageToken) { + this.nextPageToken = Optional.of(nextPageToken); + return this; + } + + public ListModelsResponse build() { + return new ListModelsResponse(models, nextPageToken, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/Metrics.java b/src/main/java/com/cohere/api/types/Metrics.java new file mode 100644 index 0000000..8f3eafd --- /dev/null +++ b/src/main/java/com/cohere/api/types/Metrics.java @@ -0,0 +1,95 @@ +/** + * 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 = Metrics.Builder.class) +public final class Metrics { + private final Optional finetuneDatasetMetrics; + + private final Map additionalProperties; + + private Metrics(Optional finetuneDatasetMetrics, Map additionalProperties) { + this.finetuneDatasetMetrics = finetuneDatasetMetrics; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("finetune_dataset_metrics") + public Optional getFinetuneDatasetMetrics() { + return finetuneDatasetMetrics; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Metrics && equalTo((Metrics) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Metrics other) { + return finetuneDatasetMetrics.equals(other.finetuneDatasetMetrics); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.finetuneDatasetMetrics); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional finetuneDatasetMetrics = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Metrics other) { + finetuneDatasetMetrics(other.getFinetuneDatasetMetrics()); + return this; + } + + @JsonSetter(value = "finetune_dataset_metrics", nulls = Nulls.SKIP) + public Builder finetuneDatasetMetrics(Optional finetuneDatasetMetrics) { + this.finetuneDatasetMetrics = finetuneDatasetMetrics; + return this; + } + + public Builder finetuneDatasetMetrics(FinetuneDatasetMetrics finetuneDatasetMetrics) { + this.finetuneDatasetMetrics = Optional.of(finetuneDatasetMetrics); + return this; + } + + public Metrics build() { + return new Metrics(finetuneDatasetMetrics, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/NonStreamedChatResponse.java b/src/main/java/com/cohere/api/types/NonStreamedChatResponse.java index 579243b..3bc2379 100644 --- a/src/main/java/com/cohere/api/types/NonStreamedChatResponse.java +++ b/src/main/java/com/cohere/api/types/NonStreamedChatResponse.java @@ -23,32 +23,52 @@ public final class NonStreamedChatResponse { private final String text; - private final String generationId; + private final Optional generationId; private final Optional> citations; private final Optional>> documents; + private final Optional isSearchRequired; + private final Optional> searchQueries; private final Optional> searchResults; + private final Optional finishReason; + + private final Optional> toolCalls; + + private final Optional> chatHistory; + + private final Optional meta; + private final Map additionalProperties; private NonStreamedChatResponse( String text, - String generationId, + Optional generationId, Optional> citations, Optional>> documents, + Optional isSearchRequired, Optional> searchQueries, Optional> searchResults, + Optional finishReason, + Optional> toolCalls, + Optional> chatHistory, + Optional meta, Map additionalProperties) { this.text = text; this.generationId = generationId; this.citations = citations; this.documents = documents; + this.isSearchRequired = isSearchRequired; this.searchQueries = searchQueries; this.searchResults = searchResults; + this.finishReason = finishReason; + this.toolCalls = toolCalls; + this.chatHistory = chatHistory; + this.meta = meta; this.additionalProperties = additionalProperties; } @@ -64,7 +84,7 @@ public String getText() { * @return Unique identifier for the generated reply. Useful for submitting feedback. */ @JsonProperty("generation_id") - public String getGenerationId() { + public Optional getGenerationId() { return generationId; } @@ -84,6 +104,14 @@ public Optional>> getDocuments() { return documents; } + /** + * @return Denotes that a search for documents is required during the RAG flow. + */ + @JsonProperty("is_search_required") + public Optional getIsSearchRequired() { + return isSearchRequired; + } + /** * @return Generated search queries, meant to be used as part of the RAG flow. */ @@ -100,7 +128,30 @@ public Optional> getSearchResults() { return searchResults; } - @Override + @JsonProperty("finish_reason") + public Optional getFinishReason() { + return finishReason; + } + + @JsonProperty("tool_calls") + public Optional> getToolCalls() { + return toolCalls; + } + + /** + * @return A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message. + */ + @JsonProperty("chat_history") + public Optional> getChatHistory() { + return chatHistory; + } + + @JsonProperty("meta") + public Optional getMeta() { + return meta; + } + + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof NonStreamedChatResponse && equalTo((NonStreamedChatResponse) other); @@ -116,17 +167,32 @@ private boolean equalTo(NonStreamedChatResponse other) { && generationId.equals(other.generationId) && citations.equals(other.citations) && documents.equals(other.documents) + && isSearchRequired.equals(other.isSearchRequired) && searchQueries.equals(other.searchQueries) - && searchResults.equals(other.searchResults); + && searchResults.equals(other.searchResults) + && finishReason.equals(other.finishReason) + && toolCalls.equals(other.toolCalls) + && chatHistory.equals(other.chatHistory) + && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( - this.text, this.generationId, this.citations, this.documents, this.searchQueries, this.searchResults); + this.text, + this.generationId, + this.citations, + this.documents, + this.isSearchRequired, + this.searchQueries, + this.searchResults, + this.finishReason, + this.toolCalls, + this.chatHistory, + this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -136,18 +202,18 @@ public static TextStage builder() { } public interface TextStage { - GenerationIdStage text(String text); + _FinalStage text(String text); Builder from(NonStreamedChatResponse other); } - public interface GenerationIdStage { - _FinalStage generationId(String generationId); - } - public interface _FinalStage { NonStreamedChatResponse build(); + _FinalStage generationId(Optional generationId); + + _FinalStage generationId(String generationId); + _FinalStage citations(Optional> citations); _FinalStage citations(List citations); @@ -156,6 +222,10 @@ public interface _FinalStage { _FinalStage documents(List> documents); + _FinalStage isSearchRequired(Optional isSearchRequired); + + _FinalStage isSearchRequired(Boolean isSearchRequired); + _FinalStage searchQueries(Optional> searchQueries); _FinalStage searchQueries(List searchQueries); @@ -163,35 +233,66 @@ public interface _FinalStage { _FinalStage searchResults(Optional> searchResults); _FinalStage searchResults(List searchResults); + + _FinalStage finishReason(Optional finishReason); + + _FinalStage finishReason(FinishReason finishReason); + + _FinalStage toolCalls(Optional> toolCalls); + + _FinalStage toolCalls(List toolCalls); + + _FinalStage chatHistory(Optional> chatHistory); + + _FinalStage chatHistory(List chatHistory); + + _FinalStage meta(Optional meta); + + _FinalStage meta(ApiMeta meta); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TextStage, GenerationIdStage, _FinalStage { + public static final class Builder implements TextStage, _FinalStage { private String text; - private String generationId; + private Optional meta = Optional.empty(); + + private Optional> chatHistory = Optional.empty(); + + private Optional> toolCalls = Optional.empty(); + + private Optional finishReason = Optional.empty(); private Optional> searchResults = Optional.empty(); private Optional> searchQueries = Optional.empty(); + private Optional isSearchRequired = Optional.empty(); + private Optional>> documents = Optional.empty(); private Optional> citations = Optional.empty(); + private Optional generationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @Override + @java.lang.Override public Builder from(NonStreamedChatResponse other) { text(other.getText()); generationId(other.getGenerationId()); citations(other.getCitations()); documents(other.getDocuments()); + isSearchRequired(other.getIsSearchRequired()); searchQueries(other.getSearchQueries()); searchResults(other.getSearchResults()); + finishReason(other.getFinishReason()); + toolCalls(other.getToolCalls()); + chatHistory(other.getChatHistory()); + meta(other.getMeta()); return this; } @@ -199,21 +300,66 @@ public Builder from(NonStreamedChatResponse other) { *

Contents of the reply generated by the model.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") - public GenerationIdStage text(String text) { + public _FinalStage text(String text) { this.text = text; return this; } + @java.lang.Override + public _FinalStage meta(ApiMeta meta) { + this.meta = Optional.of(meta); + return this; + } + + @java.lang.Override + @JsonSetter(value = "meta", nulls = Nulls.SKIP) + public _FinalStage meta(Optional meta) { + this.meta = meta; + return this; + } + /** - *

Unique identifier for the generated reply. Useful for submitting feedback.

+ *

A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override - @JsonSetter("generation_id") - public _FinalStage generationId(String generationId) { - this.generationId = generationId; + @java.lang.Override + public _FinalStage chatHistory(List chatHistory) { + this.chatHistory = Optional.of(chatHistory); + return this; + } + + @java.lang.Override + @JsonSetter(value = "chat_history", nulls = Nulls.SKIP) + public _FinalStage chatHistory(Optional> chatHistory) { + this.chatHistory = chatHistory; + return this; + } + + @java.lang.Override + public _FinalStage toolCalls(List toolCalls) { + this.toolCalls = Optional.of(toolCalls); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tool_calls", nulls = Nulls.SKIP) + public _FinalStage toolCalls(Optional> toolCalls) { + this.toolCalls = toolCalls; + return this; + } + + @java.lang.Override + public _FinalStage finishReason(FinishReason finishReason) { + this.finishReason = Optional.of(finishReason); + return this; + } + + @java.lang.Override + @JsonSetter(value = "finish_reason", nulls = Nulls.SKIP) + public _FinalStage finishReason(Optional finishReason) { + this.finishReason = finishReason; return this; } @@ -221,13 +367,13 @@ public _FinalStage generationId(String generationId) { *

Documents retrieved from each of the conducted searches.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage searchResults(List searchResults) { this.searchResults = Optional.of(searchResults); return this; } - @Override + @java.lang.Override @JsonSetter(value = "search_results", nulls = Nulls.SKIP) public _FinalStage searchResults(Optional> searchResults) { this.searchResults = searchResults; @@ -238,30 +384,47 @@ public _FinalStage searchResults(Optional> searchResults) *

Generated search queries, meant to be used as part of the RAG flow.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage searchQueries(List searchQueries) { this.searchQueries = Optional.of(searchQueries); return this; } - @Override + @java.lang.Override @JsonSetter(value = "search_queries", nulls = Nulls.SKIP) public _FinalStage searchQueries(Optional> searchQueries) { this.searchQueries = searchQueries; return this; } + /** + *

Denotes that a search for documents is required during the RAG flow.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage isSearchRequired(Boolean isSearchRequired) { + this.isSearchRequired = Optional.of(isSearchRequired); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_search_required", nulls = Nulls.SKIP) + public _FinalStage isSearchRequired(Optional isSearchRequired) { + this.isSearchRequired = isSearchRequired; + return this; + } + /** *

Documents seen by the model when generating the reply.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage documents(List> documents) { this.documents = Optional.of(documents); return this; } - @Override + @java.lang.Override @JsonSetter(value = "documents", nulls = Nulls.SKIP) public _FinalStage documents(Optional>> documents) { this.documents = documents; @@ -272,23 +435,51 @@ public _FinalStage documents(Optional>> documents) { *

Inline citations for the generated reply.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage citations(List citations) { this.citations = Optional.of(citations); return this; } - @Override + @java.lang.Override @JsonSetter(value = "citations", nulls = Nulls.SKIP) public _FinalStage citations(Optional> citations) { this.citations = citations; return this; } - @Override + /** + *

Unique identifier for the generated reply. Useful for submitting feedback.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage generationId(String generationId) { + this.generationId = Optional.of(generationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "generation_id", nulls = Nulls.SKIP) + public _FinalStage generationId(Optional generationId) { + this.generationId = generationId; + return this; + } + + @java.lang.Override public NonStreamedChatResponse build() { return new NonStreamedChatResponse( - text, generationId, citations, documents, searchQueries, searchResults, additionalProperties); + text, + generationId, + citations, + documents, + isSearchRequired, + searchQueries, + searchResults, + finishReason, + toolCalls, + chatHistory, + meta, + additionalProperties); } } } diff --git a/src/main/java/com/cohere/api/types/OAuthAuthorizeResponse.java b/src/main/java/com/cohere/api/types/OAuthAuthorizeResponse.java index 9abedfa..b46c99e 100644 --- a/src/main/java/com/cohere/api/types/OAuthAuthorizeResponse.java +++ b/src/main/java/com/cohere/api/types/OAuthAuthorizeResponse.java @@ -37,7 +37,7 @@ public Optional getRedirectUrl() { return redirectUrl; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof OAuthAuthorizeResponse && equalTo((OAuthAuthorizeResponse) other); @@ -52,12 +52,12 @@ private boolean equalTo(OAuthAuthorizeResponse other) { return redirectUrl.equals(other.redirectUrl); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.redirectUrl); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/ParseInfo.java b/src/main/java/com/cohere/api/types/ParseInfo.java new file mode 100644 index 0000000..b1045db --- /dev/null +++ b/src/main/java/com/cohere/api/types/ParseInfo.java @@ -0,0 +1,118 @@ +/** + * 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 = ParseInfo.Builder.class) +public final class ParseInfo { + private final Optional separator; + + private final Optional delimiter; + + private final Map additionalProperties; + + private ParseInfo( + Optional separator, Optional delimiter, Map additionalProperties) { + this.separator = separator; + this.delimiter = delimiter; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("separator") + public Optional getSeparator() { + return separator; + } + + @JsonProperty("delimiter") + public Optional getDelimiter() { + return delimiter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ParseInfo && equalTo((ParseInfo) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ParseInfo other) { + return separator.equals(other.separator) && delimiter.equals(other.delimiter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.separator, this.delimiter); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional separator = Optional.empty(); + + private Optional delimiter = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ParseInfo other) { + separator(other.getSeparator()); + delimiter(other.getDelimiter()); + return this; + } + + @JsonSetter(value = "separator", nulls = Nulls.SKIP) + public Builder separator(Optional separator) { + this.separator = separator; + return this; + } + + public Builder separator(String separator) { + this.separator = Optional.of(separator); + return this; + } + + @JsonSetter(value = "delimiter", nulls = Nulls.SKIP) + public Builder delimiter(Optional delimiter) { + this.delimiter = delimiter; + return this; + } + + public Builder delimiter(String delimiter) { + this.delimiter = Optional.of(delimiter); + return this; + } + + public ParseInfo build() { + return new ParseInfo(separator, delimiter, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/RerankRequestDocumentsItem.java b/src/main/java/com/cohere/api/types/RerankRequestDocumentsItem.java index a92da20..91aed13 100644 --- a/src/main/java/com/cohere/api/types/RerankRequestDocumentsItem.java +++ b/src/main/java/com/cohere/api/types/RerankRequestDocumentsItem.java @@ -38,7 +38,7 @@ public T visit(Visitor visitor) { throw new IllegalStateException("Failed to visit value. This should never happen."); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankRequestDocumentsItem && equalTo((RerankRequestDocumentsItem) other); @@ -48,12 +48,12 @@ private boolean equalTo(RerankRequestDocumentsItem other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return this.value.toString(); } @@ -77,7 +77,7 @@ static final class Deserializer extends StdDeserializerThe text of the document to rerank.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; return this; } - @Override + @java.lang.Override public RerankRequestDocumentsItemText build() { return new RerankRequestDocumentsItemText(text, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/RerankResponse.java b/src/main/java/com/cohere/api/types/RerankResponse.java index 19ecc1e..303e0ae 100644 --- a/src/main/java/com/cohere/api/types/RerankResponse.java +++ b/src/main/java/com/cohere/api/types/RerankResponse.java @@ -59,7 +59,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankResponse && equalTo((RerankResponse) other); @@ -74,12 +74,12 @@ private boolean equalTo(RerankResponse other) { return id.equals(other.id) && results.equals(other.results) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.results, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/RerankResponseResultsItem.java b/src/main/java/com/cohere/api/types/RerankResponseResultsItem.java index bdaf1e3..e32fe3b 100644 --- a/src/main/java/com/cohere/api/types/RerankResponseResultsItem.java +++ b/src/main/java/com/cohere/api/types/RerankResponseResultsItem.java @@ -63,7 +63,7 @@ public double getRelevanceScore() { return relevanceScore; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankResponseResultsItem && equalTo((RerankResponseResultsItem) other); @@ -78,12 +78,12 @@ private boolean equalTo(RerankResponseResultsItem other) { return document.equals(other.document) && index == other.index && relevanceScore == other.relevanceScore; } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.document, this.index, this.relevanceScore); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -123,7 +123,7 @@ public static final class Builder implements IndexStage, RelevanceScoreStage, _F private Builder() {} - @Override + @java.lang.Override public Builder from(RerankResponseResultsItem other) { document(other.getDocument()); index(other.getIndex()); @@ -135,7 +135,7 @@ public Builder from(RerankResponseResultsItem other) { *

The index of the input document

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("index") public RelevanceScoreStage index(int index) { this.index = index; @@ -146,7 +146,7 @@ public RelevanceScoreStage index(int index) { *

A relevance score assigned to the ranking

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("relevance_score") public _FinalStage relevanceScore(double relevanceScore) { this.relevanceScore = relevanceScore; @@ -157,20 +157,20 @@ public _FinalStage relevanceScore(double relevanceScore) { *

The doc object which was ranked

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage document(RerankResponseResultsItemDocument document) { this.document = Optional.of(document); return this; } - @Override + @java.lang.Override @JsonSetter(value = "document", nulls = Nulls.SKIP) public _FinalStage document(Optional document) { this.document = document; return this; } - @Override + @java.lang.Override public RerankResponseResultsItem build() { return new RerankResponseResultsItem(document, index, relevanceScore, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/RerankResponseResultsItemDocument.java b/src/main/java/com/cohere/api/types/RerankResponseResultsItemDocument.java index 7bde141..35fc243 100644 --- a/src/main/java/com/cohere/api/types/RerankResponseResultsItemDocument.java +++ b/src/main/java/com/cohere/api/types/RerankResponseResultsItemDocument.java @@ -35,7 +35,7 @@ public String getText() { return text; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof RerankResponseResultsItemDocument && equalTo((RerankResponseResultsItemDocument) other); @@ -50,12 +50,12 @@ private boolean equalTo(RerankResponseResultsItemDocument other) { return text.equals(other.text); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.text); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -83,7 +83,7 @@ public static final class Builder implements TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(RerankResponseResultsItemDocument other) { text(other.getText()); return this; @@ -93,14 +93,14 @@ public Builder from(RerankResponseResultsItemDocument other) { *

The text of the document to rerank

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; return this; } - @Override + @java.lang.Override public RerankResponseResultsItemDocument build() { return new RerankResponseResultsItemDocument(text, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/RerankerDataMetrics.java b/src/main/java/com/cohere/api/types/RerankerDataMetrics.java new file mode 100644 index 0000000..1fa81bf --- /dev/null +++ b/src/main/java/com/cohere/api/types/RerankerDataMetrics.java @@ -0,0 +1,248 @@ +/** + * 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 = RerankerDataMetrics.Builder.class) +public final class RerankerDataMetrics { + private final Optional numTrainQueries; + + private final Optional numTrainRelevantPassages; + + private final Optional numTrainHardNegatives; + + private final Optional numEvalQueries; + + private final Optional numEvalRelevantPassages; + + private final Optional numEvalHardNegatives; + + private final Map additionalProperties; + + private RerankerDataMetrics( + Optional numTrainQueries, + Optional numTrainRelevantPassages, + Optional numTrainHardNegatives, + Optional numEvalQueries, + Optional numEvalRelevantPassages, + Optional numEvalHardNegatives, + Map additionalProperties) { + this.numTrainQueries = numTrainQueries; + this.numTrainRelevantPassages = numTrainRelevantPassages; + this.numTrainHardNegatives = numTrainHardNegatives; + this.numEvalQueries = numEvalQueries; + this.numEvalRelevantPassages = numEvalRelevantPassages; + this.numEvalHardNegatives = numEvalHardNegatives; + this.additionalProperties = additionalProperties; + } + + /** + * @return The number of training queries. + */ + @JsonProperty("num_train_queries") + public Optional getNumTrainQueries() { + return numTrainQueries; + } + + /** + * @return The sum of all relevant passages of valid training examples. + */ + @JsonProperty("num_train_relevant_passages") + public Optional getNumTrainRelevantPassages() { + return numTrainRelevantPassages; + } + + /** + * @return The sum of all hard negatives of valid training examples. + */ + @JsonProperty("num_train_hard_negatives") + public Optional getNumTrainHardNegatives() { + return numTrainHardNegatives; + } + + /** + * @return The number of evaluation queries. + */ + @JsonProperty("num_eval_queries") + public Optional getNumEvalQueries() { + return numEvalQueries; + } + + /** + * @return The sum of all relevant passages of valid eval examples. + */ + @JsonProperty("num_eval_relevant_passages") + public Optional getNumEvalRelevantPassages() { + return numEvalRelevantPassages; + } + + /** + * @return The sum of all hard negatives of valid eval examples. + */ + @JsonProperty("num_eval_hard_negatives") + public Optional getNumEvalHardNegatives() { + return numEvalHardNegatives; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RerankerDataMetrics && equalTo((RerankerDataMetrics) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RerankerDataMetrics other) { + return numTrainQueries.equals(other.numTrainQueries) + && numTrainRelevantPassages.equals(other.numTrainRelevantPassages) + && numTrainHardNegatives.equals(other.numTrainHardNegatives) + && numEvalQueries.equals(other.numEvalQueries) + && numEvalRelevantPassages.equals(other.numEvalRelevantPassages) + && numEvalHardNegatives.equals(other.numEvalHardNegatives); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.numTrainQueries, + this.numTrainRelevantPassages, + this.numTrainHardNegatives, + this.numEvalQueries, + this.numEvalRelevantPassages, + this.numEvalHardNegatives); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional numTrainQueries = Optional.empty(); + + private Optional numTrainRelevantPassages = Optional.empty(); + + private Optional numTrainHardNegatives = Optional.empty(); + + private Optional numEvalQueries = Optional.empty(); + + private Optional numEvalRelevantPassages = Optional.empty(); + + private Optional numEvalHardNegatives = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RerankerDataMetrics other) { + numTrainQueries(other.getNumTrainQueries()); + numTrainRelevantPassages(other.getNumTrainRelevantPassages()); + numTrainHardNegatives(other.getNumTrainHardNegatives()); + numEvalQueries(other.getNumEvalQueries()); + numEvalRelevantPassages(other.getNumEvalRelevantPassages()); + numEvalHardNegatives(other.getNumEvalHardNegatives()); + return this; + } + + @JsonSetter(value = "num_train_queries", nulls = Nulls.SKIP) + public Builder numTrainQueries(Optional numTrainQueries) { + this.numTrainQueries = numTrainQueries; + return this; + } + + public Builder numTrainQueries(String numTrainQueries) { + this.numTrainQueries = Optional.of(numTrainQueries); + return this; + } + + @JsonSetter(value = "num_train_relevant_passages", nulls = Nulls.SKIP) + public Builder numTrainRelevantPassages(Optional numTrainRelevantPassages) { + this.numTrainRelevantPassages = numTrainRelevantPassages; + return this; + } + + public Builder numTrainRelevantPassages(String numTrainRelevantPassages) { + this.numTrainRelevantPassages = Optional.of(numTrainRelevantPassages); + return this; + } + + @JsonSetter(value = "num_train_hard_negatives", nulls = Nulls.SKIP) + public Builder numTrainHardNegatives(Optional numTrainHardNegatives) { + this.numTrainHardNegatives = numTrainHardNegatives; + return this; + } + + public Builder numTrainHardNegatives(String numTrainHardNegatives) { + this.numTrainHardNegatives = Optional.of(numTrainHardNegatives); + return this; + } + + @JsonSetter(value = "num_eval_queries", nulls = Nulls.SKIP) + public Builder numEvalQueries(Optional numEvalQueries) { + this.numEvalQueries = numEvalQueries; + return this; + } + + public Builder numEvalQueries(String numEvalQueries) { + this.numEvalQueries = Optional.of(numEvalQueries); + return this; + } + + @JsonSetter(value = "num_eval_relevant_passages", nulls = Nulls.SKIP) + public Builder numEvalRelevantPassages(Optional numEvalRelevantPassages) { + this.numEvalRelevantPassages = numEvalRelevantPassages; + return this; + } + + public Builder numEvalRelevantPassages(String numEvalRelevantPassages) { + this.numEvalRelevantPassages = Optional.of(numEvalRelevantPassages); + return this; + } + + @JsonSetter(value = "num_eval_hard_negatives", nulls = Nulls.SKIP) + public Builder numEvalHardNegatives(Optional numEvalHardNegatives) { + this.numEvalHardNegatives = numEvalHardNegatives; + return this; + } + + public Builder numEvalHardNegatives(String numEvalHardNegatives) { + this.numEvalHardNegatives = Optional.of(numEvalHardNegatives); + return this; + } + + public RerankerDataMetrics build() { + return new RerankerDataMetrics( + numTrainQueries, + numTrainRelevantPassages, + numTrainHardNegatives, + numEvalQueries, + numEvalRelevantPassages, + numEvalHardNegatives, + additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/SingleGeneration.java b/src/main/java/com/cohere/api/types/SingleGeneration.java index cd66282..6bd9158 100644 --- a/src/main/java/com/cohere/api/types/SingleGeneration.java +++ b/src/main/java/com/cohere/api/types/SingleGeneration.java @@ -79,7 +79,7 @@ public Optional> getTokenLikelihoods( return tokenLikelihoods; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SingleGeneration && equalTo((SingleGeneration) other); @@ -98,12 +98,12 @@ private boolean equalTo(SingleGeneration other) { && tokenLikelihoods.equals(other.tokenLikelihoods); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.text, this.index, this.likelihood, this.tokenLikelihoods); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -155,7 +155,7 @@ public static final class Builder implements IdStage, TextStage, _FinalStage { private Builder() {} - @Override + @java.lang.Override public Builder from(SingleGeneration other) { id(other.getId()); text(other.getText()); @@ -165,14 +165,14 @@ public Builder from(SingleGeneration other) { return this; } - @Override + @java.lang.Override @JsonSetter("id") public TextStage id(String id) { this.id = id; return this; } - @Override + @java.lang.Override @JsonSetter("text") public _FinalStage text(String text) { this.text = text; @@ -183,26 +183,26 @@ public _FinalStage text(String text) { *

Only returned if return_likelihoods is set to GENERATION or ALL. The likelihood refers to the average log-likelihood of the entire specified string, which is useful for evaluating the performance of your model, especially if you've created a custom model. Individual token likelihoods provide the log-likelihood of each token. The first token will not have a likelihood.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage tokenLikelihoods(List tokenLikelihoods) { this.tokenLikelihoods = Optional.of(tokenLikelihoods); return this; } - @Override + @java.lang.Override @JsonSetter(value = "token_likelihoods", nulls = Nulls.SKIP) public _FinalStage tokenLikelihoods(Optional> tokenLikelihoods) { this.tokenLikelihoods = tokenLikelihoods; return this; } - @Override + @java.lang.Override public _FinalStage likelihood(Double likelihood) { this.likelihood = Optional.of(likelihood); return this; } - @Override + @java.lang.Override @JsonSetter(value = "likelihood", nulls = Nulls.SKIP) public _FinalStage likelihood(Optional likelihood) { this.likelihood = likelihood; @@ -213,20 +213,20 @@ public _FinalStage likelihood(Optional likelihood) { *

Refers to the nth generation. Only present when num_generations is greater than zero.

* @return Reference to {@code this} so that method calls can be chained together. */ - @Override + @java.lang.Override public _FinalStage index(Integer index) { this.index = Optional.of(index); return this; } - @Override + @java.lang.Override @JsonSetter(value = "index", nulls = Nulls.SKIP) public _FinalStage index(Optional index) { this.index = index; return this; } - @Override + @java.lang.Override public SingleGeneration build() { return new SingleGeneration(id, text, index, likelihood, tokenLikelihoods, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/SingleGenerationInStream.java b/src/main/java/com/cohere/api/types/SingleGenerationInStream.java new file mode 100644 index 0000000..15829d9 --- /dev/null +++ b/src/main/java/com/cohere/api/types/SingleGenerationInStream.java @@ -0,0 +1,197 @@ +/** + * 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 = SingleGenerationInStream.Builder.class) +public final class SingleGenerationInStream { + private final String id; + + private final String text; + + private final Optional index; + + private final FinishReason finishReason; + + private final Map additionalProperties; + + private SingleGenerationInStream( + String id, + String text, + Optional index, + FinishReason finishReason, + Map additionalProperties) { + this.id = id; + this.text = text; + this.index = index; + this.finishReason = finishReason; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return Full text of the generation. + */ + @JsonProperty("text") + public String getText() { + return text; + } + + /** + * @return Refers to the nth generation. Only present when num_generations is greater than zero. + */ + @JsonProperty("index") + public Optional getIndex() { + return index; + } + + @JsonProperty("finish_reason") + public FinishReason getFinishReason() { + return finishReason; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SingleGenerationInStream && equalTo((SingleGenerationInStream) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SingleGenerationInStream other) { + return id.equals(other.id) + && text.equals(other.text) + && index.equals(other.index) + && finishReason.equals(other.finishReason); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.text, this.index, this.finishReason); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + TextStage id(String id); + + Builder from(SingleGenerationInStream other); + } + + public interface TextStage { + FinishReasonStage text(String text); + } + + public interface FinishReasonStage { + _FinalStage finishReason(FinishReason finishReason); + } + + public interface _FinalStage { + SingleGenerationInStream build(); + + _FinalStage index(Optional index); + + _FinalStage index(Integer index); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, TextStage, FinishReasonStage, _FinalStage { + private String id; + + private String text; + + private FinishReason finishReason; + + private Optional index = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SingleGenerationInStream other) { + id(other.getId()); + text(other.getText()); + index(other.getIndex()); + finishReason(other.getFinishReason()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public TextStage id(String id) { + this.id = id; + return this; + } + + /** + *

Full text of the generation.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("text") + public FinishReasonStage text(String text) { + this.text = text; + return this; + } + + @java.lang.Override + @JsonSetter("finish_reason") + public _FinalStage finishReason(FinishReason finishReason) { + this.finishReason = finishReason; + return this; + } + + /** + *

Refers to the nth generation. Only present when num_generations is greater than zero.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage index(Integer index) { + this.index = Optional.of(index); + return this; + } + + @java.lang.Override + @JsonSetter(value = "index", nulls = Nulls.SKIP) + public _FinalStage index(Optional index) { + this.index = index; + return this; + } + + @java.lang.Override + public SingleGenerationInStream build() { + return new SingleGenerationInStream(id, text, index, finishReason, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/SingleGenerationTokenLikelihoodsItem.java b/src/main/java/com/cohere/api/types/SingleGenerationTokenLikelihoodsItem.java index 1699a36..512ab9e 100644 --- a/src/main/java/com/cohere/api/types/SingleGenerationTokenLikelihoodsItem.java +++ b/src/main/java/com/cohere/api/types/SingleGenerationTokenLikelihoodsItem.java @@ -41,7 +41,7 @@ public double getLikelihood() { return likelihood; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SingleGenerationTokenLikelihoodsItem @@ -57,12 +57,12 @@ private boolean equalTo(SingleGenerationTokenLikelihoodsItem other) { return token.equals(other.token) && likelihood == other.likelihood; } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.token, this.likelihood); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -96,28 +96,28 @@ public static final class Builder implements TokenStage, LikelihoodStage, _Final private Builder() {} - @Override + @java.lang.Override public Builder from(SingleGenerationTokenLikelihoodsItem other) { token(other.getToken()); likelihood(other.getLikelihood()); return this; } - @Override + @java.lang.Override @JsonSetter("token") public LikelihoodStage token(String token) { this.token = token; return this; } - @Override + @java.lang.Override @JsonSetter("likelihood") public _FinalStage likelihood(double likelihood) { this.likelihood = likelihood; return this; } - @Override + @java.lang.Override public SingleGenerationTokenLikelihoodsItem build() { return new SingleGenerationTokenLikelihoodsItem(token, likelihood, additionalProperties); } diff --git a/src/main/java/com/cohere/api/types/StreamedChatResponse.java b/src/main/java/com/cohere/api/types/StreamedChatResponse.java index 6fb6ff8..1ae5d66 100644 --- a/src/main/java/com/cohere/api/types/StreamedChatResponse.java +++ b/src/main/java/com/cohere/api/types/StreamedChatResponse.java @@ -46,6 +46,10 @@ public static StreamedChatResponse citationGeneration(ChatCitationGenerationEven return new StreamedChatResponse(new CitationGenerationValue(value)); } + public static StreamedChatResponse toolCallsGeneration(ChatToolCallsGenerationEvent value) { + return new StreamedChatResponse(new ToolCallsGenerationValue(value)); + } + public static StreamedChatResponse streamEnd(ChatStreamEndEvent value) { return new StreamedChatResponse(new StreamEndValue(value)); } @@ -70,6 +74,10 @@ public boolean isCitationGeneration() { return value instanceof CitationGenerationValue; } + public boolean isToolCallsGeneration() { + return value instanceof ToolCallsGenerationValue; + } + public boolean isStreamEnd() { return value instanceof StreamEndValue; } @@ -113,6 +121,13 @@ public Optional getCitationGeneration() { return Optional.empty(); } + public Optional getToolCallsGeneration() { + if (isToolCallsGeneration()) { + return Optional.of(((ToolCallsGenerationValue) value).value); + } + return Optional.empty(); + } + public Optional getStreamEnd() { if (isStreamEnd()) { return Optional.of(((StreamEndValue) value).value); @@ -143,6 +158,8 @@ public interface Visitor { T visitCitationGeneration(ChatCitationGenerationEvent citationGeneration); + T visitToolCallsGeneration(ChatToolCallsGenerationEvent toolCallsGeneration); + T visitStreamEnd(ChatStreamEndEvent streamEnd); T _visitUnknown(Object unknownType); @@ -159,6 +176,7 @@ public interface Visitor { @JsonSubTypes.Type(SearchResultsValue.class), @JsonSubTypes.Type(TextGenerationValue.class), @JsonSubTypes.Type(CitationGenerationValue.class), + @JsonSubTypes.Type(ToolCallsGenerationValue.class), @JsonSubTypes.Type(StreamEndValue.class) }) @JsonIgnoreProperties(ignoreUnknown = true) @@ -178,12 +196,12 @@ private StreamStartValue(ChatStreamStartEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitStreamStart(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof StreamStartValue && equalTo((StreamStartValue) other); @@ -193,12 +211,12 @@ private boolean equalTo(StreamStartValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -216,12 +234,12 @@ private SearchQueriesGenerationValue(ChatSearchQueriesGenerationEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitSearchQueriesGeneration(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SearchQueriesGenerationValue && equalTo((SearchQueriesGenerationValue) other); @@ -231,12 +249,12 @@ private boolean equalTo(SearchQueriesGenerationValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -254,12 +272,12 @@ private SearchResultsValue(ChatSearchResultsEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitSearchResults(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SearchResultsValue && equalTo((SearchResultsValue) other); @@ -269,12 +287,12 @@ private boolean equalTo(SearchResultsValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -292,12 +310,12 @@ private TextGenerationValue(ChatTextGenerationEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitTextGeneration(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof TextGenerationValue && equalTo((TextGenerationValue) other); @@ -307,12 +325,12 @@ private boolean equalTo(TextGenerationValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -330,12 +348,12 @@ private CitationGenerationValue(ChatCitationGenerationEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitCitationGeneration(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof CitationGenerationValue && equalTo((CitationGenerationValue) other); @@ -345,12 +363,50 @@ private boolean equalTo(CitationGenerationValue other) { return value.equals(other.value); } - @Override + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "StreamedChatResponse{" + "value: " + value + "}"; + } + } + + @JsonTypeName("tool-calls-generation") + private static final class ToolCallsGenerationValue implements Value { + @JsonUnwrapped + private ChatToolCallsGenerationEvent value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private ToolCallsGenerationValue() {} + + private ToolCallsGenerationValue(ChatToolCallsGenerationEvent value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitToolCallsGeneration(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ToolCallsGenerationValue && equalTo((ToolCallsGenerationValue) other); + } + + private boolean equalTo(ToolCallsGenerationValue other) { + return value.equals(other.value); + } + + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -368,12 +424,12 @@ private StreamEndValue(ChatStreamEndEvent value) { this.value = value; } - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor.visitStreamEnd(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof StreamEndValue && equalTo((StreamEndValue) other); @@ -383,12 +439,12 @@ private boolean equalTo(StreamEndValue other) { return value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "value: " + value + "}"; } @@ -403,12 +459,12 @@ private static final class _UnknownValue implements Value { @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) private _UnknownValue(@JsonProperty("value") Object value) {} - @Override + @java.lang.Override public T visit(Visitor visitor) { return visitor._visitUnknown(value); } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof _UnknownValue && equalTo((_UnknownValue) other); @@ -418,12 +474,12 @@ private boolean equalTo(_UnknownValue other) { return type.equals(other.type) && value.equals(other.value); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.type, this.value); } - @Override + @java.lang.Override public String toString() { return "StreamedChatResponse{" + "type: " + type + ", value: " + value + "}"; } diff --git a/src/main/java/com/cohere/api/types/SummarizeRequestExtractiveness.java b/src/main/java/com/cohere/api/types/SummarizeRequestExtractiveness.java index ff2a6b7..cad2968 100644 --- a/src/main/java/com/cohere/api/types/SummarizeRequestExtractiveness.java +++ b/src/main/java/com/cohere/api/types/SummarizeRequestExtractiveness.java @@ -19,7 +19,7 @@ public enum SummarizeRequestExtractiveness { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/SummarizeRequestFormat.java b/src/main/java/com/cohere/api/types/SummarizeRequestFormat.java index ab3aa6c..8be83d8 100644 --- a/src/main/java/com/cohere/api/types/SummarizeRequestFormat.java +++ b/src/main/java/com/cohere/api/types/SummarizeRequestFormat.java @@ -17,7 +17,7 @@ public enum SummarizeRequestFormat { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/SummarizeRequestLength.java b/src/main/java/com/cohere/api/types/SummarizeRequestLength.java index a62850d..fd552e2 100644 --- a/src/main/java/com/cohere/api/types/SummarizeRequestLength.java +++ b/src/main/java/com/cohere/api/types/SummarizeRequestLength.java @@ -19,7 +19,7 @@ public enum SummarizeRequestLength { } @JsonValue - @Override + @java.lang.Override public String toString() { return this.value; } diff --git a/src/main/java/com/cohere/api/types/SummarizeResponse.java b/src/main/java/com/cohere/api/types/SummarizeResponse.java index f999fad..32a2d8b 100644 --- a/src/main/java/com/cohere/api/types/SummarizeResponse.java +++ b/src/main/java/com/cohere/api/types/SummarizeResponse.java @@ -60,7 +60,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof SummarizeResponse && equalTo((SummarizeResponse) other); @@ -75,12 +75,12 @@ private boolean equalTo(SummarizeResponse other) { return id.equals(other.id) && summary.equals(other.summary) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.id, this.summary, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/TokenizeResponse.java b/src/main/java/com/cohere/api/types/TokenizeResponse.java index 6e51495..66aeed9 100644 --- a/src/main/java/com/cohere/api/types/TokenizeResponse.java +++ b/src/main/java/com/cohere/api/types/TokenizeResponse.java @@ -59,7 +59,7 @@ public Optional getMeta() { return meta; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; return other instanceof TokenizeResponse && equalTo((TokenizeResponse) other); @@ -74,12 +74,12 @@ private boolean equalTo(TokenizeResponse other) { return tokens.equals(other.tokens) && tokenStrings.equals(other.tokenStrings) && meta.equals(other.meta); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.tokens, this.tokenStrings, this.meta); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } diff --git a/src/main/java/com/cohere/api/types/Tool.java b/src/main/java/com/cohere/api/types/Tool.java new file mode 100644 index 0000000..95a99d8 --- /dev/null +++ b/src/main/java/com/cohere/api/types/Tool.java @@ -0,0 +1,197 @@ +/** + * 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 = Tool.Builder.class) +public final class Tool { + private final String name; + + private final String description; + + private final Optional> parameterDefinitions; + + private final Map additionalProperties; + + private Tool( + String name, + String description, + Optional> parameterDefinitions, + Map additionalProperties) { + this.name = name; + this.description = description; + this.parameterDefinitions = parameterDefinitions; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the tool to be called. Valid names contain only the characters a-z, A-Z, 0-9, _ and must not begin with a digit. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The description of what the tool does, the model uses the description to choose when and how to call the function. + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * @return The input parameters of the tool. Accepts a dictionary where the key is the name of the parameter and the value is the parameter spec. Valid parameter names contain only the characters a-z, A-Z, 0-9, _ and must not begin with a digit. + *
{
+     *   "my_param": {
+     *     "description": <string>,
+     *     "type": <string>, // any python data type, such as 'str', 'bool'
+     *     "required": <boolean>
+     *   }
+     * }
+     * 
+ */ + @JsonProperty("parameter_definitions") + public Optional> getParameterDefinitions() { + return parameterDefinitions; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Tool && equalTo((Tool) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Tool other) { + return name.equals(other.name) + && description.equals(other.description) + && parameterDefinitions.equals(other.parameterDefinitions); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.description, this.parameterDefinitions); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + DescriptionStage name(String name); + + Builder from(Tool other); + } + + public interface DescriptionStage { + _FinalStage description(String description); + } + + public interface _FinalStage { + Tool build(); + + _FinalStage parameterDefinitions(Optional> parameterDefinitions); + + _FinalStage parameterDefinitions(Map parameterDefinitions); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, DescriptionStage, _FinalStage { + private String name; + + private String description; + + private Optional> parameterDefinitions = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Tool other) { + name(other.getName()); + description(other.getDescription()); + parameterDefinitions(other.getParameterDefinitions()); + return this; + } + + /** + *

The name of the tool to be called. Valid names contain only the characters a-z, A-Z, 0-9, _ and must not begin with a digit.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public DescriptionStage name(String name) { + this.name = name; + return this; + } + + /** + *

The description of what the tool does, the model uses the description to choose when and how to call the function.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("description") + public _FinalStage description(String description) { + this.description = description; + return this; + } + + /** + *

The input parameters of the tool. Accepts a dictionary where the key is the name of the parameter and the value is the parameter spec. Valid parameter names contain only the characters a-z, A-Z, 0-9, _ and must not begin with a digit.

+ *
{
+         *   "my_param": {
+         *     "description": <string>,
+         *     "type": <string>, // any python data type, such as 'str', 'bool'
+         *     "required": <boolean>
+         *   }
+         * }
+         * 
+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parameterDefinitions(Map parameterDefinitions) { + this.parameterDefinitions = Optional.of(parameterDefinitions); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parameter_definitions", nulls = Nulls.SKIP) + public _FinalStage parameterDefinitions( + Optional> parameterDefinitions) { + this.parameterDefinitions = parameterDefinitions; + return this; + } + + @java.lang.Override + public Tool build() { + return new Tool(name, description, parameterDefinitions, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ToolCall.java b/src/main/java/com/cohere/api/types/ToolCall.java new file mode 100644 index 0000000..d7e58e3 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ToolCall.java @@ -0,0 +1,158 @@ +/** + * 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.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ToolCall.Builder.class) +public final class ToolCall { + private final String name; + + private final Map parameters; + + private final Map additionalProperties; + + private ToolCall(String name, Map parameters, Map additionalProperties) { + this.name = name; + this.parameters = parameters; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name of the tool to call. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The name and value of the parameters to use when invoking a tool. + */ + @JsonProperty("parameters") + public Map getParameters() { + return parameters; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ToolCall && equalTo((ToolCall) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ToolCall other) { + return name.equals(other.name) && parameters.equals(other.parameters); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.parameters); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + _FinalStage name(String name); + + Builder from(ToolCall other); + } + + public interface _FinalStage { + ToolCall build(); + + _FinalStage parameters(Map parameters); + + _FinalStage putAllParameters(Map parameters); + + _FinalStage parameters(String key, Object value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, _FinalStage { + private String name; + + private Map parameters = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ToolCall other) { + name(other.getName()); + parameters(other.getParameters()); + return this; + } + + /** + *

Name of the tool to call.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(String name) { + this.name = name; + return this; + } + + /** + *

The name and value of the parameters to use when invoking a tool.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parameters(String key, Object value) { + this.parameters.put(key, value); + return this; + } + + /** + *

The name and value of the parameters to use when invoking a tool.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParameters(Map parameters) { + this.parameters.putAll(parameters); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parameters", nulls = Nulls.SKIP) + public _FinalStage parameters(Map parameters) { + this.parameters.clear(); + this.parameters.putAll(parameters); + return this; + } + + @java.lang.Override + public ToolCall build() { + return new ToolCall(name, parameters, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/ToolParameterDefinitionsValue.java b/src/main/java/com/cohere/api/types/ToolParameterDefinitionsValue.java new file mode 100644 index 0000000..d28f712 --- /dev/null +++ b/src/main/java/com/cohere/api/types/ToolParameterDefinitionsValue.java @@ -0,0 +1,184 @@ +/** + * 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 = ToolParameterDefinitionsValue.Builder.class) +public final class ToolParameterDefinitionsValue { + private final Optional description; + + private final String type; + + private final Optional required; + + private final Map additionalProperties; + + private ToolParameterDefinitionsValue( + Optional description, + String type, + Optional required, + Map additionalProperties) { + this.description = description; + this.type = type; + this.required = required; + this.additionalProperties = additionalProperties; + } + + /** + * @return The description of the parameter. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The type of the parameter. Must be a valid Python type. + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * @return Denotes whether the parameter is always present (required) or not. Defaults to not required. + */ + @JsonProperty("required") + public Optional getRequired() { + return required; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ToolParameterDefinitionsValue && equalTo((ToolParameterDefinitionsValue) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ToolParameterDefinitionsValue other) { + return description.equals(other.description) && type.equals(other.type) && required.equals(other.required); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.description, this.type, this.required); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + _FinalStage type(String type); + + Builder from(ToolParameterDefinitionsValue other); + } + + public interface _FinalStage { + ToolParameterDefinitionsValue build(); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage required(Optional required); + + _FinalStage required(Boolean required); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TypeStage, _FinalStage { + private String type; + + private Optional required = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ToolParameterDefinitionsValue other) { + description(other.getDescription()); + type(other.getType()); + required(other.getRequired()); + return this; + } + + /** + *

The type of the parameter. Must be a valid Python type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("type") + public _FinalStage type(String type) { + this.type = type; + return this; + } + + /** + *

Denotes whether the parameter is always present (required) or not. Defaults to not required.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage required(Boolean required) { + this.required = Optional.of(required); + return this; + } + + @java.lang.Override + @JsonSetter(value = "required", nulls = Nulls.SKIP) + public _FinalStage required(Optional required) { + this.required = required; + return this; + } + + /** + *

The description of the parameter.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.of(description); + return this; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public ToolParameterDefinitionsValue build() { + return new ToolParameterDefinitionsValue(description, type, required, additionalProperties); + } + } +} diff --git a/src/main/java/com/cohere/api/types/UpdateResponse.java b/src/main/java/com/cohere/api/types/UpdateConnectorResponse.java similarity index 72% rename from src/main/java/com/cohere/api/types/UpdateResponse.java rename to src/main/java/com/cohere/api/types/UpdateConnectorResponse.java index 4000622..7bb1f56 100644 --- a/src/main/java/com/cohere/api/types/UpdateResponse.java +++ b/src/main/java/com/cohere/api/types/UpdateConnectorResponse.java @@ -16,13 +16,13 @@ import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UpdateResponse.Builder.class) -public final class UpdateResponse { +@JsonDeserialize(builder = UpdateConnectorResponse.Builder.class) +public final class UpdateConnectorResponse { private final Connector connector; private final Map additionalProperties; - private UpdateResponse(Connector connector, Map additionalProperties) { + private UpdateConnectorResponse(Connector connector, Map additionalProperties) { this.connector = connector; this.additionalProperties = additionalProperties; } @@ -32,10 +32,10 @@ public Connector getConnector() { return connector; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof UpdateResponse && equalTo((UpdateResponse) other); + return other instanceof UpdateConnectorResponse && equalTo((UpdateConnectorResponse) other); } @JsonAnyGetter @@ -43,16 +43,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(UpdateResponse other) { + private boolean equalTo(UpdateConnectorResponse other) { return connector.equals(other.connector); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.connector); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -64,11 +64,11 @@ public static ConnectorStage builder() { public interface ConnectorStage { _FinalStage connector(Connector connector); - Builder from(UpdateResponse other); + Builder from(UpdateConnectorResponse other); } public interface _FinalStage { - UpdateResponse build(); + UpdateConnectorResponse build(); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -80,22 +80,22 @@ public static final class Builder implements ConnectorStage, _FinalStage { private Builder() {} - @Override - public Builder from(UpdateResponse other) { + @java.lang.Override + public Builder from(UpdateConnectorResponse other) { connector(other.getConnector()); return this; } - @Override + @java.lang.Override @JsonSetter("connector") public _FinalStage connector(Connector connector) { this.connector = connector; return this; } - @Override - public UpdateResponse build() { - return new UpdateResponse(connector, additionalProperties); + @java.lang.Override + public UpdateConnectorResponse build() { + return new UpdateConnectorResponse(connector, additionalProperties); } } }