├── .fernignore ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .publish └── prepare.sh ├── CODEOWNERS ├── LICENSE ├── README.md ├── banner.png ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample-app ├── build.gradle └── src │ └── main │ └── java │ └── sample │ └── App.java ├── settings.gradle └── src ├── main └── java │ └── com │ └── cohere │ └── api │ ├── Cohere.java │ ├── CohereBuilder.java │ ├── core │ ├── ClientOptions.java │ ├── CohereApiException.java │ ├── CohereException.java │ ├── DateTimeDeserializer.java │ ├── Environment.java │ ├── FileStream.java │ ├── InputStreamRequestBody.java │ ├── MediaTypes.java │ ├── ObjectMappers.java │ ├── RequestOptions.java │ ├── ResponseBodyInputStream.java │ ├── ResponseBodyReader.java │ ├── RetryInterceptor.java │ ├── Stream.java │ └── Suppliers.java │ ├── errors │ ├── BadRequestError.java │ ├── ClientClosedRequestError.java │ ├── ForbiddenError.java │ ├── GatewayTimeoutError.java │ ├── InternalServerError.java │ ├── InvalidTokenError.java │ ├── NotFoundError.java │ ├── NotImplementedError.java │ ├── ServiceUnavailableError.java │ ├── TooManyRequestsError.java │ ├── UnauthorizedError.java │ └── UnprocessableEntityError.java │ ├── requests │ ├── ChatRequest.java │ ├── ChatStreamRequest.java │ ├── ClassifyRequest.java │ ├── DetokenizeRequest.java │ ├── EmbedRequest.java │ ├── GenerateRequest.java │ ├── GenerateStreamRequest.java │ ├── RerankRequest.java │ ├── SummarizeRequest.java │ └── TokenizeRequest.java │ ├── resources │ ├── connectors │ │ ├── ConnectorsClient.java │ │ └── requests │ │ │ ├── ConnectorsListRequest.java │ │ │ ├── ConnectorsOAuthAuthorizeRequest.java │ │ │ ├── CreateConnectorRequest.java │ │ │ └── UpdateConnectorRequest.java │ ├── datasets │ │ ├── DatasetsClient.java │ │ ├── requests │ │ │ ├── DatasetsCreateRequest.java │ │ │ └── DatasetsListRequest.java │ │ └── types │ │ │ ├── DatasetsCreateResponse.java │ │ │ ├── DatasetsCreateResponseDatasetPartsItem.java │ │ │ ├── DatasetsGetResponse.java │ │ │ ├── DatasetsGetUsageResponse.java │ │ │ └── DatasetsListResponse.java │ ├── embedjobs │ │ ├── EmbedJobsClient.java │ │ ├── requests │ │ │ └── CreateEmbedJobRequest.java │ │ └── types │ │ │ └── CreateEmbedJobRequestTruncate.java │ ├── finetuning │ │ ├── FinetuningClient.java │ │ ├── finetuning │ │ │ └── types │ │ │ │ ├── BaseModel.java │ │ │ │ ├── BaseType.java │ │ │ │ ├── CreateFinetunedModelResponse.java │ │ │ │ ├── Event.java │ │ │ │ ├── FinetunedModel.java │ │ │ │ ├── GetFinetunedModelResponse.java │ │ │ │ ├── Hyperparameters.java │ │ │ │ ├── ListEventsResponse.java │ │ │ │ ├── ListFinetunedModelsResponse.java │ │ │ │ ├── ListTrainingStepMetricsResponse.java │ │ │ │ ├── LoraTargetModules.java │ │ │ │ ├── Settings.java │ │ │ │ ├── Status.java │ │ │ │ ├── Strategy.java │ │ │ │ ├── TrainingStepMetrics.java │ │ │ │ ├── UpdateFinetunedModelResponse.java │ │ │ │ └── WandbConfig.java │ │ └── requests │ │ │ ├── FinetuningListEventsRequest.java │ │ │ ├── FinetuningListFinetunedModelsRequest.java │ │ │ ├── FinetuningListTrainingStepMetricsRequest.java │ │ │ └── FinetuningUpdateFinetunedModelRequest.java │ ├── models │ │ ├── ModelsClient.java │ │ └── requests │ │ │ └── ModelsListRequest.java │ └── v2 │ │ ├── V2Client.java │ │ ├── requests │ │ ├── V2ChatRequest.java │ │ ├── V2ChatStreamRequest.java │ │ ├── V2EmbedRequest.java │ │ └── V2RerankRequest.java │ │ └── types │ │ ├── V2ChatRequestDocumentsItem.java │ │ ├── V2ChatRequestSafetyMode.java │ │ ├── V2ChatRequestToolChoice.java │ │ ├── V2ChatStreamRequestDocumentsItem.java │ │ ├── V2ChatStreamRequestSafetyMode.java │ │ ├── V2ChatStreamRequestToolChoice.java │ │ ├── V2EmbedRequestTruncate.java │ │ ├── V2RerankResponse.java │ │ ├── V2RerankResponseResultsItem.java │ │ └── V2RerankResponseResultsItemDocument.java │ └── types │ ├── ApiMeta.java │ ├── ApiMetaApiVersion.java │ ├── ApiMetaBilledUnits.java │ ├── ApiMetaTokens.java │ ├── AssistantMessage.java │ ├── AssistantMessageContent.java │ ├── AssistantMessageContentItem.java │ ├── AssistantMessageResponse.java │ ├── AssistantMessageResponseContentItem.java │ ├── AuthTokenType.java │ ├── ChatCitation.java │ ├── ChatCitationGenerationEvent.java │ ├── ChatCitationType.java │ ├── ChatConnector.java │ ├── ChatContentDeltaEvent.java │ ├── ChatContentDeltaEventDelta.java │ ├── ChatContentDeltaEventDeltaMessage.java │ ├── ChatContentDeltaEventDeltaMessageContent.java │ ├── ChatContentEndEvent.java │ ├── ChatContentStartEvent.java │ ├── ChatContentStartEventDelta.java │ ├── ChatContentStartEventDeltaMessage.java │ ├── ChatContentStartEventDeltaMessageContent.java │ ├── ChatDataMetrics.java │ ├── ChatDebugEvent.java │ ├── ChatFinishReason.java │ ├── ChatMessage.java │ ├── ChatMessageEndEvent.java │ ├── ChatMessageEndEventDelta.java │ ├── ChatMessageStartEvent.java │ ├── ChatMessageStartEventDelta.java │ ├── ChatMessageStartEventDeltaMessage.java │ ├── ChatMessageV2.java │ ├── ChatRequestCitationQuality.java │ ├── ChatRequestConnectorsSearchOptions.java │ ├── ChatRequestPromptTruncation.java │ ├── ChatRequestSafetyMode.java │ ├── ChatResponse.java │ ├── ChatSearchQueriesGenerationEvent.java │ ├── ChatSearchQuery.java │ ├── ChatSearchResult.java │ ├── ChatSearchResultConnector.java │ ├── ChatSearchResultsEvent.java │ ├── ChatStreamEndEvent.java │ ├── ChatStreamEndEventFinishReason.java │ ├── ChatStreamEvent.java │ ├── ChatStreamEventType.java │ ├── ChatStreamRequestCitationQuality.java │ ├── ChatStreamRequestConnectorsSearchOptions.java │ ├── ChatStreamRequestPromptTruncation.java │ ├── ChatStreamRequestSafetyMode.java │ ├── ChatStreamStartEvent.java │ ├── ChatTextGenerationEvent.java │ ├── ChatToolCallDeltaEvent.java │ ├── ChatToolCallDeltaEventDelta.java │ ├── ChatToolCallDeltaEventDeltaMessage.java │ ├── ChatToolCallDeltaEventDeltaMessageToolCalls.java │ ├── ChatToolCallDeltaEventDeltaMessageToolCallsFunction.java │ ├── ChatToolCallEndEvent.java │ ├── ChatToolCallStartEvent.java │ ├── ChatToolCallStartEventDelta.java │ ├── ChatToolCallStartEventDeltaMessage.java │ ├── ChatToolCallsChunkEvent.java │ ├── ChatToolCallsGenerationEvent.java │ ├── ChatToolPlanDeltaEvent.java │ ├── ChatToolPlanDeltaEventDelta.java │ ├── ChatToolPlanDeltaEventDeltaMessage.java │ ├── CheckApiKeyResponse.java │ ├── Citation.java │ ├── CitationEndEvent.java │ ├── CitationOptions.java │ ├── CitationOptionsMode.java │ ├── CitationStartEvent.java │ ├── CitationStartEventDelta.java │ ├── CitationStartEventDeltaMessage.java │ ├── CitationType.java │ ├── ClassifyDataMetrics.java │ ├── ClassifyExample.java │ ├── ClassifyRequestTruncate.java │ ├── ClassifyResponse.java │ ├── ClassifyResponseClassificationsItem.java │ ├── ClassifyResponseClassificationsItemClassificationType.java │ ├── ClassifyResponseClassificationsItemLabelsValue.java │ ├── CompatibleEndpoint.java │ ├── Connector.java │ ├── ConnectorAuthStatus.java │ ├── ConnectorOAuth.java │ ├── Content.java │ ├── CreateConnectorOAuth.java │ ├── CreateConnectorResponse.java │ ├── CreateConnectorServiceAuth.java │ ├── CreateEmbedJobResponse.java │ ├── Dataset.java │ ├── DatasetPart.java │ ├── DatasetType.java │ ├── DatasetValidationStatus.java │ ├── DetokenizeResponse.java │ ├── Document.java │ ├── DocumentContent.java │ ├── DocumentSource.java │ ├── EmbedByTypeResponse.java │ ├── EmbedByTypeResponseEmbeddings.java │ ├── EmbedContent.java │ ├── EmbedFloatsResponse.java │ ├── EmbedImage.java │ ├── EmbedImageUrl.java │ ├── EmbedInput.java │ ├── EmbedInputType.java │ ├── EmbedJob.java │ ├── EmbedJobStatus.java │ ├── EmbedJobTruncate.java │ ├── EmbedRequestTruncate.java │ ├── EmbedResponse.java │ ├── EmbedText.java │ ├── EmbeddingType.java │ ├── FinetuneDatasetMetrics.java │ ├── FinishReason.java │ ├── GenerateRequestReturnLikelihoods.java │ ├── GenerateRequestTruncate.java │ ├── GenerateStreamEnd.java │ ├── GenerateStreamEndResponse.java │ ├── GenerateStreamError.java │ ├── GenerateStreamEvent.java │ ├── GenerateStreamRequestReturnLikelihoods.java │ ├── GenerateStreamRequestTruncate.java │ ├── GenerateStreamText.java │ ├── GenerateStreamedResponse.java │ ├── Generation.java │ ├── GetConnectorResponse.java │ ├── GetModelResponse.java │ ├── IChatStreamEvent.java │ ├── IChatStreamEventType.java │ ├── IGenerateStreamEvent.java │ ├── Image.java │ ├── ImageContent.java │ ├── ImageUrl.java │ ├── JsonResponseFormat.java │ ├── JsonResponseFormatV2.java │ ├── LabelMetric.java │ ├── ListConnectorsResponse.java │ ├── ListEmbedJobResponse.java │ ├── ListModelsResponse.java │ ├── LogprobItem.java │ ├── Message.java │ ├── Metrics.java │ ├── MetricsEmbedData.java │ ├── MetricsEmbedDataFieldsItem.java │ ├── NonStreamedChatResponse.java │ ├── OAuthAuthorizeResponse.java │ ├── ParseInfo.java │ ├── ReasoningEffort.java │ ├── RerankRequestDocumentsItem.java │ ├── RerankResponse.java │ ├── RerankResponseResultsItem.java │ ├── RerankResponseResultsItemDocument.java │ ├── RerankerDataMetrics.java │ ├── ResponseFormat.java │ ├── ResponseFormatV2.java │ ├── SingleGeneration.java │ ├── SingleGenerationInStream.java │ ├── SingleGenerationTokenLikelihoodsItem.java │ ├── Source.java │ ├── StreamedChatResponse.java │ ├── StreamedChatResponseV2.java │ ├── SummarizeRequestExtractiveness.java │ ├── SummarizeRequestFormat.java │ ├── SummarizeRequestLength.java │ ├── SummarizeResponse.java │ ├── SystemMessage.java │ ├── SystemMessageContent.java │ ├── SystemMessageContentItem.java │ ├── TextContent.java │ ├── TextResponseFormat.java │ ├── TextResponseFormatV2.java │ ├── TokenizeResponse.java │ ├── Tool.java │ ├── ToolCall.java │ ├── ToolCallDelta.java │ ├── ToolCallV2.java │ ├── ToolCallV2Function.java │ ├── ToolContent.java │ ├── ToolMessage.java │ ├── ToolMessageV2.java │ ├── ToolMessageV2Content.java │ ├── ToolParameterDefinitionsValue.java │ ├── ToolResult.java │ ├── ToolSource.java │ ├── ToolV2.java │ ├── ToolV2Function.java │ ├── TruncationStrategy.java │ ├── TruncationStrategyAutoPreserveOrder.java │ ├── TruncationStrategyNone.java │ ├── UpdateConnectorResponse.java │ ├── Usage.java │ ├── UsageBilledUnits.java │ ├── UsageTokens.java │ ├── UserMessage.java │ └── UserMessageContent.java └── test └── java └── com └── cohere └── api └── TestClient.java /.fernignore: -------------------------------------------------------------------------------- 1 | README.md 2 | banner.png 3 | CODEOWNERS -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: [push] 4 | 5 | jobs: 6 | compile: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout repo 11 | uses: actions/checkout@v3 12 | 13 | - name: Set up Java 14 | id: setup-jre 15 | uses: actions/setup-java@v1 16 | with: 17 | java-version: "11" 18 | architecture: x64 19 | 20 | - name: Compile 21 | run: ./gradlew compileJava 22 | 23 | test: 24 | needs: [ compile ] 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: Checkout repo 28 | uses: actions/checkout@v3 29 | 30 | - name: Set up Java 31 | id: setup-jre 32 | uses: actions/setup-java@v1 33 | with: 34 | java-version: "11" 35 | architecture: x64 36 | 37 | - name: Test 38 | run: ./gradlew test 39 | publish: 40 | needs: [ compile, test ] 41 | if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') 42 | runs-on: ubuntu-latest 43 | 44 | steps: 45 | - name: Checkout repo 46 | uses: actions/checkout@v3 47 | 48 | - name: Set up Java 49 | id: setup-jre 50 | uses: actions/setup-java@v1 51 | with: 52 | java-version: "11" 53 | architecture: x64 54 | 55 | - name: Publish to maven 56 | run: | 57 | ./.publish/prepare.sh 58 | ./gradlew publish 59 | env: 60 | MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} 61 | MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} 62 | MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/" 63 | MAVEN_SIGNATURE_KID: ${{ secrets.MAVEN_SIGNATURE_KID }} 64 | MAVEN_SIGNATURE_SECRET_KEY: ${{ secrets.MAVEN_SIGNATURE_SECRET_KEY }} 65 | MAVEN_SIGNATURE_PASSWORD: ${{ secrets.MAVEN_SIGNATURE_PASSWORD }} 66 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .project 3 | .gradle 4 | ? 5 | .classpath 6 | .checkstyle 7 | .settings 8 | .node 9 | build 10 | 11 | # IntelliJ 12 | *.iml 13 | *.ipr 14 | *.iws 15 | .idea/ 16 | out/ 17 | 18 | # Eclipse/IntelliJ APT 19 | generated_src/ 20 | generated_testSrc/ 21 | generated/ 22 | 23 | bin 24 | build -------------------------------------------------------------------------------- /.publish/prepare.sh: -------------------------------------------------------------------------------- 1 | # Write key ring file 2 | echo "$MAVEN_SIGNATURE_SECRET_KEY" > armored_key.asc 3 | gpg -o publish_key.gpg --dearmor armored_key.asc 4 | 5 | # Generate gradle.properties file 6 | echo "signing.keyId=$MAVEN_SIGNATURE_KID" > gradle.properties 7 | echo "signing.secretKeyRingFile=publish_key.gpg" >> gradle.properties 8 | echo "signing.password=$MAVEN_SIGNATURE_PASSWORD" >> gradle.properties 9 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @cohere-ai/cohere-java 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Cohere. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cohere-ai/cohere-java/c056764140e304b114a83458f1c03ac5eb5ec074/banner.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'maven-publish' 4 | id 'com.diffplug.spotless' version '6.11.0' 5 | id 'signing' 6 | } 7 | 8 | repositories { 9 | mavenCentral() 10 | maven { 11 | url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' 12 | } 13 | } 14 | 15 | dependencies { 16 | api 'com.squareup.okhttp3:okhttp:4.12.0' 17 | api 'com.fasterxml.jackson.core:jackson-databind:2.13.0' 18 | api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.3' 19 | api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3' 20 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' 21 | testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2' 22 | } 23 | 24 | 25 | sourceCompatibility = 1.8 26 | targetCompatibility = 1.8 27 | 28 | spotless { 29 | java { 30 | palantirJavaFormat() 31 | } 32 | } 33 | 34 | java { 35 | withSourcesJar() 36 | withJavadocJar() 37 | } 38 | 39 | signing { 40 | sign(publishing.publications) 41 | } 42 | test { 43 | useJUnitPlatform() 44 | testLogging { 45 | showStandardStreams = true 46 | } 47 | } 48 | publishing { 49 | publications { 50 | maven(MavenPublication) { 51 | groupId = 'com.cohere' 52 | artifactId = 'cohere-java' 53 | version = '1.7.0' 54 | from components.java 55 | pom { 56 | name = 'cohere' 57 | description = 'The official Java library for Cohere\'s API.' 58 | url = 'https://docs.cohere.com' 59 | licenses { 60 | license { 61 | name = 'MIT' 62 | } 63 | } 64 | developers { 65 | developer { 66 | name = 'cohere' 67 | email = 'platform@cohere.com' 68 | } 69 | } 70 | scm { 71 | connection = 'scm:git:git://github.com/cohere-ai/cohere-java.git' 72 | developerConnection = 'scm:git:git://github.com/cohere-ai/cohere-java.git' 73 | url = 'https://github.com/cohere-ai/cohere-java' 74 | } 75 | } 76 | } 77 | } 78 | repositories { 79 | maven { 80 | url "$System.env.MAVEN_PUBLISH_REGISTRY_URL" 81 | credentials { 82 | username "$System.env.MAVEN_USERNAME" 83 | password "$System.env.MAVEN_PASSWORD" 84 | } 85 | } 86 | } 87 | } 88 | 89 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cohere-ai/cohere-java/c056764140e304b114a83458f1c03ac5eb5ec074/gradle.properties -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cohere-ai/cohere-java/c056764140e304b114a83458f1c03ac5eb5ec074/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 1>&2 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 48 | echo. 1>&2 49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 50 | echo location of your Java installation. 1>&2 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 1>&2 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 62 | echo. 1>&2 63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 64 | echo location of your Java installation. 1>&2 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /sample-app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven { 8 | url 'https://s01.oss.sonatype.org/content/repositories/releases/' 9 | } 10 | } 11 | 12 | dependencies { 13 | implementation rootProject 14 | } 15 | 16 | 17 | sourceCompatibility = 1.8 18 | targetCompatibility = 1.8 19 | 20 | -------------------------------------------------------------------------------- /sample-app/src/main/java/sample/App.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | package sample; 6 | 7 | import java.lang.String; 8 | 9 | public final class App { 10 | public static void main(String[] args) { 11 | // import com.cohere.api.Cohere 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'sample-app' -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/CohereBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api; 5 | 6 | import com.cohere.api.core.ClientOptions; 7 | import com.cohere.api.core.Environment; 8 | 9 | public final class CohereBuilder { 10 | private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); 11 | 12 | private String token = System.getenv("CO_API_KEY"); 13 | 14 | private String clientName = null; 15 | 16 | private Environment environment = Environment.PRODUCTION; 17 | 18 | /** 19 | * Sets token. 20 | * Defaults to the CO_API_KEY environment variable. 21 | */ 22 | public CohereBuilder token(String token) { 23 | this.token = token; 24 | return this; 25 | } 26 | 27 | /** 28 | * Sets clientName 29 | */ 30 | public CohereBuilder clientName(String clientName) { 31 | this.clientName = clientName; 32 | return this; 33 | } 34 | 35 | public CohereBuilder environment(Environment environment) { 36 | this.environment = environment; 37 | return this; 38 | } 39 | 40 | public CohereBuilder url(String url) { 41 | this.environment = Environment.custom(url); 42 | return this; 43 | } 44 | 45 | public Cohere build() { 46 | if (token == null) { 47 | throw new RuntimeException("Please provide token or set the CO_API_KEY environment variable."); 48 | } 49 | this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); 50 | if (clientName != null) { 51 | this.clientOptionsBuilder.addHeader("X-Client-Name", this.clientName); 52 | } 53 | clientOptionsBuilder.environment(this.environment); 54 | return new Cohere(clientOptionsBuilder.build()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/CohereApiException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | /** 7 | * This exception type will be thrown for any non-2XX API responses. 8 | */ 9 | public class CohereApiException extends CohereException { 10 | /** 11 | * The error code of the response that triggered the exception. 12 | */ 13 | private final int statusCode; 14 | 15 | /** 16 | * The body of the response that triggered the exception. 17 | */ 18 | private final Object body; 19 | 20 | public CohereApiException(String message, int statusCode, Object body) { 21 | super(message); 22 | this.statusCode = statusCode; 23 | this.body = body; 24 | } 25 | 26 | /** 27 | * @return the statusCode 28 | */ 29 | public int statusCode() { 30 | return this.statusCode; 31 | } 32 | 33 | /** 34 | * @return the body 35 | */ 36 | public Object body() { 37 | return this.body; 38 | } 39 | 40 | @java.lang.Override 41 | public String toString() { 42 | return "CohereApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body 43 | + "}"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/CohereException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | /** 7 | * This class serves as the base exception for all errors in the SDK. 8 | */ 9 | public class CohereException extends RuntimeException { 10 | public CohereException(String message) { 11 | super(message); 12 | } 13 | 14 | public CohereException(String message, Exception e) { 15 | super(message, e); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/DateTimeDeserializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import com.fasterxml.jackson.core.JsonParser; 7 | import com.fasterxml.jackson.core.JsonToken; 8 | import com.fasterxml.jackson.databind.DeserializationContext; 9 | import com.fasterxml.jackson.databind.JsonDeserializer; 10 | import com.fasterxml.jackson.databind.module.SimpleModule; 11 | import java.io.IOException; 12 | import java.time.Instant; 13 | import java.time.LocalDateTime; 14 | import java.time.OffsetDateTime; 15 | import java.time.ZoneOffset; 16 | import java.time.format.DateTimeFormatter; 17 | import java.time.temporal.TemporalAccessor; 18 | import java.time.temporal.TemporalQueries; 19 | 20 | /** 21 | * Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects. 22 | */ 23 | class DateTimeDeserializer extends JsonDeserializer { 24 | private static final SimpleModule MODULE; 25 | 26 | static { 27 | MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer()); 28 | } 29 | 30 | /** 31 | * Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper. 32 | * 33 | * @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper. 34 | */ 35 | public static SimpleModule getModule() { 36 | return MODULE; 37 | } 38 | 39 | @Override 40 | public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { 41 | JsonToken token = parser.currentToken(); 42 | if (token == JsonToken.VALUE_NUMBER_INT) { 43 | return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC); 44 | } else { 45 | TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( 46 | parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from); 47 | 48 | if (temporal.query(TemporalQueries.offset()) == null) { 49 | return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC); 50 | } else { 51 | return OffsetDateTime.from(temporal); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/Environment.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | public final class Environment { 7 | public static final Environment PRODUCTION = new Environment("https://api.cohere.com"); 8 | 9 | private final String url; 10 | 11 | private Environment(String url) { 12 | this.url = url; 13 | } 14 | 15 | public String getUrl() { 16 | return this.url; 17 | } 18 | 19 | public static Environment custom(String url) { 20 | return new Environment(url); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/FileStream.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import java.io.InputStream; 7 | import java.util.Objects; 8 | import okhttp3.MediaType; 9 | import okhttp3.RequestBody; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | /** 13 | * Represents a file stream with associated metadata for file uploads. 14 | */ 15 | public class FileStream { 16 | private final InputStream inputStream; 17 | private final String fileName; 18 | private final MediaType contentType; 19 | 20 | /** 21 | * Constructs a FileStream with the given input stream and optional metadata. 22 | * 23 | * @param inputStream The input stream of the file content. Must not be null. 24 | * @param fileName The name of the file, or null if unknown. 25 | * @param contentType The MIME type of the file content, or null if unknown. 26 | * @throws NullPointerException if inputStream is null 27 | */ 28 | public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) { 29 | this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null"); 30 | this.fileName = fileName; 31 | this.contentType = contentType; 32 | } 33 | 34 | public FileStream(InputStream inputStream) { 35 | this(inputStream, null, null); 36 | } 37 | 38 | public InputStream getInputStream() { 39 | return inputStream; 40 | } 41 | 42 | @Nullable 43 | public String getFileName() { 44 | return fileName; 45 | } 46 | 47 | @Nullable 48 | public MediaType getContentType() { 49 | return contentType; 50 | } 51 | 52 | /** 53 | * Creates a RequestBody suitable for use with OkHttp client. 54 | * 55 | * @return A RequestBody instance representing this file stream. 56 | */ 57 | public RequestBody toRequestBody() { 58 | return new InputStreamRequestBody(contentType, inputStream); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/InputStreamRequestBody.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.util.Objects; 9 | import okhttp3.MediaType; 10 | import okhttp3.RequestBody; 11 | import okhttp3.internal.Util; 12 | import okio.BufferedSink; 13 | import okio.Okio; 14 | import okio.Source; 15 | import org.jetbrains.annotations.Nullable; 16 | 17 | /** 18 | * A custom implementation of OkHttp's RequestBody that wraps an InputStream. 19 | * This class allows streaming of data from an InputStream directly to an HTTP request body, 20 | * which is useful for file uploads or sending large amounts of data without loading it all into memory. 21 | */ 22 | public class InputStreamRequestBody extends RequestBody { 23 | private final InputStream inputStream; 24 | private final MediaType contentType; 25 | 26 | /** 27 | * Constructs an InputStreamRequestBody with the specified content type and input stream. 28 | * 29 | * @param contentType the MediaType of the content, or null if not known 30 | * @param inputStream the InputStream containing the data to be sent 31 | * @throws NullPointerException if inputStream is null 32 | */ 33 | public InputStreamRequestBody(@Nullable MediaType contentType, InputStream inputStream) { 34 | this.contentType = contentType; 35 | this.inputStream = Objects.requireNonNull(inputStream, "inputStream == null"); 36 | } 37 | 38 | /** 39 | * Returns the content type of this request body. 40 | * 41 | * @return the MediaType of the content, or null if not specified 42 | */ 43 | @Nullable 44 | @Override 45 | public MediaType contentType() { 46 | return contentType; 47 | } 48 | 49 | /** 50 | * Returns the content length of this request body, if known. 51 | * This method attempts to determine the length using the InputStream's available() method, 52 | * which may not always accurately reflect the total length of the stream. 53 | * 54 | * @return the content length, or -1 if the length is unknown 55 | * @throws IOException if an I/O error occurs 56 | */ 57 | @Override 58 | public long contentLength() throws IOException { 59 | return inputStream.available() == 0 ? -1 : inputStream.available(); 60 | } 61 | 62 | /** 63 | * Writes the content of the InputStream to the given BufferedSink. 64 | * This method is responsible for transferring the data from the InputStream to the network request. 65 | * 66 | * @param sink the BufferedSink to write the content to 67 | * @throws IOException if an I/O error occurs during writing 68 | */ 69 | @Override 70 | public void writeTo(BufferedSink sink) throws IOException { 71 | Source source = null; 72 | try { 73 | source = Okio.source(inputStream); 74 | sink.writeAll(source); 75 | } finally { 76 | Util.closeQuietly(Objects.requireNonNull(source)); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/MediaTypes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import okhttp3.MediaType; 7 | 8 | public final class MediaTypes { 9 | 10 | public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); 11 | 12 | private MediaTypes() {} 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/ObjectMappers.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import com.fasterxml.jackson.annotation.JsonInclude; 7 | import com.fasterxml.jackson.databind.DeserializationFeature; 8 | import com.fasterxml.jackson.databind.ObjectMapper; 9 | import com.fasterxml.jackson.databind.SerializationFeature; 10 | import com.fasterxml.jackson.databind.json.JsonMapper; 11 | import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; 12 | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; 13 | import java.io.IOException; 14 | 15 | public final class ObjectMappers { 16 | public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() 17 | .addModule(new Jdk8Module()) 18 | .addModule(new JavaTimeModule()) 19 | .addModule(DateTimeDeserializer.getModule()) 20 | .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) 21 | .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) 22 | .build(); 23 | 24 | private ObjectMappers() {} 25 | 26 | public static String stringify(Object o) { 27 | try { 28 | return JSON_MAPPER 29 | .setSerializationInclusion(JsonInclude.Include.ALWAYS) 30 | .writerWithDefaultPrettyPrinter() 31 | .writeValueAsString(o); 32 | } catch (IOException e) { 33 | return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/RequestOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.Optional; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | public final class RequestOptions { 12 | private final String token; 13 | 14 | private final String clientName; 15 | 16 | private final Optional timeout; 17 | 18 | private final TimeUnit timeoutTimeUnit; 19 | 20 | private RequestOptions(String token, String clientName, Optional timeout, TimeUnit timeoutTimeUnit) { 21 | this.token = token; 22 | this.clientName = clientName; 23 | this.timeout = timeout; 24 | this.timeoutTimeUnit = timeoutTimeUnit; 25 | } 26 | 27 | public Optional getTimeout() { 28 | return timeout; 29 | } 30 | 31 | public TimeUnit getTimeoutTimeUnit() { 32 | return timeoutTimeUnit; 33 | } 34 | 35 | public Map getHeaders() { 36 | Map headers = new HashMap<>(); 37 | if (this.token != null) { 38 | headers.put("Authorization", "Bearer " + this.token); 39 | } 40 | if (this.clientName != null) { 41 | headers.put("X-Client-Name", this.clientName); 42 | } 43 | return headers; 44 | } 45 | 46 | public static Builder builder() { 47 | return new Builder(); 48 | } 49 | 50 | public static final class Builder { 51 | private String token = null; 52 | 53 | private String clientName = null; 54 | 55 | private Optional timeout = Optional.empty(); 56 | 57 | private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; 58 | 59 | public Builder token(String token) { 60 | this.token = token; 61 | return this; 62 | } 63 | 64 | public Builder clientName(String clientName) { 65 | this.clientName = clientName; 66 | return this; 67 | } 68 | 69 | public Builder timeout(Integer timeout) { 70 | this.timeout = Optional.of(timeout); 71 | return this; 72 | } 73 | 74 | public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { 75 | this.timeout = Optional.of(timeout); 76 | this.timeoutTimeUnit = timeoutTimeUnit; 77 | return this; 78 | } 79 | 80 | public RequestOptions build() { 81 | return new RequestOptions(token, clientName, timeout, timeoutTimeUnit); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/ResponseBodyInputStream.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import java.io.FilterInputStream; 7 | import java.io.IOException; 8 | import okhttp3.Response; 9 | 10 | /** 11 | * A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the 12 | * OkHttp Response object is properly closed when the stream is closed. 13 | * 14 | * This class extends FilterInputStream and takes an OkHttp Response object as a parameter. 15 | * It retrieves the InputStream from the Response and overrides the close method to close 16 | * both the InputStream and the Response object, ensuring proper resource management and preventing 17 | * premature closure of the underlying HTTP connection. 18 | */ 19 | public class ResponseBodyInputStream extends FilterInputStream { 20 | private final Response response; 21 | 22 | /** 23 | * Constructs a ResponseBodyInputStream that wraps the InputStream from the given OkHttp 24 | * Response object. 25 | * 26 | * @param response the OkHttp Response object from which the InputStream is retrieved 27 | * @throws IOException if an I/O error occurs while retrieving the InputStream 28 | */ 29 | public ResponseBodyInputStream(Response response) throws IOException { 30 | super(response.body().byteStream()); 31 | this.response = response; 32 | } 33 | 34 | /** 35 | * Closes the InputStream and the associated OkHttp Response object. This ensures that the 36 | * underlying HTTP connection is properly closed after the stream is no longer needed. 37 | * 38 | * @throws IOException if an I/O error occurs 39 | */ 40 | @Override 41 | public void close() throws IOException { 42 | super.close(); 43 | response.close(); // Ensure the response is closed when the stream is closed 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/ResponseBodyReader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import java.io.FilterReader; 7 | import java.io.IOException; 8 | import okhttp3.Response; 9 | 10 | /** 11 | * A custom Reader that wraps the Reader from the OkHttp Response and ensures that the 12 | * OkHttp Response object is properly closed when the reader is closed. 13 | * 14 | * This class extends FilterReader and takes an OkHttp Response object as a parameter. 15 | * It retrieves the Reader from the Response and overrides the close method to close 16 | * both the Reader and the Response object, ensuring proper resource management and preventing 17 | * premature closure of the underlying HTTP connection. 18 | */ 19 | public class ResponseBodyReader extends FilterReader { 20 | private final Response response; 21 | 22 | /** 23 | * Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object. 24 | * 25 | * @param response the OkHttp Response object from which the Reader is retrieved 26 | * @throws IOException if an I/O error occurs while retrieving the Reader 27 | */ 28 | public ResponseBodyReader(Response response) throws IOException { 29 | super(response.body().charStream()); 30 | this.response = response; 31 | } 32 | 33 | /** 34 | * Closes the Reader and the associated OkHttp Response object. This ensures that the 35 | * underlying HTTP connection is properly closed after the reader is no longer needed. 36 | * 37 | * @throws IOException if an I/O error occurs 38 | */ 39 | @Override 40 | public void close() throws IOException { 41 | super.close(); 42 | response.close(); // Ensure the response is closed when the reader is closed 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/RetryInterceptor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import java.io.IOException; 7 | import java.time.Duration; 8 | import java.util.Optional; 9 | import java.util.Random; 10 | import okhttp3.Interceptor; 11 | import okhttp3.Response; 12 | 13 | public class RetryInterceptor implements Interceptor { 14 | 15 | private static final Duration ONE_SECOND = Duration.ofSeconds(1); 16 | private final ExponentialBackoff backoff; 17 | private final Random random = new Random(); 18 | 19 | public RetryInterceptor(int maxRetries) { 20 | this.backoff = new ExponentialBackoff(maxRetries); 21 | } 22 | 23 | @Override 24 | public Response intercept(Chain chain) throws IOException { 25 | Response response = chain.proceed(chain.request()); 26 | 27 | if (shouldRetry(response.code())) { 28 | return retryChain(response, chain); 29 | } 30 | 31 | return response; 32 | } 33 | 34 | private Response retryChain(Response response, Chain chain) throws IOException { 35 | Optional nextBackoff = this.backoff.nextBackoff(); 36 | while (nextBackoff.isPresent()) { 37 | try { 38 | Thread.sleep(nextBackoff.get().toMillis()); 39 | } catch (InterruptedException e) { 40 | throw new IOException("Interrupted while trying request", e); 41 | } 42 | response.close(); 43 | response = chain.proceed(chain.request()); 44 | if (shouldRetry(response.code())) { 45 | nextBackoff = this.backoff.nextBackoff(); 46 | } else { 47 | return response; 48 | } 49 | } 50 | 51 | return response; 52 | } 53 | 54 | private static boolean shouldRetry(int statusCode) { 55 | return statusCode == 408 || statusCode == 409 || statusCode == 429 || statusCode >= 500; 56 | } 57 | 58 | private final class ExponentialBackoff { 59 | 60 | private final int maxNumRetries; 61 | 62 | private int retryNumber = 0; 63 | 64 | ExponentialBackoff(int maxNumRetries) { 65 | this.maxNumRetries = maxNumRetries; 66 | } 67 | 68 | public Optional nextBackoff() { 69 | retryNumber += 1; 70 | if (retryNumber > maxNumRetries) { 71 | return Optional.empty(); 72 | } 73 | 74 | int upperBound = (int) Math.pow(2, retryNumber); 75 | return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/core/Suppliers.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.core; 5 | 6 | import java.util.Objects; 7 | import java.util.concurrent.atomic.AtomicReference; 8 | import java.util.function.Supplier; 9 | 10 | public final class Suppliers { 11 | private Suppliers() {} 12 | 13 | public static Supplier memoize(Supplier delegate) { 14 | AtomicReference value = new AtomicReference<>(); 15 | return () -> { 16 | T val = value.get(); 17 | if (val == null) { 18 | val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); 19 | } 20 | return val; 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/BadRequestError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class BadRequestError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public BadRequestError(Object body) { 15 | super("BadRequestError", 400, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/ClientClosedRequestError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class ClientClosedRequestError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public ClientClosedRequestError(Object body) { 15 | super("ClientClosedRequestError", 499, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/ForbiddenError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class ForbiddenError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public ForbiddenError(Object body) { 15 | super("ForbiddenError", 403, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/GatewayTimeoutError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class GatewayTimeoutError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public GatewayTimeoutError(Object body) { 15 | super("GatewayTimeoutError", 504, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/InternalServerError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class InternalServerError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public InternalServerError(Object body) { 15 | super("InternalServerError", 500, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/InvalidTokenError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class InvalidTokenError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public InvalidTokenError(Object body) { 15 | super("InvalidTokenError", 498, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/NotFoundError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class NotFoundError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public NotFoundError(Object body) { 15 | super("NotFoundError", 404, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/NotImplementedError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class NotImplementedError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public NotImplementedError(Object body) { 15 | super("NotImplementedError", 501, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/ServiceUnavailableError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class ServiceUnavailableError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public ServiceUnavailableError(Object body) { 15 | super("ServiceUnavailableError", 503, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/TooManyRequestsError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class TooManyRequestsError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public TooManyRequestsError(Object body) { 15 | super("TooManyRequestsError", 429, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/UnauthorizedError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class UnauthorizedError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public UnauthorizedError(Object body) { 15 | super("UnauthorizedError", 401, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/errors/UnprocessableEntityError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.errors; 5 | 6 | import com.cohere.api.core.CohereApiException; 7 | 8 | public final class UnprocessableEntityError extends CohereApiException { 9 | /** 10 | * The body of the response that triggered the exception. 11 | */ 12 | private final Object body; 13 | 14 | public UnprocessableEntityError(Object body) { 15 | super("UnprocessableEntityError", 422, body); 16 | this.body = body; 17 | } 18 | 19 | /** 20 | * @return the body 21 | */ 22 | @java.lang.Override 23 | public Object body() { 24 | return this.body; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/datasets/types/DatasetsCreateResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.datasets.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = DatasetsCreateResponse.Builder.class) 22 | public final class DatasetsCreateResponse { 23 | private final Optional id; 24 | 25 | private final Map additionalProperties; 26 | 27 | private DatasetsCreateResponse(Optional id, Map additionalProperties) { 28 | this.id = id; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | /** 33 | * @return The dataset ID 34 | */ 35 | @JsonProperty("id") 36 | public Optional getId() { 37 | return id; 38 | } 39 | 40 | @java.lang.Override 41 | public boolean equals(Object other) { 42 | if (this == other) return true; 43 | return other instanceof DatasetsCreateResponse && equalTo((DatasetsCreateResponse) other); 44 | } 45 | 46 | @JsonAnyGetter 47 | public Map getAdditionalProperties() { 48 | return this.additionalProperties; 49 | } 50 | 51 | private boolean equalTo(DatasetsCreateResponse other) { 52 | return id.equals(other.id); 53 | } 54 | 55 | @java.lang.Override 56 | public int hashCode() { 57 | return Objects.hash(this.id); 58 | } 59 | 60 | @java.lang.Override 61 | public String toString() { 62 | return ObjectMappers.stringify(this); 63 | } 64 | 65 | public static Builder builder() { 66 | return new Builder(); 67 | } 68 | 69 | @JsonIgnoreProperties(ignoreUnknown = true) 70 | public static final class Builder { 71 | private Optional id = Optional.empty(); 72 | 73 | @JsonAnySetter 74 | private Map additionalProperties = new HashMap<>(); 75 | 76 | private Builder() {} 77 | 78 | public Builder from(DatasetsCreateResponse other) { 79 | id(other.getId()); 80 | return this; 81 | } 82 | 83 | @JsonSetter(value = "id", nulls = Nulls.SKIP) 84 | public Builder id(Optional id) { 85 | this.id = id; 86 | return this; 87 | } 88 | 89 | public Builder id(String id) { 90 | this.id = Optional.ofNullable(id); 91 | return this; 92 | } 93 | 94 | public DatasetsCreateResponse build() { 95 | return new DatasetsCreateResponse(id, additionalProperties); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/datasets/types/DatasetsListResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.datasets.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.cohere.api.types.Dataset; 8 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 9 | import com.fasterxml.jackson.annotation.JsonAnySetter; 10 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 11 | import com.fasterxml.jackson.annotation.JsonInclude; 12 | import com.fasterxml.jackson.annotation.JsonProperty; 13 | import com.fasterxml.jackson.annotation.JsonSetter; 14 | import com.fasterxml.jackson.annotation.Nulls; 15 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | import java.util.Objects; 20 | import java.util.Optional; 21 | 22 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 23 | @JsonDeserialize(builder = DatasetsListResponse.Builder.class) 24 | public final class DatasetsListResponse { 25 | private final Optional> datasets; 26 | 27 | private final Map additionalProperties; 28 | 29 | private DatasetsListResponse(Optional> datasets, Map additionalProperties) { 30 | this.datasets = datasets; 31 | this.additionalProperties = additionalProperties; 32 | } 33 | 34 | @JsonProperty("datasets") 35 | public Optional> getDatasets() { 36 | return datasets; 37 | } 38 | 39 | @java.lang.Override 40 | public boolean equals(Object other) { 41 | if (this == other) return true; 42 | return other instanceof DatasetsListResponse && equalTo((DatasetsListResponse) other); 43 | } 44 | 45 | @JsonAnyGetter 46 | public Map getAdditionalProperties() { 47 | return this.additionalProperties; 48 | } 49 | 50 | private boolean equalTo(DatasetsListResponse other) { 51 | return datasets.equals(other.datasets); 52 | } 53 | 54 | @java.lang.Override 55 | public int hashCode() { 56 | return Objects.hash(this.datasets); 57 | } 58 | 59 | @java.lang.Override 60 | public String toString() { 61 | return ObjectMappers.stringify(this); 62 | } 63 | 64 | public static Builder builder() { 65 | return new Builder(); 66 | } 67 | 68 | @JsonIgnoreProperties(ignoreUnknown = true) 69 | public static final class Builder { 70 | private Optional> datasets = Optional.empty(); 71 | 72 | @JsonAnySetter 73 | private Map additionalProperties = new HashMap<>(); 74 | 75 | private Builder() {} 76 | 77 | public Builder from(DatasetsListResponse other) { 78 | datasets(other.getDatasets()); 79 | return this; 80 | } 81 | 82 | @JsonSetter(value = "datasets", nulls = Nulls.SKIP) 83 | public Builder datasets(Optional> datasets) { 84 | this.datasets = datasets; 85 | return this; 86 | } 87 | 88 | public Builder datasets(List datasets) { 89 | this.datasets = Optional.ofNullable(datasets); 90 | return this; 91 | } 92 | 93 | public DatasetsListResponse build() { 94 | return new DatasetsListResponse(datasets, additionalProperties); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/embedjobs/types/CreateEmbedJobRequestTruncate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.embedjobs.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum CreateEmbedJobRequestTruncate { 9 | START("START"), 10 | 11 | END("END"); 12 | 13 | private final String value; 14 | 15 | CreateEmbedJobRequestTruncate(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | @java.lang.Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/finetuning/finetuning/types/BaseType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.finetuning.finetuning.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum BaseType { 9 | BASE_TYPE_UNSPECIFIED("BASE_TYPE_UNSPECIFIED"), 10 | 11 | BASE_TYPE_GENERATIVE("BASE_TYPE_GENERATIVE"), 12 | 13 | BASE_TYPE_CLASSIFICATION("BASE_TYPE_CLASSIFICATION"), 14 | 15 | BASE_TYPE_RERANK("BASE_TYPE_RERANK"), 16 | 17 | BASE_TYPE_CHAT("BASE_TYPE_CHAT"); 18 | 19 | private final String value; 20 | 21 | BaseType(String value) { 22 | this.value = value; 23 | } 24 | 25 | @JsonValue 26 | @java.lang.Override 27 | public String toString() { 28 | return this.value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/finetuning/finetuning/types/LoraTargetModules.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.finetuning.finetuning.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum LoraTargetModules { 9 | LORA_TARGET_MODULES_UNSPECIFIED("LORA_TARGET_MODULES_UNSPECIFIED"), 10 | 11 | LORA_TARGET_MODULES_QV("LORA_TARGET_MODULES_QV"), 12 | 13 | LORA_TARGET_MODULES_QKVO("LORA_TARGET_MODULES_QKVO"), 14 | 15 | LORA_TARGET_MODULES_QKVO_FFN("LORA_TARGET_MODULES_QKVO_FFN"); 16 | 17 | private final String value; 18 | 19 | LoraTargetModules(String value) { 20 | this.value = value; 21 | } 22 | 23 | @JsonValue 24 | @java.lang.Override 25 | public String toString() { 26 | return this.value; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Status.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.finetuning.finetuning.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum Status { 9 | STATUS_UNSPECIFIED("STATUS_UNSPECIFIED"), 10 | 11 | STATUS_FINETUNING("STATUS_FINETUNING"), 12 | 13 | STATUS_DEPLOYING_API("STATUS_DEPLOYING_API"), 14 | 15 | STATUS_READY("STATUS_READY"), 16 | 17 | STATUS_FAILED("STATUS_FAILED"), 18 | 19 | STATUS_DELETED("STATUS_DELETED"), 20 | 21 | STATUS_TEMPORARILY_OFFLINE("STATUS_TEMPORARILY_OFFLINE"), 22 | 23 | STATUS_PAUSED("STATUS_PAUSED"), 24 | 25 | STATUS_QUEUED("STATUS_QUEUED"); 26 | 27 | private final String value; 28 | 29 | Status(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | @java.lang.Override 35 | public String toString() { 36 | return this.value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/finetuning/finetuning/types/Strategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.finetuning.finetuning.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum Strategy { 9 | STRATEGY_UNSPECIFIED("STRATEGY_UNSPECIFIED"), 10 | 11 | STRATEGY_VANILLA("STRATEGY_VANILLA"), 12 | 13 | STRATEGY_TFEW("STRATEGY_TFEW"); 14 | 15 | private final String value; 16 | 17 | Strategy(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/v2/types/V2ChatRequestDocumentsItem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.v2.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.cohere.api.types.Document; 8 | import com.fasterxml.jackson.annotation.JsonValue; 9 | import com.fasterxml.jackson.core.JsonParseException; 10 | import com.fasterxml.jackson.core.JsonParser; 11 | import com.fasterxml.jackson.databind.DeserializationContext; 12 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 13 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; 14 | import java.io.IOException; 15 | import java.util.Objects; 16 | 17 | @JsonDeserialize(using = V2ChatRequestDocumentsItem.Deserializer.class) 18 | public final class V2ChatRequestDocumentsItem { 19 | private final Object value; 20 | 21 | private final int type; 22 | 23 | private V2ChatRequestDocumentsItem(Object value, int type) { 24 | this.value = value; 25 | this.type = type; 26 | } 27 | 28 | @JsonValue 29 | public Object get() { 30 | return this.value; 31 | } 32 | 33 | public T visit(Visitor visitor) { 34 | if (this.type == 0) { 35 | return visitor.visit((String) this.value); 36 | } else if (this.type == 1) { 37 | return visitor.visit((Document) this.value); 38 | } 39 | throw new IllegalStateException("Failed to visit value. This should never happen."); 40 | } 41 | 42 | @java.lang.Override 43 | public boolean equals(Object other) { 44 | if (this == other) return true; 45 | return other instanceof V2ChatRequestDocumentsItem && equalTo((V2ChatRequestDocumentsItem) other); 46 | } 47 | 48 | private boolean equalTo(V2ChatRequestDocumentsItem other) { 49 | return value.equals(other.value); 50 | } 51 | 52 | @java.lang.Override 53 | public int hashCode() { 54 | return Objects.hash(this.value); 55 | } 56 | 57 | @java.lang.Override 58 | public String toString() { 59 | return this.value.toString(); 60 | } 61 | 62 | public static V2ChatRequestDocumentsItem of(String value) { 63 | return new V2ChatRequestDocumentsItem(value, 0); 64 | } 65 | 66 | public static V2ChatRequestDocumentsItem of(Document value) { 67 | return new V2ChatRequestDocumentsItem(value, 1); 68 | } 69 | 70 | public interface Visitor { 71 | T visit(String value); 72 | 73 | T visit(Document value); 74 | } 75 | 76 | static final class Deserializer extends StdDeserializer { 77 | Deserializer() { 78 | super(V2ChatRequestDocumentsItem.class); 79 | } 80 | 81 | @java.lang.Override 82 | public V2ChatRequestDocumentsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { 83 | Object value = p.readValueAs(Object.class); 84 | try { 85 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); 86 | } catch (IllegalArgumentException e) { 87 | } 88 | try { 89 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, Document.class)); 90 | } catch (IllegalArgumentException e) { 91 | } 92 | throw new JsonParseException(p, "Failed to deserialize"); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/v2/types/V2ChatRequestSafetyMode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.v2.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum V2ChatRequestSafetyMode { 9 | CONTEXTUAL("CONTEXTUAL"), 10 | 11 | STRICT("STRICT"), 12 | 13 | OFF("OFF"); 14 | 15 | private final String value; 16 | 17 | V2ChatRequestSafetyMode(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/v2/types/V2ChatRequestToolChoice.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.v2.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum V2ChatRequestToolChoice { 9 | REQUIRED("REQUIRED"), 10 | 11 | NONE("NONE"); 12 | 13 | private final String value; 14 | 15 | V2ChatRequestToolChoice(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | @java.lang.Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/v2/types/V2ChatStreamRequestDocumentsItem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.v2.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.cohere.api.types.Document; 8 | import com.fasterxml.jackson.annotation.JsonValue; 9 | import com.fasterxml.jackson.core.JsonParseException; 10 | import com.fasterxml.jackson.core.JsonParser; 11 | import com.fasterxml.jackson.databind.DeserializationContext; 12 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 13 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; 14 | import java.io.IOException; 15 | import java.util.Objects; 16 | 17 | @JsonDeserialize(using = V2ChatStreamRequestDocumentsItem.Deserializer.class) 18 | public final class V2ChatStreamRequestDocumentsItem { 19 | private final Object value; 20 | 21 | private final int type; 22 | 23 | private V2ChatStreamRequestDocumentsItem(Object value, int type) { 24 | this.value = value; 25 | this.type = type; 26 | } 27 | 28 | @JsonValue 29 | public Object get() { 30 | return this.value; 31 | } 32 | 33 | public T visit(Visitor visitor) { 34 | if (this.type == 0) { 35 | return visitor.visit((String) this.value); 36 | } else if (this.type == 1) { 37 | return visitor.visit((Document) this.value); 38 | } 39 | throw new IllegalStateException("Failed to visit value. This should never happen."); 40 | } 41 | 42 | @java.lang.Override 43 | public boolean equals(Object other) { 44 | if (this == other) return true; 45 | return other instanceof V2ChatStreamRequestDocumentsItem && equalTo((V2ChatStreamRequestDocumentsItem) other); 46 | } 47 | 48 | private boolean equalTo(V2ChatStreamRequestDocumentsItem other) { 49 | return value.equals(other.value); 50 | } 51 | 52 | @java.lang.Override 53 | public int hashCode() { 54 | return Objects.hash(this.value); 55 | } 56 | 57 | @java.lang.Override 58 | public String toString() { 59 | return this.value.toString(); 60 | } 61 | 62 | public static V2ChatStreamRequestDocumentsItem of(String value) { 63 | return new V2ChatStreamRequestDocumentsItem(value, 0); 64 | } 65 | 66 | public static V2ChatStreamRequestDocumentsItem of(Document value) { 67 | return new V2ChatStreamRequestDocumentsItem(value, 1); 68 | } 69 | 70 | public interface Visitor { 71 | T visit(String value); 72 | 73 | T visit(Document value); 74 | } 75 | 76 | static final class Deserializer extends StdDeserializer { 77 | Deserializer() { 78 | super(V2ChatStreamRequestDocumentsItem.class); 79 | } 80 | 81 | @java.lang.Override 82 | public V2ChatStreamRequestDocumentsItem deserialize(JsonParser p, DeserializationContext ctxt) 83 | throws IOException { 84 | Object value = p.readValueAs(Object.class); 85 | try { 86 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); 87 | } catch (IllegalArgumentException e) { 88 | } 89 | try { 90 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, Document.class)); 91 | } catch (IllegalArgumentException e) { 92 | } 93 | throw new JsonParseException(p, "Failed to deserialize"); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/v2/types/V2ChatStreamRequestSafetyMode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.v2.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum V2ChatStreamRequestSafetyMode { 9 | CONTEXTUAL("CONTEXTUAL"), 10 | 11 | STRICT("STRICT"), 12 | 13 | OFF("OFF"); 14 | 15 | private final String value; 16 | 17 | V2ChatStreamRequestSafetyMode(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/v2/types/V2ChatStreamRequestToolChoice.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.v2.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum V2ChatStreamRequestToolChoice { 9 | REQUIRED("REQUIRED"), 10 | 11 | NONE("NONE"); 12 | 13 | private final String value; 14 | 15 | V2ChatStreamRequestToolChoice(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | @java.lang.Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/resources/v2/types/V2EmbedRequestTruncate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.resources.v2.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum V2EmbedRequestTruncate { 9 | NONE("NONE"), 10 | 11 | START("START"), 12 | 13 | END("END"); 14 | 15 | private final String value; 16 | 17 | V2EmbedRequestTruncate(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/AssistantMessageContent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonValue; 8 | import com.fasterxml.jackson.core.JsonParseException; 9 | import com.fasterxml.jackson.core.JsonParser; 10 | import com.fasterxml.jackson.core.type.TypeReference; 11 | import com.fasterxml.jackson.databind.DeserializationContext; 12 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 13 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; 14 | import java.io.IOException; 15 | import java.util.List; 16 | import java.util.Objects; 17 | 18 | @JsonDeserialize(using = AssistantMessageContent.Deserializer.class) 19 | public final class AssistantMessageContent { 20 | private final Object value; 21 | 22 | private final int type; 23 | 24 | private AssistantMessageContent(Object value, int type) { 25 | this.value = value; 26 | this.type = type; 27 | } 28 | 29 | @JsonValue 30 | public Object get() { 31 | return this.value; 32 | } 33 | 34 | public T visit(Visitor visitor) { 35 | if (this.type == 0) { 36 | return visitor.visit((String) this.value); 37 | } else if (this.type == 1) { 38 | return visitor.visit((List) this.value); 39 | } 40 | throw new IllegalStateException("Failed to visit value. This should never happen."); 41 | } 42 | 43 | @java.lang.Override 44 | public boolean equals(Object other) { 45 | if (this == other) return true; 46 | return other instanceof AssistantMessageContent && equalTo((AssistantMessageContent) other); 47 | } 48 | 49 | private boolean equalTo(AssistantMessageContent other) { 50 | return value.equals(other.value); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.value); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return this.value.toString(); 61 | } 62 | 63 | public static AssistantMessageContent of(String value) { 64 | return new AssistantMessageContent(value, 0); 65 | } 66 | 67 | public static AssistantMessageContent of(List value) { 68 | return new AssistantMessageContent(value, 1); 69 | } 70 | 71 | public interface Visitor { 72 | T visit(String value); 73 | 74 | T visit(List value); 75 | } 76 | 77 | static final class Deserializer extends StdDeserializer { 78 | Deserializer() { 79 | super(AssistantMessageContent.class); 80 | } 81 | 82 | @java.lang.Override 83 | public AssistantMessageContent deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { 84 | Object value = p.readValueAs(Object.class); 85 | try { 86 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); 87 | } catch (IllegalArgumentException e) { 88 | } 89 | try { 90 | return of(ObjectMappers.JSON_MAPPER.convertValue( 91 | value, new TypeReference>() {})); 92 | } catch (IllegalArgumentException e) { 93 | } 94 | throw new JsonParseException(p, "Failed to deserialize"); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/AuthTokenType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum AuthTokenType { 9 | BEARER("bearer"), 10 | 11 | BASIC("basic"), 12 | 13 | NOSCHEME("noscheme"); 14 | 15 | private final String value; 16 | 17 | AuthTokenType(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatCitationType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ChatCitationType { 9 | TEXT_CONTENT("TEXT_CONTENT"), 10 | 11 | PLAN("PLAN"); 12 | 13 | private final String value; 14 | 15 | ChatCitationType(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | @java.lang.Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatContentDeltaEventDelta.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatContentDeltaEventDelta.Builder.class) 22 | public final class ChatContentDeltaEventDelta { 23 | private final Optional message; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatContentDeltaEventDelta( 28 | Optional message, Map additionalProperties) { 29 | this.message = message; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("message") 34 | public Optional getMessage() { 35 | return message; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ChatContentDeltaEventDelta && equalTo((ChatContentDeltaEventDelta) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ChatContentDeltaEventDelta other) { 50 | return message.equals(other.message); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.message); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional message = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ChatContentDeltaEventDelta other) { 77 | message(other.getMessage()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "message", nulls = Nulls.SKIP) 82 | public Builder message(Optional message) { 83 | this.message = message; 84 | return this; 85 | } 86 | 87 | public Builder message(ChatContentDeltaEventDeltaMessage message) { 88 | this.message = Optional.ofNullable(message); 89 | return this; 90 | } 91 | 92 | public ChatContentDeltaEventDelta build() { 93 | return new ChatContentDeltaEventDelta(message, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatContentDeltaEventDeltaMessageContent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatContentDeltaEventDeltaMessageContent.Builder.class) 22 | public final class ChatContentDeltaEventDeltaMessageContent { 23 | private final Optional text; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatContentDeltaEventDeltaMessageContent(Optional text, Map additionalProperties) { 28 | this.text = text; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | @JsonProperty("text") 33 | public Optional getText() { 34 | return text; 35 | } 36 | 37 | @java.lang.Override 38 | public boolean equals(Object other) { 39 | if (this == other) return true; 40 | return other instanceof ChatContentDeltaEventDeltaMessageContent 41 | && equalTo((ChatContentDeltaEventDeltaMessageContent) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ChatContentDeltaEventDeltaMessageContent other) { 50 | return text.equals(other.text); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.text); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional text = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ChatContentDeltaEventDeltaMessageContent other) { 77 | text(other.getText()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "text", nulls = Nulls.SKIP) 82 | public Builder text(Optional text) { 83 | this.text = text; 84 | return this; 85 | } 86 | 87 | public Builder text(String text) { 88 | this.text = Optional.ofNullable(text); 89 | return this; 90 | } 91 | 92 | public ChatContentDeltaEventDeltaMessageContent build() { 93 | return new ChatContentDeltaEventDeltaMessageContent(text, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatContentEndEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatContentEndEvent.Builder.class) 22 | public final class ChatContentEndEvent implements IChatStreamEventType { 23 | private final Optional index; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatContentEndEvent(Optional index, Map additionalProperties) { 28 | this.index = index; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | @JsonProperty("index") 33 | public Optional getIndex() { 34 | return index; 35 | } 36 | 37 | @java.lang.Override 38 | public boolean equals(Object other) { 39 | if (this == other) return true; 40 | return other instanceof ChatContentEndEvent && equalTo((ChatContentEndEvent) other); 41 | } 42 | 43 | @JsonAnyGetter 44 | public Map getAdditionalProperties() { 45 | return this.additionalProperties; 46 | } 47 | 48 | private boolean equalTo(ChatContentEndEvent other) { 49 | return index.equals(other.index); 50 | } 51 | 52 | @java.lang.Override 53 | public int hashCode() { 54 | return Objects.hash(this.index); 55 | } 56 | 57 | @java.lang.Override 58 | public String toString() { 59 | return ObjectMappers.stringify(this); 60 | } 61 | 62 | public static Builder builder() { 63 | return new Builder(); 64 | } 65 | 66 | @JsonIgnoreProperties(ignoreUnknown = true) 67 | public static final class Builder { 68 | private Optional index = Optional.empty(); 69 | 70 | @JsonAnySetter 71 | private Map additionalProperties = new HashMap<>(); 72 | 73 | private Builder() {} 74 | 75 | public Builder from(ChatContentEndEvent other) { 76 | index(other.getIndex()); 77 | return this; 78 | } 79 | 80 | @JsonSetter(value = "index", nulls = Nulls.SKIP) 81 | public Builder index(Optional index) { 82 | this.index = index; 83 | return this; 84 | } 85 | 86 | public Builder index(Integer index) { 87 | this.index = Optional.ofNullable(index); 88 | return this; 89 | } 90 | 91 | public ChatContentEndEvent build() { 92 | return new ChatContentEndEvent(index, additionalProperties); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatContentStartEventDelta.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatContentStartEventDelta.Builder.class) 22 | public final class ChatContentStartEventDelta { 23 | private final Optional message; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatContentStartEventDelta( 28 | Optional message, Map additionalProperties) { 29 | this.message = message; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("message") 34 | public Optional getMessage() { 35 | return message; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ChatContentStartEventDelta && equalTo((ChatContentStartEventDelta) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ChatContentStartEventDelta other) { 50 | return message.equals(other.message); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.message); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional message = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ChatContentStartEventDelta other) { 77 | message(other.getMessage()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "message", nulls = Nulls.SKIP) 82 | public Builder message(Optional message) { 83 | this.message = message; 84 | return this; 85 | } 86 | 87 | public Builder message(ChatContentStartEventDeltaMessage message) { 88 | this.message = Optional.ofNullable(message); 89 | return this; 90 | } 91 | 92 | public ChatContentStartEventDelta build() { 93 | return new ChatContentStartEventDelta(message, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatDebugEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatDebugEvent.Builder.class) 22 | public final class ChatDebugEvent implements IChatStreamEvent { 23 | private final Optional prompt; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatDebugEvent(Optional prompt, Map additionalProperties) { 28 | this.prompt = prompt; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | @JsonProperty("prompt") 33 | public Optional getPrompt() { 34 | return prompt; 35 | } 36 | 37 | @java.lang.Override 38 | public boolean equals(Object other) { 39 | if (this == other) return true; 40 | return other instanceof ChatDebugEvent && equalTo((ChatDebugEvent) other); 41 | } 42 | 43 | @JsonAnyGetter 44 | public Map getAdditionalProperties() { 45 | return this.additionalProperties; 46 | } 47 | 48 | private boolean equalTo(ChatDebugEvent other) { 49 | return prompt.equals(other.prompt); 50 | } 51 | 52 | @java.lang.Override 53 | public int hashCode() { 54 | return Objects.hash(this.prompt); 55 | } 56 | 57 | @java.lang.Override 58 | public String toString() { 59 | return ObjectMappers.stringify(this); 60 | } 61 | 62 | public static Builder builder() { 63 | return new Builder(); 64 | } 65 | 66 | @JsonIgnoreProperties(ignoreUnknown = true) 67 | public static final class Builder { 68 | private Optional prompt = Optional.empty(); 69 | 70 | @JsonAnySetter 71 | private Map additionalProperties = new HashMap<>(); 72 | 73 | private Builder() {} 74 | 75 | public Builder from(ChatDebugEvent other) { 76 | prompt(other.getPrompt()); 77 | return this; 78 | } 79 | 80 | @JsonSetter(value = "prompt", nulls = Nulls.SKIP) 81 | public Builder prompt(Optional prompt) { 82 | this.prompt = prompt; 83 | return this; 84 | } 85 | 86 | public Builder prompt(String prompt) { 87 | this.prompt = Optional.ofNullable(prompt); 88 | return this; 89 | } 90 | 91 | public ChatDebugEvent build() { 92 | return new ChatDebugEvent(prompt, additionalProperties); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatFinishReason.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ChatFinishReason { 9 | COMPLETE("COMPLETE"), 10 | 11 | STOP_SEQUENCE("STOP_SEQUENCE"), 12 | 13 | MAX_TOKENS("MAX_TOKENS"), 14 | 15 | TOOL_CALL("TOOL_CALL"), 16 | 17 | ERROR("ERROR"); 18 | 19 | private final String value; 20 | 21 | ChatFinishReason(String value) { 22 | this.value = value; 23 | } 24 | 25 | @JsonValue 26 | @java.lang.Override 27 | public String toString() { 28 | return this.value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatMessageStartEventDelta.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatMessageStartEventDelta.Builder.class) 22 | public final class ChatMessageStartEventDelta { 23 | private final Optional message; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatMessageStartEventDelta( 28 | Optional message, Map additionalProperties) { 29 | this.message = message; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("message") 34 | public Optional getMessage() { 35 | return message; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ChatMessageStartEventDelta && equalTo((ChatMessageStartEventDelta) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ChatMessageStartEventDelta other) { 50 | return message.equals(other.message); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.message); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional message = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ChatMessageStartEventDelta other) { 77 | message(other.getMessage()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "message", nulls = Nulls.SKIP) 82 | public Builder message(Optional message) { 83 | this.message = message; 84 | return this; 85 | } 86 | 87 | public Builder message(ChatMessageStartEventDeltaMessage message) { 88 | this.message = Optional.ofNullable(message); 89 | return this; 90 | } 91 | 92 | public ChatMessageStartEventDelta build() { 93 | return new ChatMessageStartEventDelta(message, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatMessageStartEventDeltaMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatMessageStartEventDeltaMessage.Builder.class) 22 | public final class ChatMessageStartEventDeltaMessage { 23 | private final Optional role; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatMessageStartEventDeltaMessage(Optional role, Map additionalProperties) { 28 | this.role = role; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | /** 33 | * @return The role of the message. 34 | */ 35 | @JsonProperty("role") 36 | public Optional getRole() { 37 | return role; 38 | } 39 | 40 | @java.lang.Override 41 | public boolean equals(Object other) { 42 | if (this == other) return true; 43 | return other instanceof ChatMessageStartEventDeltaMessage && equalTo((ChatMessageStartEventDeltaMessage) other); 44 | } 45 | 46 | @JsonAnyGetter 47 | public Map getAdditionalProperties() { 48 | return this.additionalProperties; 49 | } 50 | 51 | private boolean equalTo(ChatMessageStartEventDeltaMessage other) { 52 | return role.equals(other.role); 53 | } 54 | 55 | @java.lang.Override 56 | public int hashCode() { 57 | return Objects.hash(this.role); 58 | } 59 | 60 | @java.lang.Override 61 | public String toString() { 62 | return ObjectMappers.stringify(this); 63 | } 64 | 65 | public static Builder builder() { 66 | return new Builder(); 67 | } 68 | 69 | @JsonIgnoreProperties(ignoreUnknown = true) 70 | public static final class Builder { 71 | private Optional role = Optional.empty(); 72 | 73 | @JsonAnySetter 74 | private Map additionalProperties = new HashMap<>(); 75 | 76 | private Builder() {} 77 | 78 | public Builder from(ChatMessageStartEventDeltaMessage other) { 79 | role(other.getRole()); 80 | return this; 81 | } 82 | 83 | @JsonSetter(value = "role", nulls = Nulls.SKIP) 84 | public Builder role(Optional role) { 85 | this.role = role; 86 | return this; 87 | } 88 | 89 | public Builder role(String role) { 90 | this.role = Optional.ofNullable(role); 91 | return this; 92 | } 93 | 94 | public ChatMessageStartEventDeltaMessage build() { 95 | return new ChatMessageStartEventDeltaMessage(role, additionalProperties); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatRequestCitationQuality.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ChatRequestCitationQuality { 9 | FAST("fast"), 10 | 11 | ACCURATE("accurate"), 12 | 13 | OFF("off"); 14 | 15 | private final String value; 16 | 17 | ChatRequestCitationQuality(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatRequestPromptTruncation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ChatRequestPromptTruncation { 9 | OFF("OFF"), 10 | 11 | AUTO("AUTO"), 12 | 13 | AUTO_PRESERVE_ORDER("AUTO_PRESERVE_ORDER"); 14 | 15 | private final String value; 16 | 17 | ChatRequestPromptTruncation(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatRequestSafetyMode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ChatRequestSafetyMode { 9 | CONTEXTUAL("CONTEXTUAL"), 10 | 11 | STRICT("STRICT"), 12 | 13 | NONE("NONE"); 14 | 15 | private final String value; 16 | 17 | ChatRequestSafetyMode(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatStreamEndEventFinishReason.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ChatStreamEndEventFinishReason { 9 | COMPLETE("COMPLETE"), 10 | 11 | ERROR_LIMIT("ERROR_LIMIT"), 12 | 13 | MAX_TOKENS("MAX_TOKENS"), 14 | 15 | ERROR("ERROR"), 16 | 17 | ERROR_TOXIC("ERROR_TOXIC"); 18 | 19 | private final String value; 20 | 21 | ChatStreamEndEventFinishReason(String value) { 22 | this.value = value; 23 | } 24 | 25 | @JsonValue 26 | @java.lang.Override 27 | public String toString() { 28 | return this.value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatStreamEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 16 | @JsonDeserialize(builder = ChatStreamEvent.Builder.class) 17 | public final class ChatStreamEvent implements IChatStreamEvent { 18 | private final Map additionalProperties; 19 | 20 | private ChatStreamEvent(Map additionalProperties) { 21 | this.additionalProperties = additionalProperties; 22 | } 23 | 24 | @java.lang.Override 25 | public boolean equals(Object other) { 26 | if (this == other) return true; 27 | return other instanceof ChatStreamEvent; 28 | } 29 | 30 | @JsonAnyGetter 31 | public Map getAdditionalProperties() { 32 | return this.additionalProperties; 33 | } 34 | 35 | @java.lang.Override 36 | public String toString() { 37 | return ObjectMappers.stringify(this); 38 | } 39 | 40 | public static Builder builder() { 41 | return new Builder(); 42 | } 43 | 44 | @JsonIgnoreProperties(ignoreUnknown = true) 45 | public static final class Builder { 46 | @JsonAnySetter 47 | private Map additionalProperties = new HashMap<>(); 48 | 49 | private Builder() {} 50 | 51 | public Builder from(ChatStreamEvent other) { 52 | return this; 53 | } 54 | 55 | public ChatStreamEvent build() { 56 | return new ChatStreamEvent(additionalProperties); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatStreamEventType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 16 | @JsonDeserialize(builder = ChatStreamEventType.Builder.class) 17 | public final class ChatStreamEventType implements IChatStreamEventType { 18 | private final Map additionalProperties; 19 | 20 | private ChatStreamEventType(Map additionalProperties) { 21 | this.additionalProperties = additionalProperties; 22 | } 23 | 24 | @java.lang.Override 25 | public boolean equals(Object other) { 26 | if (this == other) return true; 27 | return other instanceof ChatStreamEventType; 28 | } 29 | 30 | @JsonAnyGetter 31 | public Map getAdditionalProperties() { 32 | return this.additionalProperties; 33 | } 34 | 35 | @java.lang.Override 36 | public String toString() { 37 | return ObjectMappers.stringify(this); 38 | } 39 | 40 | public static Builder builder() { 41 | return new Builder(); 42 | } 43 | 44 | @JsonIgnoreProperties(ignoreUnknown = true) 45 | public static final class Builder { 46 | @JsonAnySetter 47 | private Map additionalProperties = new HashMap<>(); 48 | 49 | private Builder() {} 50 | 51 | public Builder from(ChatStreamEventType other) { 52 | return this; 53 | } 54 | 55 | public ChatStreamEventType build() { 56 | return new ChatStreamEventType(additionalProperties); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatStreamRequestCitationQuality.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ChatStreamRequestCitationQuality { 9 | FAST("fast"), 10 | 11 | ACCURATE("accurate"), 12 | 13 | OFF("off"); 14 | 15 | private final String value; 16 | 17 | ChatStreamRequestCitationQuality(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatStreamRequestPromptTruncation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ChatStreamRequestPromptTruncation { 9 | OFF("OFF"), 10 | 11 | AUTO("AUTO"), 12 | 13 | AUTO_PRESERVE_ORDER("AUTO_PRESERVE_ORDER"); 14 | 15 | private final String value; 16 | 17 | ChatStreamRequestPromptTruncation(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatStreamRequestSafetyMode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ChatStreamRequestSafetyMode { 9 | CONTEXTUAL("CONTEXTUAL"), 10 | 11 | STRICT("STRICT"), 12 | 13 | NONE("NONE"); 14 | 15 | private final String value; 16 | 17 | ChatStreamRequestSafetyMode(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatToolCallDeltaEventDelta.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatToolCallDeltaEventDelta.Builder.class) 22 | public final class ChatToolCallDeltaEventDelta { 23 | private final Optional message; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatToolCallDeltaEventDelta( 28 | Optional message, Map additionalProperties) { 29 | this.message = message; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("message") 34 | public Optional getMessage() { 35 | return message; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ChatToolCallDeltaEventDelta && equalTo((ChatToolCallDeltaEventDelta) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ChatToolCallDeltaEventDelta other) { 50 | return message.equals(other.message); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.message); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional message = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ChatToolCallDeltaEventDelta other) { 77 | message(other.getMessage()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "message", nulls = Nulls.SKIP) 82 | public Builder message(Optional message) { 83 | this.message = message; 84 | return this; 85 | } 86 | 87 | public Builder message(ChatToolCallDeltaEventDeltaMessage message) { 88 | this.message = Optional.ofNullable(message); 89 | return this; 90 | } 91 | 92 | public ChatToolCallDeltaEventDelta build() { 93 | return new ChatToolCallDeltaEventDelta(message, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatToolCallEndEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatToolCallEndEvent.Builder.class) 22 | public final class ChatToolCallEndEvent implements IChatStreamEventType { 23 | private final Optional index; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatToolCallEndEvent(Optional index, Map additionalProperties) { 28 | this.index = index; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | @JsonProperty("index") 33 | public Optional getIndex() { 34 | return index; 35 | } 36 | 37 | @java.lang.Override 38 | public boolean equals(Object other) { 39 | if (this == other) return true; 40 | return other instanceof ChatToolCallEndEvent && equalTo((ChatToolCallEndEvent) other); 41 | } 42 | 43 | @JsonAnyGetter 44 | public Map getAdditionalProperties() { 45 | return this.additionalProperties; 46 | } 47 | 48 | private boolean equalTo(ChatToolCallEndEvent other) { 49 | return index.equals(other.index); 50 | } 51 | 52 | @java.lang.Override 53 | public int hashCode() { 54 | return Objects.hash(this.index); 55 | } 56 | 57 | @java.lang.Override 58 | public String toString() { 59 | return ObjectMappers.stringify(this); 60 | } 61 | 62 | public static Builder builder() { 63 | return new Builder(); 64 | } 65 | 66 | @JsonIgnoreProperties(ignoreUnknown = true) 67 | public static final class Builder { 68 | private Optional index = Optional.empty(); 69 | 70 | @JsonAnySetter 71 | private Map additionalProperties = new HashMap<>(); 72 | 73 | private Builder() {} 74 | 75 | public Builder from(ChatToolCallEndEvent other) { 76 | index(other.getIndex()); 77 | return this; 78 | } 79 | 80 | @JsonSetter(value = "index", nulls = Nulls.SKIP) 81 | public Builder index(Optional index) { 82 | this.index = index; 83 | return this; 84 | } 85 | 86 | public Builder index(Integer index) { 87 | this.index = Optional.ofNullable(index); 88 | return this; 89 | } 90 | 91 | public ChatToolCallEndEvent build() { 92 | return new ChatToolCallEndEvent(index, additionalProperties); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatToolCallStartEventDelta.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatToolCallStartEventDelta.Builder.class) 22 | public final class ChatToolCallStartEventDelta { 23 | private final Optional message; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatToolCallStartEventDelta( 28 | Optional message, Map additionalProperties) { 29 | this.message = message; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("message") 34 | public Optional getMessage() { 35 | return message; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ChatToolCallStartEventDelta && equalTo((ChatToolCallStartEventDelta) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ChatToolCallStartEventDelta other) { 50 | return message.equals(other.message); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.message); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional message = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ChatToolCallStartEventDelta other) { 77 | message(other.getMessage()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "message", nulls = Nulls.SKIP) 82 | public Builder message(Optional message) { 83 | this.message = message; 84 | return this; 85 | } 86 | 87 | public Builder message(ChatToolCallStartEventDeltaMessage message) { 88 | this.message = Optional.ofNullable(message); 89 | return this; 90 | } 91 | 92 | public ChatToolCallStartEventDelta build() { 93 | return new ChatToolCallStartEventDelta(message, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatToolCallStartEventDeltaMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatToolCallStartEventDeltaMessage.Builder.class) 22 | public final class ChatToolCallStartEventDeltaMessage { 23 | private final Optional toolCalls; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatToolCallStartEventDeltaMessage( 28 | Optional toolCalls, Map additionalProperties) { 29 | this.toolCalls = toolCalls; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("tool_calls") 34 | public Optional getToolCalls() { 35 | return toolCalls; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ChatToolCallStartEventDeltaMessage 42 | && equalTo((ChatToolCallStartEventDeltaMessage) other); 43 | } 44 | 45 | @JsonAnyGetter 46 | public Map getAdditionalProperties() { 47 | return this.additionalProperties; 48 | } 49 | 50 | private boolean equalTo(ChatToolCallStartEventDeltaMessage other) { 51 | return toolCalls.equals(other.toolCalls); 52 | } 53 | 54 | @java.lang.Override 55 | public int hashCode() { 56 | return Objects.hash(this.toolCalls); 57 | } 58 | 59 | @java.lang.Override 60 | public String toString() { 61 | return ObjectMappers.stringify(this); 62 | } 63 | 64 | public static Builder builder() { 65 | return new Builder(); 66 | } 67 | 68 | @JsonIgnoreProperties(ignoreUnknown = true) 69 | public static final class Builder { 70 | private Optional toolCalls = Optional.empty(); 71 | 72 | @JsonAnySetter 73 | private Map additionalProperties = new HashMap<>(); 74 | 75 | private Builder() {} 76 | 77 | public Builder from(ChatToolCallStartEventDeltaMessage other) { 78 | toolCalls(other.getToolCalls()); 79 | return this; 80 | } 81 | 82 | @JsonSetter(value = "tool_calls", nulls = Nulls.SKIP) 83 | public Builder toolCalls(Optional toolCalls) { 84 | this.toolCalls = toolCalls; 85 | return this; 86 | } 87 | 88 | public Builder toolCalls(ToolCallV2 toolCalls) { 89 | this.toolCalls = Optional.ofNullable(toolCalls); 90 | return this; 91 | } 92 | 93 | public ChatToolCallStartEventDeltaMessage build() { 94 | return new ChatToolCallStartEventDeltaMessage(toolCalls, additionalProperties); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatToolPlanDeltaEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatToolPlanDeltaEvent.Builder.class) 22 | public final class ChatToolPlanDeltaEvent implements IChatStreamEventType { 23 | private final Optional delta; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatToolPlanDeltaEvent( 28 | Optional delta, Map additionalProperties) { 29 | this.delta = delta; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("delta") 34 | public Optional getDelta() { 35 | return delta; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ChatToolPlanDeltaEvent && equalTo((ChatToolPlanDeltaEvent) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ChatToolPlanDeltaEvent other) { 50 | return delta.equals(other.delta); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.delta); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional delta = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ChatToolPlanDeltaEvent other) { 77 | delta(other.getDelta()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "delta", nulls = Nulls.SKIP) 82 | public Builder delta(Optional delta) { 83 | this.delta = delta; 84 | return this; 85 | } 86 | 87 | public Builder delta(ChatToolPlanDeltaEventDelta delta) { 88 | this.delta = Optional.ofNullable(delta); 89 | return this; 90 | } 91 | 92 | public ChatToolPlanDeltaEvent build() { 93 | return new ChatToolPlanDeltaEvent(delta, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatToolPlanDeltaEventDelta.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatToolPlanDeltaEventDelta.Builder.class) 22 | public final class ChatToolPlanDeltaEventDelta { 23 | private final Optional message; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatToolPlanDeltaEventDelta( 28 | Optional message, Map additionalProperties) { 29 | this.message = message; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("message") 34 | public Optional getMessage() { 35 | return message; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ChatToolPlanDeltaEventDelta && equalTo((ChatToolPlanDeltaEventDelta) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ChatToolPlanDeltaEventDelta other) { 50 | return message.equals(other.message); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.message); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional message = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ChatToolPlanDeltaEventDelta other) { 77 | message(other.getMessage()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "message", nulls = Nulls.SKIP) 82 | public Builder message(Optional message) { 83 | this.message = message; 84 | return this; 85 | } 86 | 87 | public Builder message(ChatToolPlanDeltaEventDeltaMessage message) { 88 | this.message = Optional.ofNullable(message); 89 | return this; 90 | } 91 | 92 | public ChatToolPlanDeltaEventDelta build() { 93 | return new ChatToolPlanDeltaEventDelta(message, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ChatToolPlanDeltaEventDeltaMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = ChatToolPlanDeltaEventDeltaMessage.Builder.class) 22 | public final class ChatToolPlanDeltaEventDeltaMessage { 23 | private final Optional toolPlan; 24 | 25 | private final Map additionalProperties; 26 | 27 | private ChatToolPlanDeltaEventDeltaMessage(Optional toolPlan, Map additionalProperties) { 28 | this.toolPlan = toolPlan; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | @JsonProperty("tool_plan") 33 | public Optional getToolPlan() { 34 | return toolPlan; 35 | } 36 | 37 | @java.lang.Override 38 | public boolean equals(Object other) { 39 | if (this == other) return true; 40 | return other instanceof ChatToolPlanDeltaEventDeltaMessage 41 | && equalTo((ChatToolPlanDeltaEventDeltaMessage) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ChatToolPlanDeltaEventDeltaMessage other) { 50 | return toolPlan.equals(other.toolPlan); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.toolPlan); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional toolPlan = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ChatToolPlanDeltaEventDeltaMessage other) { 77 | toolPlan(other.getToolPlan()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "tool_plan", nulls = Nulls.SKIP) 82 | public Builder toolPlan(Optional toolPlan) { 83 | this.toolPlan = toolPlan; 84 | return this; 85 | } 86 | 87 | public Builder toolPlan(String toolPlan) { 88 | this.toolPlan = Optional.ofNullable(toolPlan); 89 | return this; 90 | } 91 | 92 | public ChatToolPlanDeltaEventDeltaMessage build() { 93 | return new ChatToolPlanDeltaEventDeltaMessage(toolPlan, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/CitationEndEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = CitationEndEvent.Builder.class) 22 | public final class CitationEndEvent implements IChatStreamEventType { 23 | private final Optional index; 24 | 25 | private final Map additionalProperties; 26 | 27 | private CitationEndEvent(Optional index, Map additionalProperties) { 28 | this.index = index; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | @JsonProperty("index") 33 | public Optional getIndex() { 34 | return index; 35 | } 36 | 37 | @java.lang.Override 38 | public boolean equals(Object other) { 39 | if (this == other) return true; 40 | return other instanceof CitationEndEvent && equalTo((CitationEndEvent) other); 41 | } 42 | 43 | @JsonAnyGetter 44 | public Map getAdditionalProperties() { 45 | return this.additionalProperties; 46 | } 47 | 48 | private boolean equalTo(CitationEndEvent other) { 49 | return index.equals(other.index); 50 | } 51 | 52 | @java.lang.Override 53 | public int hashCode() { 54 | return Objects.hash(this.index); 55 | } 56 | 57 | @java.lang.Override 58 | public String toString() { 59 | return ObjectMappers.stringify(this); 60 | } 61 | 62 | public static Builder builder() { 63 | return new Builder(); 64 | } 65 | 66 | @JsonIgnoreProperties(ignoreUnknown = true) 67 | public static final class Builder { 68 | private Optional index = Optional.empty(); 69 | 70 | @JsonAnySetter 71 | private Map additionalProperties = new HashMap<>(); 72 | 73 | private Builder() {} 74 | 75 | public Builder from(CitationEndEvent other) { 76 | index(other.getIndex()); 77 | return this; 78 | } 79 | 80 | @JsonSetter(value = "index", nulls = Nulls.SKIP) 81 | public Builder index(Optional index) { 82 | this.index = index; 83 | return this; 84 | } 85 | 86 | public Builder index(Integer index) { 87 | this.index = Optional.ofNullable(index); 88 | return this; 89 | } 90 | 91 | public CitationEndEvent build() { 92 | return new CitationEndEvent(index, additionalProperties); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/CitationOptionsMode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum CitationOptionsMode { 9 | FAST("FAST"), 10 | 11 | ACCURATE("ACCURATE"), 12 | 13 | OFF("OFF"); 14 | 15 | private final String value; 16 | 17 | CitationOptionsMode(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/CitationStartEventDelta.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = CitationStartEventDelta.Builder.class) 22 | public final class CitationStartEventDelta { 23 | private final Optional message; 24 | 25 | private final Map additionalProperties; 26 | 27 | private CitationStartEventDelta( 28 | Optional message, Map additionalProperties) { 29 | this.message = message; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("message") 34 | public Optional getMessage() { 35 | return message; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof CitationStartEventDelta && equalTo((CitationStartEventDelta) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(CitationStartEventDelta other) { 50 | return message.equals(other.message); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.message); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional message = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(CitationStartEventDelta other) { 77 | message(other.getMessage()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "message", nulls = Nulls.SKIP) 82 | public Builder message(Optional message) { 83 | this.message = message; 84 | return this; 85 | } 86 | 87 | public Builder message(CitationStartEventDeltaMessage message) { 88 | this.message = Optional.ofNullable(message); 89 | return this; 90 | } 91 | 92 | public CitationStartEventDelta build() { 93 | return new CitationStartEventDelta(message, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/CitationStartEventDeltaMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = CitationStartEventDeltaMessage.Builder.class) 22 | public final class CitationStartEventDeltaMessage { 23 | private final Optional citations; 24 | 25 | private final Map additionalProperties; 26 | 27 | private CitationStartEventDeltaMessage(Optional citations, Map additionalProperties) { 28 | this.citations = citations; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | @JsonProperty("citations") 33 | public Optional getCitations() { 34 | return citations; 35 | } 36 | 37 | @java.lang.Override 38 | public boolean equals(Object other) { 39 | if (this == other) return true; 40 | return other instanceof CitationStartEventDeltaMessage && equalTo((CitationStartEventDeltaMessage) other); 41 | } 42 | 43 | @JsonAnyGetter 44 | public Map getAdditionalProperties() { 45 | return this.additionalProperties; 46 | } 47 | 48 | private boolean equalTo(CitationStartEventDeltaMessage other) { 49 | return citations.equals(other.citations); 50 | } 51 | 52 | @java.lang.Override 53 | public int hashCode() { 54 | return Objects.hash(this.citations); 55 | } 56 | 57 | @java.lang.Override 58 | public String toString() { 59 | return ObjectMappers.stringify(this); 60 | } 61 | 62 | public static Builder builder() { 63 | return new Builder(); 64 | } 65 | 66 | @JsonIgnoreProperties(ignoreUnknown = true) 67 | public static final class Builder { 68 | private Optional citations = Optional.empty(); 69 | 70 | @JsonAnySetter 71 | private Map additionalProperties = new HashMap<>(); 72 | 73 | private Builder() {} 74 | 75 | public Builder from(CitationStartEventDeltaMessage other) { 76 | citations(other.getCitations()); 77 | return this; 78 | } 79 | 80 | @JsonSetter(value = "citations", nulls = Nulls.SKIP) 81 | public Builder citations(Optional citations) { 82 | this.citations = citations; 83 | return this; 84 | } 85 | 86 | public Builder citations(Citation citations) { 87 | this.citations = Optional.ofNullable(citations); 88 | return this; 89 | } 90 | 91 | public CitationStartEventDeltaMessage build() { 92 | return new CitationStartEventDeltaMessage(citations, additionalProperties); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/CitationType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum CitationType { 9 | TEXT_CONTENT("TEXT_CONTENT"), 10 | 11 | PLAN("PLAN"); 12 | 13 | private final String value; 14 | 15 | CitationType(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | @java.lang.Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ClassifyDataMetrics.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | import java.util.Objects; 19 | import java.util.Optional; 20 | 21 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 22 | @JsonDeserialize(builder = ClassifyDataMetrics.Builder.class) 23 | public final class ClassifyDataMetrics { 24 | private final Optional> labelMetrics; 25 | 26 | private final Map additionalProperties; 27 | 28 | private ClassifyDataMetrics(Optional> labelMetrics, Map additionalProperties) { 29 | this.labelMetrics = labelMetrics; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("label_metrics") 34 | public Optional> getLabelMetrics() { 35 | return labelMetrics; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ClassifyDataMetrics && equalTo((ClassifyDataMetrics) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ClassifyDataMetrics other) { 50 | return labelMetrics.equals(other.labelMetrics); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.labelMetrics); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional> labelMetrics = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ClassifyDataMetrics other) { 77 | labelMetrics(other.getLabelMetrics()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "label_metrics", nulls = Nulls.SKIP) 82 | public Builder labelMetrics(Optional> labelMetrics) { 83 | this.labelMetrics = labelMetrics; 84 | return this; 85 | } 86 | 87 | public Builder labelMetrics(List labelMetrics) { 88 | this.labelMetrics = Optional.ofNullable(labelMetrics); 89 | return this; 90 | } 91 | 92 | public ClassifyDataMetrics build() { 93 | return new ClassifyDataMetrics(labelMetrics, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ClassifyRequestTruncate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ClassifyRequestTruncate { 9 | NONE("NONE"), 10 | 11 | START("START"), 12 | 13 | END("END"); 14 | 15 | private final String value; 16 | 17 | ClassifyRequestTruncate(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ClassifyResponseClassificationsItemClassificationType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ClassifyResponseClassificationsItemClassificationType { 9 | SINGLE_LABEL("single-label"), 10 | 11 | MULTI_LABEL("multi-label"); 12 | 13 | private final String value; 14 | 15 | ClassifyResponseClassificationsItemClassificationType(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | @java.lang.Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/CompatibleEndpoint.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum CompatibleEndpoint { 9 | CHAT("chat"), 10 | 11 | EMBED("embed"), 12 | 13 | CLASSIFY("classify"), 14 | 15 | SUMMARIZE("summarize"), 16 | 17 | RERANK("rerank"), 18 | 19 | RATE("rate"), 20 | 21 | GENERATE("generate"); 22 | 23 | private final String value; 24 | 25 | CompatibleEndpoint(String value) { 26 | this.value = value; 27 | } 28 | 29 | @JsonValue 30 | @java.lang.Override 31 | public String toString() { 32 | return this.value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ConnectorAuthStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ConnectorAuthStatus { 9 | VALID("valid"), 10 | 11 | EXPIRED("expired"); 12 | 13 | private final String value; 14 | 15 | ConnectorAuthStatus(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | @java.lang.Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/DatasetType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum DatasetType { 9 | EMBED_INPUT("embed-input"), 10 | 11 | EMBED_RESULT("embed-result"), 12 | 13 | CLUSTER_RESULT("cluster-result"), 14 | 15 | CLUSTER_OUTLIERS("cluster-outliers"), 16 | 17 | RERANKER_FINETUNE_INPUT("reranker-finetune-input"), 18 | 19 | SINGLE_LABEL_CLASSIFICATION_FINETUNE_INPUT("single-label-classification-finetune-input"), 20 | 21 | CHAT_FINETUNE_INPUT("chat-finetune-input"), 22 | 23 | MULTI_LABEL_CLASSIFICATION_FINETUNE_INPUT("multi-label-classification-finetune-input"); 24 | 25 | private final String value; 26 | 27 | DatasetType(String value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonValue 32 | @java.lang.Override 33 | public String toString() { 34 | return this.value; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/DatasetValidationStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum DatasetValidationStatus { 9 | UNKNOWN("unknown"), 10 | 11 | QUEUED("queued"), 12 | 13 | PROCESSING("processing"), 14 | 15 | FAILED("failed"), 16 | 17 | VALIDATED("validated"), 18 | 19 | SKIPPED("skipped"); 20 | 21 | private final String value; 22 | 23 | DatasetValidationStatus(String value) { 24 | this.value = value; 25 | } 26 | 27 | @JsonValue 28 | @java.lang.Override 29 | public String toString() { 30 | return this.value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/DocumentContent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.Objects; 17 | import org.jetbrains.annotations.NotNull; 18 | 19 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 20 | @JsonDeserialize(builder = DocumentContent.Builder.class) 21 | public final class DocumentContent { 22 | private final Document document; 23 | 24 | private final Map additionalProperties; 25 | 26 | private DocumentContent(Document document, Map additionalProperties) { 27 | this.document = document; 28 | this.additionalProperties = additionalProperties; 29 | } 30 | 31 | @JsonProperty("document") 32 | public Document getDocument() { 33 | return document; 34 | } 35 | 36 | @java.lang.Override 37 | public boolean equals(Object other) { 38 | if (this == other) return true; 39 | return other instanceof DocumentContent && equalTo((DocumentContent) other); 40 | } 41 | 42 | @JsonAnyGetter 43 | public Map getAdditionalProperties() { 44 | return this.additionalProperties; 45 | } 46 | 47 | private boolean equalTo(DocumentContent other) { 48 | return document.equals(other.document); 49 | } 50 | 51 | @java.lang.Override 52 | public int hashCode() { 53 | return Objects.hash(this.document); 54 | } 55 | 56 | @java.lang.Override 57 | public String toString() { 58 | return ObjectMappers.stringify(this); 59 | } 60 | 61 | public static DocumentStage builder() { 62 | return new Builder(); 63 | } 64 | 65 | public interface DocumentStage { 66 | _FinalStage document(@NotNull Document document); 67 | 68 | Builder from(DocumentContent other); 69 | } 70 | 71 | public interface _FinalStage { 72 | DocumentContent build(); 73 | } 74 | 75 | @JsonIgnoreProperties(ignoreUnknown = true) 76 | public static final class Builder implements DocumentStage, _FinalStage { 77 | private Document document; 78 | 79 | @JsonAnySetter 80 | private Map additionalProperties = new HashMap<>(); 81 | 82 | private Builder() {} 83 | 84 | @java.lang.Override 85 | public Builder from(DocumentContent other) { 86 | document(other.getDocument()); 87 | return this; 88 | } 89 | 90 | @java.lang.Override 91 | @JsonSetter("document") 92 | public _FinalStage document(@NotNull Document document) { 93 | this.document = Objects.requireNonNull(document, "document must not be null"); 94 | return this; 95 | } 96 | 97 | @java.lang.Override 98 | public DocumentContent build() { 99 | return new DocumentContent(document, additionalProperties); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/EmbedImage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = EmbedImage.Builder.class) 22 | public final class EmbedImage { 23 | private final Optional imageUrl; 24 | 25 | private final Map additionalProperties; 26 | 27 | private EmbedImage(Optional imageUrl, Map additionalProperties) { 28 | this.imageUrl = imageUrl; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | @JsonProperty("image_url") 33 | public Optional getImageUrl() { 34 | return imageUrl; 35 | } 36 | 37 | @java.lang.Override 38 | public boolean equals(Object other) { 39 | if (this == other) return true; 40 | return other instanceof EmbedImage && equalTo((EmbedImage) other); 41 | } 42 | 43 | @JsonAnyGetter 44 | public Map getAdditionalProperties() { 45 | return this.additionalProperties; 46 | } 47 | 48 | private boolean equalTo(EmbedImage other) { 49 | return imageUrl.equals(other.imageUrl); 50 | } 51 | 52 | @java.lang.Override 53 | public int hashCode() { 54 | return Objects.hash(this.imageUrl); 55 | } 56 | 57 | @java.lang.Override 58 | public String toString() { 59 | return ObjectMappers.stringify(this); 60 | } 61 | 62 | public static Builder builder() { 63 | return new Builder(); 64 | } 65 | 66 | @JsonIgnoreProperties(ignoreUnknown = true) 67 | public static final class Builder { 68 | private Optional imageUrl = Optional.empty(); 69 | 70 | @JsonAnySetter 71 | private Map additionalProperties = new HashMap<>(); 72 | 73 | private Builder() {} 74 | 75 | public Builder from(EmbedImage other) { 76 | imageUrl(other.getImageUrl()); 77 | return this; 78 | } 79 | 80 | @JsonSetter(value = "image_url", nulls = Nulls.SKIP) 81 | public Builder imageUrl(Optional imageUrl) { 82 | this.imageUrl = imageUrl; 83 | return this; 84 | } 85 | 86 | public Builder imageUrl(EmbedImageUrl imageUrl) { 87 | this.imageUrl = Optional.ofNullable(imageUrl); 88 | return this; 89 | } 90 | 91 | public EmbedImage build() { 92 | return new EmbedImage(imageUrl, additionalProperties); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/EmbedImageUrl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.Objects; 17 | import org.jetbrains.annotations.NotNull; 18 | 19 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 20 | @JsonDeserialize(builder = EmbedImageUrl.Builder.class) 21 | public final class EmbedImageUrl { 22 | private final String url; 23 | 24 | private final Map additionalProperties; 25 | 26 | private EmbedImageUrl(String url, Map additionalProperties) { 27 | this.url = url; 28 | this.additionalProperties = additionalProperties; 29 | } 30 | 31 | @JsonProperty("url") 32 | public String getUrl() { 33 | return url; 34 | } 35 | 36 | @java.lang.Override 37 | public boolean equals(Object other) { 38 | if (this == other) return true; 39 | return other instanceof EmbedImageUrl && equalTo((EmbedImageUrl) other); 40 | } 41 | 42 | @JsonAnyGetter 43 | public Map getAdditionalProperties() { 44 | return this.additionalProperties; 45 | } 46 | 47 | private boolean equalTo(EmbedImageUrl other) { 48 | return url.equals(other.url); 49 | } 50 | 51 | @java.lang.Override 52 | public int hashCode() { 53 | return Objects.hash(this.url); 54 | } 55 | 56 | @java.lang.Override 57 | public String toString() { 58 | return ObjectMappers.stringify(this); 59 | } 60 | 61 | public static UrlStage builder() { 62 | return new Builder(); 63 | } 64 | 65 | public interface UrlStage { 66 | _FinalStage url(@NotNull String url); 67 | 68 | Builder from(EmbedImageUrl other); 69 | } 70 | 71 | public interface _FinalStage { 72 | EmbedImageUrl build(); 73 | } 74 | 75 | @JsonIgnoreProperties(ignoreUnknown = true) 76 | public static final class Builder implements UrlStage, _FinalStage { 77 | private String url; 78 | 79 | @JsonAnySetter 80 | private Map additionalProperties = new HashMap<>(); 81 | 82 | private Builder() {} 83 | 84 | @java.lang.Override 85 | public Builder from(EmbedImageUrl other) { 86 | url(other.getUrl()); 87 | return this; 88 | } 89 | 90 | @java.lang.Override 91 | @JsonSetter("url") 92 | public _FinalStage url(@NotNull String url) { 93 | this.url = Objects.requireNonNull(url, "url must not be null"); 94 | return this; 95 | } 96 | 97 | @java.lang.Override 98 | public EmbedImageUrl build() { 99 | return new EmbedImageUrl(url, additionalProperties); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/EmbedInputType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum EmbedInputType { 9 | SEARCH_DOCUMENT("search_document"), 10 | 11 | SEARCH_QUERY("search_query"), 12 | 13 | CLASSIFICATION("classification"), 14 | 15 | CLUSTERING("clustering"), 16 | 17 | IMAGE("image"); 18 | 19 | private final String value; 20 | 21 | EmbedInputType(String value) { 22 | this.value = value; 23 | } 24 | 25 | @JsonValue 26 | @java.lang.Override 27 | public String toString() { 28 | return this.value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/EmbedJobStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum EmbedJobStatus { 9 | PROCESSING("processing"), 10 | 11 | COMPLETE("complete"), 12 | 13 | CANCELLING("cancelling"), 14 | 15 | CANCELLED("cancelled"), 16 | 17 | FAILED("failed"); 18 | 19 | private final String value; 20 | 21 | EmbedJobStatus(String value) { 22 | this.value = value; 23 | } 24 | 25 | @JsonValue 26 | @java.lang.Override 27 | public String toString() { 28 | return this.value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/EmbedJobTruncate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum EmbedJobTruncate { 9 | START("START"), 10 | 11 | END("END"); 12 | 13 | private final String value; 14 | 15 | EmbedJobTruncate(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | @java.lang.Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/EmbedRequestTruncate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum EmbedRequestTruncate { 9 | NONE("NONE"), 10 | 11 | START("START"), 12 | 13 | END("END"); 14 | 15 | private final String value; 16 | 17 | EmbedRequestTruncate(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/EmbedText.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = EmbedText.Builder.class) 22 | public final class EmbedText { 23 | private final Optional text; 24 | 25 | private final Map additionalProperties; 26 | 27 | private EmbedText(Optional text, Map additionalProperties) { 28 | this.text = text; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | @JsonProperty("text") 33 | public Optional getText() { 34 | return text; 35 | } 36 | 37 | @java.lang.Override 38 | public boolean equals(Object other) { 39 | if (this == other) return true; 40 | return other instanceof EmbedText && equalTo((EmbedText) other); 41 | } 42 | 43 | @JsonAnyGetter 44 | public Map getAdditionalProperties() { 45 | return this.additionalProperties; 46 | } 47 | 48 | private boolean equalTo(EmbedText other) { 49 | return text.equals(other.text); 50 | } 51 | 52 | @java.lang.Override 53 | public int hashCode() { 54 | return Objects.hash(this.text); 55 | } 56 | 57 | @java.lang.Override 58 | public String toString() { 59 | return ObjectMappers.stringify(this); 60 | } 61 | 62 | public static Builder builder() { 63 | return new Builder(); 64 | } 65 | 66 | @JsonIgnoreProperties(ignoreUnknown = true) 67 | public static final class Builder { 68 | private Optional text = Optional.empty(); 69 | 70 | @JsonAnySetter 71 | private Map additionalProperties = new HashMap<>(); 72 | 73 | private Builder() {} 74 | 75 | public Builder from(EmbedText other) { 76 | text(other.getText()); 77 | return this; 78 | } 79 | 80 | @JsonSetter(value = "text", nulls = Nulls.SKIP) 81 | public Builder text(Optional text) { 82 | this.text = text; 83 | return this; 84 | } 85 | 86 | public Builder text(String text) { 87 | this.text = Optional.ofNullable(text); 88 | return this; 89 | } 90 | 91 | public EmbedText build() { 92 | return new EmbedText(text, additionalProperties); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/EmbeddingType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum EmbeddingType { 9 | FLOAT("float"), 10 | 11 | INT_8("int8"), 12 | 13 | UINT_8("uint8"), 14 | 15 | BINARY("binary"), 16 | 17 | UBINARY("ubinary"); 18 | 19 | private final String value; 20 | 21 | EmbeddingType(String value) { 22 | this.value = value; 23 | } 24 | 25 | @JsonValue 26 | @java.lang.Override 27 | public String toString() { 28 | return this.value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/FinishReason.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum FinishReason { 9 | COMPLETE("COMPLETE"), 10 | 11 | STOP_SEQUENCE("STOP_SEQUENCE"), 12 | 13 | ERROR("ERROR"), 14 | 15 | ERROR_TOXIC("ERROR_TOXIC"), 16 | 17 | ERROR_LIMIT("ERROR_LIMIT"), 18 | 19 | USER_CANCEL("USER_CANCEL"), 20 | 21 | MAX_TOKENS("MAX_TOKENS"); 22 | 23 | private final String value; 24 | 25 | FinishReason(String value) { 26 | this.value = value; 27 | } 28 | 29 | @JsonValue 30 | @java.lang.Override 31 | public String toString() { 32 | return this.value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/GenerateRequestReturnLikelihoods.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum GenerateRequestReturnLikelihoods { 9 | GENERATION("GENERATION"), 10 | 11 | ALL("ALL"), 12 | 13 | NONE("NONE"); 14 | 15 | private final String value; 16 | 17 | GenerateRequestReturnLikelihoods(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/GenerateRequestTruncate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum GenerateRequestTruncate { 9 | NONE("NONE"), 10 | 11 | START("START"), 12 | 13 | END("END"); 14 | 15 | private final String value; 16 | 17 | GenerateRequestTruncate(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/GenerateStreamEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 16 | @JsonDeserialize(builder = GenerateStreamEvent.Builder.class) 17 | public final class GenerateStreamEvent implements IGenerateStreamEvent { 18 | private final Map additionalProperties; 19 | 20 | private GenerateStreamEvent(Map additionalProperties) { 21 | this.additionalProperties = additionalProperties; 22 | } 23 | 24 | @java.lang.Override 25 | public boolean equals(Object other) { 26 | if (this == other) return true; 27 | return other instanceof GenerateStreamEvent; 28 | } 29 | 30 | @JsonAnyGetter 31 | public Map getAdditionalProperties() { 32 | return this.additionalProperties; 33 | } 34 | 35 | @java.lang.Override 36 | public String toString() { 37 | return ObjectMappers.stringify(this); 38 | } 39 | 40 | public static Builder builder() { 41 | return new Builder(); 42 | } 43 | 44 | @JsonIgnoreProperties(ignoreUnknown = true) 45 | public static final class Builder { 46 | @JsonAnySetter 47 | private Map additionalProperties = new HashMap<>(); 48 | 49 | private Builder() {} 50 | 51 | public Builder from(GenerateStreamEvent other) { 52 | return this; 53 | } 54 | 55 | public GenerateStreamEvent build() { 56 | return new GenerateStreamEvent(additionalProperties); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/GenerateStreamRequestReturnLikelihoods.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum GenerateStreamRequestReturnLikelihoods { 9 | GENERATION("GENERATION"), 10 | 11 | ALL("ALL"), 12 | 13 | NONE("NONE"); 14 | 15 | private final String value; 16 | 17 | GenerateStreamRequestReturnLikelihoods(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/GenerateStreamRequestTruncate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum GenerateStreamRequestTruncate { 9 | NONE("NONE"), 10 | 11 | START("START"), 12 | 13 | END("END"); 14 | 15 | private final String value; 16 | 17 | GenerateStreamRequestTruncate(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/IChatStreamEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | public interface IChatStreamEvent {} 7 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/IChatStreamEventType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | public interface IChatStreamEventType {} 7 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/IGenerateStreamEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | public interface IGenerateStreamEvent {} 7 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ImageContent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.Objects; 17 | import org.jetbrains.annotations.NotNull; 18 | 19 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 20 | @JsonDeserialize(builder = ImageContent.Builder.class) 21 | public final class ImageContent { 22 | private final ImageUrl imageUrl; 23 | 24 | private final Map additionalProperties; 25 | 26 | private ImageContent(ImageUrl imageUrl, Map additionalProperties) { 27 | this.imageUrl = imageUrl; 28 | this.additionalProperties = additionalProperties; 29 | } 30 | 31 | @JsonProperty("image_url") 32 | public ImageUrl getImageUrl() { 33 | return imageUrl; 34 | } 35 | 36 | @java.lang.Override 37 | public boolean equals(Object other) { 38 | if (this == other) return true; 39 | return other instanceof ImageContent && equalTo((ImageContent) other); 40 | } 41 | 42 | @JsonAnyGetter 43 | public Map getAdditionalProperties() { 44 | return this.additionalProperties; 45 | } 46 | 47 | private boolean equalTo(ImageContent other) { 48 | return imageUrl.equals(other.imageUrl); 49 | } 50 | 51 | @java.lang.Override 52 | public int hashCode() { 53 | return Objects.hash(this.imageUrl); 54 | } 55 | 56 | @java.lang.Override 57 | public String toString() { 58 | return ObjectMappers.stringify(this); 59 | } 60 | 61 | public static ImageUrlStage builder() { 62 | return new Builder(); 63 | } 64 | 65 | public interface ImageUrlStage { 66 | _FinalStage imageUrl(@NotNull ImageUrl imageUrl); 67 | 68 | Builder from(ImageContent other); 69 | } 70 | 71 | public interface _FinalStage { 72 | ImageContent build(); 73 | } 74 | 75 | @JsonIgnoreProperties(ignoreUnknown = true) 76 | public static final class Builder implements ImageUrlStage, _FinalStage { 77 | private ImageUrl imageUrl; 78 | 79 | @JsonAnySetter 80 | private Map additionalProperties = new HashMap<>(); 81 | 82 | private Builder() {} 83 | 84 | @java.lang.Override 85 | public Builder from(ImageContent other) { 86 | imageUrl(other.getImageUrl()); 87 | return this; 88 | } 89 | 90 | @java.lang.Override 91 | @JsonSetter("image_url") 92 | public _FinalStage imageUrl(@NotNull ImageUrl imageUrl) { 93 | this.imageUrl = Objects.requireNonNull(imageUrl, "imageUrl must not be null"); 94 | return this; 95 | } 96 | 97 | @java.lang.Override 98 | public ImageContent build() { 99 | return new ImageContent(imageUrl, additionalProperties); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ImageUrl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.Objects; 17 | import org.jetbrains.annotations.NotNull; 18 | 19 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 20 | @JsonDeserialize(builder = ImageUrl.Builder.class) 21 | public final class ImageUrl { 22 | private final String url; 23 | 24 | private final Map additionalProperties; 25 | 26 | private ImageUrl(String url, Map additionalProperties) { 27 | this.url = url; 28 | this.additionalProperties = additionalProperties; 29 | } 30 | 31 | @JsonProperty("url") 32 | public String getUrl() { 33 | return url; 34 | } 35 | 36 | @java.lang.Override 37 | public boolean equals(Object other) { 38 | if (this == other) return true; 39 | return other instanceof ImageUrl && equalTo((ImageUrl) other); 40 | } 41 | 42 | @JsonAnyGetter 43 | public Map getAdditionalProperties() { 44 | return this.additionalProperties; 45 | } 46 | 47 | private boolean equalTo(ImageUrl other) { 48 | return url.equals(other.url); 49 | } 50 | 51 | @java.lang.Override 52 | public int hashCode() { 53 | return Objects.hash(this.url); 54 | } 55 | 56 | @java.lang.Override 57 | public String toString() { 58 | return ObjectMappers.stringify(this); 59 | } 60 | 61 | public static UrlStage builder() { 62 | return new Builder(); 63 | } 64 | 65 | public interface UrlStage { 66 | _FinalStage url(@NotNull String url); 67 | 68 | Builder from(ImageUrl other); 69 | } 70 | 71 | public interface _FinalStage { 72 | ImageUrl build(); 73 | } 74 | 75 | @JsonIgnoreProperties(ignoreUnknown = true) 76 | public static final class Builder implements UrlStage, _FinalStage { 77 | private String url; 78 | 79 | @JsonAnySetter 80 | private Map additionalProperties = new HashMap<>(); 81 | 82 | private Builder() {} 83 | 84 | @java.lang.Override 85 | public Builder from(ImageUrl other) { 86 | url(other.getUrl()); 87 | return this; 88 | } 89 | 90 | @java.lang.Override 91 | @JsonSetter("url") 92 | public _FinalStage url(@NotNull String url) { 93 | this.url = Objects.requireNonNull(url, "url must not be null"); 94 | return this; 95 | } 96 | 97 | @java.lang.Override 98 | public ImageUrl build() { 99 | return new ImageUrl(url, additionalProperties); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ListEmbedJobResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | import java.util.Objects; 19 | import java.util.Optional; 20 | 21 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 22 | @JsonDeserialize(builder = ListEmbedJobResponse.Builder.class) 23 | public final class ListEmbedJobResponse { 24 | private final Optional> embedJobs; 25 | 26 | private final Map additionalProperties; 27 | 28 | private ListEmbedJobResponse(Optional> embedJobs, Map additionalProperties) { 29 | this.embedJobs = embedJobs; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("embed_jobs") 34 | public Optional> getEmbedJobs() { 35 | return embedJobs; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ListEmbedJobResponse && equalTo((ListEmbedJobResponse) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ListEmbedJobResponse other) { 50 | return embedJobs.equals(other.embedJobs); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.embedJobs); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional> embedJobs = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ListEmbedJobResponse other) { 77 | embedJobs(other.getEmbedJobs()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "embed_jobs", nulls = Nulls.SKIP) 82 | public Builder embedJobs(Optional> embedJobs) { 83 | this.embedJobs = embedJobs; 84 | return this; 85 | } 86 | 87 | public Builder embedJobs(List embedJobs) { 88 | this.embedJobs = Optional.ofNullable(embedJobs); 89 | return this; 90 | } 91 | 92 | public ListEmbedJobResponse build() { 93 | return new ListEmbedJobResponse(embedJobs, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/OAuthAuthorizeResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 21 | @JsonDeserialize(builder = OAuthAuthorizeResponse.Builder.class) 22 | public final class OAuthAuthorizeResponse { 23 | private final Optional redirectUrl; 24 | 25 | private final Map additionalProperties; 26 | 27 | private OAuthAuthorizeResponse(Optional redirectUrl, Map additionalProperties) { 28 | this.redirectUrl = redirectUrl; 29 | this.additionalProperties = additionalProperties; 30 | } 31 | 32 | /** 33 | * @return The OAuth 2.0 redirect url. Redirect the user to this url to authorize the connector. 34 | */ 35 | @JsonProperty("redirect_url") 36 | public Optional getRedirectUrl() { 37 | return redirectUrl; 38 | } 39 | 40 | @java.lang.Override 41 | public boolean equals(Object other) { 42 | if (this == other) return true; 43 | return other instanceof OAuthAuthorizeResponse && equalTo((OAuthAuthorizeResponse) other); 44 | } 45 | 46 | @JsonAnyGetter 47 | public Map getAdditionalProperties() { 48 | return this.additionalProperties; 49 | } 50 | 51 | private boolean equalTo(OAuthAuthorizeResponse other) { 52 | return redirectUrl.equals(other.redirectUrl); 53 | } 54 | 55 | @java.lang.Override 56 | public int hashCode() { 57 | return Objects.hash(this.redirectUrl); 58 | } 59 | 60 | @java.lang.Override 61 | public String toString() { 62 | return ObjectMappers.stringify(this); 63 | } 64 | 65 | public static Builder builder() { 66 | return new Builder(); 67 | } 68 | 69 | @JsonIgnoreProperties(ignoreUnknown = true) 70 | public static final class Builder { 71 | private Optional redirectUrl = Optional.empty(); 72 | 73 | @JsonAnySetter 74 | private Map additionalProperties = new HashMap<>(); 75 | 76 | private Builder() {} 77 | 78 | public Builder from(OAuthAuthorizeResponse other) { 79 | redirectUrl(other.getRedirectUrl()); 80 | return this; 81 | } 82 | 83 | @JsonSetter(value = "redirect_url", nulls = Nulls.SKIP) 84 | public Builder redirectUrl(Optional redirectUrl) { 85 | this.redirectUrl = redirectUrl; 86 | return this; 87 | } 88 | 89 | public Builder redirectUrl(String redirectUrl) { 90 | this.redirectUrl = Optional.ofNullable(redirectUrl); 91 | return this; 92 | } 93 | 94 | public OAuthAuthorizeResponse build() { 95 | return new OAuthAuthorizeResponse(redirectUrl, additionalProperties); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ReasoningEffort.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum ReasoningEffort { 9 | LOW("low"), 10 | 11 | MEDIUM("medium"), 12 | 13 | HIGH("high"); 14 | 15 | private final String value; 16 | 17 | ReasoningEffort(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/RerankRequestDocumentsItem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonValue; 8 | import com.fasterxml.jackson.core.JsonParseException; 9 | import com.fasterxml.jackson.core.JsonParser; 10 | import com.fasterxml.jackson.core.type.TypeReference; 11 | import com.fasterxml.jackson.databind.DeserializationContext; 12 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 13 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; 14 | import java.io.IOException; 15 | import java.util.Map; 16 | import java.util.Objects; 17 | 18 | @JsonDeserialize(using = RerankRequestDocumentsItem.Deserializer.class) 19 | public final class RerankRequestDocumentsItem { 20 | private final Object value; 21 | 22 | private final int type; 23 | 24 | private RerankRequestDocumentsItem(Object value, int type) { 25 | this.value = value; 26 | this.type = type; 27 | } 28 | 29 | @JsonValue 30 | public Object get() { 31 | return this.value; 32 | } 33 | 34 | public T visit(Visitor visitor) { 35 | if (this.type == 0) { 36 | return visitor.visit((String) this.value); 37 | } else if (this.type == 1) { 38 | return visitor.visit((Map) this.value); 39 | } 40 | throw new IllegalStateException("Failed to visit value. This should never happen."); 41 | } 42 | 43 | @java.lang.Override 44 | public boolean equals(Object other) { 45 | if (this == other) return true; 46 | return other instanceof RerankRequestDocumentsItem && equalTo((RerankRequestDocumentsItem) other); 47 | } 48 | 49 | private boolean equalTo(RerankRequestDocumentsItem other) { 50 | return value.equals(other.value); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.value); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return this.value.toString(); 61 | } 62 | 63 | public static RerankRequestDocumentsItem of(String value) { 64 | return new RerankRequestDocumentsItem(value, 0); 65 | } 66 | 67 | public static RerankRequestDocumentsItem of(Map value) { 68 | return new RerankRequestDocumentsItem(value, 1); 69 | } 70 | 71 | public interface Visitor { 72 | T visit(String value); 73 | 74 | T visit(Map value); 75 | } 76 | 77 | static final class Deserializer extends StdDeserializer { 78 | Deserializer() { 79 | super(RerankRequestDocumentsItem.class); 80 | } 81 | 82 | @java.lang.Override 83 | public RerankRequestDocumentsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { 84 | Object value = p.readValueAs(Object.class); 85 | try { 86 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); 87 | } catch (IllegalArgumentException e) { 88 | } 89 | try { 90 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); 91 | } catch (IllegalArgumentException e) { 92 | } 93 | throw new JsonParseException(p, "Failed to deserialize"); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/SummarizeRequestExtractiveness.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum SummarizeRequestExtractiveness { 9 | LOW("low"), 10 | 11 | MEDIUM("medium"), 12 | 13 | HIGH("high"); 14 | 15 | private final String value; 16 | 17 | SummarizeRequestExtractiveness(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/SummarizeRequestFormat.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum SummarizeRequestFormat { 9 | PARAGRAPH("paragraph"), 10 | 11 | BULLETS("bullets"); 12 | 13 | private final String value; 14 | 15 | SummarizeRequestFormat(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | @java.lang.Override 21 | public String toString() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/SummarizeRequestLength.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.fasterxml.jackson.annotation.JsonValue; 7 | 8 | public enum SummarizeRequestLength { 9 | SHORT("short"), 10 | 11 | MEDIUM("medium"), 12 | 13 | LONG("long"); 14 | 15 | private final String value; 16 | 17 | SummarizeRequestLength(String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | @java.lang.Override 23 | public String toString() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/SystemMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.Objects; 17 | import org.jetbrains.annotations.NotNull; 18 | 19 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 20 | @JsonDeserialize(builder = SystemMessage.Builder.class) 21 | public final class SystemMessage { 22 | private final SystemMessageContent content; 23 | 24 | private final Map additionalProperties; 25 | 26 | private SystemMessage(SystemMessageContent content, Map additionalProperties) { 27 | this.content = content; 28 | this.additionalProperties = additionalProperties; 29 | } 30 | 31 | @JsonProperty("content") 32 | public SystemMessageContent getContent() { 33 | return content; 34 | } 35 | 36 | @java.lang.Override 37 | public boolean equals(Object other) { 38 | if (this == other) return true; 39 | return other instanceof SystemMessage && equalTo((SystemMessage) other); 40 | } 41 | 42 | @JsonAnyGetter 43 | public Map getAdditionalProperties() { 44 | return this.additionalProperties; 45 | } 46 | 47 | private boolean equalTo(SystemMessage other) { 48 | return content.equals(other.content); 49 | } 50 | 51 | @java.lang.Override 52 | public int hashCode() { 53 | return Objects.hash(this.content); 54 | } 55 | 56 | @java.lang.Override 57 | public String toString() { 58 | return ObjectMappers.stringify(this); 59 | } 60 | 61 | public static ContentStage builder() { 62 | return new Builder(); 63 | } 64 | 65 | public interface ContentStage { 66 | _FinalStage content(@NotNull SystemMessageContent content); 67 | 68 | Builder from(SystemMessage other); 69 | } 70 | 71 | public interface _FinalStage { 72 | SystemMessage build(); 73 | } 74 | 75 | @JsonIgnoreProperties(ignoreUnknown = true) 76 | public static final class Builder implements ContentStage, _FinalStage { 77 | private SystemMessageContent content; 78 | 79 | @JsonAnySetter 80 | private Map additionalProperties = new HashMap<>(); 81 | 82 | private Builder() {} 83 | 84 | @java.lang.Override 85 | public Builder from(SystemMessage other) { 86 | content(other.getContent()); 87 | return this; 88 | } 89 | 90 | @java.lang.Override 91 | @JsonSetter("content") 92 | public _FinalStage content(@NotNull SystemMessageContent content) { 93 | this.content = Objects.requireNonNull(content, "content must not be null"); 94 | return this; 95 | } 96 | 97 | @java.lang.Override 98 | public SystemMessage build() { 99 | return new SystemMessage(content, additionalProperties); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/SystemMessageContent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonValue; 8 | import com.fasterxml.jackson.core.JsonParseException; 9 | import com.fasterxml.jackson.core.JsonParser; 10 | import com.fasterxml.jackson.core.type.TypeReference; 11 | import com.fasterxml.jackson.databind.DeserializationContext; 12 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 13 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; 14 | import java.io.IOException; 15 | import java.util.List; 16 | import java.util.Objects; 17 | 18 | @JsonDeserialize(using = SystemMessageContent.Deserializer.class) 19 | public final class SystemMessageContent { 20 | private final Object value; 21 | 22 | private final int type; 23 | 24 | private SystemMessageContent(Object value, int type) { 25 | this.value = value; 26 | this.type = type; 27 | } 28 | 29 | @JsonValue 30 | public Object get() { 31 | return this.value; 32 | } 33 | 34 | public T visit(Visitor visitor) { 35 | if (this.type == 0) { 36 | return visitor.visit((String) this.value); 37 | } else if (this.type == 1) { 38 | return visitor.visit((List) this.value); 39 | } 40 | throw new IllegalStateException("Failed to visit value. This should never happen."); 41 | } 42 | 43 | @java.lang.Override 44 | public boolean equals(Object other) { 45 | if (this == other) return true; 46 | return other instanceof SystemMessageContent && equalTo((SystemMessageContent) other); 47 | } 48 | 49 | private boolean equalTo(SystemMessageContent other) { 50 | return value.equals(other.value); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.value); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return this.value.toString(); 61 | } 62 | 63 | public static SystemMessageContent of(String value) { 64 | return new SystemMessageContent(value, 0); 65 | } 66 | 67 | public static SystemMessageContent of(List value) { 68 | return new SystemMessageContent(value, 1); 69 | } 70 | 71 | public interface Visitor { 72 | T visit(String value); 73 | 74 | T visit(List value); 75 | } 76 | 77 | static final class Deserializer extends StdDeserializer { 78 | Deserializer() { 79 | super(SystemMessageContent.class); 80 | } 81 | 82 | @java.lang.Override 83 | public SystemMessageContent deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { 84 | Object value = p.readValueAs(Object.class); 85 | try { 86 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); 87 | } catch (IllegalArgumentException e) { 88 | } 89 | try { 90 | return of(ObjectMappers.JSON_MAPPER.convertValue( 91 | value, new TypeReference>() {})); 92 | } catch (IllegalArgumentException e) { 93 | } 94 | throw new JsonParseException(p, "Failed to deserialize"); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/TextContent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.Objects; 17 | import org.jetbrains.annotations.NotNull; 18 | 19 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 20 | @JsonDeserialize(builder = TextContent.Builder.class) 21 | public final class TextContent { 22 | private final String text; 23 | 24 | private final Map additionalProperties; 25 | 26 | private TextContent(String text, Map additionalProperties) { 27 | this.text = text; 28 | this.additionalProperties = additionalProperties; 29 | } 30 | 31 | @JsonProperty("text") 32 | public String getText() { 33 | return text; 34 | } 35 | 36 | @java.lang.Override 37 | public boolean equals(Object other) { 38 | if (this == other) return true; 39 | return other instanceof TextContent && equalTo((TextContent) other); 40 | } 41 | 42 | @JsonAnyGetter 43 | public Map getAdditionalProperties() { 44 | return this.additionalProperties; 45 | } 46 | 47 | private boolean equalTo(TextContent other) { 48 | return text.equals(other.text); 49 | } 50 | 51 | @java.lang.Override 52 | public int hashCode() { 53 | return Objects.hash(this.text); 54 | } 55 | 56 | @java.lang.Override 57 | public String toString() { 58 | return ObjectMappers.stringify(this); 59 | } 60 | 61 | public static TextStage builder() { 62 | return new Builder(); 63 | } 64 | 65 | public interface TextStage { 66 | _FinalStage text(@NotNull String text); 67 | 68 | Builder from(TextContent other); 69 | } 70 | 71 | public interface _FinalStage { 72 | TextContent build(); 73 | } 74 | 75 | @JsonIgnoreProperties(ignoreUnknown = true) 76 | public static final class Builder implements TextStage, _FinalStage { 77 | private String text; 78 | 79 | @JsonAnySetter 80 | private Map additionalProperties = new HashMap<>(); 81 | 82 | private Builder() {} 83 | 84 | @java.lang.Override 85 | public Builder from(TextContent other) { 86 | text(other.getText()); 87 | return this; 88 | } 89 | 90 | @java.lang.Override 91 | @JsonSetter("text") 92 | public _FinalStage text(@NotNull String text) { 93 | this.text = Objects.requireNonNull(text, "text must not be null"); 94 | return this; 95 | } 96 | 97 | @java.lang.Override 98 | public TextContent build() { 99 | return new TextContent(text, additionalProperties); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/TextResponseFormat.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 16 | @JsonDeserialize(builder = TextResponseFormat.Builder.class) 17 | public final class TextResponseFormat { 18 | private final Map additionalProperties; 19 | 20 | private TextResponseFormat(Map additionalProperties) { 21 | this.additionalProperties = additionalProperties; 22 | } 23 | 24 | @java.lang.Override 25 | public boolean equals(Object other) { 26 | if (this == other) return true; 27 | return other instanceof TextResponseFormat; 28 | } 29 | 30 | @JsonAnyGetter 31 | public Map getAdditionalProperties() { 32 | return this.additionalProperties; 33 | } 34 | 35 | @java.lang.Override 36 | public String toString() { 37 | return ObjectMappers.stringify(this); 38 | } 39 | 40 | public static Builder builder() { 41 | return new Builder(); 42 | } 43 | 44 | @JsonIgnoreProperties(ignoreUnknown = true) 45 | public static final class Builder { 46 | @JsonAnySetter 47 | private Map additionalProperties = new HashMap<>(); 48 | 49 | private Builder() {} 50 | 51 | public Builder from(TextResponseFormat other) { 52 | return this; 53 | } 54 | 55 | public TextResponseFormat build() { 56 | return new TextResponseFormat(additionalProperties); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/TextResponseFormatV2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 16 | @JsonDeserialize(builder = TextResponseFormatV2.Builder.class) 17 | public final class TextResponseFormatV2 { 18 | private final Map additionalProperties; 19 | 20 | private TextResponseFormatV2(Map additionalProperties) { 21 | this.additionalProperties = additionalProperties; 22 | } 23 | 24 | @java.lang.Override 25 | public boolean equals(Object other) { 26 | if (this == other) return true; 27 | return other instanceof TextResponseFormatV2; 28 | } 29 | 30 | @JsonAnyGetter 31 | public Map getAdditionalProperties() { 32 | return this.additionalProperties; 33 | } 34 | 35 | @java.lang.Override 36 | public String toString() { 37 | return ObjectMappers.stringify(this); 38 | } 39 | 40 | public static Builder builder() { 41 | return new Builder(); 42 | } 43 | 44 | @JsonIgnoreProperties(ignoreUnknown = true) 45 | public static final class Builder { 46 | @JsonAnySetter 47 | private Map additionalProperties = new HashMap<>(); 48 | 49 | private Builder() {} 50 | 51 | public Builder from(TextResponseFormatV2 other) { 52 | return this; 53 | } 54 | 55 | public TextResponseFormatV2 build() { 56 | return new TextResponseFormatV2(additionalProperties); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ToolMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonSetter; 13 | import com.fasterxml.jackson.annotation.Nulls; 14 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | import java.util.Objects; 19 | import java.util.Optional; 20 | 21 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 22 | @JsonDeserialize(builder = ToolMessage.Builder.class) 23 | public final class ToolMessage { 24 | private final Optional> toolResults; 25 | 26 | private final Map additionalProperties; 27 | 28 | private ToolMessage(Optional> toolResults, Map additionalProperties) { 29 | this.toolResults = toolResults; 30 | this.additionalProperties = additionalProperties; 31 | } 32 | 33 | @JsonProperty("tool_results") 34 | public Optional> getToolResults() { 35 | return toolResults; 36 | } 37 | 38 | @java.lang.Override 39 | public boolean equals(Object other) { 40 | if (this == other) return true; 41 | return other instanceof ToolMessage && equalTo((ToolMessage) other); 42 | } 43 | 44 | @JsonAnyGetter 45 | public Map getAdditionalProperties() { 46 | return this.additionalProperties; 47 | } 48 | 49 | private boolean equalTo(ToolMessage other) { 50 | return toolResults.equals(other.toolResults); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.toolResults); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return ObjectMappers.stringify(this); 61 | } 62 | 63 | public static Builder builder() { 64 | return new Builder(); 65 | } 66 | 67 | @JsonIgnoreProperties(ignoreUnknown = true) 68 | public static final class Builder { 69 | private Optional> toolResults = Optional.empty(); 70 | 71 | @JsonAnySetter 72 | private Map additionalProperties = new HashMap<>(); 73 | 74 | private Builder() {} 75 | 76 | public Builder from(ToolMessage other) { 77 | toolResults(other.getToolResults()); 78 | return this; 79 | } 80 | 81 | @JsonSetter(value = "tool_results", nulls = Nulls.SKIP) 82 | public Builder toolResults(Optional> toolResults) { 83 | this.toolResults = toolResults; 84 | return this; 85 | } 86 | 87 | public Builder toolResults(List toolResults) { 88 | this.toolResults = Optional.ofNullable(toolResults); 89 | return this; 90 | } 91 | 92 | public ToolMessage build() { 93 | return new ToolMessage(toolResults, additionalProperties); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/ToolMessageV2Content.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonValue; 8 | import com.fasterxml.jackson.core.JsonParseException; 9 | import com.fasterxml.jackson.core.JsonParser; 10 | import com.fasterxml.jackson.core.type.TypeReference; 11 | import com.fasterxml.jackson.databind.DeserializationContext; 12 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 13 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; 14 | import java.io.IOException; 15 | import java.util.List; 16 | import java.util.Objects; 17 | 18 | @JsonDeserialize(using = ToolMessageV2Content.Deserializer.class) 19 | public final class ToolMessageV2Content { 20 | private final Object value; 21 | 22 | private final int type; 23 | 24 | private ToolMessageV2Content(Object value, int type) { 25 | this.value = value; 26 | this.type = type; 27 | } 28 | 29 | @JsonValue 30 | public Object get() { 31 | return this.value; 32 | } 33 | 34 | public T visit(Visitor visitor) { 35 | if (this.type == 0) { 36 | return visitor.visit((String) this.value); 37 | } else if (this.type == 1) { 38 | return visitor.visit((List) this.value); 39 | } 40 | throw new IllegalStateException("Failed to visit value. This should never happen."); 41 | } 42 | 43 | @java.lang.Override 44 | public boolean equals(Object other) { 45 | if (this == other) return true; 46 | return other instanceof ToolMessageV2Content && equalTo((ToolMessageV2Content) other); 47 | } 48 | 49 | private boolean equalTo(ToolMessageV2Content other) { 50 | return value.equals(other.value); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.value); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return this.value.toString(); 61 | } 62 | 63 | public static ToolMessageV2Content of(String value) { 64 | return new ToolMessageV2Content(value, 0); 65 | } 66 | 67 | public static ToolMessageV2Content of(List value) { 68 | return new ToolMessageV2Content(value, 1); 69 | } 70 | 71 | public interface Visitor { 72 | T visit(String value); 73 | 74 | T visit(List value); 75 | } 76 | 77 | static final class Deserializer extends StdDeserializer { 78 | Deserializer() { 79 | super(ToolMessageV2Content.class); 80 | } 81 | 82 | @java.lang.Override 83 | public ToolMessageV2Content deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { 84 | Object value = p.readValueAs(Object.class); 85 | try { 86 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); 87 | } catch (IllegalArgumentException e) { 88 | } 89 | try { 90 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); 91 | } catch (IllegalArgumentException e) { 92 | } 93 | throw new JsonParseException(p, "Failed to deserialize"); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/TruncationStrategyAutoPreserveOrder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 16 | @JsonDeserialize(builder = TruncationStrategyAutoPreserveOrder.Builder.class) 17 | public final class TruncationStrategyAutoPreserveOrder { 18 | private final Map additionalProperties; 19 | 20 | private TruncationStrategyAutoPreserveOrder(Map additionalProperties) { 21 | this.additionalProperties = additionalProperties; 22 | } 23 | 24 | @java.lang.Override 25 | public boolean equals(Object other) { 26 | if (this == other) return true; 27 | return other instanceof TruncationStrategyAutoPreserveOrder; 28 | } 29 | 30 | @JsonAnyGetter 31 | public Map getAdditionalProperties() { 32 | return this.additionalProperties; 33 | } 34 | 35 | @java.lang.Override 36 | public String toString() { 37 | return ObjectMappers.stringify(this); 38 | } 39 | 40 | public static Builder builder() { 41 | return new Builder(); 42 | } 43 | 44 | @JsonIgnoreProperties(ignoreUnknown = true) 45 | public static final class Builder { 46 | @JsonAnySetter 47 | private Map additionalProperties = new HashMap<>(); 48 | 49 | private Builder() {} 50 | 51 | public Builder from(TruncationStrategyAutoPreserveOrder other) { 52 | return this; 53 | } 54 | 55 | public TruncationStrategyAutoPreserveOrder build() { 56 | return new TruncationStrategyAutoPreserveOrder(additionalProperties); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/TruncationStrategyNone.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 8 | import com.fasterxml.jackson.annotation.JsonAnySetter; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @JsonInclude(JsonInclude.Include.NON_ABSENT) 16 | @JsonDeserialize(builder = TruncationStrategyNone.Builder.class) 17 | public final class TruncationStrategyNone { 18 | private final Map additionalProperties; 19 | 20 | private TruncationStrategyNone(Map additionalProperties) { 21 | this.additionalProperties = additionalProperties; 22 | } 23 | 24 | @java.lang.Override 25 | public boolean equals(Object other) { 26 | if (this == other) return true; 27 | return other instanceof TruncationStrategyNone; 28 | } 29 | 30 | @JsonAnyGetter 31 | public Map getAdditionalProperties() { 32 | return this.additionalProperties; 33 | } 34 | 35 | @java.lang.Override 36 | public String toString() { 37 | return ObjectMappers.stringify(this); 38 | } 39 | 40 | public static Builder builder() { 41 | return new Builder(); 42 | } 43 | 44 | @JsonIgnoreProperties(ignoreUnknown = true) 45 | public static final class Builder { 46 | @JsonAnySetter 47 | private Map additionalProperties = new HashMap<>(); 48 | 49 | private Builder() {} 50 | 51 | public Builder from(TruncationStrategyNone other) { 52 | return this; 53 | } 54 | 55 | public TruncationStrategyNone build() { 56 | return new TruncationStrategyNone(additionalProperties); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cohere/api/types/UserMessageContent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api.types; 5 | 6 | import com.cohere.api.core.ObjectMappers; 7 | import com.fasterxml.jackson.annotation.JsonValue; 8 | import com.fasterxml.jackson.core.JsonParseException; 9 | import com.fasterxml.jackson.core.JsonParser; 10 | import com.fasterxml.jackson.core.type.TypeReference; 11 | import com.fasterxml.jackson.databind.DeserializationContext; 12 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 13 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; 14 | import java.io.IOException; 15 | import java.util.List; 16 | import java.util.Objects; 17 | 18 | @JsonDeserialize(using = UserMessageContent.Deserializer.class) 19 | public final class UserMessageContent { 20 | private final Object value; 21 | 22 | private final int type; 23 | 24 | private UserMessageContent(Object value, int type) { 25 | this.value = value; 26 | this.type = type; 27 | } 28 | 29 | @JsonValue 30 | public Object get() { 31 | return this.value; 32 | } 33 | 34 | public T visit(Visitor visitor) { 35 | if (this.type == 0) { 36 | return visitor.visit((String) this.value); 37 | } else if (this.type == 1) { 38 | return visitor.visit((List) this.value); 39 | } 40 | throw new IllegalStateException("Failed to visit value. This should never happen."); 41 | } 42 | 43 | @java.lang.Override 44 | public boolean equals(Object other) { 45 | if (this == other) return true; 46 | return other instanceof UserMessageContent && equalTo((UserMessageContent) other); 47 | } 48 | 49 | private boolean equalTo(UserMessageContent other) { 50 | return value.equals(other.value); 51 | } 52 | 53 | @java.lang.Override 54 | public int hashCode() { 55 | return Objects.hash(this.value); 56 | } 57 | 58 | @java.lang.Override 59 | public String toString() { 60 | return this.value.toString(); 61 | } 62 | 63 | public static UserMessageContent of(String value) { 64 | return new UserMessageContent(value, 0); 65 | } 66 | 67 | public static UserMessageContent of(List value) { 68 | return new UserMessageContent(value, 1); 69 | } 70 | 71 | public interface Visitor { 72 | T visit(String value); 73 | 74 | T visit(List value); 75 | } 76 | 77 | static final class Deserializer extends StdDeserializer { 78 | Deserializer() { 79 | super(UserMessageContent.class); 80 | } 81 | 82 | @java.lang.Override 83 | public UserMessageContent deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { 84 | Object value = p.readValueAs(Object.class); 85 | try { 86 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); 87 | } catch (IllegalArgumentException e) { 88 | } 89 | try { 90 | return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); 91 | } catch (IllegalArgumentException e) { 92 | } 93 | throw new JsonParseException(p, "Failed to deserialize"); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/test/java/com/cohere/api/TestClient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | package com.cohere.api; 5 | 6 | public final class TestClient { 7 | public void test() { 8 | // Add tests here and mark this file in .fernignore 9 | assert true; 10 | } 11 | } 12 | --------------------------------------------------------------------------------