├── .devfile.yaml ├── .github └── workflows │ ├── build_java_maven.yml │ └── release_maven_central.yml ├── .gitignore ├── .sdkmanrc ├── .vscode └── extensions.json ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── codestyle ├── spotless_java.importorder └── spotless_java_eclipseformat.xml ├── media └── simple-openai.png ├── pom.xml ├── rundemo.sh └── src ├── demo ├── java │ └── io │ │ └── github │ │ └── sashirestela │ │ └── openai │ │ └── demo │ │ ├── AbstractDemo.java │ │ ├── AssistantV2AzureDemo.java │ │ ├── AssistantV2Demo.java │ │ ├── AudioDemo.java │ │ ├── BatchDemo.java │ │ ├── ChatAnyscaleDemo.java │ │ ├── ChatAzureDemo.java │ │ ├── ChatDeepseekDemo.java │ │ ├── ChatDemo.java │ │ ├── ChatGeminiGoogleDemo.java │ │ ├── ChatGeminiVertexDemo.java │ │ ├── ChatMistralDemo.java │ │ ├── CompletionDemo.java │ │ ├── ConversationDemo.java │ │ ├── ConversationV2Demo.java │ │ ├── ConversationV3Demo.java │ │ ├── EmbeddingDemo.java │ │ ├── EmbeddingGeminiGoogleDemo.java │ │ ├── EmbeddingMistralDemo.java │ │ ├── ExceptionDemo.java │ │ ├── FileAzureDemo.java │ │ ├── FileDemo.java │ │ ├── FinetuningDemo.java │ │ ├── ImageDemo.java │ │ ├── ModelDeepseekDemo.java │ │ ├── ModelDemo.java │ │ ├── ModelMistralDemo.java │ │ ├── ModerationDemo.java │ │ ├── RealtimeDemo.java │ │ ├── ResponseDemo.java │ │ ├── SessionTokenDemo.java │ │ ├── ThreadMessageV2AzureDemo.java │ │ ├── ThreadMessageV2Demo.java │ │ ├── ThreadRunStepV2AzureDemo.java │ │ ├── ThreadRunStepV2Demo.java │ │ ├── ThreadRunV2AzureDemo.java │ │ ├── ThreadRunV2Demo.java │ │ ├── ThreadV2AzureDemo.java │ │ ├── ThreadV2Demo.java │ │ ├── UploadDemo.java │ │ ├── VectorStoreFileBatchV2AzureDemo.java │ │ ├── VectorStoreFileBatchV2Demo.java │ │ ├── VectorStoreFileV2AzureDemo.java │ │ ├── VectorStoreFileV2Demo.java │ │ ├── VectorStoreV2AzureDemo.java │ │ ├── VectorStoreV2Demo.java │ │ └── util │ │ └── UtilSpecs.java └── resources │ ├── answer1.mp3 │ ├── answer2.mp3 │ ├── batch_request.jsonl │ ├── code_interpreter_file.txt │ ├── hello_audio.mp3 │ ├── little_cat.png │ ├── little_cat_rgba.png │ ├── machupicchu.jpg │ ├── math_reasoning.json │ ├── mistral-ai.txt │ ├── question1.mp3 │ ├── question2.mp3 │ ├── simplelogger.properties │ └── test_data.jsonl ├── main └── java │ └── io │ └── github │ └── sashirestela │ └── openai │ ├── OpenAI.java │ ├── OpenAIBeta2.java │ ├── OpenAIRealtime.java │ ├── SimpleOpenAI.java │ ├── SimpleOpenAIAnyscale.java │ ├── SimpleOpenAIAzure.java │ ├── SimpleOpenAIDeepseek.java │ ├── SimpleOpenAIGeminiGoogle.java │ ├── SimpleOpenAIGeminiVertex.java │ ├── SimpleOpenAIMistral.java │ ├── base │ ├── ClientConfig.java │ ├── OpenAIConfigurator.java │ ├── OpenAIProvider.java │ └── RealtimeConfig.java │ ├── common │ ├── DeletedObject.java │ ├── Generic.java │ ├── Page.java │ ├── PageRequest.java │ ├── ResponseFormat.java │ ├── StreamOptions.java │ ├── Usage.java │ ├── audio │ │ ├── AudioFormat.java │ │ ├── InputAudioFormat.java │ │ └── Voice.java │ ├── content │ │ ├── ContentPart.java │ │ ├── FileAnnotation.java │ │ └── ImageDetail.java │ ├── function │ │ ├── FunctionCall.java │ │ ├── FunctionDef.java │ │ ├── FunctionExecutor.java │ │ ├── Functional.java │ │ └── SchemaConverter.java │ └── tool │ │ ├── Tool.java │ │ ├── ToolCall.java │ │ ├── ToolChoice.java │ │ ├── ToolChoiceOption.java │ │ └── ToolType.java │ ├── domain │ ├── assistant │ │ ├── Assistant.java │ │ ├── AssistantModifyRequest.java │ │ ├── AssistantRequest.java │ │ ├── AssistantTool.java │ │ ├── Attachment.java │ │ ├── ChunkingStrategy.java │ │ ├── ExpiresAfter.java │ │ ├── FileCount.java │ │ ├── FileStatus.java │ │ ├── IncompleteDetail.java │ │ ├── LastError.java │ │ ├── RankingOption.java │ │ ├── RunStepType.java │ │ ├── StepDetail.java │ │ ├── Thread.java │ │ ├── ThreadCreateAndRunRequest.java │ │ ├── ThreadMessage.java │ │ ├── ThreadMessageDelta.java │ │ ├── ThreadMessageModifyRequest.java │ │ ├── ThreadMessageRequest.java │ │ ├── ThreadMessageRole.java │ │ ├── ThreadModifyRequest.java │ │ ├── ThreadRequest.java │ │ ├── ThreadRun.java │ │ ├── ThreadRunModifyRequest.java │ │ ├── ThreadRunRequest.java │ │ ├── ThreadRunStep.java │ │ ├── ThreadRunStepDelta.java │ │ ├── ThreadRunStepQuery.java │ │ ├── ThreadRunSubmitOutputRequest.java │ │ ├── ToolResource.java │ │ ├── ToolResourceFull.java │ │ ├── TruncationStrategy.java │ │ ├── VectorStore.java │ │ ├── VectorStoreFile.java │ │ ├── VectorStoreFileBatch.java │ │ ├── VectorStoreFileBatchRequest.java │ │ ├── VectorStoreFileRequest.java │ │ ├── VectorStoreModifyRequest.java │ │ ├── VectorStoreRequest.java │ │ └── events │ │ │ ├── AssistantStreamEvent.java │ │ │ └── EventName.java │ ├── audio │ │ ├── AudioResponseFormat.java │ │ ├── SpeechRequest.java │ │ ├── Transcription.java │ │ ├── TranscriptionRequest.java │ │ └── TranslationRequest.java │ ├── batch │ │ ├── Batch.java │ │ ├── BatchRequest.java │ │ └── EndpointType.java │ ├── chat │ │ ├── Chat.java │ │ ├── ChatMessage.java │ │ └── ChatRequest.java │ ├── completion │ │ ├── Completion.java │ │ └── CompletionRequest.java │ ├── embedding │ │ ├── Embedding.java │ │ ├── EmbeddingBase64.java │ │ ├── EmbeddingFloat.java │ │ └── EmbeddingRequest.java │ ├── file │ │ ├── FileRequest.java │ │ └── FileResponse.java │ ├── finetuning │ │ ├── FineTuning.java │ │ ├── FineTuningCheckpoint.java │ │ ├── FineTuningEvent.java │ │ ├── FineTuningRequest.java │ │ ├── HyperParams.java │ │ ├── Integration.java │ │ └── MethodFineTunning.java │ ├── image │ │ ├── AbstractImageRequest.java │ │ ├── Background.java │ │ ├── Image.java │ │ ├── ImageEditsRequest.java │ │ ├── ImageRequest.java │ │ ├── ImageResponseFormat.java │ │ ├── ImageVariationsRequest.java │ │ ├── Quality.java │ │ └── Size.java │ ├── model │ │ └── Model.java │ ├── moderation │ │ ├── Moderation.java │ │ └── ModerationRequest.java │ ├── realtime │ │ ├── BaseEvent.java │ │ ├── ClientEvent.java │ │ ├── Item.java │ │ ├── Realtime.java │ │ ├── RealtimeResponse.java │ │ ├── RealtimeSession.java │ │ ├── RealtimeSessionToken.java │ │ ├── RealtimeTranscriptionSession.java │ │ ├── RealtimeTranscriptionSessionToken.java │ │ ├── Response.java │ │ └── ServerEvent.java │ ├── response │ │ ├── Action.java │ │ ├── FilterDeserializer.java │ │ ├── Input.java │ │ ├── InputItems.java │ │ ├── ItemDeserializer.java │ │ ├── Prompt.java │ │ ├── Reasoning.java │ │ ├── Response.java │ │ ├── ResponseRequest.java │ │ ├── ResponseText.java │ │ ├── ResponseTool.java │ │ ├── ResponseToolChoice.java │ │ └── stream │ │ │ ├── EventName.java │ │ │ ├── ResponseContentPartEvent.java │ │ │ ├── ResponseErrorEvent.java │ │ │ ├── ResponseEvent.java │ │ │ ├── ResponseFileSearchCallEvent.java │ │ │ ├── ResponseFunctionCallArgsEvent.java │ │ │ ├── ResponseImageGenerationCallEvent.java │ │ │ ├── ResponseImageGenerationCallPartialEvent.java │ │ │ ├── ResponseMcpCallArgumentsEvent.java │ │ │ ├── ResponseMcpCallEvent.java │ │ │ ├── ResponseMcpCallInProgressEvent.java │ │ │ ├── ResponseMcpListToolsEvent.java │ │ │ ├── ResponseOutputItemEvent.java │ │ │ ├── ResponseOutputTextAnnotEvent.java │ │ │ ├── ResponseOutputTextEvent.java │ │ │ ├── ResponseReasonSummPartEvent.java │ │ │ ├── ResponseReasonSummTextEvent.java │ │ │ ├── ResponseReasoningEvent.java │ │ │ ├── ResponseReasoningSummaryEvent.java │ │ │ ├── ResponseRefusalEvent.java │ │ │ ├── ResponseStreamEvent.java │ │ │ └── ResponseWebSearchCallEvent.java │ └── upload │ │ ├── Upload.java │ │ ├── UploadCompleteRequest.java │ │ ├── UploadPart.java │ │ ├── UploadPartRequest.java │ │ └── UploadRequest.java │ ├── exception │ ├── OpenAIException.java │ ├── OpenAIExceptionConverter.java │ ├── OpenAIResponseInfo.java │ ├── PollingAbortedException.java │ └── SimpleOpenAIException.java │ ├── service │ ├── AssistantServices.java │ ├── AudioServices.java │ ├── BatchServices.java │ ├── ChatCompletionServices.java │ ├── CompletionServices.java │ ├── EmbeddingServices.java │ ├── FileServices.java │ ├── FineTunningServices.java │ ├── ImageServices.java │ ├── ModelServices.java │ ├── ModerationServices.java │ ├── RealtimeServices.java │ ├── ResponseServices.java │ ├── SessionServices.java │ └── UploadServices.java │ └── support │ ├── Base64Util.java │ ├── Constant.java │ ├── DefaultSchemaConverter.java │ ├── GeminiAccessToken.java │ ├── JsonSchemaUtil.java │ └── Poller.java └── test ├── java └── io │ └── github │ └── sashirestela │ └── openai │ ├── OpenAIRealtimeTest.java │ ├── SimpleOpenAIAnyscaleTest.java │ ├── SimpleOpenAIAzureTest.java │ ├── SimpleOpenAIDeepseekTest.java │ ├── SimpleOpenAIExceptionTest.java │ ├── SimpleOpenAIGeminiGoogleTest.java │ ├── SimpleOpenAIGeminiVertexTest.java │ ├── SimpleOpenAIMistralTest.java │ ├── SimpleOpenAITest.java │ ├── common │ ├── GenericTest.java │ └── function │ │ └── FunctionExecutorTest.java │ ├── domain │ ├── DomainTestingHelper.java │ ├── assistant │ │ ├── AssistantDomainTest.java │ │ ├── ThreadDomainTest.java │ │ ├── ThreadMessageDomainTest.java │ │ ├── ThreadRunDomainTest.java │ │ ├── ThreadRunStepDomainTest.java │ │ ├── VectorStoreDomainTest.java │ │ ├── VectorStoreFileBatchDomainTest.java │ │ └── VectorStoreFileDomainTest.java │ ├── audio │ │ ├── AudioDomainTest.java │ │ └── AudioFilterTest.java │ ├── batch │ │ └── BatchDomainTest.java │ ├── chat │ │ └── ChatDomainTest.java │ ├── completion │ │ └── CompletionDomainTest.java │ ├── embedding │ │ └── EmbeddingDomainTest.java │ ├── file │ │ └── FileDomainTest.java │ ├── finetuning │ │ └── FineTuningDomainTest.java │ ├── image │ │ └── ImageDomainTest.java │ ├── model │ │ └── ModelDomainTest.java │ ├── moderation │ │ └── ModerationDomainTest.java │ ├── realtime │ │ └── BaseEventTest.java │ ├── response │ │ ├── ResponseDomainSerDeserTest.java │ │ └── ResponseDomainTest.java │ ├── sessiontoken │ │ └── SessionTokenDomainTest.java │ └── upload │ │ └── UploadDomainTest.java │ ├── exception │ └── OpenAIExceptionConverterTest.java │ ├── support │ ├── Base64UtilTest.java │ ├── CustomSchemaConverter.java │ ├── CustomSchemaConverterTest.java │ ├── DefaultSchemaConverterTest.java │ ├── GeminiAccessTokenTest.java │ ├── JsonSchemaUtilTest.java │ └── PollerTest.java │ └── test │ ├── captors │ └── CapturedValues.java │ └── utils │ └── UtilSpecs.java └── resources ├── assistants_create.json ├── assistants_delete.json ├── assistants_getlist.json ├── assistants_getone.json ├── assistants_modify.json ├── audios_speak.mp3 ├── audios_transcribe.json ├── audios_transcribe_plain.txt ├── audios_translate.json ├── audios_translate_plain.txt ├── batches_cancel.json ├── batches_create.json ├── batches_getlist.json ├── batches_getone.json ├── chatcompletions_create.json ├── chatcompletions_create_audio_1.json ├── chatcompletions_create_audio_2.json ├── chatcompletions_create_function_answer.json ├── chatcompletions_create_function_question.json ├── chatcompletions_create_stream.txt ├── chatcompletions_create_structured_output.json ├── chatcompletions_create_vision.json ├── chatcompletions_create_websearch_stream.txt ├── completions_create.json ├── completions_create_stream.txt ├── embeddings_create_base64.json ├── embeddings_create_float.json ├── files_create.json ├── files_delete.json ├── files_getcontent.txt ├── files_getlist.json ├── files_getone.json ├── finetunings_cancel.json ├── finetunings_create.json ├── finetunings_getcheckpoints.json ├── finetunings_getevents.json ├── finetunings_getlist.json ├── finetunings_getone.json ├── images_create.json ├── images_create_edits.json ├── images_create_variations.json ├── mistral_body_actual.json ├── mistral_body_expected.json ├── models_delete.json ├── models_getlist.json ├── models_getone.json ├── moderations_create.json ├── response_create.json ├── response_create_codeinterpreter.json ├── response_create_filesearch.json ├── response_create_functions_1.json ├── response_create_functions_2.json ├── response_create_imagegeneration.json ├── response_create_remote_mcp.json ├── response_create_stream.txt ├── response_create_structuredoutputs.json ├── response_create_vision.json ├── response_create_websearch.json ├── response_delete.json ├── response_getone.json ├── response_listinputitems.json ├── sessiontokens_create.json ├── sessiontokens_transcription_create.json ├── threads__create.json ├── threads__delete.json ├── threads__getone.json ├── threads__modify.json ├── threads_messages_create.json ├── threads_messages_create_vision.json ├── threads_messages_delete.json ├── threads_messages_getlist.json ├── threads_messages_getone.json ├── threads_messages_modify.json ├── threads_runs_cancel_1.json ├── threads_runs_cancel_2.json ├── threads_runs_create_1.json ├── threads_runs_create_2.json ├── threads_runs_create_stream_1.txt ├── threads_runs_create_stream_error_1.txt ├── threads_runs_createthreadandrun_1.json ├── threads_runs_createthreadandrun_2.json ├── threads_runs_createthreadandrun_stream_1.txt ├── threads_runs_getlist.json ├── threads_runs_getone.json ├── threads_runs_modify.json ├── threads_runs_submittool_1.json ├── threads_runs_submittool_2.json ├── threads_runs_submittool_3.json ├── threads_runs_submittool_stream_1.json ├── threads_runs_submittool_stream_2.txt ├── threads_runssteps_delta.txt ├── threads_runssteps_getlist.json ├── threads_runssteps_getone.json ├── threads_runssteps_getunknown_tool.json ├── uploads_add_part.json ├── uploads_cancel.json ├── uploads_complete.json ├── uploads_create.json ├── vector_store__create.json ├── vector_store__delete.json ├── vector_store__getlist.json ├── vector_store__getone.json ├── vector_store__modify.json ├── vector_store_file__create.json ├── vector_store_file__delete.json ├── vector_store_file__getlist.json ├── vector_store_file__getone.json ├── vector_store_file_batch_cancel.json ├── vector_store_file_batch_create.json ├── vector_store_file_batch_getfiles.json └── vector_store_file_batch_getone.json /.devfile.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.2.0 2 | metadata: 3 | attributes: 4 | metadata-name-field: generateName 5 | metadata-name-original-value: simple-openai 6 | name: simple-openai 7 | namespace: sashirestela-dev 8 | attributes: 9 | che-theia.eclipse.org/sidecar-policy: mergeImage 10 | projects: 11 | - name: simple-openai 12 | git: 13 | remotes: 14 | origin: https://github.com/sashirestela/simple-openai.git 15 | components: 16 | - name: universal-developer-image 17 | container: 18 | image: quay.io/devfile/universal-developer-image:ubi8-latest 19 | volumeMounts: 20 | - name: m2 21 | path: /home/user/.m2 22 | mountSources: true 23 | memoryRequest: 2G 24 | memoryLimit: 6G 25 | cpuRequest: 2000m 26 | cpuLimit: 4000m 27 | - name: m2 28 | volume: 29 | size: 8Gi 30 | commands: [] 31 | -------------------------------------------------------------------------------- /.github/workflows/build_java_maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven 3 | 4 | name: Java CI with Maven 5 | 6 | on: 7 | push: 8 | branches: ["main"] 9 | pull_request: 10 | branches: ["main"] 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v4 19 | with: 20 | fetch-depth: 0 21 | - name: Set up JDK 11 22 | uses: actions/setup-java@v4 23 | with: 24 | java-version: "11" 25 | distribution: "temurin" 26 | cache: maven 27 | - name: Check code format with Spotless 28 | run: mvn spotless:check 29 | - name: Build with Maven 30 | run: mvn -B package --file pom.xml 31 | - name: Upload coverage reports to Codecov 32 | uses: codecov/codecov-action@v4 33 | env: 34 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 35 | -------------------------------------------------------------------------------- /.github/workflows/release_maven_central.yml: -------------------------------------------------------------------------------- 1 | name: Release to Maven Central 2 | run-name: Release run ${{ github.run_number }} 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | release: 8 | name: Release 9 | runs-on: ubuntu-latest 10 | environment: production 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v4 14 | - name: Setup Java 15 | uses: actions/setup-java@v4 16 | with: 17 | java-version: "11" 18 | distribution: "temurin" 19 | java-package: "jdk" 20 | check-latest: true 21 | server-id: "central" 22 | server-username: SERVER_USERNAME 23 | server-password: SERVER_PASSWORD 24 | gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} 25 | gpg-passphrase: GPG_PASSPHRASE 26 | cache: "maven" 27 | - name: Build & Deploy 28 | run: mvn -U -B clean deploy -P release 29 | env: 30 | SERVER_USERNAME: ${{ secrets.SERVER_USERNAME }} 31 | SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }} 32 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .settings/ 2 | target/ 3 | .cache/ 4 | .upm/ 5 | .vscode/* 6 | .idea/ 7 | 8 | .project 9 | .classpath 10 | .breakpoints 11 | 12 | dependency-reduced-pom.xml 13 | .flattened-pom.xml 14 | .factorypath 15 | *.log 16 | 17 | src/demo/resources/response.mp3 18 | .replit 19 | replit.nix 20 | 21 | !.vscode/extensions.json -------------------------------------------------------------------------------- /.sdkmanrc: -------------------------------------------------------------------------------- 1 | # Enable auto-env through the sdkman_auto_env config 2 | # Add key=value pairs of SDKs to use below 3 | java=21.0.2-tem 4 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "vscjava.vscode-java-pack", 4 | "redhat.vscode-xml", 5 | "redhat.vscode-yaml", 6 | "eamodio.gitlens", 7 | "ryanluker.vscode-coverage-gutters", 8 | "SonarSource.sonarlint-vscode" 9 | ] 10 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Sashir Estela 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. 22 | -------------------------------------------------------------------------------- /codestyle/spotless_java.importorder: -------------------------------------------------------------------------------- 1 | #Organize Import Order 2 | #Mon Feb 26 16:38:48 PET 2024 3 | 0= 4 | 1=javax 5 | 2=java 6 | 3=\# 7 | -------------------------------------------------------------------------------- /media/simple-openai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/media/simple-openai.png -------------------------------------------------------------------------------- /rundemo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | java_file="Model" 4 | 5 | if [ ! -z "$1" ]; then 6 | java_file="$1" 7 | fi 8 | 9 | main_class="io.github.sashirestela.openai.demo.${java_file}Demo" 10 | 11 | command="mvn exec:java -Dexec.mainClass=${main_class}" 12 | 13 | echo $command 14 | 15 | eval $command -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/AssistantV2AzureDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class AssistantV2AzureDemo extends AssistantV2Demo { 4 | 5 | protected AssistantV2AzureDemo(String model) { 6 | super("azure", model, new FileAzureDemo()); 7 | this.assistantProvider = this.openAIAzure; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new AssistantV2AzureDemo("N/A"); 12 | demo.addTitleAction("Demo Assistant v2 Create", demo::createAssistant); 13 | demo.addTitleAction("Demo Assistant v2 Modify", demo::modifyAssistant); 14 | demo.addTitleAction("Demo Assistant v2 Retrieve", demo::retrieveAssistant); 15 | demo.addTitleAction("Demo Assistant v2 List", demo::listAssistants); 16 | demo.addTitleAction("Demo Assistant v2 Delete", demo::deleteAssistant); 17 | demo.run(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ChatAnyscaleDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class ChatAnyscaleDemo extends ChatDemo { 4 | 5 | public ChatAnyscaleDemo(String model) { 6 | super("anyscale", model, null); 7 | this.chatProvider = this.openAIAnyscale; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new ChatAnyscaleDemo("mistralai/Mixtral-8x7B-Instruct-v0.1"); 12 | 13 | demo.addTitleAction("Call Chat (Streaming Approach)", demo::demoCallChatStreaming); 14 | demo.addTitleAction("Call Chat (Blocking Approach)", demo::demoCallChatBlocking); 15 | demo.addTitleAction("Call Chat with Functions", demo::demoCallChatWithFunctions); 16 | 17 | demo.run(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ChatDeepseekDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | import io.github.sashirestela.openai.domain.chat.ChatMessage.UserMessage; 4 | import io.github.sashirestela.openai.domain.chat.ChatRequest; 5 | 6 | public class ChatDeepseekDemo extends ChatDemo { 7 | 8 | public ChatDeepseekDemo(String model) { 9 | super("deepseek", model, null); 10 | this.chatProvider = this.openAIDeepseek; 11 | } 12 | 13 | public void demoCallChatShowThinking() { 14 | var chatResponse = chatProvider.chatCompletions() 15 | .createStream(ChatRequest.builder() 16 | .model("deepseek-reasoner") 17 | .message(UserMessage.of("9.11 and 9.8, which is greater?")) 18 | .maxTokens(512) 19 | .build()) 20 | .join(); 21 | chatResponse.forEach(this::processResponseChunk); 22 | } 23 | 24 | public static void main(String[] args) { 25 | var demo = new ChatDeepseekDemo("deepseek-chat"); 26 | 27 | demo.addTitleAction("Call Chat (Streaming Approach)", demo::demoCallChatStreaming); 28 | demo.addTitleAction("Call Chat (Blocking Approach)", demo::demoCallChatBlocking); 29 | demo.addTitleAction("Call Chat (Show Thinking)", demo::demoCallChatShowThinking); 30 | demo.addTitleAction("Call Chat with Functions", demo::demoCallChatWithFunctions); 31 | 32 | demo.run(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ChatGeminiGoogleDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class ChatGeminiGoogleDemo extends ChatDemo { 4 | 5 | public ChatGeminiGoogleDemo(String model) { 6 | super("gemini_google", model, null); 7 | this.chatProvider = this.openAIGeminiGoogle; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new ChatGeminiGoogleDemo("gemini-1.5-flash"); 12 | 13 | demo.addTitleAction("Call Chat (Streaming Approach)", demo::demoCallChatStreaming); 14 | demo.addTitleAction("Call Chat (Blocking Approach)", demo::demoCallChatBlocking); 15 | demo.addTitleAction("Call Chat with Functions", demo::demoCallChatWithFunctions); 16 | demo.addTitleAction("Call Chat with Vision (Local image)", demo::demoCallChatWithVisionLocalImage); 17 | demo.addTitleAction("Call Chat with Structured Outputs", demo::demoCallChatWithStructuredOutputs); 18 | 19 | demo.run(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ChatMistralDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class ChatMistralDemo extends ChatDemo { 4 | 5 | public ChatMistralDemo(String model) { 6 | super("mistral", model, null); 7 | this.sleepSeconds = 1; //Free tier limit: 1 request per 1 second 8 | this.chatProvider = this.openAIMistral; 9 | } 10 | 11 | public static void main(String[] args) { 12 | var demo = new ChatMistralDemo("pixtral-12b-2409"); 13 | 14 | demo.addTitleAction("Call Chat (Streaming Approach)", demo::demoCallChatStreaming); 15 | demo.addTitleAction("Call Chat (Blocking Approach)", demo::demoCallChatBlocking); 16 | demo.addTitleAction("Call Chat with Functions", demo::demoCallChatWithFunctions); 17 | demo.addTitleAction("Call Chat with Vision (External image)", demo::demoCallChatWithVisionExternalImage); 18 | demo.addTitleAction("Call Chat with Vision (Local image)", demo::demoCallChatWithVisionLocalImage); 19 | 20 | demo.run(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/EmbeddingGeminiGoogleDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class EmbeddingGeminiGoogleDemo extends EmbeddingDemo { 4 | 5 | public EmbeddingGeminiGoogleDemo(String model) { 6 | super("gemini_google", model); 7 | this.embeddingProvider = openAIGeminiGoogle; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new EmbeddingGeminiGoogleDemo("text-embedding-004"); 12 | 13 | demo.addTitleAction("Call Embedding Float Format", demo::demoCallEmbeddingFloat); 14 | 15 | demo.run(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/EmbeddingMistralDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class EmbeddingMistralDemo extends EmbeddingDemo { 4 | 5 | public EmbeddingMistralDemo(String model) { 6 | super("mistral", model); 7 | this.embeddingProvider = this.openAIMistral; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new EmbeddingMistralDemo("mistral-embed"); 12 | 13 | demo.addTitleAction("Call Embedding Float Format", demo::demoCallEmbeddingFloat); 14 | 15 | demo.run(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/FileAzureDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class FileAzureDemo extends FileDemo { 4 | 5 | protected FileAzureDemo() { 6 | super("azure"); 7 | this.fileProvider = this.openAIAzure; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new FileAzureDemo(); 12 | 13 | demo.addTitleAction("Call File Create", demo::demoCallFileCreate); 14 | demo.addTitleAction("Call File List", demo::demoCallFileGetList); 15 | demo.addTitleAction("Call File One", demo::demoCallFileGetOne); 16 | demo.addTitleAction("Call File Delete", demo::demoCallFileDelete); 17 | 18 | demo.run(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ModelDeepseekDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class ModelDeepseekDemo extends ModelDemo { 4 | 5 | public ModelDeepseekDemo() { 6 | super("deepseek"); 7 | this.modelProvider = this.openAIDeepseek; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new ModelDeepseekDemo(); 12 | 13 | demo.addTitleAction("List of All Models", demo::demoGetModels); 14 | 15 | demo.run(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ModelDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | import io.github.sashirestela.openai.service.ModelServices; 4 | 5 | public class ModelDemo extends AbstractDemo { 6 | 7 | protected String modelId; 8 | protected ModelServices modelProvider; 9 | 10 | public ModelDemo() { 11 | this("standard"); 12 | } 13 | 14 | protected ModelDemo(String provider) { 15 | super(provider); 16 | this.modelProvider = this.openAI; 17 | } 18 | 19 | public void demoGetModels() { 20 | var futureModels = modelProvider.models().getList(); 21 | var models = futureModels.join(); 22 | models.forEach(System.out::println); 23 | 24 | modelId = models.get(0).getId(); 25 | } 26 | 27 | public void demoGetModel() { 28 | var futureModel = modelProvider.models().getOne(modelId); 29 | var model = futureModel.join(); 30 | System.out.println(model); 31 | } 32 | 33 | @SuppressWarnings("unused") 34 | public void demoDeleteModel() { 35 | var futureModel = modelProvider.models().delete(modelId); 36 | try { 37 | var deleted = futureModel.join(); 38 | } catch (Exception e) { 39 | System.out.println(e.getMessage()); 40 | } 41 | } 42 | 43 | public static void main(String[] args) { 44 | var demo = new ModelDemo(); 45 | 46 | demo.addTitleAction("List of All Models", demo::demoGetModels); 47 | demo.addTitleAction("First Model in List", demo::demoGetModel); 48 | demo.addTitleAction("Trying to Delete a Model", demo::demoDeleteModel); 49 | 50 | demo.run(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ModelMistralDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class ModelMistralDemo extends ModelDemo { 4 | 5 | public ModelMistralDemo() { 6 | super("mistral"); 7 | this.modelProvider = this.openAIMistral; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new ModelMistralDemo(); 12 | 13 | demo.addTitleAction("List of All Models", demo::demoGetModels); 14 | demo.addTitleAction("First Model in List", demo::demoGetModel); 15 | demo.addTitleAction("Trying to Delete a Model", demo::demoDeleteModel); 16 | 17 | demo.run(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ModerationDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | import io.github.sashirestela.openai.domain.moderation.ModerationRequest; 4 | import io.github.sashirestela.openai.domain.moderation.ModerationRequest.MultiModalInput.ImageUrlInput; 5 | import io.github.sashirestela.openai.domain.moderation.ModerationRequest.MultiModalInput.TextInput; 6 | 7 | import java.util.Arrays; 8 | 9 | public class ModerationDemo extends AbstractDemo { 10 | 11 | public void demoCallModerationCreate() { 12 | var moderationRequest = ModerationRequest.builder() 13 | .input(Arrays.asList( 14 | TextInput.of("I want to kill them."), 15 | ImageUrlInput.of("https://upload.wikimedia.org/wikipedia/commons/e/e3/BWHammerSickle.jpg"), 16 | TextInput.of("I am not sure what to think about them."))) 17 | .model("omni-moderation-latest") 18 | .build(); 19 | var futureModeration = openAI.moderations().create(moderationRequest); 20 | var moderationResponse = futureModeration.join(); 21 | moderationResponse.getResults() 22 | .stream() 23 | .forEach(System.out::println); 24 | } 25 | 26 | public static void main(String[] args) { 27 | var demo = new ModerationDemo(); 28 | 29 | demo.addTitleAction("Call Moderation", demo::demoCallModerationCreate); 30 | 31 | demo.run(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ThreadRunStepV2AzureDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class ThreadRunStepV2AzureDemo extends ThreadRunStepV2Demo { 4 | 5 | protected ThreadRunStepV2AzureDemo(String model) { 6 | super("azure", model); 7 | this.assistantProvider = this.openAIAzure; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new ThreadRunStepV2AzureDemo("N/A"); 12 | demo.prepareDemo(); 13 | demo.addTitleAction("Demo ThreadRun v2 Create", demo::createThreadRun); 14 | demo.addTitleAction("Demo ThreadRunStep v2 List", demo::listThreadRunSteps); 15 | demo.addTitleAction("Demo ThreadRunStep v2 Retrieve", demo::retrieveThreadRunStep); 16 | demo.addTitleAction("Demo ThreadRunStep v2 Retrieve with Filters", demo::retrieveThreadRunStepWithFilters); 17 | demo.addTitleAction("Demo ThreadRun v2 Delete", demo::deleteDemo); 18 | demo.run(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ThreadRunV2AzureDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class ThreadRunV2AzureDemo extends ThreadRunV2Demo { 4 | 5 | protected ThreadRunV2AzureDemo(String model) { 6 | super("azure", model, new FileAzureDemo()); 7 | this.assistantProvider = this.openAIAzure; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new ThreadRunV2AzureDemo("N/A"); 12 | demo.prepareDemo(); 13 | demo.addTitleAction("Demo ThreadRun v2 Create", demo::createThreadRun); 14 | demo.addTitleAction("Demo ThreadRun v2 Create Stream", demo::createThreadRunStream); 15 | demo.addTitleAction("Demo ThreadRun v2 Submit Tool Output", demo::submitToolOutputToThreadRun); 16 | demo.addTitleAction("Demo ThreadRun v2 Submit Tool Output Stream", demo::submitToolOutputToThreadRunStream); 17 | demo.addTitleAction("Demo ThreadRun v2 Create Thread and Run", demo::createThreadAndThreadRun); 18 | demo.addTitleAction("Demo ThreadRun v2 Create Thread and Run Stream", demo::createThreadAndThreadRunStream); 19 | demo.addTitleAction("Demo ThreadRun v2 Modify", demo::modifyThreadRun); 20 | demo.addTitleAction("Demo ThreadRun v2 Retrieve", demo::retrieveThreadRun); 21 | demo.addTitleAction("Demo ThreadRun v2 List", demo::listThreadRuns); 22 | demo.addTitleAction("Demo ThreadRun v2 Delete", demo::deleteDemo); 23 | demo.run(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/ThreadV2AzureDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class ThreadV2AzureDemo extends ThreadV2Demo { 4 | 5 | protected ThreadV2AzureDemo(String model) { 6 | super("azure", model, new FileAzureDemo()); 7 | this.assistantProvider = this.openAIAzure; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new ThreadV2AzureDemo("N/A"); 12 | demo.prepareDemo(); 13 | demo.addTitleAction("Demo Thread v2 Create", demo::createThread); 14 | demo.addTitleAction("Demo Thread v2 Modify", demo::modifyThread); 15 | demo.addTitleAction("Demo Thread v2 Retrieve", demo::retrieveThread); 16 | demo.addTitleAction("Demo Thread v2 Delete", demo::deleteThread); 17 | demo.run(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/VectorStoreFileBatchV2AzureDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class VectorStoreFileBatchV2AzureDemo extends VectorStoreFileBatchV2Demo { 4 | 5 | protected VectorStoreFileBatchV2AzureDemo() { 6 | super("azure", new FileAzureDemo()); 7 | this.assistantProvider = this.openAIAzure; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new VectorStoreFileBatchV2AzureDemo(); 12 | demo.prepareDemo(); 13 | demo.addTitleAction("Demo VectorStoreFileBatch v2 Create", demo::createVectorStoreFileBatch); 14 | demo.addTitleAction("Demo VectorStoreFileBatch v2 Retrieve", demo::retrieveVectorStoreFileBatch); 15 | demo.addTitleAction("Demo VectorStoreFileBatch v2 List", demo::listVectorStoreFilesInBatch); 16 | demo.addTitleAction("Demo VectorStoreFiles v2 Delete", demo::deletedVectorStoreFiles); 17 | demo.run(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/VectorStoreFileV2AzureDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class VectorStoreFileV2AzureDemo extends VectorStoreFileV2Demo { 4 | 5 | protected VectorStoreFileV2AzureDemo() { 6 | super("azure", new FileAzureDemo()); 7 | this.assistantProvider = this.openAIAzure; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new VectorStoreFileV2AzureDemo(); 12 | demo.prepareDemo(); 13 | demo.addTitleAction("Demo VectorStoreFile v2 Create", demo::createVectorStoreFile); 14 | demo.addTitleAction("Demo VectorStoreFile v2 Retrieve", demo::retrieveVectorStoreFile); 15 | demo.addTitleAction("Demo VectorStoreFile v2 List", demo::listVectorStoreFiles); 16 | demo.addTitleAction("Demo VectorStoreFile v2 Delete", demo::deletedVectorStoreFile); 17 | demo.run(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/demo/java/io/github/sashirestela/openai/demo/VectorStoreV2AzureDemo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.demo; 2 | 3 | public class VectorStoreV2AzureDemo extends VectorStoreV2Demo { 4 | 5 | protected VectorStoreV2AzureDemo() { 6 | super("azure", new FileAzureDemo()); 7 | this.assistantProvider = this.openAIAzure; 8 | } 9 | 10 | public static void main(String[] args) { 11 | var demo = new VectorStoreV2AzureDemo(); 12 | demo.prepareDemo(); 13 | demo.addTitleAction("Demo VectorStore v2 Create", demo::createVectorStore); 14 | demo.addTitleAction("Demo VectorStore v2 Modify", demo::modifyVectorStore); 15 | demo.addTitleAction("Demo VectorStore v2 Retrieve", demo::retrieveVectorStore); 16 | demo.addTitleAction("Demo VectorStore v2 List", demo::listVectorStores); 17 | demo.addTitleAction("Demo VectorStore v2 Delete", demo::deleteVectorStore); 18 | demo.run(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/demo/resources/answer1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/src/demo/resources/answer1.mp3 -------------------------------------------------------------------------------- /src/demo/resources/answer2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/src/demo/resources/answer2.mp3 -------------------------------------------------------------------------------- /src/demo/resources/batch_request.jsonl: -------------------------------------------------------------------------------- 1 | {"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are an AI expert."}, {"role": "user", "content": "What is LLM?"}]}} 2 | {"custom_id": "request-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are an AI expert."}, {"role": "user", "content": "What is a Prompt?"}]}} 3 | -------------------------------------------------------------------------------- /src/demo/resources/code_interpreter_file.txt: -------------------------------------------------------------------------------- 1 | y := sin(x) -------------------------------------------------------------------------------- /src/demo/resources/hello_audio.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/src/demo/resources/hello_audio.mp3 -------------------------------------------------------------------------------- /src/demo/resources/little_cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/src/demo/resources/little_cat.png -------------------------------------------------------------------------------- /src/demo/resources/little_cat_rgba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/src/demo/resources/little_cat_rgba.png -------------------------------------------------------------------------------- /src/demo/resources/machupicchu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/src/demo/resources/machupicchu.jpg -------------------------------------------------------------------------------- /src/demo/resources/math_reasoning.json: -------------------------------------------------------------------------------- 1 | {"type":"object","properties":{"finalAnswer":{"type":"string"},"steps":{"type":"array","items":{"type":"object","properties":{"explanation":{"type":"string"},"output":{"type":"string"}},"required":["explanation","output"],"additionalProperties":false}}},"required":["finalAnswer","steps"],"additionalProperties":false} -------------------------------------------------------------------------------- /src/demo/resources/question1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/src/demo/resources/question1.mp3 -------------------------------------------------------------------------------- /src/demo/resources/question2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/src/demo/resources/question2.mp3 -------------------------------------------------------------------------------- /src/demo/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | org.slf4j.simpleLogger.logFile=demo.log 2 | org.slf4j.simpleLogger.defaultLogLevel=debug 3 | org.slf4j.simpleLogger.showDateTime=true 4 | org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss.SSSZ 5 | org.slf4j.simpleLogger.log.com.github.victools=off 6 | io.github.sashirestela.slimvalidator=off -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/base/ClientConfig.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.base; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import io.github.sashirestela.cleverclient.client.HttpClientAdapter; 5 | import io.github.sashirestela.cleverclient.http.HttpRequestData; 6 | import io.github.sashirestela.cleverclient.http.HttpResponseData; 7 | import io.github.sashirestela.cleverclient.retry.RetryConfig; 8 | import lombok.Builder; 9 | import lombok.Getter; 10 | import lombok.NonNull; 11 | 12 | import java.net.http.HttpClient; 13 | import java.util.Map; 14 | import java.util.function.UnaryOperator; 15 | 16 | @Getter 17 | @Builder 18 | public class ClientConfig { 19 | 20 | @NonNull 21 | private final String baseUrl; 22 | private final Map headers; 23 | private final UnaryOperator requestInterceptor; 24 | private final UnaryOperator responseInterceptor; 25 | private final RetryConfig retryConfig; 26 | private final HttpClientAdapter clientAdapter; 27 | private final ObjectMapper objectMapper; 28 | private final RealtimeConfig realtimeConfig; 29 | // @deprecated CleverClient has deprecated this field in favor of clientAdapter. 30 | @Deprecated(since = "3.16.0", forRemoval = true) 31 | private final HttpClient httpClient; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/base/OpenAIConfigurator.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.base; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import io.github.sashirestela.cleverclient.client.HttpClientAdapter; 5 | import io.github.sashirestela.cleverclient.retry.RetryConfig; 6 | import lombok.AllArgsConstructor; 7 | import lombok.experimental.SuperBuilder; 8 | 9 | import java.net.http.HttpClient; 10 | 11 | @SuperBuilder 12 | @AllArgsConstructor 13 | public abstract class OpenAIConfigurator { 14 | 15 | protected String apiKey; 16 | protected String baseUrl; 17 | protected HttpClientAdapter clientAdapter; 18 | protected RetryConfig retryConfig; 19 | protected ObjectMapper objectMapper; 20 | /** 21 | * @deprecated CleverClient has deprecated this field in favor of clientAdapter. 22 | */ 23 | @Deprecated(since = "3.16.0", forRemoval = true) 24 | protected HttpClient httpClient; 25 | 26 | public abstract ClientConfig buildConfig(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/base/RealtimeConfig.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.base; 2 | 3 | import io.github.sashirestela.cleverclient.websocket.WebSocketAdapter; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | 8 | import java.util.Map; 9 | 10 | @Getter 11 | @Builder 12 | @AllArgsConstructor 13 | public class RealtimeConfig { 14 | 15 | private String model; 16 | private String endpointUrl; 17 | private Map headers; 18 | private Map queryParams; 19 | private WebSocketAdapter webSocketAdapter; 20 | 21 | public static RealtimeConfig of(String model) { 22 | return new RealtimeConfig(model, null, null, null, null); 23 | } 24 | 25 | public static RealtimeConfig of(String model, WebSocketAdapter webSocketAdapter) { 26 | return new RealtimeConfig(model, null, null, null, webSocketAdapter); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/DeletedObject.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.ToString; 6 | 7 | @NoArgsConstructor 8 | @Getter 9 | @ToString 10 | public class DeletedObject { 11 | 12 | private String id; 13 | private String object; 14 | private Boolean deleted; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/Generic.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | import java.util.List; 11 | 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @ToString 15 | @Getter 16 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 17 | public class Generic { 18 | 19 | private String object; 20 | private Long created; 21 | private List data; 22 | private String nextStartingAfter; 23 | private boolean hasMore; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/Page.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | import java.util.AbstractList; 11 | import java.util.List; 12 | 13 | @NoArgsConstructor 14 | @Getter 15 | @ToString 16 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 17 | @JsonFormat(shape = JsonFormat.Shape.OBJECT) 18 | public class Page extends AbstractList { 19 | 20 | private String object; 21 | private List data; 22 | private String firstId; 23 | private String lastId; 24 | private boolean hasMore; 25 | 26 | @Override 27 | public T get(int index) { 28 | return data.get(index); 29 | } 30 | 31 | @Override 32 | public int size() { 33 | return data.size(); 34 | } 35 | 36 | public T first() { 37 | return get(0); 38 | } 39 | 40 | public T last() { 41 | return get(size() - 1); 42 | } 43 | 44 | @Override 45 | public boolean equals(Object other) { 46 | return super.equals(other); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/PageRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | @Builder 10 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 11 | public class PageRequest { 12 | 13 | private Integer limit; 14 | private Order order; 15 | private String after; 16 | private String before; 17 | 18 | public enum Order { 19 | 20 | @JsonProperty("asc") 21 | ASC, 22 | 23 | @JsonProperty("desc") 24 | DESC 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/StreamOptions.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import lombok.AccessLevel; 8 | import lombok.AllArgsConstructor; 9 | import lombok.Getter; 10 | 11 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 12 | @Getter 13 | @JsonInclude(Include.NON_EMPTY) 14 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 15 | public class StreamOptions { 16 | 17 | private Boolean includeUsage; 18 | 19 | public static StreamOptions of(Boolean includeUsage) { 20 | return new StreamOptions(includeUsage); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/Usage.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class Usage { 14 | 15 | private Integer promptTokens; 16 | private Integer completionTokens; 17 | private Integer totalTokens; 18 | private CompletionTokensDetails completionTokensDetails; 19 | private PromptTokensDetails promptTokensDetails; 20 | 21 | @NoArgsConstructor 22 | @Getter 23 | @ToString 24 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 25 | public static class CompletionTokensDetails { 26 | 27 | private Integer audioTokens; 28 | private Integer reasoningTokens; 29 | 30 | } 31 | 32 | @NoArgsConstructor 33 | @Getter 34 | @ToString 35 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 36 | public static class PromptTokensDetails { 37 | 38 | private Integer audioTokens; 39 | private Integer cachedTokens; 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/audio/AudioFormat.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.audio; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum AudioFormat { 6 | 7 | @JsonProperty("mp3") 8 | MP3, 9 | 10 | @JsonProperty("opus") 11 | OPUS, 12 | 13 | @JsonProperty("aac") 14 | AAC, 15 | 16 | @JsonProperty("flac") 17 | FLAC, 18 | 19 | @JsonProperty("wav") 20 | WAV, 21 | 22 | @JsonProperty("pcm") 23 | PCM, 24 | 25 | @JsonProperty("pcm16") 26 | PCM16; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/audio/InputAudioFormat.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.audio; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum InputAudioFormat { 6 | 7 | @JsonProperty("wav") 8 | WAV, 9 | 10 | @JsonProperty("mp3") 11 | MP3; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/audio/Voice.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.audio; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum Voice { 6 | 7 | @JsonProperty("alloy") 8 | ALLOY, 9 | 10 | @JsonProperty("ash") 11 | ASH, 12 | 13 | @JsonProperty("coral") 14 | CORAL, 15 | 16 | @JsonProperty("echo") 17 | ECHO, 18 | 19 | @JsonProperty("fable") 20 | FABLE, 21 | 22 | @JsonProperty("onyx") 23 | ONYX, 24 | 25 | @JsonProperty("nova") 26 | NOVA, 27 | 28 | @JsonProperty("sage") 29 | SAGE, 30 | 31 | @JsonProperty("shimmer") 32 | SHIMMER; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/content/ImageDetail.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.content; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum ImageDetail { 6 | 7 | @JsonProperty("auto") 8 | AUTO, 9 | 10 | @JsonProperty("low") 11 | LOW, 12 | 13 | @JsonProperty("high") 14 | HIGH; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/function/FunctionCall.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.function; 2 | 3 | import io.github.sashirestela.slimvalidator.constraints.Required; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Getter 12 | @Setter 13 | public class FunctionCall { 14 | 15 | @Required 16 | private String name; 17 | 18 | @Required 19 | private String arguments; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/function/FunctionDef.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.function; 2 | 3 | import com.fasterxml.jackson.annotation.JsonClassDescription; 4 | import io.github.sashirestela.openai.support.JsonSchemaUtil; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | import lombok.NonNull; 8 | 9 | @Getter 10 | @Builder 11 | public class FunctionDef { 12 | 13 | @NonNull 14 | private String name; 15 | 16 | private String description; 17 | 18 | @NonNull 19 | private Class functionalClass; 20 | 21 | private Boolean strict; 22 | 23 | @Builder.Default 24 | private SchemaConverter schemaConverter = JsonSchemaUtil.defaultConverter; 25 | 26 | public static FunctionDef of(Class functionalClass) { 27 | var name = functionalClass.getSimpleName(); 28 | var description = functionalClass.isAnnotationPresent(JsonClassDescription.class) 29 | ? functionalClass.getAnnotation(JsonClassDescription.class).value() 30 | : ""; 31 | var strict = Boolean.TRUE; 32 | return FunctionDef.builder() 33 | .name(name) 34 | .description(description) 35 | .functionalClass(functionalClass) 36 | .strict(strict) 37 | .build(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/function/Functional.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.function; 2 | 3 | @FunctionalInterface 4 | public interface Functional { 5 | 6 | Object execute(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/function/SchemaConverter.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.function; 2 | 3 | import com.fasterxml.jackson.databind.JsonNode; 4 | 5 | public interface SchemaConverter { 6 | 7 | JsonNode convert(Class c); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/tool/Tool.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.tool; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | import io.github.sashirestela.openai.common.function.FunctionDef; 6 | import io.github.sashirestela.slimvalidator.constraints.Required; 7 | import io.github.sashirestela.slimvalidator.constraints.Size; 8 | import lombok.AllArgsConstructor; 9 | import lombok.Getter; 10 | import lombok.NoArgsConstructor; 11 | import lombok.ToString; 12 | 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Getter 16 | @ToString 17 | @JsonInclude(JsonInclude.Include.NON_NULL) 18 | public class Tool { 19 | 20 | protected ToolType type; 21 | protected ToolFunctionDef function; 22 | 23 | public static Tool function(FunctionDef function) { 24 | return new Tool(ToolType.FUNCTION, 25 | new ToolFunctionDef( 26 | function.getName(), 27 | function.getDescription(), 28 | function.getSchemaConverter().convert(function.getFunctionalClass()), 29 | function.getStrict())); 30 | } 31 | 32 | @AllArgsConstructor 33 | @NoArgsConstructor 34 | @Getter 35 | @ToString 36 | @JsonInclude(JsonInclude.Include.NON_NULL) 37 | public static class ToolFunctionDef { 38 | 39 | @Required 40 | @Size(max = 64) 41 | private String name; 42 | 43 | private String description; 44 | 45 | @Required 46 | private JsonNode parameters; 47 | 48 | private Boolean strict; 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/tool/ToolCall.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.tool; 2 | 3 | import io.github.sashirestela.openai.common.function.FunctionCall; 4 | import io.github.sashirestela.slimvalidator.constraints.Required; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | @Getter 13 | @ToString 14 | public class ToolCall { 15 | 16 | private Integer index; 17 | 18 | @Required 19 | private String id; 20 | 21 | @Required 22 | private ToolType type; 23 | 24 | @Required 25 | private FunctionCall function; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/tool/ToolChoice.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.tool; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import io.github.sashirestela.slimvalidator.constraints.Required; 5 | import lombok.AccessLevel; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.ToString; 10 | 11 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 12 | @NoArgsConstructor 13 | @Getter 14 | @ToString 15 | @JsonInclude(JsonInclude.Include.NON_NULL) 16 | public class ToolChoice { 17 | 18 | @Required 19 | private ToolType type; 20 | 21 | @Required 22 | private FunctionName function; 23 | 24 | public static ToolChoice function(String name) { 25 | return new ToolChoice(ToolType.FUNCTION, new FunctionName(name)); 26 | } 27 | 28 | @AllArgsConstructor 29 | @NoArgsConstructor 30 | @Getter 31 | @ToString 32 | @JsonInclude(JsonInclude.Include.NON_NULL) 33 | public static class FunctionName { 34 | 35 | @Required 36 | private String name; 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/tool/ToolChoiceOption.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.tool; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum ToolChoiceOption { 6 | 7 | @JsonProperty("none") 8 | NONE, 9 | 10 | @JsonProperty("auto") 11 | AUTO, 12 | 13 | @JsonProperty("required") 14 | REQUIRED; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/common/tool/ToolType.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common.tool; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum ToolType { 6 | 7 | @JsonProperty("code_interpreter") 8 | CODE_INTERPRETER, 9 | 10 | @JsonProperty("file_search") 11 | FILE_SEARCH, 12 | 13 | @JsonProperty("function") 14 | FUNCTION; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/Assistant.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import io.github.sashirestela.openai.common.tool.Tool; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | @NoArgsConstructor 14 | @Getter 15 | @ToString 16 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 17 | public class Assistant { 18 | 19 | private String id; 20 | private String object; 21 | private Integer createdAt; 22 | private String name; 23 | private String description; 24 | private String model; 25 | private String instructions; 26 | private List tools; 27 | private ToolResource toolResources; 28 | private Map metadata; 29 | private Double temperature; 30 | private Double topP; 31 | private Object responseFormat; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/Attachment.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import io.github.sashirestela.openai.common.tool.ToolType; 7 | import lombok.AllArgsConstructor; 8 | import lombok.Builder; 9 | import lombok.Getter; 10 | import lombok.NoArgsConstructor; 11 | import lombok.Singular; 12 | import lombok.ToString; 13 | 14 | import java.util.List; 15 | 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Getter 19 | @ToString 20 | @Builder 21 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 22 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 23 | public class Attachment { 24 | 25 | private String fileId; 26 | 27 | @Singular 28 | private List tools; 29 | 30 | @AllArgsConstructor 31 | @NoArgsConstructor 32 | @Getter 33 | @ToString 34 | @JsonInclude(JsonInclude.Include.NON_NULL) 35 | public static class AttachmentTool { 36 | 37 | public static final AttachmentTool CODE_INTERPRETER = new AttachmentTool(ToolType.CODE_INTERPRETER); 38 | public static final AttachmentTool FILE_SEARCH = new AttachmentTool(ToolType.FILE_SEARCH); 39 | 40 | private ToolType type; 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ExpiresAfter.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 7 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 8 | import io.github.sashirestela.slimvalidator.constraints.Required; 9 | import io.github.sashirestela.slimvalidator.constraints.Size; 10 | import lombok.AllArgsConstructor; 11 | import lombok.Builder; 12 | import lombok.Getter; 13 | import lombok.NoArgsConstructor; 14 | import lombok.ToString; 15 | 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Getter 19 | @ToString 20 | @Builder 21 | @JsonInclude(Include.NON_EMPTY) 22 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 23 | public class ExpiresAfter { 24 | 25 | @Required 26 | private Anchor anchor; 27 | 28 | @Required 29 | @Size(min = 1, max = 365) 30 | private Integer days; 31 | 32 | public enum Anchor { 33 | 34 | @JsonProperty("last_active_at") 35 | LAST_ACTIVE_AT; 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/FileCount.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class FileCount { 14 | 15 | private Integer inProgress; 16 | private Integer completed; 17 | private Integer failed; 18 | private Integer cancelled; 19 | private Integer total; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/FileStatus.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum FileStatus { 6 | 7 | @JsonProperty("in_progress") 8 | IN_PROGRESS, 9 | 10 | @JsonProperty("completed") 11 | COMPLETED, 12 | 13 | @JsonProperty("cancelled") 14 | CANCELLED, 15 | 16 | @JsonProperty("failed") 17 | FAILED, 18 | 19 | @JsonProperty("frozen") 20 | FROZEN; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/IncompleteDetail.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class IncompleteDetail { 15 | 16 | private IncompleteDetailReason reason; 17 | 18 | public enum IncompleteDetailReason { 19 | 20 | @JsonProperty("content_filter") 21 | CONTENT_FILTER, 22 | 23 | @JsonProperty("max_tokens") 24 | MAX_TOKENS, 25 | 26 | @JsonProperty("run_cancelled") 27 | RUN_CANCELLED, 28 | 29 | @JsonProperty("run_expired") 30 | RUN_EXPIRED, 31 | 32 | @JsonProperty("run_failed") 33 | RUN_FAILED, 34 | 35 | @JsonProperty("max_completion_tokens") 36 | MAX_COMPLETION_TOKENS, 37 | 38 | @JsonProperty("max_prompt_tokens") 39 | MAX_PROMPT_TOKENS; 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/LastError.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class LastError { 14 | 15 | private String code; 16 | private String message; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/RankingOption.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.ObjectType; 8 | import io.github.sashirestela.slimvalidator.constraints.Range; 9 | import lombok.AllArgsConstructor; 10 | import lombok.Builder; 11 | import lombok.Getter; 12 | import lombok.NoArgsConstructor; 13 | import lombok.ToString; 14 | 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @Getter 18 | @Builder 19 | @ToString 20 | @JsonInclude(JsonInclude.Include.NON_NULL) 21 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 22 | public class RankingOption { 23 | 24 | @ObjectType(baseClass = { RankerType.class, String.class }) 25 | private Object ranker; 26 | 27 | @Range(min = 0.0, max = 1.0) 28 | private Double scoreThreshold; 29 | 30 | public enum RankerType { 31 | 32 | @JsonProperty("auto") 33 | AUTO, 34 | 35 | @JsonProperty("default_2024_08_21") 36 | DEFAULT_2024_08_21 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/RunStepType.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum RunStepType { 6 | 7 | @JsonProperty("message_creation") 8 | MESSAGE_CREATION, 9 | 10 | @JsonProperty("tool_calls") 11 | TOOL_CALLS; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/Thread.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | import java.util.Map; 10 | 11 | @NoArgsConstructor 12 | @Getter 13 | @ToString 14 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 15 | public class Thread { 16 | 17 | private String id; 18 | private String object; 19 | private Integer createdAt; 20 | private ToolResource toolResources; 21 | private Map metadata; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadMessage.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import io.github.sashirestela.openai.common.content.ContentPart; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.ToString; 10 | 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | @NoArgsConstructor 15 | @Getter 16 | @ToString 17 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 18 | public class ThreadMessage { 19 | 20 | private String id; 21 | private String object; 22 | private Integer createdAt; 23 | private String threadId; 24 | private ThreadMessageStatus status; 25 | private IncompleteDetail incompleteDetails; 26 | private Integer completedAt; 27 | private Integer incompleteAt; 28 | private ThreadMessageRole role; 29 | private List content; 30 | private String assistantId; 31 | private String runId; 32 | private List attachments; 33 | private Map metadata; 34 | 35 | public enum ThreadMessageStatus { 36 | 37 | @JsonProperty("in_progress") 38 | IN_PROGRESS, 39 | 40 | @JsonProperty("incomplete") 41 | INCOMPLETE, 42 | 43 | @JsonProperty("completed") 44 | COMPLETED; 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadMessageDelta.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import io.github.sashirestela.openai.common.content.ContentPart; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | import java.util.List; 11 | 12 | @NoArgsConstructor 13 | @Getter 14 | @ToString 15 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 16 | public class ThreadMessageDelta { 17 | 18 | private String id; 19 | private String object; 20 | private MessageDeltaDetail delta; 21 | 22 | @NoArgsConstructor 23 | @Getter 24 | @ToString 25 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 26 | public static class MessageDeltaDetail { 27 | 28 | private ThreadMessageRole role; 29 | private List content; 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadMessageModifyRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import io.github.sashirestela.slimvalidator.constraints.Size; 7 | import lombok.Builder; 8 | import lombok.Getter; 9 | 10 | import java.util.Map; 11 | 12 | @Getter 13 | @Builder 14 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 15 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 16 | public class ThreadMessageModifyRequest { 17 | 18 | @Size(max = 16) 19 | private Map metadata; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadMessageRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import io.github.sashirestela.openai.common.content.ContentPart; 7 | import io.github.sashirestela.slimvalidator.constraints.ObjectType; 8 | import io.github.sashirestela.slimvalidator.constraints.ObjectType.Schema; 9 | import io.github.sashirestela.slimvalidator.constraints.Required; 10 | import io.github.sashirestela.slimvalidator.constraints.Size; 11 | import lombok.Builder; 12 | import lombok.Getter; 13 | import lombok.Singular; 14 | 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | @Getter 19 | @Builder 20 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 21 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 22 | public class ThreadMessageRequest { 23 | 24 | @Required 25 | private ThreadMessageRole role; 26 | 27 | @Required 28 | @ObjectType(baseClass = String.class) 29 | @ObjectType(schema = Schema.COLL, baseClass = ContentPart.class) 30 | private Object content; 31 | 32 | @Singular 33 | private List attachments; 34 | 35 | @Size(max = 16) 36 | private Map metadata; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadMessageRole.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum ThreadMessageRole { 6 | 7 | @JsonProperty("user") 8 | USER, 9 | 10 | @JsonProperty("assistant") 11 | ASSISTANT; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadModifyRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Size; 8 | import lombok.Builder; 9 | import lombok.Getter; 10 | 11 | import java.util.Map; 12 | 13 | @Getter 14 | @Builder 15 | @JsonInclude(Include.NON_EMPTY) 16 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 17 | public class ThreadModifyRequest { 18 | 19 | private ToolResource toolResources; 20 | 21 | @Size(max = 16) 22 | private Map metadata; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Size; 8 | import lombok.Builder; 9 | import lombok.Getter; 10 | import lombok.Singular; 11 | 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | @Getter 16 | @Builder 17 | @JsonInclude(Include.NON_EMPTY) 18 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 19 | public class ThreadRequest { 20 | 21 | @Singular 22 | private List messages; 23 | 24 | private ToolResourceFull toolResources; 25 | 26 | @Size(max = 16) 27 | private Map metadata; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadRunModifyRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import io.github.sashirestela.slimvalidator.constraints.Size; 7 | import lombok.Builder; 8 | import lombok.Getter; 9 | 10 | import java.util.Map; 11 | 12 | @Getter 13 | @Builder 14 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 15 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 16 | public class ThreadRunModifyRequest { 17 | 18 | @Size(max = 16) 19 | private Map metadata; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadRunStep.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import io.github.sashirestela.openai.common.Usage; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.ToString; 10 | 11 | import java.util.Map; 12 | 13 | @NoArgsConstructor 14 | @Getter 15 | @ToString 16 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 17 | public class ThreadRunStep { 18 | 19 | private String id; 20 | private String object; 21 | private Integer createdAt; 22 | private String assistantId; 23 | private String threadId; 24 | private String runId; 25 | private RunStepType type; 26 | private RunStepStatus status; 27 | private StepDetail stepDetails; 28 | private LastError lastError; 29 | private Integer expiredAt; 30 | private Integer cancelledAt; 31 | private Integer failedAt; 32 | private Integer completedAt; 33 | private Map metadata; 34 | private Usage usage; 35 | 36 | public enum RunStepStatus { 37 | 38 | @JsonProperty("in_progress") 39 | IN_PROGRESS, 40 | 41 | @JsonProperty("cancelled") 42 | CANCELLED, 43 | 44 | @JsonProperty("failed") 45 | FAILED, 46 | 47 | @JsonProperty("completed") 48 | COMPLETED, 49 | 50 | @JsonProperty("expired") 51 | EXPIRED; 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadRunStepDelta.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ThreadRunStepDelta { 14 | 15 | private String id; 16 | private String object; 17 | private RunStepDeltaDetail delta; 18 | 19 | @NoArgsConstructor 20 | @Getter 21 | @ToString 22 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 23 | public static class RunStepDeltaDetail { 24 | 25 | private StepDetail stepDetails; 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadRunStepQuery.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum ThreadRunStepQuery { 6 | 7 | @JsonProperty("step_details.tool_calls[*].file_search.results[*].content") 8 | FILE_SEARCH_RESULT; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadRunSubmitOutputRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import io.github.sashirestela.slimvalidator.constraints.Required; 7 | import lombok.Builder; 8 | import lombok.Getter; 9 | import lombok.Singular; 10 | import lombok.ToString; 11 | import lombok.With; 12 | 13 | import java.util.List; 14 | 15 | @Getter 16 | @Builder 17 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 18 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 19 | public class ThreadRunSubmitOutputRequest { 20 | 21 | @Required 22 | @Singular 23 | private List toolOutputs; 24 | 25 | @With 26 | private Boolean stream; 27 | 28 | @Getter 29 | @Builder 30 | @ToString 31 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 32 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 33 | public static class ToolOutput { 34 | 35 | private String toolCallId; 36 | private String output; 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/TruncationStrategy.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Range; 8 | import io.github.sashirestela.slimvalidator.constraints.Required; 9 | import lombok.AllArgsConstructor; 10 | import lombok.Builder; 11 | import lombok.Getter; 12 | import lombok.NoArgsConstructor; 13 | import lombok.ToString; 14 | 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @Getter 18 | @Builder 19 | @ToString 20 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 21 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 22 | public class TruncationStrategy { 23 | 24 | @Required 25 | private TruncationStrategyType type; 26 | 27 | @Range(min = 1) 28 | private Integer lastMessages; 29 | 30 | public enum TruncationStrategyType { 31 | 32 | @JsonProperty("auto") 33 | AUTO, 34 | 35 | @JsonProperty("last_messages") 36 | LAST_MESSAGES; 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/VectorStore.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | import java.util.Map; 11 | 12 | @NoArgsConstructor 13 | @Getter 14 | @ToString 15 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 16 | public class VectorStore { 17 | 18 | private String id; 19 | private String object; 20 | private Integer createdAt; 21 | private String name; 22 | private Integer usageBytes; 23 | private FileCount fileCounts; 24 | private VectorStoreStatus status; 25 | private ExpiresAfter expriresAfter; 26 | private Integer expiresAt; 27 | private Integer lastActiveAt; 28 | private Map metadata; 29 | 30 | public enum VectorStoreStatus { 31 | 32 | @JsonProperty("expired") 33 | EXPIRED, 34 | 35 | @JsonProperty("in_progress") 36 | IN_PROGRESS, 37 | 38 | @JsonProperty("completed") 39 | COMPLETED; 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/VectorStoreFile.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class VectorStoreFile { 14 | 15 | private String id; 16 | private String object; 17 | private Integer usageBytes; 18 | private Integer createdAt; 19 | private String vectorStoreId; 20 | private FileStatus status; 21 | private LastError lastError; 22 | private ChunkingStrategy chunkingStrategy; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/VectorStoreFileBatch.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class VectorStoreFileBatch { 14 | 15 | private String id; 16 | private String object; 17 | private Integer createdAt; 18 | private String vectorStoreId; 19 | private FileStatus status; 20 | private FileCount fileCounts; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/VectorStoreFileBatchRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Required; 8 | import io.github.sashirestela.slimvalidator.constraints.Size; 9 | import lombok.Builder; 10 | import lombok.Getter; 11 | import lombok.Singular; 12 | 13 | import java.util.List; 14 | 15 | @Getter 16 | @Builder 17 | @JsonInclude(Include.NON_EMPTY) 18 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 19 | public class VectorStoreFileBatchRequest { 20 | 21 | @Singular 22 | @Required 23 | @Size(min = 1, max = 500) 24 | private List fileIds; 25 | 26 | private ChunkingStrategy chunkingStrategy; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/VectorStoreFileRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Required; 8 | import lombok.Builder; 9 | import lombok.Getter; 10 | 11 | @Getter 12 | @Builder 13 | @JsonInclude(Include.NON_EMPTY) 14 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 15 | public class VectorStoreFileRequest { 16 | 17 | @Required 18 | private String fileId; 19 | 20 | private ChunkingStrategy chunkingStrategy; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/VectorStoreModifyRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Size; 8 | import lombok.Builder; 9 | import lombok.Getter; 10 | 11 | import java.util.Map; 12 | 13 | @Getter 14 | @Builder 15 | @JsonInclude(Include.NON_EMPTY) 16 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 17 | public class VectorStoreModifyRequest { 18 | 19 | private String name; 20 | 21 | private ExpiresAfter expiresAfter; 22 | 23 | @Size(max = 16) 24 | private Map metadata; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/assistant/VectorStoreRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.assistant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Size; 8 | import lombok.Builder; 9 | import lombok.Getter; 10 | import lombok.Singular; 11 | 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | @Getter 16 | @Builder 17 | @JsonInclude(Include.NON_EMPTY) 18 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 19 | public class VectorStoreRequest { 20 | 21 | @Singular 22 | @Size(max = 500) 23 | private List fileIds; 24 | 25 | private String name; 26 | 27 | private ExpiresAfter expiresAfter; 28 | 29 | private ChunkingStrategy chunkingStrategy; 30 | 31 | @Size(max = 16) 32 | private Map metadata; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/audio/AudioResponseFormat.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.audio; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum AudioResponseFormat { 6 | 7 | @JsonProperty("json") 8 | JSON, 9 | 10 | @JsonProperty("text") 11 | TEXT, 12 | 13 | @JsonProperty("srt") 14 | SRT, 15 | 16 | @JsonProperty("verbose_json") 17 | VERBOSE_JSON, 18 | 19 | @JsonProperty("vtt") 20 | VTT; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/audio/SpeechRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.audio; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.openai.common.audio.AudioFormat; 8 | import io.github.sashirestela.openai.common.audio.Voice; 9 | import io.github.sashirestela.slimvalidator.constraints.Range; 10 | import io.github.sashirestela.slimvalidator.constraints.Required; 11 | import io.github.sashirestela.slimvalidator.constraints.Size; 12 | import lombok.Builder; 13 | import lombok.Getter; 14 | 15 | @Getter 16 | @Builder 17 | @JsonInclude(Include.NON_EMPTY) 18 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 19 | public class SpeechRequest { 20 | 21 | @Required 22 | private String model; 23 | 24 | @Required 25 | @Size(max = 4096) 26 | private String input; 27 | 28 | @Required 29 | private Voice voice; 30 | 31 | private AudioFormat responseFormat; 32 | 33 | @Range(min = 0.25, max = 4.0) 34 | private Double speed; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/audio/Transcription.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.audio; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | import java.util.List; 10 | 11 | @NoArgsConstructor 12 | @Getter 13 | @ToString 14 | public class Transcription { 15 | 16 | private String task; 17 | private String language; 18 | private Double duration; 19 | private String text; 20 | private List words; 21 | private List segments; 22 | 23 | @NoArgsConstructor 24 | @Getter 25 | @ToString 26 | public static class AudioWord { 27 | 28 | private String word; 29 | private Double start; 30 | private Double end; 31 | 32 | } 33 | 34 | @NoArgsConstructor 35 | @Getter 36 | @ToString 37 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 38 | public static class Segment { 39 | 40 | private Integer id; 41 | private Integer seek; 42 | private Double start; 43 | private Double end; 44 | private String text; 45 | private List tokens; 46 | private Double temperature; 47 | private Double avgLogprob; 48 | private Double compressionRatio; 49 | private Double noSpeechProb; 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/audio/TranslationRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.audio; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Extension; 8 | import io.github.sashirestela.slimvalidator.constraints.Range; 9 | import io.github.sashirestela.slimvalidator.constraints.Required; 10 | import lombok.Builder; 11 | import lombok.Getter; 12 | import lombok.With; 13 | 14 | import java.nio.file.Path; 15 | 16 | @Getter 17 | @Builder 18 | @JsonInclude(Include.NON_EMPTY) 19 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 20 | public class TranslationRequest { 21 | 22 | @Required 23 | @Extension({ "flac", "mp3", "mp4", "mpeg", "mpga", "m4a", "ogg", "wav", "webm" }) 24 | private Path file; 25 | 26 | @Required 27 | private String model; 28 | 29 | private String prompt; 30 | 31 | @With 32 | private AudioResponseFormat responseFormat; 33 | 34 | @Range(min = 0.0, max = 1.0) 35 | private Double temperature; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/batch/BatchRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.batch; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 7 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 8 | import io.github.sashirestela.slimvalidator.constraints.Required; 9 | import io.github.sashirestela.slimvalidator.constraints.Size; 10 | import lombok.Builder; 11 | import lombok.Getter; 12 | 13 | import java.util.Map; 14 | 15 | @Getter 16 | @Builder 17 | @JsonInclude(Include.NON_EMPTY) 18 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 19 | public class BatchRequest { 20 | 21 | @Required 22 | private String inputFileId; 23 | 24 | @Required 25 | private EndpointType endpoint; 26 | 27 | @Required 28 | private CompletionWindowType completionWindow; 29 | 30 | @Size(max = 16) 31 | private Map metadata; 32 | 33 | public enum CompletionWindowType { 34 | 35 | @JsonProperty("24h") 36 | T24H; 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/batch/EndpointType.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.batch; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum EndpointType { 6 | 7 | @JsonProperty("/v1/chat/completions") 8 | CHAT_COMPLETIONS, 9 | 10 | @JsonProperty("/v1/embeddings") 11 | EMBEDDINGS; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/embedding/Embedding.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.embedding; 2 | 3 | import io.github.sashirestela.openai.common.Usage; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.ToString; 7 | 8 | import java.util.List; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | public class Embedding { 14 | 15 | private String object; 16 | private List data; 17 | private String model; 18 | private Usage usage; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/embedding/EmbeddingBase64.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.embedding; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.ToString; 6 | 7 | @NoArgsConstructor 8 | @Getter 9 | @ToString 10 | public class EmbeddingBase64 { 11 | 12 | private Integer index; 13 | private String embedding; 14 | private String object; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/embedding/EmbeddingFloat.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.embedding; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.ToString; 6 | 7 | import java.util.List; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | public class EmbeddingFloat { 13 | 14 | private Integer index; 15 | private List embedding; 16 | private String object; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/embedding/EmbeddingRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.embedding; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 7 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 8 | import io.github.sashirestela.slimvalidator.constraints.ObjectType; 9 | import io.github.sashirestela.slimvalidator.constraints.ObjectType.Schema; 10 | import io.github.sashirestela.slimvalidator.constraints.Range; 11 | import io.github.sashirestela.slimvalidator.constraints.Required; 12 | import lombok.Builder; 13 | import lombok.Getter; 14 | import lombok.With; 15 | 16 | @Getter 17 | @Builder 18 | @JsonInclude(Include.NON_EMPTY) 19 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 20 | public class EmbeddingRequest { 21 | 22 | @Required 23 | @ObjectType(baseClass = String.class) 24 | @ObjectType(schema = Schema.COLL, baseClass = { String.class, Integer.class }) 25 | @ObjectType(schema = Schema.COLL_COLL, baseClass = Integer.class) 26 | private Object input; 27 | 28 | @Required 29 | private String model; 30 | 31 | @With 32 | private EncodingFormat encodingFormat; 33 | 34 | @Range(min = 1) 35 | private Integer dimensions; 36 | 37 | private String user; 38 | 39 | public enum EncodingFormat { 40 | 41 | @JsonProperty("float") 42 | FLOAT, 43 | 44 | @JsonProperty("base64") 45 | BASE64; 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/file/FileRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.file; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import io.github.sashirestela.slimvalidator.constraints.Required; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | 8 | import java.nio.file.Path; 9 | 10 | @Getter 11 | @Builder 12 | public class FileRequest { 13 | 14 | @Required 15 | private Path file; 16 | 17 | @Required 18 | private PurposeType purpose; 19 | 20 | public enum PurposeType { 21 | 22 | @JsonProperty("fine-tune") 23 | FINE_TUNE, 24 | 25 | @JsonProperty("assistants") 26 | ASSISTANTS, 27 | 28 | @JsonProperty("batch") 29 | BATCH, 30 | 31 | @JsonProperty("vision") 32 | USER_DATA, 33 | 34 | @JsonProperty("user_data") 35 | VISION; 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/file/FileResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.file; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class FileResponse { 14 | 15 | private String id; 16 | private Integer bytes; 17 | private Long createdAt; 18 | private String filename; 19 | private String object; 20 | private String purpose; 21 | 22 | /** 23 | * @deprecated OpenAI has deperecated this field, but there isn't a known alternative for this. 24 | */ 25 | @Deprecated(since = "1.0.0", forRemoval = true) 26 | private String status; 27 | 28 | /** 29 | * @deprecated OpenAI has deperecated this field, but there isn't a known alternative for this. 30 | */ 31 | @Deprecated(since = "1.0.0", forRemoval = true) 32 | private String statusDetails; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/finetuning/FineTuning.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.finetuning; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | import java.util.List; 10 | 11 | @NoArgsConstructor 12 | @Getter 13 | @ToString 14 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 15 | public class FineTuning { 16 | 17 | private String id; 18 | private Long createdAt; 19 | private FineTuningError error; 20 | private String fineTunedModel; 21 | private Long finishedAt; 22 | private HyperParams hyperparameters; 23 | private String model; 24 | private String object; 25 | private String organizationId; 26 | private List resultFiles; 27 | private String status; 28 | private Integer trainedTokens; 29 | private String trainingFile; 30 | private String validationFile; 31 | private List integrations; 32 | private Integer seed; 33 | private Integer estimatedFinish; 34 | private MethodFineTunning method; 35 | 36 | @NoArgsConstructor 37 | @Getter 38 | @ToString 39 | public static class FineTuningError { 40 | 41 | private String code; 42 | private String message; 43 | private String param; 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/finetuning/FineTuningCheckpoint.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.finetuning; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class FineTuningCheckpoint { 14 | 15 | private String id; 16 | private Integer createdAt; 17 | private String fineTunedModelCheckpoint; 18 | private Integer stepNumber; 19 | private Metrics metrics; 20 | private String fineTuningJobId; 21 | private String object; 22 | 23 | @NoArgsConstructor 24 | @Getter 25 | @ToString 26 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 27 | public static class Metrics { 28 | 29 | private Double step; 30 | private Double trainLoss; 31 | private Double trainMeanTokenAccuracy; 32 | private Double validLoss; 33 | private Double validMeanTokenAccuracy; 34 | private Double fullValidLoss; 35 | private Double fullValidMeanTokenAccuracy; 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/finetuning/FineTuningEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.finetuning; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class FineTuningEvent { 14 | 15 | private String id; 16 | private Long createdAt; 17 | private String level; 18 | private String message; 19 | private String object; 20 | private String type; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/finetuning/FineTuningRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.finetuning; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Required; 8 | import lombok.AllArgsConstructor; 9 | import lombok.Builder; 10 | import lombok.Getter; 11 | import lombok.Singular; 12 | 13 | import java.util.List; 14 | 15 | @Getter 16 | @Builder 17 | @AllArgsConstructor 18 | @JsonInclude(Include.NON_EMPTY) 19 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 20 | public class FineTuningRequest { 21 | 22 | @Required 23 | private String model; 24 | 25 | @Required 26 | private String trainingFile; 27 | 28 | private String validationFile; 29 | 30 | /** 31 | * @deprecated OpenAI has deperecated this field in favor of method, and should be passed in under 32 | * the method parameter. 33 | */ 34 | @Deprecated(since = "3.12.0", forRemoval = true) 35 | private HyperParams hyperparameters; 36 | 37 | private String suffix; 38 | 39 | @Singular 40 | private List integrations; 41 | 42 | private Integer seed; 43 | 44 | private MethodFineTunning method; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/finetuning/HyperParams.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.finetuning; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.ObjectType; 8 | import lombok.AccessLevel; 9 | import lombok.AllArgsConstructor; 10 | import lombok.Builder; 11 | import lombok.Getter; 12 | import lombok.NoArgsConstructor; 13 | import lombok.ToString; 14 | 15 | @Getter 16 | @Builder 17 | @NoArgsConstructor 18 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 19 | @ToString 20 | @JsonInclude(Include.NON_EMPTY) 21 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 22 | public class HyperParams { 23 | 24 | @ObjectType(baseClass = { Integer.class, String.class }) 25 | private Object beta; 26 | 27 | @ObjectType(baseClass = { Integer.class, String.class }) 28 | private Object batchSize; 29 | 30 | @ObjectType(baseClass = { Double.class, String.class }) 31 | private Object learningRateMultiplier; 32 | 33 | @ObjectType(baseClass = { Integer.class, String.class }) 34 | private Object nEpochs; 35 | 36 | public Object getnEpochs() { 37 | return nEpochs; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/finetuning/Integration.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.finetuning; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 7 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 8 | import io.github.sashirestela.slimvalidator.constraints.Required; 9 | import lombok.AllArgsConstructor; 10 | import lombok.Builder; 11 | import lombok.Getter; 12 | import lombok.NoArgsConstructor; 13 | import lombok.Singular; 14 | 15 | import java.util.List; 16 | 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | @Getter 20 | @Builder 21 | @JsonInclude(Include.NON_EMPTY) 22 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 23 | public class Integration { 24 | 25 | @Required 26 | private IntegrationType type; 27 | 28 | @Required 29 | private WandbIntegration wandb; 30 | 31 | public enum IntegrationType { 32 | 33 | @JsonProperty("wandb") 34 | WANDB; 35 | 36 | } 37 | 38 | @NoArgsConstructor 39 | @AllArgsConstructor 40 | @Getter 41 | @Builder 42 | @JsonInclude(Include.NON_EMPTY) 43 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 44 | public static class WandbIntegration { 45 | 46 | @Required 47 | private String project; 48 | 49 | private String name; 50 | 51 | private String entity; 52 | 53 | @Singular 54 | private List tags; 55 | 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/image/AbstractImageRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.image; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Range; 8 | import lombok.Getter; 9 | import lombok.experimental.SuperBuilder; 10 | 11 | @Getter 12 | @SuperBuilder 13 | @JsonInclude(Include.NON_EMPTY) 14 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 15 | public abstract class AbstractImageRequest { 16 | 17 | protected String model; 18 | 19 | @Range(min = 1, max = 10) 20 | protected Integer n; 21 | 22 | protected ImageResponseFormat responseFormat; 23 | 24 | protected Size size; 25 | 26 | protected String user; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/image/Background.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.image; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum Background { 6 | 7 | @JsonProperty("transparent") 8 | TRANSPARENT, 9 | 10 | @JsonProperty("opaque") 11 | OPAQUE, 12 | 13 | @JsonProperty("auto") 14 | AUTO; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/image/Image.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.image; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | import java.util.List; 10 | 11 | @NoArgsConstructor 12 | @Getter 13 | @ToString 14 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 15 | public class Image { 16 | 17 | private Integer created; 18 | private List data; 19 | private ImageUsage usage; 20 | 21 | @NoArgsConstructor 22 | @Getter 23 | @ToString 24 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 25 | public static class ImageData { 26 | 27 | private String url; 28 | private String b64Json; 29 | private String revisedPrompt; 30 | 31 | } 32 | 33 | @NoArgsConstructor 34 | @Getter 35 | @ToString 36 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 37 | public static class ImageUsage { 38 | 39 | private Integer inputTokens; 40 | private Integer outputTokens; 41 | private Integer totalTokens; 42 | private ImageTokensDetails inputTokenDetails; 43 | 44 | } 45 | 46 | @NoArgsConstructor 47 | @Getter 48 | @ToString 49 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 50 | public static class ImageTokensDetails { 51 | 52 | private Integer imageTokens; 53 | private Integer textTokens; 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/image/ImageEditsRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.image; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import io.github.sashirestela.slimvalidator.constraints.Extension; 6 | import io.github.sashirestela.slimvalidator.constraints.ObjectType; 7 | import io.github.sashirestela.slimvalidator.constraints.ObjectType.Schema; 8 | import io.github.sashirestela.slimvalidator.constraints.Required; 9 | import lombok.Getter; 10 | import lombok.experimental.SuperBuilder; 11 | 12 | import java.nio.file.Path; 13 | 14 | @Getter 15 | @SuperBuilder 16 | @JsonInclude(Include.NON_EMPTY) 17 | public class ImageEditsRequest extends AbstractImageRequest { 18 | 19 | @Required 20 | @ObjectType(baseClass = Path.class) 21 | @ObjectType(schema = Schema.COLL, baseClass = Path.class) 22 | private Object image; 23 | 24 | @Required 25 | private String prompt; 26 | 27 | private Background background; 28 | 29 | @Extension({ "png" }) 30 | private Path mask; 31 | 32 | private Quality quality; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/image/ImageRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.image; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import io.github.sashirestela.slimvalidator.constraints.Range; 7 | import io.github.sashirestela.slimvalidator.constraints.Required; 8 | import lombok.Getter; 9 | import lombok.experimental.SuperBuilder; 10 | 11 | @Getter 12 | @SuperBuilder 13 | @JsonInclude(Include.NON_EMPTY) 14 | public class ImageRequest extends AbstractImageRequest { 15 | 16 | @Required 17 | private String prompt; 18 | 19 | private Background background; 20 | 21 | private Moderation moderation; 22 | 23 | @Range(min = 0, max = 100) 24 | private Integer outputCompression; 25 | 26 | private OutputFormat outputFormat; 27 | 28 | private Quality quality; 29 | 30 | private Style style; 31 | 32 | public enum Style { 33 | 34 | @JsonProperty("vivid") 35 | VIVID, 36 | 37 | @JsonProperty("natural") 38 | NATURAL; 39 | 40 | } 41 | 42 | public enum Moderation { 43 | 44 | @JsonProperty("low") 45 | LOW, 46 | 47 | @JsonProperty("auto") 48 | AUTO; 49 | 50 | } 51 | 52 | public enum OutputFormat { 53 | 54 | @JsonProperty("png") 55 | PNG, 56 | 57 | @JsonProperty("webp") 58 | WEBP, 59 | 60 | @JsonProperty("jpeg") 61 | JPEG; 62 | 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/image/ImageResponseFormat.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.image; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum ImageResponseFormat { 6 | 7 | @JsonProperty("url") 8 | URL, 9 | 10 | @JsonProperty("b64_json") 11 | B64JSON; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/image/ImageVariationsRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.image; 2 | 3 | import io.github.sashirestela.slimvalidator.constraints.Extension; 4 | import io.github.sashirestela.slimvalidator.constraints.Required; 5 | import lombok.Getter; 6 | import lombok.experimental.SuperBuilder; 7 | 8 | import java.nio.file.Path; 9 | 10 | @Getter 11 | @SuperBuilder 12 | public class ImageVariationsRequest extends AbstractImageRequest { 13 | 14 | @Required 15 | @Extension({ "png" }) 16 | private Path image; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/image/Quality.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.image; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum Quality { 6 | 7 | // DALL-E-3 and DALL-E-2 8 | @JsonProperty("standard") 9 | STANDARD, 10 | 11 | // DALL-E-3 12 | @JsonProperty("hd") 13 | HD, 14 | 15 | // GPT-Image-1 16 | @JsonProperty("low") 17 | LOW, 18 | @JsonProperty("medium") 19 | MEDIUM, 20 | @JsonProperty("high") 21 | HIGH, 22 | 23 | // Default 24 | @JsonProperty("auto") 25 | AUTO; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/image/Size.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.image; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public enum Size { 6 | // Common 7 | @JsonProperty("1024x1024") 8 | X_1024_1024, 9 | 10 | // DALL-E-2 11 | @JsonProperty("256x256") 12 | X_256_256, 13 | @JsonProperty("512x512") 14 | X_512_512, 15 | 16 | // DALL-E-3 17 | @JsonProperty("1792x1024") 18 | X_1792_1024, 19 | @JsonProperty("1024x1792") 20 | X_1024_1792, 21 | 22 | // GPT-Image-1 23 | @JsonProperty("1536x1024") 24 | X_1536_1024, 25 | @JsonProperty("1024x1536") 26 | X_1024_1536, 27 | @JsonProperty("auto") 28 | AUTO; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/model/Model.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.model; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class Model { 14 | 15 | private String id; 16 | private String object; 17 | private long created; 18 | private String ownedBy; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/realtime/RealtimeSessionToken.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.realtime; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @ToString(callSuper = true) 11 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 12 | public class RealtimeSessionToken extends RealtimeSession { 13 | 14 | private Secret clientSecret; 15 | 16 | public Secret getClientSecretAtResponse() { 17 | return clientSecret; 18 | } 19 | 20 | @NoArgsConstructor 21 | @Getter 22 | @ToString 23 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 24 | public static class Secret { 25 | 26 | private String value; 27 | private Long expiresAt; 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/realtime/RealtimeTranscriptionSessionToken.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.realtime; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import io.github.sashirestela.openai.domain.realtime.RealtimeSessionToken.Secret; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | import lombok.experimental.SuperBuilder; 9 | 10 | @NoArgsConstructor 11 | @SuperBuilder 12 | @ToString(callSuper = true) 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class RealtimeTranscriptionSessionToken extends RealtimeTranscriptionSession { 15 | 16 | private Secret clientSecret; 17 | 18 | public Secret getClientSecretAtResponse() { 19 | return clientSecret; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/InputItems.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | import java.util.List; 11 | 12 | @NoArgsConstructor 13 | @Getter 14 | @ToString 15 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 16 | public class InputItems { 17 | 18 | private String object; 19 | @JsonDeserialize(contentUsing = ItemDeserializer.class) 20 | private List data; 21 | private String firstId; 22 | private String lastId; 23 | private boolean hasMore; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/Prompt.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.ObjectType; 8 | import io.github.sashirestela.slimvalidator.constraints.ObjectType.Schema; 9 | import io.github.sashirestela.slimvalidator.constraints.Required; 10 | import lombok.AccessLevel; 11 | import lombok.AllArgsConstructor; 12 | import lombok.Getter; 13 | import lombok.NoArgsConstructor; 14 | import lombok.ToString; 15 | 16 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 17 | @NoArgsConstructor 18 | @Getter 19 | @ToString 20 | @JsonInclude(Include.NON_EMPTY) 21 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 22 | public class Prompt { 23 | 24 | @Required 25 | private String id; 26 | 27 | @ObjectType(schema = Schema.MAP, keyClass = String.class, baseClass = { String.class, Input.Content.class }) 28 | private Object variable; 29 | 30 | private String version; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/Reasoning.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 7 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 8 | import io.github.sashirestela.openai.domain.chat.ChatRequest.ReasoningEffort; 9 | import lombok.AccessLevel; 10 | import lombok.AllArgsConstructor; 11 | import lombok.Getter; 12 | import lombok.NoArgsConstructor; 13 | import lombok.ToString; 14 | 15 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 16 | @NoArgsConstructor 17 | @Getter 18 | @ToString 19 | @JsonInclude(Include.NON_EMPTY) 20 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 21 | public class Reasoning { 22 | 23 | private ReasoningEffort effort; 24 | private Summary summary; 25 | 26 | public static Reasoning of(ReasoningEffort effort) { 27 | return new Reasoning(effort, null); 28 | } 29 | 30 | public static Reasoning of(ReasoningEffort effort, Summary summary) { 31 | return new Reasoning(effort, summary); 32 | } 33 | 34 | public enum Summary { 35 | @JsonProperty("auto") 36 | AUTO, 37 | 38 | @JsonProperty("concise") 39 | CONCISE, 40 | 41 | @JsonProperty("detailed") 42 | DETAILED; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseContentPartEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import io.github.sashirestela.openai.domain.response.Input; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class ResponseContentPartEvent { 15 | 16 | private String type; 17 | private String itemId; 18 | private Integer outputIndex; 19 | private Integer contentIndex; 20 | private Input.OutputContent part; 21 | private Integer sequenceNumber; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseErrorEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseErrorEvent { 14 | 15 | private String type; 16 | private String code; 17 | private String message; 18 | private String param; 19 | private Integer sequenceNumber; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import io.github.sashirestela.openai.domain.response.Response; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class ResponseEvent { 15 | 16 | private String type; 17 | private Response response; 18 | private Integer sequenceNumber; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseFileSearchCallEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseFileSearchCallEvent { 14 | 15 | private String type; 16 | private String itemId; 17 | private Integer outputIndex; 18 | private Integer sequenceNumber; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseFunctionCallArgsEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAlias; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class ResponseFunctionCallArgsEvent { 15 | 16 | private String type; 17 | private String itemId; 18 | private Integer outputIndex; 19 | @JsonAlias({ "delta" }) 20 | private String arguments; 21 | private Integer sequenceNumber; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseImageGenerationCallEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseImageGenerationCallEvent { 14 | 15 | private String type; 16 | private String itemId; 17 | private Integer outputIndex; 18 | private Integer sequenceNumber; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseImageGenerationCallPartialEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseImageGenerationCallPartialEvent { 14 | 15 | private String type; 16 | private String itemId; 17 | private Integer outputIndex; 18 | private String partialImageB64; 19 | private Integer partialImageIndex; 20 | private Integer sequenceNumber; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseMcpCallArgumentsEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAlias; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class ResponseMcpCallArgumentsEvent { 15 | 16 | private String type; 17 | private String itemId; 18 | private Integer outputIndex; 19 | @JsonAlias({ "delta" }) 20 | private Object arguments; 21 | private Integer sequenceNumber; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseMcpCallEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseMcpCallEvent { 14 | 15 | private String type; 16 | private Integer sequenceNumber; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseMcpCallInProgressEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseMcpCallInProgressEvent { 14 | 15 | private String type; 16 | private String itemId; 17 | private Integer outputIndex; 18 | private Integer sequenceNumber; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseMcpListToolsEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseMcpListToolsEvent { 14 | 15 | private String type; 16 | private Integer sequenceNumber; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseOutputItemEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import io.github.sashirestela.openai.domain.response.Input; 7 | import io.github.sashirestela.openai.domain.response.ItemDeserializer; 8 | import lombok.Getter; 9 | import lombok.NoArgsConstructor; 10 | import lombok.ToString; 11 | 12 | @NoArgsConstructor 13 | @Getter 14 | @ToString 15 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 16 | public class ResponseOutputItemEvent { 17 | 18 | private String type; 19 | private Integer outputIndex; 20 | @JsonDeserialize(using = ItemDeserializer.class) 21 | private Input.Item item; 22 | private Integer sequenceNumber; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseOutputTextAnnotEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import io.github.sashirestela.openai.domain.response.Input; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class ResponseOutputTextAnnotEvent { 15 | 16 | private String type; 17 | private String itemId; 18 | private Integer outputIndex; 19 | private Integer contentIndex; 20 | private Integer annotationIndex; 21 | private Input.Citation annotation; 22 | private Integer sequenceNumber; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseOutputTextEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAlias; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class ResponseOutputTextEvent { 15 | 16 | private String type; 17 | private String itemId; 18 | private Integer outputIndex; 19 | private Integer contentIndex; 20 | @JsonAlias({ "delta" }) 21 | private String text; 22 | private Integer sequenceNumber; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseReasonSummPartEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import io.github.sashirestela.openai.domain.response.Input; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class ResponseReasonSummPartEvent { 15 | 16 | private String type; 17 | private String itemId; 18 | private Integer outputIndex; 19 | private Integer summaryIndex; 20 | private Input.ReasoningContent part; 21 | private Integer sequenceNumber; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseReasonSummTextEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAlias; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class ResponseReasonSummTextEvent { 15 | 16 | private String type; 17 | private String itemId; 18 | private Integer outputIndex; 19 | private Integer summaryIndex; 20 | @JsonAlias({ "delta" }) 21 | private String text; 22 | private Integer sequenceNumber; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseReasoningEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseReasoningEvent { 14 | 15 | private String type; 16 | private String itemId; 17 | private Integer outputIndex; 18 | private Integer contentIndex; 19 | private Object delta; 20 | private String text; 21 | private Integer sequenceNumber; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseReasoningSummaryEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseReasoningSummaryEvent { 14 | 15 | private String type; 16 | private String itemId; 17 | private Integer outputIndex; 18 | private Integer summaryIndex; 19 | private Object delta; 20 | private String text; 21 | private Integer sequenceNumber; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseRefusalEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAlias; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | @NoArgsConstructor 11 | @Getter 12 | @ToString 13 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 14 | public class ResponseRefusalEvent { 15 | 16 | private String type; 17 | private String itemId; 18 | private Integer outputIndex; 19 | private Integer contentIndex; 20 | @JsonAlias({ "delta" }) 21 | private String refusal; 22 | private Integer sequenceNumber; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/response/stream/ResponseWebSearchCallEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.response.stream; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class ResponseWebSearchCallEvent { 14 | 15 | private String type; 16 | private String itemId; 17 | private Integer outputIndex; 18 | private Integer sequenceNumber; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/upload/Upload.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.upload; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 6 | import io.github.sashirestela.openai.domain.file.FileResponse; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.ToString; 10 | 11 | @NoArgsConstructor 12 | @Getter 13 | @ToString 14 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 15 | public class Upload { 16 | 17 | private String id; 18 | private Long createdAt; 19 | private String filename; 20 | private Long bytes; 21 | private String purpose; 22 | private UploadStatus status; 23 | private Long expiresAt; 24 | private String object; 25 | private FileResponse file; 26 | 27 | public enum UploadStatus { 28 | 29 | @JsonProperty("pending") 30 | PENDING, 31 | 32 | @JsonProperty("completed") 33 | COMPLETED, 34 | 35 | @JsonProperty("cancelled") 36 | CANCELLED, 37 | 38 | @JsonProperty("expired") 39 | EXPIRED; 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/upload/UploadCompleteRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.upload; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Required; 8 | import lombok.Builder; 9 | import lombok.Getter; 10 | import lombok.Singular; 11 | 12 | import java.util.List; 13 | 14 | @Getter 15 | @Builder 16 | @JsonInclude(Include.NON_EMPTY) 17 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 18 | public class UploadCompleteRequest { 19 | 20 | @Required 21 | @Singular 22 | private List partIds; 23 | 24 | private String md5; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/upload/UploadPart.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.upload; 2 | 3 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 4 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @NoArgsConstructor 10 | @Getter 11 | @ToString 12 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 13 | public class UploadPart { 14 | 15 | private String id; 16 | private Long createdAt; 17 | private String uploadId; 18 | private String object; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/upload/UploadPartRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.upload; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.slimvalidator.constraints.Required; 8 | import lombok.Builder; 9 | import lombok.Getter; 10 | 11 | import java.nio.file.Path; 12 | 13 | @Getter 14 | @Builder 15 | @JsonInclude(Include.NON_EMPTY) 16 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 17 | public class UploadPartRequest { 18 | 19 | @Required 20 | private Path data; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/domain/upload/UploadRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.domain.upload; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import com.fasterxml.jackson.databind.annotation.JsonNaming; 7 | import io.github.sashirestela.openai.domain.file.FileRequest.PurposeType; 8 | import io.github.sashirestela.slimvalidator.constraints.Range; 9 | import io.github.sashirestela.slimvalidator.constraints.Required; 10 | import lombok.Builder; 11 | import lombok.Getter; 12 | 13 | @Getter 14 | @Builder 15 | @JsonInclude(Include.NON_EMPTY) 16 | @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) 17 | public class UploadRequest { 18 | 19 | @Required 20 | private String filename; 21 | 22 | @Required 23 | private PurposeType purpose; 24 | 25 | @Required 26 | @Range(max = 8_589_934_592L) 27 | private Long bytes; 28 | 29 | @Required 30 | private String mimeType; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/exception/OpenAIResponseInfo.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.exception; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | import lombok.Value; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | @Value 14 | @Builder 15 | public class OpenAIResponseInfo { 16 | 17 | private int status; 18 | private OpenAIErrorResponse errorResponse; 19 | private String httpMethod; 20 | private String url; 21 | private Map> responseHeaders; 22 | private Map> requestHeaders; 23 | 24 | @Getter 25 | @ToString 26 | @Builder 27 | @NoArgsConstructor 28 | @AllArgsConstructor 29 | public static class OpenAIErrorResponse { 30 | 31 | private OpenAIError error; 32 | 33 | @Getter 34 | @ToString 35 | @Builder 36 | @NoArgsConstructor 37 | @AllArgsConstructor 38 | public static class OpenAIError { 39 | 40 | private String message; 41 | private String type; 42 | private String param; 43 | private String code; 44 | 45 | } 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/exception/PollingAbortedException.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.exception; 2 | 3 | public class PollingAbortedException extends SimpleOpenAIException { 4 | 5 | public PollingAbortedException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/exception/SimpleOpenAIException.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.exception; 2 | 3 | import java.text.MessageFormat; 4 | import java.util.Arrays; 5 | 6 | public class SimpleOpenAIException extends RuntimeException { 7 | 8 | public SimpleOpenAIException(String message) { 9 | super(message); 10 | } 11 | 12 | public SimpleOpenAIException(String message, Object... parameters) { 13 | super(MessageFormat.format(message, Arrays.copyOfRange(parameters, 0, parameters.length - 1)), 14 | (Throwable) parameters[parameters.length - 1]); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/AssistantServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAIBeta2; 4 | 5 | public interface AssistantServices { 6 | 7 | OpenAIBeta2.Assistants assistants(); 8 | 9 | OpenAIBeta2.Threads threads(); 10 | 11 | OpenAIBeta2.ThreadMessages threadMessages(); 12 | 13 | OpenAIBeta2.ThreadRuns threadRuns(); 14 | 15 | OpenAIBeta2.ThreadRunSteps threadRunSteps(); 16 | 17 | OpenAIBeta2.VectorStores vectorStores(); 18 | 19 | OpenAIBeta2.VectorStoreFiles vectorStoreFiles(); 20 | 21 | OpenAIBeta2.VectorStoreFileBatches vectorStoreFileBatches(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/AudioServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface AudioServices { 6 | 7 | OpenAI.Audios audios(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/BatchServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface BatchServices { 6 | 7 | OpenAI.Batches batches(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/ChatCompletionServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface ChatCompletionServices { 6 | 7 | OpenAI.ChatCompletions chatCompletions(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/CompletionServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface CompletionServices { 6 | 7 | OpenAI.Completions completions(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/EmbeddingServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface EmbeddingServices { 6 | 7 | OpenAI.Embeddings embeddings(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/FileServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface FileServices { 6 | 7 | OpenAI.Files files(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/FineTunningServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface FineTunningServices { 6 | 7 | OpenAI.FineTunings fineTunings(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/ImageServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface ImageServices { 6 | 7 | OpenAI.Images images(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/ModelServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface ModelServices { 6 | 7 | OpenAI.Models models(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/ModerationServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface ModerationServices { 6 | 7 | OpenAI.Moderations moderations(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/RealtimeServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAIRealtime; 4 | 5 | public interface RealtimeServices { 6 | 7 | OpenAIRealtime realtime(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/ResponseServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface ResponseServices { 6 | 7 | OpenAI.Responses responses(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/SessionServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface SessionServices { 6 | 7 | OpenAI.SessionTokens sessionTokens(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/service/UploadServices.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.service; 2 | 3 | import io.github.sashirestela.openai.OpenAI; 4 | 5 | public interface UploadServices { 6 | 7 | OpenAI.Uploads uploads(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/support/Constant.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.support; 2 | 3 | public final class Constant { 4 | 5 | private Constant() { 6 | } 7 | 8 | public static final String AUTHORIZATION_HEADER = "Authorization"; 9 | public static final String BEARER_AUTHORIZATION = "Bearer "; 10 | 11 | public static final String OPENAI_BASE_URL = "https://api.openai.com"; 12 | public static final String OPENAI_ORG_HEADER = "OpenAI-Organization"; 13 | public static final String OPENAI_PRJ_HEADER = "OpenAI-Project"; 14 | public static final String OPENAI_WS_ENDPOINT_URL = "wss://api.openai.com/v1/realtime"; 15 | public static final String OPENAI_BETA_HEADER = "OpenAI-Beta"; 16 | public static final String OPENAI_ASSISTANT_VERSION = "assistants=v2"; 17 | public static final String OPENAI_REALTIME_VERSION = "realtime=v1"; 18 | public static final String OPENAI_REALTIME_MODEL_NAME = "model"; 19 | 20 | public static final String ANYSCALE_BASE_URL = "https://api.endpoints.anyscale.com"; 21 | 22 | public static final String AZURE_APIKEY_HEADER = "api-key"; 23 | public static final String AZURE_API_VERSION = "api-version"; 24 | 25 | public static final String MISTRAL_BASE_URL = "https://api.mistral.ai"; 26 | 27 | public static final String DEEPSEEK_BASE_URL = "https://api.deepseek.com"; 28 | 29 | public static final String GEMINIGOOGLE_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai"; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/support/JsonSchemaUtil.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.support; 2 | 3 | import com.fasterxml.jackson.databind.JsonNode; 4 | import io.github.sashirestela.openai.common.function.SchemaConverter; 5 | 6 | public class JsonSchemaUtil { 7 | 8 | public static final SchemaConverter defaultConverter = new DefaultSchemaConverter(); 9 | 10 | public static final String JSON_EMPTY_CLASS = "{\"type\":\"object\",\"properties\":{},\"additionalProperties\":false}"; 11 | 12 | private JsonSchemaUtil() { 13 | } 14 | 15 | public static JsonNode classToJsonSchema(Class clazz) { 16 | return defaultConverter.convert(clazz); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/sashirestela/openai/support/Poller.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.support; 2 | 3 | import io.github.sashirestela.openai.exception.PollingAbortedException; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NonNull; 7 | 8 | import java.time.Duration; 9 | import java.util.function.Predicate; 10 | import java.util.function.UnaryOperator; 11 | 12 | @Builder 13 | @Getter 14 | public class Poller { 15 | 16 | @NonNull 17 | private Duration interval; 18 | 19 | @NonNull 20 | private UnaryOperator pollFunction; 21 | 22 | @NonNull 23 | private Predicate continueIf; 24 | 25 | private Predicate abortIf; 26 | 27 | public T execute(T startValue) { 28 | T object = startValue; 29 | do { 30 | try { 31 | java.lang.Thread.sleep(interval.toMillis()); 32 | } catch (InterruptedException e) { 33 | java.lang.Thread.currentThread().interrupt(); 34 | } 35 | if (abortIf != null && abortIf.test(object)) { 36 | throw new PollingAbortedException("Polling aborted due to abort condition."); 37 | } 38 | object = pollFunction.apply(object); 39 | } while (continueIf.test(object)); 40 | return object; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/io/github/sashirestela/openai/SimpleOpenAIDeepseekTest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertNotNull; 6 | 7 | class SimpleOpenAIDeepseekTest { 8 | 9 | @Test 10 | void shouldCreateEndpoints() { 11 | var openAI = SimpleOpenAIDeepseek.builder() 12 | .apiKey("apiKey") 13 | .baseUrl("baseUrl") 14 | .build(); 15 | assertNotNull(openAI.chatCompletions()); 16 | assertNotNull(openAI.models()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/io/github/sashirestela/openai/SimpleOpenAIExceptionTest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai; 2 | 3 | import io.github.sashirestela.openai.exception.SimpleOpenAIException; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | import static org.junit.jupiter.api.Assertions.assertNotNull; 8 | 9 | class SimpleOpenAIExceptionTest { 10 | 11 | @Test 12 | void shouldSetMessageWhenItIsPassedAsTheOnlyOneArgument() { 13 | var exception = new SimpleOpenAIException("Message"); 14 | assertNotNull(exception.getMessage()); 15 | } 16 | 17 | @Test 18 | void shouldReplaceParametersInErrorMessageWhenAnExceptionIsCreated() { 19 | var exception = new SimpleOpenAIException("{0}, {1}", "parameter1", "parameter2", null); 20 | var actualExceptionMessage = exception.getMessage(); 21 | var expectedExceptionMessage = "parameter1, parameter2"; 22 | assertEquals(expectedExceptionMessage, actualExceptionMessage); 23 | } 24 | 25 | @Test 26 | void shouldSetCauseInErrorWhenItIsPassedAsLastArgumentAtExceptionCreation() { 27 | var exception = new SimpleOpenAIException("Message", null, new Exception()); 28 | assertNotNull(exception.getCause()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/io/github/sashirestela/openai/common/GenericTest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.common; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import java.util.Arrays; 6 | 7 | import static org.junit.jupiter.api.Assertions.assertNotNull; 8 | 9 | class GenericTest { 10 | 11 | @Test 12 | void testCreateNewObject() { 13 | var generic = new Generic("object", 123456789L, Arrays.asList("one", "two"), 14 | "nextStartingAfter", false); 15 | System.out.println(generic); 16 | assertNotNull(generic); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/io/github/sashirestela/openai/support/Base64UtilTest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.support; 2 | 3 | import io.github.sashirestela.openai.support.Base64Util.MediaType; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 7 | import static org.junit.jupiter.api.Assertions.assertFalse; 8 | import static org.junit.jupiter.api.Assertions.assertThrows; 9 | import static org.junit.jupiter.api.Assertions.assertTrue; 10 | 11 | class Base64UtilTest { 12 | 13 | @Test 14 | void testEncodeDecode() { 15 | var filePath = "src/test/resources/audios_speak.mp3"; 16 | var base64StringWithMedia = Base64Util.encode(filePath, MediaType.AUDIO); 17 | assertTrue(base64StringWithMedia.startsWith("data:")); 18 | var base64String = Base64Util.encode(filePath, null); 19 | assertFalse(base64String.startsWith("data:")); 20 | assertDoesNotThrow(() -> Base64Util.decode(base64String, filePath)); 21 | } 22 | 23 | @Test 24 | void testEncodeException() { 25 | var filePath = "src/test/resources/image_not_found.png"; 26 | assertThrows(Exception.class, () -> Base64Util.encode(filePath, MediaType.IMAGE)); 27 | } 28 | 29 | @Test 30 | void testDecodeException() { 31 | var base64String = "ºªÇ"; 32 | var filePath = "src/test/resources/image_error.png"; 33 | assertThrows(Exception.class, () -> Base64Util.decode(base64String, filePath)); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/io/github/sashirestela/openai/support/DefaultSchemaConverterTest.java: -------------------------------------------------------------------------------- 1 | package io.github.sashirestela.openai.support; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import org.junit.jupiter.api.Test; 8 | 9 | import static org.junit.jupiter.api.Assertions.assertEquals; 10 | 11 | class DefaultSchemaConverterTest { 12 | 13 | @Test 14 | void testConvertStandard() { 15 | var actualJsonSchema = new DefaultSchemaConverter().convert(TestClass.class).toString(); 16 | var expectedJsonSchema = "{\"type\":\"object\",\"properties\":{\"first\":{\"type\":\"string\"}," + 17 | "\"second\":{\"type\":\"integer\"}},\"required\":[\"first\"],\"additionalProperties\":false}"; 18 | assertEquals(expectedJsonSchema, actualJsonSchema); 19 | 20 | } 21 | 22 | @Test 23 | void testConvertStructuredOutput() { 24 | var actualJsonSchema = new DefaultSchemaConverter(Boolean.TRUE).convert(TestClass.class).toString(); 25 | var expectedJsonSchema = "{\"type\":\"object\",\"properties\":{\"first\":{\"type\":\"string\"}," + 26 | "\"second\":{\"type\":\"integer\"}},\"required\":[\"first\",\"second\"],\"additionalProperties\":false}"; 27 | assertEquals(expectedJsonSchema, actualJsonSchema); 28 | 29 | } 30 | 31 | @NoArgsConstructor 32 | @AllArgsConstructor 33 | @Getter 34 | static class TestClass { 35 | 36 | @JsonProperty(required = true) 37 | public String first; 38 | 39 | public Integer second; 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/resources/assistants_create.json: -------------------------------------------------------------------------------- 1 | {"id":"asst_pTVcc7eVjgnf347eVIoEJHqG","object":"assistant","created_at":1717562128,"name":"Demo Assistant","description":"This is an assistant for demonstration purposes.","model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"file_search","file_search":{"max_num_results":10}}],"top_p":1.0,"temperature":0.2,"tool_resources":{"file_search":{"vector_store_ids":["vs_LdYNXS4dMnllTRG5t5Kp1OSg"]}},"metadata":{"user":"tester"},"response_format":"auto"} -------------------------------------------------------------------------------- /src/test/resources/assistants_delete.json: -------------------------------------------------------------------------------- 1 | {"id":"asst_aCEgMriCKzNDqvkhl1TmrJaK","object":"assistant.deleted","deleted":true} -------------------------------------------------------------------------------- /src/test/resources/assistants_getlist.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"id":"asst_aCEgMriCKzNDqvkhl1TmrJaK","object":"assistant","created_at":1714499627,"name":"Demo Assistant","description":"This is an assistant for demonstration purposes.","model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"file_search"}],"top_p":1.0,"temperature":0.3,"tool_resources":{"file_search":{"vector_store_ids":[]}},"metadata":{"user":"tester","env":"test"},"response_format":{"type":"text"}}],"first_id":"asst_aCEgMriCKzNDqvkhl1TmrJaK","last_id":"asst_aCEgMriCKzNDqvkhl1TmrJaK","has_more":false} -------------------------------------------------------------------------------- /src/test/resources/assistants_getone.json: -------------------------------------------------------------------------------- 1 | {"id":"asst_aCEgMriCKzNDqvkhl1TmrJaK","object":"assistant","created_at":1714499627,"name":"Demo Assistant","description":"This is an assistant for demonstration purposes.","model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"file_search"}],"top_p":1.0,"temperature":0.3,"tool_resources":{"file_search":{"vector_store_ids":[]}},"metadata":{"user":"tester","env":"test"},"response_format":{"type":"text"}} -------------------------------------------------------------------------------- /src/test/resources/assistants_modify.json: -------------------------------------------------------------------------------- 1 | {"id":"asst_aCEgMriCKzNDqvkhl1TmrJaK","object":"assistant","created_at":1714499627,"name":"Demo Assistant","description":"This is an assistant for demonstration purposes.","model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"file_search"}],"top_p":1.0,"temperature":0.3,"tool_resources":{"file_search":{"vector_store_ids":[]}},"metadata":{"user":"tester","env":"test"},"response_format":{"type":"text"}} -------------------------------------------------------------------------------- /src/test/resources/audios_speak.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sashirestela/simple-openai/7af0d7d8daf5c555cd65b202664a2c970be4479e/src/test/resources/audios_speak.mp3 -------------------------------------------------------------------------------- /src/test/resources/audios_transcribe.json: -------------------------------------------------------------------------------- 1 | { "task": "transcribe", "language": "english", "duration": 5.159999847412109, "text": "Hello, everybody. This is a test to speech recognition.", "segments": [ { "id": 0, "seek": 0, "start": 0.6000000238418579, "end": 4.880000114440918, "text": " Hello, everybody. This is a test to speech recognition.", "tokens": [ 50364, 2425, 11, 2201, 13, 639, 307, 257, 1500, 281, 6218, 11150, 13, 50614 ], "temperature": 0, "avg_logprob": -0.45482543110847473, "compression_ratio": 0.9016393423080444, "no_speech_prob": 0.010660942643880844 } ], "words": [ { "word": "Hello", "start": 0.6000000238418579, "end": 1.2799999713897705 }, { "word": "everybody", "start": 1.440000057220459, "end": 1.9199999570846558 }, { "word": "This", "start": 2.299999952316284, "end": 2.5199999809265137 }, { "word": "is", "start": 2.5199999809265137, "end": 2.8399999141693115 }, { "word": "a", "start": 2.8399999141693115, "end": 3.0399999618530273 }, { "word": "test", "start": 3.0399999618530273, "end": 3.4000000953674316 }, { "word": "to", "start": 3.4000000953674316, "end": 3.7200000286102295 }, { "word": "speech", "start": 3.7200000286102295, "end": 4.21999979019165 }, { "word": "recognition", "start": 4.21999979019165, "end": 4.880000114440918 } ] } -------------------------------------------------------------------------------- /src/test/resources/audios_transcribe_plain.txt: -------------------------------------------------------------------------------- 1 | Hello, everybody. This is a test to speech recognition. -------------------------------------------------------------------------------- /src/test/resources/audios_translate.json: -------------------------------------------------------------------------------- 1 | { "text": "Hello, everybody. This is a test to speech recognition." } -------------------------------------------------------------------------------- /src/test/resources/audios_translate_plain.txt: -------------------------------------------------------------------------------- 1 | WEBVTT 2 | 3 | 00:00:00.000 --> 00:00:05.000 4 | Hello, everybody. This is a test to speech recognition. -------------------------------------------------------------------------------- /src/test/resources/batches_cancel.json: -------------------------------------------------------------------------------- 1 | {"id":"batch_kHnPT5OdGUU7Cha4Vj1RnM6i","object":"batch","endpoint":"/v1/chat/completions","errors":{"object":"list","data":[{"code":"123456err","message":"This is an error with batches","param":"param1","line":1}]},"input_file_id":"file-pbNU1kkJTfCtM7FQBNNQ8PAW","completion_window":"24h","status":"cancelling","output_file_id":"file-N1gnfCTY4P0zL2IecQD2POKK","error_file_id":null,"created_at":1713478694,"in_progress_at":1713478695,"expires_at":1713565094,"finalizing_at":null,"completed_at":null,"failed_at":null,"expired_at":null,"cancelling_at":1713478758,"cancelled_at":null,"request_counts":{"total":2,"completed":2,"failed":0},"metadata":null} -------------------------------------------------------------------------------- /src/test/resources/batches_create.json: -------------------------------------------------------------------------------- 1 | { "id": "batch_kHnPT5OdGUU7Cha4Vj1RnM6i", "object": "batch", "endpoint": "/v1/chat/completions", "errors": null, "input_file_id": "file-pbNU1kkJTfCtM7FQBNNQ8PAW", "completion_window": "24h", "status": "validating", "output_file_id": null, "error_file_id": null, "created_at": 1713478694, "in_progress_at": null, "expires_at": 1713565094, "finalizing_at": null, "completed_at": null, "failed_at": null, "expired_at": null, "cancelling_at": null, "cancelled_at": null, "request_counts": { "total": 0, "completed": 0, "failed": 0 }, "metadata": null } -------------------------------------------------------------------------------- /src/test/resources/batches_getone.json: -------------------------------------------------------------------------------- 1 | { "id": "batch_kHnPT5OdGUU7Cha4Vj1RnM6i", "object": "batch", "endpoint": "/v1/chat/completions", "errors": null, "input_file_id": "file-pbNU1kkJTfCtM7FQBNNQ8PAW", "completion_window": "24h", "status": "completed", "output_file_id": "file-N1gnfCTY4P0zL2IecQD2POKK", "error_file_id": null, "created_at": 1713478694, "in_progress_at": 1713478695, "expires_at": 1713565094, "finalizing_at": 1713478758, "completed_at": 1713478766, "failed_at": null, "expired_at": null, "cancelling_at": null, "cancelled_at": null, "request_counts": { "total": 2, "completed": 2, "failed": 0 }, "metadata": null } -------------------------------------------------------------------------------- /src/test/resources/chatcompletions_create_function_answer.json: -------------------------------------------------------------------------------- 1 | { "id": "chatcmpl-8LhsmUDRgfIn2UcHVl7d5UQiCWWLp", "object": "chat.completion", "created": 1700184264, "model": "gpt-4-1106-preview", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The product of 123 and 456 is 56,088." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 120, "completion_tokens": 15, "total_tokens": 135 }, "system_fingerprint": "fp_a24b4d720c" } -------------------------------------------------------------------------------- /src/test/resources/chatcompletions_create_function_question.json: -------------------------------------------------------------------------------- 1 | { "id": "chatcmpl-8LkOfjXy71qSvozfZ7KjTRVCDaubG", "object": "chat.completion", "created": 1700193929, "model": "gpt-4-1106-preview", "choices": [ { "index": 0, "message": { "role": "assistant", "content": null, "tool_calls": [ { "id": "call_NkbBCeM6f6ONgCGIdCNEnjfL", "type": "function", "function": { "name": "product", "arguments": "{\"multiplicand\":123,\"multiplier\":456}" } } ] }, "finish_reason": "tool_calls" } ], "usage": { "prompt_tokens": 91, "completion_tokens": 20, "total_tokens": 111 }, "system_fingerprint": "fp_a24b4d720c" } -------------------------------------------------------------------------------- /src/test/resources/chatcompletions_create_structured_output.json: -------------------------------------------------------------------------------- 1 | {"id":"chatcmpl-9y1Q9ctuKrEhXcMImhdZP9OjFP3iS","object":"chat.completion","created":1724092169,"model":"gpt-4o-mini-2024-07-18","choices":[{"index":0,"message":{"role":"assistant","content":"{\"steps\":[{\"explanation\":\"We start with the equation 8x + 7 = -23. The first step is to isolate the term with x by subtracting 7 from both sides of the equation.\",\"output\":\"8x + 7 - 7 = -23 - 7\"},{\"explanation\":\"This simplifies to 8x = -30. Now we have an equation with only the variable term on one side.\",\"output\":\"8x = -30\"},{\"explanation\":\"Next, we need to solve for x by dividing both sides of the equation by 8.\",\"output\":\"x = -30 / 8\"},{\"explanation\":\"When we simplify -30 / 8, we can divide the numerator and the denominator by 2 to make it simpler.\",\"output\":\"x = -15 / 4\"}],\"finalAnswer\":\"x = -3.75\"}","refusal":null},"logprobs":null,"finish_reason":"stop"}],"usage":{"prompt_tokens":46,"completion_tokens":177,"total_tokens":223},"system_fingerprint":"fp_48196bc67a"} -------------------------------------------------------------------------------- /src/test/resources/chatcompletions_create_vision.json: -------------------------------------------------------------------------------- 1 | { "id": "chatcmpl-8Lh4NNJI84St5z1jvpGb8HKkgiFlK", "object": "chat.completion", "created": 1700181139, "model": "gpt-4-1106-vision-preview", "usage": { "prompt_tokens": 190, "completion_tokens": 79, "total_tokens": 269 }, "choices": [ { "message": { "role": "assistant", "content": "It appears that you've provided two identical images. Both images show a wooden boardwalk or path leading through a lush green meadow or wetland area. The sky is partly cloudy, suggesting a pleasant day. The scenery is tranquil and might be a natural area for walking and enjoying nature. There are no discernible differences between the two images; they seem to be exact copies of each other." }, "finish_details": { "type": "stop", "stop": "<|fim_suffix|>" }, "index": 0 } ] } -------------------------------------------------------------------------------- /src/test/resources/completions_create.json: -------------------------------------------------------------------------------- 1 | { "id": "cmpl-8Ly1VViQClDoYudPxbPqEISS5oTlj", "object": "text_completion", "created": 1700246309, "model": "gpt-3.5-turbo-instruct", "choices": [ { "text": "\n\nThe Pythagorean theorem states that in a right triangle, the square of the length of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two sides. This can be written as a^2 + b^2 = c^2, where c is the length of the hypotenuse and a and b are the lengths of the other two sides.", "index": 0, "logprobs": {"text_offset": [111, 222], "token_logprobs": [1.11, 2.22], "tokens": ["one", "two"], "top_logprobs": [[11.1, 22.2]]}, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 15, "completion_tokens": 85, "total_tokens": 100 } } -------------------------------------------------------------------------------- /src/test/resources/files_create.json: -------------------------------------------------------------------------------- 1 | { "object": "file", "id": "file-aU0dDrIU78PynduNICmpRPAw", "purpose": "fine-tune", "filename": "test_data.jsonl", "bytes": 2592, "created_at": 1693522494, "status": "uploaded", "status_details": null } -------------------------------------------------------------------------------- /src/test/resources/files_delete.json: -------------------------------------------------------------------------------- 1 | { "object": "file", "id": "file-K4lr4UcyXFXp7nfUWyzDlg8v", "deleted": true } -------------------------------------------------------------------------------- /src/test/resources/files_getlist.json: -------------------------------------------------------------------------------- 1 | { "object": "list", "data": [ { "object": "file", "id": "file-K4lr4UcyXFXp7nfUWyzDlg8v", "purpose": "fine-tune", "filename": "test_data.jsonl", "bytes": 269, "created_at": 1692570061, "status": "processed", "status_details": null } ] } -------------------------------------------------------------------------------- /src/test/resources/files_getone.json: -------------------------------------------------------------------------------- 1 | { "object": "file", "id": "file-K4lr4UcyXFXp7nfUWyzDlg8v", "purpose": "fine-tune", "filename": "test_data.jsonl", "bytes": 269, "created_at": 1692570061, "status": "processed", "status_details": null } -------------------------------------------------------------------------------- /src/test/resources/finetunings_cancel.json: -------------------------------------------------------------------------------- 1 | { "object": "fine_tuning.job", "id": "ftjob-KWKOSThKDkgcvl4Ws66NfHvo", "model": "gpt-3.5-turbo-0613", "created_at": 1693522638, "finished_at": null, "fine_tuned_model": null, "organization_id": "org-4WdgDKZ75eLPEH6zqX5hFd5e", "result_files": [], "status": "cancelled", "validation_file": null, "training_file": "file-aU0dDrIU78PynduNICmpRPAw", "hyperparameters": { "n_epochs": 10 }, "trained_tokens": null } -------------------------------------------------------------------------------- /src/test/resources/finetunings_create.json: -------------------------------------------------------------------------------- 1 | {"object":"fine_tuning.job","id":"ftjob-35j8EBrZVsuyFFe2OD8Tkmvd","model":"gpt-3.5-turbo-1106","created_at":1700533111,"finished_at":null,"fine_tuned_model":null,"organization_id":"org-4WdgDKZ75eLPEH6zqX5hFd5e","result_files":[],"status":"validating_files","validation_file":null,"training_file":"file-0e5BDWQYA1KsguTJRCCXqAa2","trained_tokens":null,"error":null,"integrations":[{"type":"wandb","wandb":{"project":"my-wandb-project","name":"ft-run-display-name","tags":["first-experiment","v2"]}}],"seed":99,"method":{"type":"supervised","supervised":{"hyperparameters":{"batch_size":"auto","learning_rate_multiplier":"auto","n_epochs":"auto"}}}} -------------------------------------------------------------------------------- /src/test/resources/finetunings_getcheckpoints.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"object":"fine_tuning.job.checkpoint","id":"ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB","created_at":1519129973,"fine_tuned_model_checkpoint":"ft:gpt-3.5-turbo-0125:my-org:custom-suffix:96olL566:ckpt-step-2000","metrics":{"full_valid_loss":0.134,"full_valid_mean_token_accuracy":0.874},"fine_tuning_job_id":"ftjob-abc123","step_number":2000},{"object":"fine_tuning.job.checkpoint","id":"ftckpt_enQCFmOTGj3syEpYVhBRLTSy","created_at":1519129833,"fine_tuned_model_checkpoint":"ft:gpt-3.5-turbo-0125:my-org:custom-suffix:7q8mpxmy:ckpt-step-1000","metrics":{"full_valid_loss":0.167,"full_valid_mean_token_accuracy":0.781},"fine_tuning_job_id":"ftjob-abc123","step_number":1000}],"first_id":"ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB","last_id":"ftckpt_enQCFmOTGj3syEpYVhBRLTSy","has_more":true} -------------------------------------------------------------------------------- /src/test/resources/finetunings_getevents.json: -------------------------------------------------------------------------------- 1 | { "object": "list", "data": [ { "object": "fine_tuning.job.event", "id": "ftevent-M73FMilTLFOs7CDqE1MW3q1m", "created_at": 1700533366, "level": "info", "message": "The job has successfully completed", "data": {}, "type": "message" }, { "object": "fine_tuning.job.event", "id": "ftevent-jxsfCQ77FixXGkmoooLA4UdE", "created_at": 1700533364, "level": "info", "message": "New fine-tuned model created: ft:gpt-3.5-turbo-1106:personal::8NAhPVlK", "data": {}, "type": "message" } ], "has_more": true } -------------------------------------------------------------------------------- /src/test/resources/finetunings_getlist.json: -------------------------------------------------------------------------------- 1 | { "object": "list", "data": [ { "object": "fine_tuning.job", "id": "ftjob-35j8EBrZVsuyFFe2OD8Tkmvd", "model": "gpt-3.5-turbo-1106", "created_at": 1700533111, "finished_at": null, "fine_tuned_model": null, "organization_id": "org-4WdgDKZ75eLPEH6zqX5hFd5e", "result_files": [], "status": "running", "validation_file": null, "training_file": "file-0e5BDWQYA1KsguTJRCCXqAa2", "hyperparameters": { "n_epochs": 10, "batch_size": 1, "learning_rate_multiplier": 2 }, "trained_tokens": null, "error": null }, { "object": "fine_tuning.job", "id": "ftjob-fL5z1zQZl4J8YIFke4oSMNAE", "model": "gpt-3.5-turbo-0613", "created_at": 1693622111, "finished_at": null, "fine_tuned_model": null, "organization_id": "org-4WdgDKZ75eLPEH6zqX5hFd5e", "result_files": [], "status": "cancelled", "validation_file": null, "training_file": "file-TbYoAf0bLugHngUHXA0OITPB", "hyperparameters": { "n_epochs": 10, "batch_size": 1, "learning_rate_multiplier": 2 }, "trained_tokens": null, "error": null }, { "object": "fine_tuning.job", "id": "ftjob-KWKOSThKDkgcvl4Ws66NfHvo", "model": "gpt-3.5-turbo-0613", "created_at": 1693522638, "finished_at": null, "fine_tuned_model": null, "organization_id": "org-4WdgDKZ75eLPEH6zqX5hFd5e", "result_files": [], "status": "cancelled", "validation_file": null, "training_file": "file-aU0dDrIU78PynduNICmpRPAw", "hyperparameters": { "n_epochs": 10, "batch_size": 1, "learning_rate_multiplier": 2 }, "trained_tokens": null, "error": null } ], "has_more": false } -------------------------------------------------------------------------------- /src/test/resources/finetunings_getone.json: -------------------------------------------------------------------------------- 1 | {"object":"fine_tuning.job","id":"ftjob-35j8EBrZVsuyFFe2OD8Tkmvd","model":"gpt-3.5-turbo-1106","created_at":1700533111,"finished_at":1700533362,"fine_tuned_model":"ft:gpt-3.5-turbo-1106:personal::8NAhPVlK","organization_id":"org-4WdgDKZ75eLPEH6zqX5hFd5e","result_files":["file-brNpFdh47xDizivX8ZMsOPo7"],"status":"succeeded","validation_file":null,"training_file":"file-0e5BDWQYA1KsguTJRCCXqAa2","hyperparameters":{"n_epochs":10,"batch_size":1,"learning_rate_multiplier":2},"trained_tokens":4790,"error":{"code":"a1b2c3","message":"sample error","param":"training_file"}} -------------------------------------------------------------------------------- /src/test/resources/images_create.json: -------------------------------------------------------------------------------- 1 | { "created": 1700537123, "data": [ { "revised_prompt": "Create an image of an adorable cartoon-style kitten with fluffy fur and bright, curious eyes. The kitten is in mid-air, having leaped energetically off the ground with its tiny paws outstretched. It is attempting to catch a round ball that is floating just out of its grasp. The ball is bright and bouncy, adding a playful element to the scene. The kitten looks determined and completely engrossed in its play. Set this lively scene against a neutral background to focus all the attention on the kitten's playful endeavors.", "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-4WdgDKZ75eLPEH6zqX5hFd5e/user-gYf5fGvHOBw8VL4qPKQYupOA/img-KE1fCp5AIpBlSM6S11908OG1.png?st=2023-11-21T02%3A25%3A23Z&se=2023-11-21T04%3A25%3A23Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-11-20T20%3A04%3A16Z&ske=2023-11-21T20%3A04%3A16Z&sks=b&skv=2021-08-06&sig=G8gX6Sdh%2BM049lmZuezozKIInPCY5tk9L/st2Rpuhsg%3D" } ] } -------------------------------------------------------------------------------- /src/test/resources/images_create_edits.json: -------------------------------------------------------------------------------- 1 | { "created": 1700537523, "data": [ { "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAAaGVYSWZNTQAqAAAACAACknwAAgAAACkAAAAmkoYAAgAAABgAAABQAAAAAE9wZW5BSS0tYzhlNDNkMmZhZmZkMTY1YjczZWQ3NGNkNjhkOTAyMTkAAE1hZGUgd2l0aCBPcGVuQUkgREFMTC1FAL9p8EgAAQAASURBVHgBACuB1H4B/P/+Af8AAAEAAP8AAAABAQEAAAAAAP8AAAH/AAAAAP8AAAEAAP8A/wEAAf8AAAAB/wD/AQAA/wEAAQAAAAAAAP8AAAEAAAAAAAAAAAAA/wD/AQABAAAAAAAA/wAAAQ" } ] } -------------------------------------------------------------------------------- /src/test/resources/images_create_variations.json: -------------------------------------------------------------------------------- 1 | { "created": 1700537812, "data": [ { "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAAaGVYSWZNTQAqAAAACAACknwAAgAAACkAAAAmkoYAAgAAABgAAABQAAAAAE9wZW5BSS0tZjk4NzE3MDUyYzliMWZkNTY4NTcwNTQzZjFmN2M5YmIAAE1hZGUgd2l0aCBPcGVuQUkgREFMTC1FAFXIOeIAAQAASURBVHgBACuB1H4BANywAAEBAAAAAAAAAAAAAAAAAAAAAQAA//8AAAAAAAAAAAAAAAAAAAD/AAABAAAAAAEAAAD/AP8BAQEA/wAAAAD/AAABAP8AAAEAAAEAAP8AAAAAAAAAAAAAAAA" } ] } -------------------------------------------------------------------------------- /src/test/resources/mistral_body_actual.json: -------------------------------------------------------------------------------- 1 | {"messages":[{"role":"user","content":"What is the product of 123 and 456?"},{"role":"assistant","content":null,"tool_calls":[{"index":null,"id":"call_83EGwRvtPRUOQUsr3jGyHxAr","type":"function","function":{"name":"product","arguments":"{\"multiplicand\":123,\"multiplier\":456}"}}],"refusal":null,"audio":null},{"role":"tool","content":"56088.0","tool_call_id":"call_83EGwRvtPRUOQUsr3jGyHxAr"}],"model":"gpt-4o-mini","stream":true,"stream_options":{"include_usage":true},"temperature":0.0,"tools":[{"type":"function","function":{"name":"product","description":"Get the product of two numbers","parameters":{"type":"object","properties":{"multiplicand":{"type":"number","description":"The multiplicand part of a product"},"multiplier":{"type":"number","description":"The multiplier part of a product"}},"required":["multiplicand","multiplier"],"additionalProperties":false},"strict":true}}],"tool_choice":"auto"} -------------------------------------------------------------------------------- /src/test/resources/mistral_body_expected.json: -------------------------------------------------------------------------------- 1 | {"messages":[{"role":"user","content":"What is the product of 123 and 456?"},{"role":"assistant","content":null,"tool_calls":[{"id":"call_83EGwRvtPRUOQUsr3jGyHxAr","type":"function","function":{"name":"product","arguments":"{\"multiplicand\":123,\"multiplier\":456}"}}]},{"role":"tool","content":"56088.0","tool_call_id":"call_83EGwRvtPRUOQUsr3jGyHxAr"}],"model":"gpt-4o-mini","stream":true,"temperature":0.0,"tools":[{"type":"function","function":{"name":"product","description":"Get the product of two numbers","parameters":{"type":"object","properties":{"multiplicand":{"type":"number","description":"The multiplicand part of a product"},"multiplier":{"type":"number","description":"The multiplier part of a product"}},"required":["multiplicand","multiplier"]}}}],"tool_choice":"auto"} -------------------------------------------------------------------------------- /src/test/resources/models_delete.json: -------------------------------------------------------------------------------- 1 | { "id": "ft:gpt-3.5-turbo:acemeco:suffix:abc123", "object": "model", "deleted": true } -------------------------------------------------------------------------------- /src/test/resources/models_getone.json: -------------------------------------------------------------------------------- 1 | { "id": "gpt-3.5-turbo-16k-0613", "object": "model", "created": 1685474247, "owned_by": "openai" } -------------------------------------------------------------------------------- /src/test/resources/moderations_create.json: -------------------------------------------------------------------------------- 1 | {"id":"modr-54b348307a50d65c6ddf0fe06740de36","model":"omni-moderation-latest","results":[{"flagged":true,"categories":{"harassment":true,"harassment/threatening":false,"sexual":false,"hate":false,"hate/threatening":false,"illicit":false,"illicit/violent":false,"self-harm/intent":false,"self-harm/instructions":false,"self-harm":false,"sexual/minors":false,"violence":true,"violence/graphic":false},"category_scores":{"harassment":0.5251772927497116,"harassment/threatening":0.35028141621957487,"sexual":0.00003569706350376584,"hate":0.02052794114568215,"hate/threatening":0.02355716044575803,"illicit":0.0944491767645023,"illicit/violent":0.04428039440389808,"self-harm/intent":0.00029646735560663617,"self-harm/instructions":3.8831109868779005e-6,"self-harm":0.004672062660465444,"sexual/minors":1.7778551863194697e-6,"violence":0.999850466154669,"violence/graphic":0.0015940995729907183},"category_applied_input_types":{"harassment":["text"],"harassment/threatening":["text"],"sexual":["text","image"],"hate":["text"],"hate/threatening":["text"],"illicit":["text"],"illicit/violent":["text"],"self-harm/intent":["text","image"],"self-harm/instructions":["text","image"],"self-harm":["text","image"],"sexual/minors":["text"],"violence":["text","image"],"violence/graphic":["text","image"]}}]} -------------------------------------------------------------------------------- /src/test/resources/response_create.json: -------------------------------------------------------------------------------- 1 | {"id":"resp_6829197b77b48198ac4e3863417459c100c150e1f0636eee","object":"response","created_at":1747523963,"status":"completed","error":null,"incomplete_details":null,"instructions":"You are a helpful tutor in Maths.","max_output_tokens":null,"model":"gpt-4o-mini-2024-07-18","output":[{"id":"msg_6829197bcb848198afda989691b089ca00c150e1f0636eee","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"text":"Thales' theorem states that if A, B, and C are points on a circle where the line segment AB is the diameter, then the angle ∠ACB is a right angle (90 degrees). This means that any triangle inscribed in a circle with one side as the diameter will always have a right angle opposite that side. This theorem is fundamental in geometry and is often used to prove properties of circles and triangles."}],"role":"assistant"}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"service_tier":"default","store":true,"temperature":0.1,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":{"input_tokens":33,"input_tokens_details":{"cached_tokens":0},"output_tokens":87,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":120},"user":null,"metadata":{}} -------------------------------------------------------------------------------- /src/test/resources/response_create_codeinterpreter.json: -------------------------------------------------------------------------------- 1 | {"id":"resp_6840fbadd184819baabc80f7daff943700bfd8a63a50b755","object":"response","created_at":1749089197,"status":"completed","background":false,"error":null,"incomplete_details":null,"instructions":"You are a personal math tutor. When asked a math question, write and run code to answer the question.","max_output_tokens":null,"model":"gpt-4o-mini-2024-07-18","output":[{"id":"ci_6840fbb06e74819ba1b8cdeea3be86de00bfd8a63a50b755","type":"code_interpreter_call","status":"completed","code":"import numpy as np\r\n\r\n# Coefficients of the equation 6x² + 5x - 6\r\na = 6\r\nb = 5\r\nc = -6\r\n\r\n# Using the quadratic formula to find the roots\r\ndiscriminant = b**2 - 4*a*c\r\nroot1 = (-b + np.sqrt(discriminant)) / (2*a)\r\nroot2 = (-b - np.sqrt(discriminant)) / (2*a)\r\n\r\nroot1, root2","container_id":"cntr_6840fbafa64081989dd5a7819dd70972092449435e241195","outputs":null},{"id":"msg_6840fbb7ae40819bac24dd1c1dfa985500bfd8a63a50b755","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"text":"The solutions to the equation \\(6x^2 + 5x - 6 = 0\\) are:\n\n- \\(x_1 \\approx 0.67\\)\n- \\(x_2 = -1.5\\)"}],"role":"assistant"}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"service_tier":"default","store":true,"temperature":0.1,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[{"type":"code_interpreter","container":{"type":"auto"}}],"top_p":1.0,"truncation":"disabled","usage":{"input_tokens":436,"input_tokens_details":{"cached_tokens":0},"output_tokens":158,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":594},"user":null,"metadata":{}} -------------------------------------------------------------------------------- /src/test/resources/response_create_vision.json: -------------------------------------------------------------------------------- 1 | {"id":"resp_682911c40fa481988d4bfc5474ebe2b10595fd579b6d1dc3","object":"response","created_at":1747521988,"status":"completed","error":null,"incomplete_details":null,"instructions":"You are a helpful tour guide.","max_output_tokens":null,"model":"gpt-4o-mini-2024-07-18","output":[{"id":"msg_682911c628308198930996010916de0a0595fd579b6d1dc3","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"text":"The image showcases the iconic ruins of Machu Picchu, nestled high in the Andes Mountains of Peru. The ancient Incan city features well-preserved stone structures, terraced fields, and pathways, all surrounded by lush greenery and dramatic mountain peaks. The sky is partly cloudy, casting a serene light over the site, enhancing its mystical atmosphere. The combination of historical architecture and breathtaking natural scenery makes Machu Picchu a UNESCO World Heritage site and a popular destination for travelers seeking adventure and cultural exploration."}],"role":"assistant"}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"service_tier":"default","store":true,"temperature":0.1,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":{"input_tokens":36872,"input_tokens_details":{"cached_tokens":0},"output_tokens":101,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":36973},"user":null,"metadata":{}} -------------------------------------------------------------------------------- /src/test/resources/response_delete.json: -------------------------------------------------------------------------------- 1 | {"id":"resp_682350f8a4288198b868ff7152e2ad290f8c61fb2344d013","object":"response.deleted","deleted":true} -------------------------------------------------------------------------------- /src/test/resources/response_getone.json: -------------------------------------------------------------------------------- 1 | {"id":"resp_682350f8a4288198b868ff7152e2ad290f8c61fb2344d013","object":"response","created_at":1747144952,"status":"completed","error":null,"incomplete_details":null,"instructions":"You are a helpful tutor in Maths.","max_output_tokens":null,"model":"gpt-4o-mini-2024-07-18","output":[{"id":"msg_682350f91e8c819885b3a39707d5d9570f8c61fb2344d013","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"text":"Euclid's Theorem states that there are infinitely many prime numbers. It can be demonstrated by assuming a finite list of primes, multiplying them together, and adding one. The resulting number is either prime itself or has prime factors not in the original list, contradicting the assumption of finiteness. Thus, primes cannot be limited to a finite set, proving their infinitude."}],"role":"assistant"}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"service_tier":"default","store":true,"temperature":0.1,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":{"input_tokens":35,"input_tokens_details":{"cached_tokens":0},"output_tokens":77,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":112},"user":null,"metadata":{}} -------------------------------------------------------------------------------- /src/test/resources/response_listinputitems.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"id":"msg_682350fae65081989a3c53847906363a08875bd3a08cd0e8","type":"message","status":"completed","content":[{"type":"input_text","text":"Explain me the Euclides Theorem in no more than 100 words."}],"role":"user"}],"first_id":"msg_682350fae65081989a3c53847906363a08875bd3a08cd0e8","has_more":false,"last_id":"msg_682350fae65081989a3c53847906363a08875bd3a08cd0e8"} -------------------------------------------------------------------------------- /src/test/resources/sessiontokens_create.json: -------------------------------------------------------------------------------- 1 | {"id":"sess_BsH4Tg3xUTOoPrEwcSKXJ","object":"realtime.session","expires_at":0,"input_audio_noise_reduction":null,"turn_detection":{"type":"server_vad","threshold":0.5,"prefix_padding_ms":300,"silence_duration_ms":200,"create_response":true,"interrupt_response":true},"input_audio_format":"pcm16","input_audio_transcription":null,"client_secret":{"value":"ek_68719859dde08191a5386c6b0263b48b","expires_at":1752275043},"include":null,"model":"gpt-4o-mini-realtime-preview","modalities":["audio","text"],"instructions":"You are a friendly assistant.","voice":"coral","output_audio_format":"pcm16","tool_choice":"auto","temperature":0.8,"max_response_output_tokens":300,"speed":1.0,"tracing":null,"tools":[]} -------------------------------------------------------------------------------- /src/test/resources/sessiontokens_transcription_create.json: -------------------------------------------------------------------------------- 1 | {"id":"sess_BsCecsDtGprLzHGgfKR0X","object":"realtime.transcription_session","expires_at":0,"input_audio_noise_reduction":{"type":"near_field"},"turn_detection":{"type":"semantic_vad","eagerness":"medium"},"input_audio_format":"pcm16","input_audio_transcription":null,"client_secret":{"value":"ek_687156067ae48191b7cecd56973242fa","expires_at":1752258064},"include":["item.input_audio_transcription.logprobs"]} -------------------------------------------------------------------------------- /src/test/resources/threads__create.json: -------------------------------------------------------------------------------- 1 | {"id":"thread_TUTv6fLdqSHLsCerxrmtSBRP","object":"thread","created_at":1714510029,"metadata":{"env":"test"},"tool_resources":{"file_search":{"vector_store_ids":["vs_Q4pV0bKeXBsIy8ap4TSbDHLS"]}}} -------------------------------------------------------------------------------- /src/test/resources/threads__delete.json: -------------------------------------------------------------------------------- 1 | {"id":"thread_TUTv6fLdqSHLsCerxrmtSBRP","object":"thread.deleted","deleted":true} -------------------------------------------------------------------------------- /src/test/resources/threads__getone.json: -------------------------------------------------------------------------------- 1 | {"id":"thread_TUTv6fLdqSHLsCerxrmtSBRP","object":"thread","created_at":1714510029,"metadata":{"env":"test","user":"thomas"},"tool_resources":{"file_search":{"vector_store_ids":["vs_Q4pV0bKeXBsIy8ap4TSbDHLS"]},"code_interpreter":{"file_ids":[]}}} -------------------------------------------------------------------------------- /src/test/resources/threads__modify.json: -------------------------------------------------------------------------------- 1 | {"id":"thread_TUTv6fLdqSHLsCerxrmtSBRP","object":"thread","created_at":1714510029,"metadata":{"env":"test","user":"thomas"},"tool_resources":{"file_search":{"vector_store_ids":["vs_Q4pV0bKeXBsIy8ap4TSbDHLS"]}}} -------------------------------------------------------------------------------- /src/test/resources/threads_messages_create.json: -------------------------------------------------------------------------------- 1 | {"id":"msg_w7i1RK9p3ooxMSvltWGXMia5","object":"thread.message","created_at":1714864442,"assistant_id":null,"thread_id":"thread_B44c9yFcrj0gnTZDO0axS1Qy","run_id":null,"role":"user","content":[{"type":"text","text":{"value":"Please, tell me what an LLM is?","annotations":[]}}],"attachments":[{"file_id":"file-23bwLoBgZkxIx6n5GYJNgWQe","tools":[{"type":"file_search"}]}],"metadata":{"item":"first"}} -------------------------------------------------------------------------------- /src/test/resources/threads_messages_create_vision.json: -------------------------------------------------------------------------------- 1 | {"id":"msg_kspC53sGug90y3a7sLmdjqGx","object":"thread.message","created_at":1715406241,"assistant_id":null,"thread_id":"thread_ury8vAUDoxfjmUDwRoaa5yPV","run_id":null,"role":"user","content":[{"type":"text","text":{"value":"Do you see any similarity or difference between the attached images?","annotations":[]}},{"type":"image_file","image_file":{"file_id":"file-TBaGv9GEvJ9DOhHf7AuDqvKf","detail":"low"}},{"type":"image_url","image_url":{"url":"https://upload.wikimedia.org/wikipedia/commons/e/eb/Machu_Picchu%2C_Peru.jpg","detail":"low"}}],"attachments":[],"metadata":{}} -------------------------------------------------------------------------------- /src/test/resources/threads_messages_delete.json: -------------------------------------------------------------------------------- 1 | {"id":"msg_w7i1RK9p3ooxMSvltWGXMia5","object":"thread.message.deleted","deleted":true} -------------------------------------------------------------------------------- /src/test/resources/threads_messages_getlist.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"id":"msg_w7i1RK9p3ooxMSvltWGXMia5","object":"thread.message","created_at":1714864442,"assistant_id":null,"thread_id":"thread_B44c9yFcrj0gnTZDO0axS1Qy","run_id":null,"role":"user","content":[{"type":"text","text":{"value":"Please, tell me what an LLM is?","annotations":[]}}],"attachments":[{"file_id":"file-23bwLoBgZkxIx6n5GYJNgWQe","tools":[{"type":"file_search"}]}],"metadata":{"item":"firstly","user":"dummy"}}],"first_id":"msg_w7i1RK9p3ooxMSvltWGXMia5","last_id":"msg_w7i1RK9p3ooxMSvltWGXMia5","has_more":false} -------------------------------------------------------------------------------- /src/test/resources/threads_messages_getone.json: -------------------------------------------------------------------------------- 1 | {"id":"msg_w7i1RK9p3ooxMSvltWGXMia5","object":"thread.message","created_at":1714864442,"assistant_id":null,"thread_id":"thread_B44c9yFcrj0gnTZDO0axS1Qy","run_id":null,"role":"user","content":[{"type":"text","text":{"value":"Please, tell me what an LLM is?","annotations":[]}}],"attachments":[{"file_id":"file-23bwLoBgZkxIx6n5GYJNgWQe","tools":[{"type":"file_search"}]}],"metadata":{"item":"firstly","user":"dummy"}} -------------------------------------------------------------------------------- /src/test/resources/threads_messages_modify.json: -------------------------------------------------------------------------------- 1 | {"id":"msg_w7i1RK9p3ooxMSvltWGXMia5","object":"thread.message","created_at":1714864442,"assistant_id":null,"thread_id":"thread_B44c9yFcrj0gnTZDO0axS1Qy","run_id":null,"role":"user","content":[{"type":"text","text":{"value":"Please, tell me what an LLM is?","annotations":[]}}],"file_ids":[],"metadata":{"item":"firstly","user":"dummy"}} -------------------------------------------------------------------------------- /src/test/resources/threads_runs_cancel_1.json: -------------------------------------------------------------------------------- 1 | {"id":"run_nsBWVGXtYo8yo8ckoGOxHlNQ","object":"thread.run","created_at":1714853381,"assistant_id":"asst_eC1BeXfmDfbyiSB79WewXLw9","thread_id":"thread_DWFcoAFxKqpNR8MKplqFREzl","status":"queued","started_at":null,"expires_at":1714853981,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"function","function":{"name":"CurrentTemperature","description":"Get the current temperature for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"},"unit":{"type":"string","description":"The temperature unit to use. Infer this from the user's location."}},"required":["location","unit"]}}},{"type":"function","function":{"name":"RainProbability","description":"Get the probability of rain for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"}},"required":["location"]}}},{"type":"file_search"}],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto"} -------------------------------------------------------------------------------- /src/test/resources/threads_runs_cancel_2.json: -------------------------------------------------------------------------------- 1 | {"id":"run_nsBWVGXtYo8yo8ckoGOxHlNQ","object":"thread.run","created_at":1714853381,"assistant_id":"asst_eC1BeXfmDfbyiSB79WewXLw9","thread_id":"thread_DWFcoAFxKqpNR8MKplqFREzl","status":"cancelling","started_at":1714853381,"expires_at":1714853981,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"function","function":{"name":"CurrentTemperature","description":"Get the current temperature for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"},"unit":{"type":"string","description":"The temperature unit to use. Infer this from the user's location."}},"required":["location","unit"]}}},{"type":"function","function":{"name":"RainProbability","description":"Get the probability of rain for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"}},"required":["location"]}}},{"type":"file_search"}],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto"} -------------------------------------------------------------------------------- /src/test/resources/threads_runs_create_1.json: -------------------------------------------------------------------------------- 1 | {"id":"run_HVCe4TdJoYM7cO7Glk1GJAUS","object":"thread.run","created_at":1714853344,"assistant_id":"asst_eC1BeXfmDfbyiSB79WewXLw9","thread_id":"thread_DWFcoAFxKqpNR8MKplqFREzl","status":"completed","started_at":1714853345,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1714853352,"required_action":null,"last_error":null,"model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"function","function":{"name":"CurrentTemperature","description":"Get the current temperature for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"},"unit":{"type":"string","description":"The temperature unit to use. Infer this from the user's location."}},"required":["location","unit"]}}},{"type":"function","function":{"name":"RainProbability","description":"Get the probability of rain for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"}},"required":["location"]}}},{"type":"file_search"}],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":957,"completion_tokens":206,"total_tokens":1163},"response_format":"auto","tool_choice":"auto"} -------------------------------------------------------------------------------- /src/test/resources/threads_runs_createthreadandrun_1.json: -------------------------------------------------------------------------------- 1 | {"id":"run_Zcxqg8WyIorSNS1l9X8JzuDP","object":"thread.run","created_at":1714853367,"assistant_id":"asst_eC1BeXfmDfbyiSB79WewXLw9","thread_id":"thread_6BG0CaeLlQkvDMLBEhT87plo","status":"completed","started_at":1714853367,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1714853373,"required_action":null,"last_error":null,"model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"function","function":{"name":"CurrentTemperature","description":"Get the current temperature for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"},"unit":{"type":"string","description":"The temperature unit to use. Infer this from the user's location."}},"required":["location","unit"]}}},{"type":"function","function":{"name":"RainProbability","description":"Get the probability of rain for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"}},"required":["location"]}}},{"type":"file_search"}],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":2390,"completion_tokens":123,"total_tokens":2513},"response_format":"auto","tool_choice":"auto"} -------------------------------------------------------------------------------- /src/test/resources/threads_runs_createthreadandrun_2.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"id":"msg_sVOA35ABPelCoSweUU80knVO","object":"thread.message","created_at":1714853370,"assistant_id":"asst_eC1BeXfmDfbyiSB79WewXLw9","thread_id":"thread_6BG0CaeLlQkvDMLBEhT87plo","run_id":"run_Zcxqg8WyIorSNS1l9X8JzuDP","role":"assistant","content":[{"type":"text","text":{"value":"The main focus of Mistral AI is on producing open-source large language models. This approach was adopted in response to proprietary models and is rooted in the importance of open-source software in the AI field【4:0†source】.\n\nRegarding models available from Mistral AI, there are currently two models that have been published and are available as weights. Additionally, three more models, categorized as Small, Medium, and Large, are only accessible via API【4:0†source】.","annotations":[{"type":"file_citation","text":"【4:0†source】","start_index":211,"end_index":223,"file_citation":{"file_id":"file-yDzn4s5jTYUHorlAIFCOrqP0"}},{"type":"file_citation","text":"【4:0†source】","start_index":457,"end_index":469,"file_citation":{"file_id":"file-yDzn4s5jTYUHorlAIFCOrqP0"}}]}}],"attachments":[],"metadata":{}},{"id":"msg_C9eXQia4XE59BLiYg41Q4MZv","object":"thread.message","created_at":1714853367,"assistant_id":null,"thread_id":"thread_6BG0CaeLlQkvDMLBEhT87plo","run_id":null,"role":"user","content":[{"type":"text","text":{"value":"What's the main focus of Mistral and what models are available?.","annotations":[]}}],"attachments":[],"metadata":{}}],"first_id":"msg_sVOA35ABPelCoSweUU80knVO","last_id":"msg_C9eXQia4XE59BLiYg41Q4MZv","has_more":false} -------------------------------------------------------------------------------- /src/test/resources/threads_runs_getone.json: -------------------------------------------------------------------------------- 1 | {"id":"run_HVCe4TdJoYM7cO7Glk1GJAUS","object":"thread.run","created_at":1714853344,"assistant_id":"asst_eC1BeXfmDfbyiSB79WewXLw9","thread_id":"thread_DWFcoAFxKqpNR8MKplqFREzl","status":"completed","started_at":1714853345,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1714853352,"required_action":null,"last_error":null,"model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"function","function":{"name":"CurrentTemperature","description":"Get the current temperature for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"},"unit":{"type":"string","description":"The temperature unit to use. Infer this from the user's location."}},"required":["location","unit"]}}},{"type":"function","function":{"name":"RainProbability","description":"Get the probability of rain for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"}},"required":["location"]}}},{"type":"file_search"}],"tool_resources":{},"metadata":{"user":"tom","env":"test"},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":957,"completion_tokens":206,"total_tokens":1163},"response_format":"auto","tool_choice":"auto"} -------------------------------------------------------------------------------- /src/test/resources/threads_runs_modify.json: -------------------------------------------------------------------------------- 1 | {"id":"run_HVCe4TdJoYM7cO7Glk1GJAUS","object":"thread.run","created_at":1714853344,"assistant_id":"asst_eC1BeXfmDfbyiSB79WewXLw9","thread_id":"thread_DWFcoAFxKqpNR8MKplqFREzl","status":"completed","started_at":1714853345,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1714853352,"required_action":null,"last_error":null,"model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"function","function":{"name":"CurrentTemperature","description":"Get the current temperature for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"},"unit":{"type":"string","description":"The temperature unit to use. Infer this from the user's location."}},"required":["location","unit"]}}},{"type":"function","function":{"name":"RainProbability","description":"Get the probability of rain for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"}},"required":["location"]}}},{"type":"file_search"}],"tool_resources":{},"metadata":{"user":"tom","env":"test"},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":957,"completion_tokens":206,"total_tokens":1163},"response_format":"auto","tool_choice":"auto"} -------------------------------------------------------------------------------- /src/test/resources/threads_runs_submittool_2.json: -------------------------------------------------------------------------------- 1 | {"id":"run_qVE9pbL2MBKO98fKNgxYuYpn","object":"thread.run","created_at":1714853358,"assistant_id":"asst_eC1BeXfmDfbyiSB79WewXLw9","thread_id":"thread_DWFcoAFxKqpNR8MKplqFREzl","status":"completed","started_at":1714853361,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1714853362,"required_action":null,"last_error":null,"model":"gpt-4-turbo","instructions":"You are a very kind assistant. If you cannot find correct facts to answer the questions, you have to refer to the attached files or use the functions provided. Finally, if you receive math questions, you must write and run code to answer them.","tools":[{"type":"function","function":{"name":"CurrentTemperature","description":"Get the current temperature for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"},"unit":{"type":"string","description":"The temperature unit to use. Infer this from the user's location."}},"required":["location","unit"]}}},{"type":"function","function":{"name":"RainProbability","description":"Get the probability of rain for a specific location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g., San Francisco, CA"}},"required":["location"]}}},{"type":"file_search"}],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":2651,"completion_tokens":39,"total_tokens":2690},"response_format":"auto","tool_choice":"auto"} -------------------------------------------------------------------------------- /src/test/resources/threads_runssteps_getlist.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"id":"step_fx5UxUjv5T5ablTZYuDwuEpt","object":"thread.run.step","created_at":1714699420,"run_id":"run_JKmOcE0VZEJZmqhM2HbCV4Pp","assistant_id":"asst_FsmmcDFkc6Yyd8mUrUCnTdoF","thread_id":"thread_xdglhpPxcInvcm4An3u3LOIP","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1714700010,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[{"id":"call_Q3gAARBsPdovB2i2l1dr2aHX","type":"function","function":{"name":"CurrentTemperature","arguments":"{\"location\": \"Lima, Peru\", \"unit\": \"C\"}","output":null}},{"id":"call_Km7HAgm0xXDK5rTtLOjWBGoe","type":"function","function":{"name":"RainProbability","arguments":"{\"location\": \"Lima, Peru\"}","output":null}}]},"usage":null},{"id":"step_79MjAyB3mMXHgrvEoaVen1R0","object":"thread.run.step","created_at":1714699413,"run_id":"run_JKmOcE0VZEJZmqhM2HbCV4Pp","assistant_id":"asst_FsmmcDFkc6Yyd8mUrUCnTdoF","thread_id":"thread_xdglhpPxcInvcm4An3u3LOIP","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1714699420,"expires_at":1714700010,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_JiAtD1jn9PxQ9lFAjMTElgBm"}},"usage":{"prompt_tokens":392,"completion_tokens":117,"total_tokens":509}}],"first_id":"step_fx5UxUjv5T5ablTZYuDwuEpt","last_id":"step_79MjAyB3mMXHgrvEoaVen1R0","has_more":false} -------------------------------------------------------------------------------- /src/test/resources/threads_runssteps_getone.json: -------------------------------------------------------------------------------- 1 | {"id":"step_fx5UxUjv5T5ablTZYuDwuEpt","object":"thread.run.step","created_at":1714699420,"run_id":"run_JKmOcE0VZEJZmqhM2HbCV4Pp","assistant_id":"asst_FsmmcDFkc6Yyd8mUrUCnTdoF","thread_id":"thread_xdglhpPxcInvcm4An3u3LOIP","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1714700010,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[{"id":"call_Q3gAARBsPdovB2i2l1dr2aHX","type":"function","function":{"name":"CurrentTemperature","arguments":"{\"location\": \"Lima, Peru\", \"unit\": \"C\"}","output":null}},{"id":"call_Km7HAgm0xXDK5rTtLOjWBGoe","type":"function","function":{"name":"RainProbability","arguments":"{\"location\": \"Lima, Peru\"}","output":null}}]},"usage":null} -------------------------------------------------------------------------------- /src/test/resources/threads_runssteps_getunknown_tool.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"id":"step_fx5UxUjv5T5ablTZYuDwuEpt","object":"thread.run.step","created_at":1714699420,"run_id":"run_JKmOcE0VZEJZmqhM2HbCV4Pp","assistant_id":"asst_FsmmcDFkc6Yyd8mUrUCnTdoF","thread_id":"thread_xdglhpPxcInvcm4An3u3LOIP","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1714700010,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[{"id":"call_Q3gAARBsPdovB2i2l1dr2aHX","type":"function","function":{"name":"CurrentTemperature","arguments":"{\"location\": \"Lima, Peru\", \"unit\": \"C\"}","output":null}},{"id":"call_rwX78tZl6MzaPfNMYu5fFsQD","type":"browser","browser":{}}]},"usage":null},{"id":"step_79MjAyB3mMXHgrvEoaVen1R0","object":"thread.run.step","created_at":1714699413,"run_id":"run_JKmOcE0VZEJZmqhM2HbCV4Pp","assistant_id":"asst_FsmmcDFkc6Yyd8mUrUCnTdoF","thread_id":"thread_xdglhpPxcInvcm4An3u3LOIP","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1714699420,"expires_at":1714700010,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_JiAtD1jn9PxQ9lFAjMTElgBm"}},"usage":{"prompt_tokens":392,"completion_tokens":117,"total_tokens":509}}],"first_id":"step_fx5UxUjv5T5ablTZYuDwuEpt","last_id":"step_79MjAyB3mMXHgrvEoaVen1R0","has_more":false} -------------------------------------------------------------------------------- /src/test/resources/uploads_add_part.json: -------------------------------------------------------------------------------- 1 | {"id":"part_6Jtu0dgFKKJcqZD7W8AjYNBp","object":"upload.part","created_at":1721510071,"upload_id":"upload_evo3LXvUbhjjwTzluS7HmLVK"} -------------------------------------------------------------------------------- /src/test/resources/uploads_cancel.json: -------------------------------------------------------------------------------- 1 | {"id":"upload_DSulbCDVm0KmatTxopmPWJhB","object":"upload","bytes":4658052,"created_at":1721510076,"filename":"constitucion_politica_peru_2024.pdf.tmp","purpose":"assistants","status":"cancelled","expires_at":1721513676} -------------------------------------------------------------------------------- /src/test/resources/uploads_complete.json: -------------------------------------------------------------------------------- 1 | {"id":"upload_evo3LXvUbhjjwTzluS7HmLVK","object":"upload","bytes":4658052,"created_at":1721510071,"filename":"constitucion_politica_peru_2024.pdf","purpose":"assistants","status":"completed","expires_at":1721513671,"file":{"object":"file","id":"file-1mR6ZyidvlbSCoe9hqjFA16C","purpose":"assistants","filename":"constitucion_politica_peru_2024.pdf","bytes":4658052,"created_at":1721510071,"status":"processed","status_details":null}} -------------------------------------------------------------------------------- /src/test/resources/uploads_create.json: -------------------------------------------------------------------------------- 1 | {"id":"upload_evo3LXvUbhjjwTzluS7HmLVK","object":"upload","bytes":4658052,"created_at":1721510071,"filename":"constitucion_politica_peru_2024.pdf","purpose":"assistants","status":"pending","expires_at":1721513671} -------------------------------------------------------------------------------- /src/test/resources/vector_store__create.json: -------------------------------------------------------------------------------- 1 | {"id":"vs_MBLs9nJ2o98DounBJ5PzCTQ7","object":"vector_store","name":"Demo Vector Store","status":"completed","usage_bytes":1615,"created_at":1714527686,"file_counts":{"in_progress":0,"completed":1,"failed":0,"cancelled":0,"total":1},"metadata":{"env":"test"},"expires_after":{"anchor":"last_active_at","days":1},"expires_at":1714614086,"last_active_at":1714527686} -------------------------------------------------------------------------------- /src/test/resources/vector_store__delete.json: -------------------------------------------------------------------------------- 1 | {"id":"vs_MBLs9nJ2o98DounBJ5PzCTQ7","object":"vector_store.deleted","deleted":true} -------------------------------------------------------------------------------- /src/test/resources/vector_store__getlist.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"id":"vs_MBLs9nJ2o98DounBJ5PzCTQ7","object":"vector_store","name":"Demonstration Vector Store","status":"completed","usage_bytes":1615,"created_at":1714527686,"file_counts":{"in_progress":0,"completed":1,"failed":0,"cancelled":0,"total":1},"metadata":{"env":"test","user":"mary"},"expires_after":{"anchor":"last_active_at","days":1},"expires_at":1714614089,"last_active_at":1714527689}],"first_id":"vs_MBLs9nJ2o98DounBJ5PzCTQ7","last_id":"vs_MBLs9nJ2o98DounBJ5PzCTQ7","has_more":false} -------------------------------------------------------------------------------- /src/test/resources/vector_store__getone.json: -------------------------------------------------------------------------------- 1 | {"id":"vs_MBLs9nJ2o98DounBJ5PzCTQ7","object":"vector_store","name":"Demonstration Vector Store","status":"completed","usage_bytes":1615,"created_at":1714527686,"file_counts":{"in_progress":0,"completed":1,"failed":0,"cancelled":0,"total":1},"metadata":{"env":"test","user":"mary"},"expires_after":{"anchor":"last_active_at","days":1},"expires_at":1714614089,"last_active_at":1714527689} -------------------------------------------------------------------------------- /src/test/resources/vector_store__modify.json: -------------------------------------------------------------------------------- 1 | {"id":"vs_MBLs9nJ2o98DounBJ5PzCTQ7","object":"vector_store","name":"Demonstration Vector Store","status":"completed","usage_bytes":1615,"created_at":1714527686,"file_counts":{"in_progress":0,"completed":1,"failed":0,"cancelled":0,"total":1},"metadata":{"env":"test","user":"mary"},"expires_after":{"anchor":"last_active_at","days":1},"expires_at":1714614089,"last_active_at":1714527689} -------------------------------------------------------------------------------- /src/test/resources/vector_store_file__create.json: -------------------------------------------------------------------------------- 1 | {"id":"file-odcbXdF4ZO6s1q2YvpYXRYT1","object":"vector_store.file","usage_bytes":1615,"created_at":1718845704,"vector_store_id":"vs_T05KbzT4HmfHwgFSnjHAQmJ3","status":"completed","last_error":null,"chunking_strategy":{"type":"static","static":{"max_chunk_size_tokens":800,"chunk_overlap_tokens":400}}} -------------------------------------------------------------------------------- /src/test/resources/vector_store_file__delete.json: -------------------------------------------------------------------------------- 1 | {"id":"file-sBzwQZrFTl3xlFnbYLEg1OB9","object":"vector_store.file.deleted","deleted":true} -------------------------------------------------------------------------------- /src/test/resources/vector_store_file__getlist.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"id":"file-odcbXdF4ZO6s1q2YvpYXRYT1","object":"vector_store.file","usage_bytes":1615,"created_at":1718845704,"vector_store_id":"vs_T05KbzT4HmfHwgFSnjHAQmJ3","status":"completed","last_error":null,"chunking_strategy":{"type":"static","static":{"max_chunk_size_tokens":800,"chunk_overlap_tokens":400}}}],"first_id":"file-odcbXdF4ZO6s1q2YvpYXRYT1","last_id":"file-odcbXdF4ZO6s1q2YvpYXRYT1","has_more":false} -------------------------------------------------------------------------------- /src/test/resources/vector_store_file__getone.json: -------------------------------------------------------------------------------- 1 | {"id":"file-odcbXdF4ZO6s1q2YvpYXRYT1","object":"vector_store.file","usage_bytes":1615,"created_at":1718845704,"vector_store_id":"vs_T05KbzT4HmfHwgFSnjHAQmJ3","status":"completed","last_error":null,"chunking_strategy":{"type":"static","static":{"max_chunk_size_tokens":800,"chunk_overlap_tokens":400}}} -------------------------------------------------------------------------------- /src/test/resources/vector_store_file_batch_cancel.json: -------------------------------------------------------------------------------- 1 | {"id":"vsfb_c5182bb7493746718ab62df039e173e6","object":"vector_store.file_batch","created_at":1714598092,"status":"completed","vector_store_id":"vs_zlZstoxCwDwdebrkRYw495e0","file_counts":{"in_progress":0,"completed":2,"failed":0,"cancelled":0,"total":2}} -------------------------------------------------------------------------------- /src/test/resources/vector_store_file_batch_create.json: -------------------------------------------------------------------------------- 1 | {"id":"vsfb_4464ab366e7b424d8101756ee87bdb8c","object":"vector_store.file_batch","created_at":1714598090,"status":"completed","vector_store_id":"vs_zlZstoxCwDwdebrkRYw495e0","file_counts":{"in_progress":0,"completed":2,"failed":0,"cancelled":0,"total":2}} -------------------------------------------------------------------------------- /src/test/resources/vector_store_file_batch_getfiles.json: -------------------------------------------------------------------------------- 1 | {"object":"list","data":[{"id":"file-Fwaz7Bur3ZBVdgjbFpFcseJE","object":"vector_store.file","created_at":1714598088,"vector_store_id":"vs_zlZstoxCwDwdebrkRYw495e0","status":"completed","last_error":null},{"id":"file-KETtd9OsHv4in03XIQprV2tt","object":"vector_store.file","created_at":1714598088,"vector_store_id":"vs_zlZstoxCwDwdebrkRYw495e0","status":"completed","last_error":null}],"first_id":"file-Fwaz7Bur3ZBVdgjbFpFcseJE","last_id":"file-KETtd9OsHv4in03XIQprV2tt","has_more":false} -------------------------------------------------------------------------------- /src/test/resources/vector_store_file_batch_getone.json: -------------------------------------------------------------------------------- 1 | {"id":"vsfb_4464ab366e7b424d8101756ee87bdb8c","object":"vector_store.file_batch","created_at":1714598090,"status":"completed","vector_store_id":"vs_zlZstoxCwDwdebrkRYw495e0","file_counts":{"in_progress":0,"completed":2,"failed":0,"cancelled":0,"total":2}} --------------------------------------------------------------------------------