From c87f1af80b1f3d898a5a1553be48ee87ea4e7b4f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 17:28:13 +0000 Subject: [PATCH 1/3] feat(client): implement per-endpoint base URL support Refactor `HttpRequest` to always take a `baseUrl`, instead of storing this in `OkHttpClient`. This allows better reuse of `OkHttpClient` when changing the `baseUrl`. --- .../com/openai/client/okhttp/OkHttpClient.kt | 17 ++--------- .../client/okhttp/OpenAIOkHttpClient.kt | 8 +---- .../client/okhttp/OpenAIOkHttpClientAsync.kt | 8 +---- .../azure/HttpRequestBuilderExtensions.kt | 5 ++-- .../kotlin/com/openai/core/ClientOptions.kt | 30 +++++++++++-------- .../com/openai/core/http/HttpRequest.kt | 12 ++++---- .../services/async/BatchServiceAsyncImpl.kt | 4 +++ .../async/CompletionServiceAsyncImpl.kt | 2 ++ .../async/ContainerServiceAsyncImpl.kt | 4 +++ .../async/EmbeddingServiceAsyncImpl.kt | 1 + .../services/async/EvalServiceAsyncImpl.kt | 5 ++++ .../services/async/FileServiceAsyncImpl.kt | 5 ++++ .../services/async/ImageServiceAsyncImpl.kt | 3 ++ .../services/async/ModelServiceAsyncImpl.kt | 3 ++ .../async/ModerationServiceAsyncImpl.kt | 1 + .../async/ResponseServiceAsyncImpl.kt | 6 ++++ .../services/async/UploadServiceAsyncImpl.kt | 3 ++ .../async/VectorStoreServiceAsyncImpl.kt | 6 ++++ .../async/audio/SpeechServiceAsyncImpl.kt | 1 + .../audio/TranscriptionServiceAsyncImpl.kt | 2 ++ .../audio/TranslationServiceAsyncImpl.kt | 1 + .../chat/ChatCompletionServiceAsyncImpl.kt | 6 ++++ .../completions/MessageServiceAsyncImpl.kt | 1 + .../async/containers/FileServiceAsyncImpl.kt | 4 +++ .../files/ContentServiceAsyncImpl.kt | 1 + .../async/evals/RunServiceAsyncImpl.kt | 5 ++++ .../evals/runs/OutputItemServiceAsyncImpl.kt | 2 ++ .../async/finetuning/JobServiceAsyncImpl.kt | 7 +++++ .../alpha/GraderServiceAsyncImpl.kt | 2 ++ .../checkpoints/PermissionServiceAsyncImpl.kt | 3 ++ .../jobs/CheckpointServiceAsyncImpl.kt | 1 + .../responses/InputItemServiceAsyncImpl.kt | 1 + .../async/uploads/PartServiceAsyncImpl.kt | 1 + .../vectorstores/FileBatchServiceAsyncImpl.kt | 4 +++ .../vectorstores/FileServiceAsyncImpl.kt | 6 ++++ .../services/blocking/BatchServiceImpl.kt | 4 +++ .../blocking/CompletionServiceImpl.kt | 2 ++ .../services/blocking/ContainerServiceImpl.kt | 4 +++ .../services/blocking/EmbeddingServiceImpl.kt | 1 + .../services/blocking/EvalServiceImpl.kt | 5 ++++ .../services/blocking/FileServiceImpl.kt | 5 ++++ .../services/blocking/ImageServiceImpl.kt | 3 ++ .../services/blocking/ModelServiceImpl.kt | 3 ++ .../blocking/ModerationServiceImpl.kt | 1 + .../services/blocking/ResponseServiceImpl.kt | 6 ++++ .../services/blocking/UploadServiceImpl.kt | 3 ++ .../blocking/VectorStoreServiceImpl.kt | 6 ++++ .../blocking/audio/SpeechServiceImpl.kt | 1 + .../audio/TranscriptionServiceImpl.kt | 2 ++ .../blocking/audio/TranslationServiceImpl.kt | 1 + .../chat/ChatCompletionServiceImpl.kt | 6 ++++ .../chat/completions/MessageServiceImpl.kt | 1 + .../blocking/containers/FileServiceImpl.kt | 4 +++ .../containers/files/ContentServiceImpl.kt | 1 + .../services/blocking/evals/RunServiceImpl.kt | 5 ++++ .../evals/runs/OutputItemServiceImpl.kt | 2 ++ .../blocking/finetuning/JobServiceImpl.kt | 7 +++++ .../finetuning/alpha/GraderServiceImpl.kt | 2 ++ .../checkpoints/PermissionServiceImpl.kt | 3 ++ .../finetuning/jobs/CheckpointServiceImpl.kt | 1 + .../responses/InputItemServiceImpl.kt | 1 + .../blocking/uploads/PartServiceImpl.kt | 1 + .../vectorstores/FileBatchServiceImpl.kt | 4 +++ .../blocking/vectorstores/FileServiceImpl.kt | 6 ++++ .../com/openai/core/http/ClientOptionsTest.kt | 14 ++++----- .../core/http/RetryingHttpClientTest.kt | 29 ++++++++++++++---- 66 files changed, 244 insertions(+), 61 deletions(-) diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt index 8fc863a5..a7996474 100644 --- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt +++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt @@ -2,7 +2,6 @@ package com.openai.client.okhttp import com.openai.core.RequestOptions import com.openai.core.Timeout -import com.openai.core.checkRequired import com.openai.core.http.Headers import com.openai.core.http.HttpClient import com.openai.core.http.HttpMethod @@ -17,7 +16,6 @@ import java.time.Duration import java.util.concurrent.CompletableFuture import okhttp3.Call import okhttp3.Callback -import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -28,8 +26,7 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient -private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : +class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { @@ -140,11 +137,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } private fun HttpRequest.toUrl(): String { - url?.let { - return it - } - - val builder = baseUrl.newBuilder() + val builder = baseUrl.toHttpUrl().newBuilder() pathSegments.forEach(builder::addPathSegment) queryParams.keys().forEach { key -> queryParams.values(key).forEach { builder.addQueryParameter(key, it) } @@ -194,12 +187,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder internal constructor() { - private var baseUrl: HttpUrl? = null private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) @@ -214,8 +204,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .writeTimeout(timeout.write()) .callTimeout(timeout.request()) .proxy(proxy) - .build(), - checkRequired("baseUrl", baseUrl), + .build() ) } } diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt index ff3485fe..0993508c 100644 --- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt +++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt @@ -186,13 +186,7 @@ class OpenAIOkHttpClient private constructor() { fun build(): OpenAIClient = OpenAIClientImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt index 517de047..12072476 100644 --- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt +++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt @@ -186,13 +186,7 @@ class OpenAIOkHttpClientAsync private constructor() { fun build(): OpenAIClientAsync = OpenAIClientAsyncImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } diff --git a/openai-java-core/src/main/kotlin/com/openai/azure/HttpRequestBuilderExtensions.kt b/openai-java-core/src/main/kotlin/com/openai/azure/HttpRequestBuilderExtensions.kt index 90511d49..cbadd473 100644 --- a/openai-java-core/src/main/kotlin/com/openai/azure/HttpRequestBuilderExtensions.kt +++ b/openai-java-core/src/main/kotlin/com/openai/azure/HttpRequestBuilderExtensions.kt @@ -10,7 +10,7 @@ internal fun HttpRequest.Builder.addPathSegmentsForAzure( clientOptions: ClientOptions, deploymentModel: String?, ): HttpRequest.Builder = apply { - if (isAzureEndpoint(clientOptions.baseUrl)) { + if (isAzureEndpoint(clientOptions.baseUrl())) { addPathSegment("openai") deploymentModel?.let { addPathSegments("deployments", it) } } @@ -21,7 +21,8 @@ internal fun HttpRequest.Builder.replaceBearerTokenForAzure( clientOptions: ClientOptions ): HttpRequest.Builder = apply { if ( - isAzureEndpoint(clientOptions.baseUrl) && clientOptions.credential is BearerTokenCredential + isAzureEndpoint(clientOptions.baseUrl()) && + clientOptions.credential is BearerTokenCredential ) { replaceHeaders("Authorization", "Bearer ${clientOptions.credential.token()}") } diff --git a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt index a2ef7809..7fa3f3a8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt @@ -28,7 +28,7 @@ private constructor( @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("streamHandlerExecutor") val streamHandlerExecutor: Executor, @get:JvmName("clock") val clock: Clock, - @get:JvmName("baseUrl") val baseUrl: String, + private val baseUrl: String?, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, @@ -46,6 +46,8 @@ private constructor( } } + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + fun organization(): Optional = Optional.ofNullable(organization) fun project(): Optional = Optional.ofNullable(project) @@ -78,7 +80,7 @@ private constructor( private var jsonMapper: JsonMapper = jsonMapper() private var streamHandlerExecutor: Executor? = null private var clock: Clock = Clock.systemUTC() - private var baseUrl: String = PRODUCTION_URL + private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false @@ -122,7 +124,10 @@ private constructor( fun clock(clock: Clock) = apply { this.clock = clock } - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation @@ -232,8 +237,6 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun baseUrl(): String = baseUrl - fun fromEnv() = apply { System.getenv("OPENAI_BASE_URL")?.let { baseUrl(it) } val openAIKey = System.getenv("OPENAI_API_KEY") @@ -299,13 +302,16 @@ private constructor( } } - if (isAzureEndpoint(baseUrl)) { - // Default Azure OpenAI version is used if Azure user doesn't - // specific a service API version in 'queryParams'. - replaceQueryParams( - "api-version", - (azureServiceVersion ?: AzureOpenAIServiceVersion.latestStableVersion()).value, - ) + baseUrl?.let { + if (isAzureEndpoint(it)) { + // Default Azure OpenAI version is used if Azure user doesn't + // specific a service API version in 'queryParams'. + replaceQueryParams( + "api-version", + (azureServiceVersion ?: AzureOpenAIServiceVersion.latestStableVersion()) + .value, + ) + } } headers.replaceAll(this.headers.build()) diff --git a/openai-java-core/src/main/kotlin/com/openai/core/http/HttpRequest.kt b/openai-java-core/src/main/kotlin/com/openai/core/http/HttpRequest.kt index dd880235..3e5a659a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/http/HttpRequest.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/http/HttpRequest.kt @@ -6,7 +6,7 @@ import com.openai.core.toImmutable class HttpRequest private constructor( @get:JvmName("method") val method: HttpMethod, - @get:JvmName("url") val url: String?, + @get:JvmName("baseUrl") val baseUrl: String, @get:JvmName("pathSegments") val pathSegments: List, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @@ -16,7 +16,7 @@ private constructor( fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = - "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" companion object { @JvmStatic fun builder() = Builder() @@ -25,7 +25,7 @@ private constructor( class Builder internal constructor() { private var method: HttpMethod? = null - private var url: String? = null + private var baseUrl: String? = null private var pathSegments: MutableList = mutableListOf() private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() @@ -34,7 +34,7 @@ private constructor( @JvmSynthetic internal fun from(request: HttpRequest) = apply { method = request.method - url = request.url + baseUrl = request.baseUrl pathSegments = request.pathSegments.toMutableList() headers = request.headers.toBuilder() queryParams = request.queryParams.toBuilder() @@ -43,7 +43,7 @@ private constructor( fun method(method: HttpMethod) = apply { this.method = method } - fun url(url: String) = apply { this.url = url } + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } fun pathSegments(pathSegments: List) = apply { this.pathSegments = pathSegments.toMutableList() @@ -140,7 +140,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( checkRequired("method", method), - url, + checkRequired("baseUrl", baseUrl), pathSegments.toImmutable(), headers.build(), queryParams.build(), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsyncImpl.kt index bcd74110..575861d0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsyncImpl.kt @@ -78,6 +78,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -111,6 +112,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches", params._pathParam(0)) .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -141,6 +143,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches") .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -181,6 +184,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt index 02d8ce55..30583bf1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt @@ -67,6 +67,7 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("completions") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -99,6 +100,7 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("completions") .body( json( diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsyncImpl.kt index eb0e5855..2953e9c7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsyncImpl.kt @@ -94,6 +94,7 @@ class ContainerServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -128,6 +129,7 @@ class ContainerServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers", params._pathParam(0)) .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -158,6 +160,7 @@ class ContainerServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers") .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -197,6 +200,7 @@ class ContainerServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsyncImpl.kt index f5f33f04..ea70fd46 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsyncImpl.kt @@ -51,6 +51,7 @@ class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("embeddings") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsyncImpl.kt index 8ceac275..f191f068 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsyncImpl.kt @@ -101,6 +101,7 @@ class EvalServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -135,6 +136,7 @@ class EvalServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0)) .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -167,6 +169,7 @@ class EvalServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -198,6 +201,7 @@ class EvalServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals") .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -238,6 +242,7 @@ class EvalServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsyncImpl.kt index 83a8c11c..f2068fbd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsyncImpl.kt @@ -89,6 +89,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -122,6 +123,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files", params._pathParam(0)) .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -152,6 +154,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files") .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -192,6 +195,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -222,6 +226,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files", params._pathParam(0), "content") .build() .prepareAsync(clientOptions, params, deploymentModel = null) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt index 15108ece..a7cd8014 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt @@ -67,6 +67,7 @@ class ImageServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("images", "variations") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -101,6 +102,7 @@ class ImageServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("images", "edits") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -135,6 +137,7 @@ class ImageServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("images", "generations") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsyncImpl.kt index 9f15cdea..9aa967ea 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsyncImpl.kt @@ -74,6 +74,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("models", params._pathParam(0)) .build() .prepareAsync(clientOptions, params, params.model().get()) @@ -104,6 +105,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("models") .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -144,6 +146,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("models", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsyncImpl.kt index cdb9bd63..f86ab6e9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsyncImpl.kt @@ -51,6 +51,7 @@ class ModerationServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("moderations") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt index 15bccd5f..c74fedde 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt @@ -120,6 +120,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -152,6 +153,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses") .body( json( @@ -196,6 +198,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0)) .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -230,6 +233,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0)) .putQueryParam("stream", "true") .build() @@ -264,6 +268,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -289,6 +294,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsyncImpl.kt index 30cc034a..a2f24c9d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsyncImpl.kt @@ -80,6 +80,7 @@ class UploadServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("uploads") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -113,6 +114,7 @@ class UploadServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("uploads", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -146,6 +148,7 @@ class UploadServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("uploads", params._pathParam(0), "complete") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsyncImpl.kt index 346bb073..3aabfacc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsyncImpl.kt @@ -129,6 +129,7 @@ class VectorStoreServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores") .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) @@ -163,6 +164,7 @@ class VectorStoreServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0)) .putAllHeaders(DEFAULT_HEADERS) .build() @@ -196,6 +198,7 @@ class VectorStoreServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0)) .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) @@ -228,6 +231,7 @@ class VectorStoreServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores") .putAllHeaders(DEFAULT_HEADERS) .build() @@ -269,6 +273,7 @@ class VectorStoreServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0)) .putAllHeaders(DEFAULT_HEADERS) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } @@ -304,6 +309,7 @@ class VectorStoreServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0), "search") .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsyncImpl.kt index f3ab0f8e..3b02a07d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsyncImpl.kt @@ -43,6 +43,7 @@ class SpeechServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("audio", "speech") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt index 8ce64e0a..9b595b73 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt @@ -83,6 +83,7 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("audio", "transcriptions") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -123,6 +124,7 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("audio", "transcriptions") .body( multipartFormData( diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsyncImpl.kt index 3089b703..222d7223 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsyncImpl.kt @@ -51,6 +51,7 @@ class TranslationServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("audio", "translations") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncImpl.kt index 260a4619..86e2f38a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncImpl.kt @@ -117,6 +117,7 @@ internal constructor(private val clientOptions: ClientOptions) : ChatCompletionS val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -149,6 +150,7 @@ internal constructor(private val clientOptions: ClientOptions) : ChatCompletionS val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions") .body( json( @@ -193,6 +195,7 @@ internal constructor(private val clientOptions: ClientOptions) : ChatCompletionS val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions", params._pathParam(0)) .build() .prepareAsync(clientOptions, params, null) @@ -225,6 +228,7 @@ internal constructor(private val clientOptions: ClientOptions) : ChatCompletionS val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -256,6 +260,7 @@ internal constructor(private val clientOptions: ClientOptions) : ChatCompletionS val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions") .build() .prepareAsync( @@ -301,6 +306,7 @@ internal constructor(private val clientOptions: ClientOptions) : ChatCompletionS val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsyncImpl.kt index 271a18a6..022f17c8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsyncImpl.kt @@ -56,6 +56,7 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions", params._pathParam(0), "messages") .build() .prepareAsync(clientOptions, params, null) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsyncImpl.kt index 85fb2694..e8da17e3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsyncImpl.kt @@ -97,6 +97,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers", params._pathParam(0), "files") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -131,6 +132,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "containers", params._pathParam(0), @@ -169,6 +171,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers", params._pathParam(0), "files") .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -208,6 +211,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "containers", params._pathParam(0), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt index 7bb51987..d6e05fd2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt @@ -47,6 +47,7 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "containers", params._pathParam(0), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsyncImpl.kt index b5d6eb0e..998be569 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsyncImpl.kt @@ -106,6 +106,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -140,6 +141,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs", params._pathParam(1)) .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -173,6 +175,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs") .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -213,6 +216,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs", params._pathParam(1)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -246,6 +250,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs", params._pathParam(1)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsyncImpl.kt index ad4cd7fa..3f9dbf8f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsyncImpl.kt @@ -65,6 +65,7 @@ class OutputItemServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "evals", params._pathParam(0), @@ -105,6 +106,7 @@ class OutputItemServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "evals", params._pathParam(0), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsyncImpl.kt index 959d5660..b8aa421f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsyncImpl.kt @@ -118,6 +118,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -151,6 +152,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0)) .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -181,6 +183,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs") .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -221,6 +224,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -255,6 +259,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "events") .build() .prepareAsync(clientOptions, params, deploymentModel = null) @@ -295,6 +300,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "pause") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -328,6 +334,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "resume") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsyncImpl.kt index 9eb20ee4..4023a138 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsyncImpl.kt @@ -59,6 +59,7 @@ class GraderServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "alpha", "graders", "run") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -90,6 +91,7 @@ class GraderServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "alpha", "graders", "validate") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt index 0d3bf5c0..958c8071 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt @@ -75,6 +75,7 @@ class PermissionServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "fine_tuning", "checkpoints", @@ -122,6 +123,7 @@ class PermissionServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "fine_tuning", "checkpoints", @@ -160,6 +162,7 @@ class PermissionServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "fine_tuning", "checkpoints", diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsyncImpl.kt index e4f74235..1b470d1f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsyncImpl.kt @@ -56,6 +56,7 @@ class CheckpointServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "checkpoints") .build() .prepareAsync(clientOptions, params, deploymentModel = null) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsyncImpl.kt index 0dbd0e04..6bf746a5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsyncImpl.kt @@ -55,6 +55,7 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0), "input_items") .build() .prepareAsync(clientOptions, params, deploymentModel = null) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsyncImpl.kt index 381fb5fb..6d866edb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsyncImpl.kt @@ -55,6 +55,7 @@ class PartServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("uploads", params._pathParam(0), "parts") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsyncImpl.kt index 1d8d8086..01d69ce9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsyncImpl.kt @@ -88,6 +88,7 @@ class FileBatchServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0), "file_batches") .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) @@ -123,6 +124,7 @@ class FileBatchServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -162,6 +164,7 @@ class FileBatchServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -203,6 +206,7 @@ class FileBatchServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsyncImpl.kt index 9780e9b6..b2c72ede 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsyncImpl.kt @@ -106,6 +106,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0), "files") .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) @@ -140,6 +141,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -178,6 +180,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -218,6 +221,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0), "files") .putAllHeaders(DEFAULT_HEADERS) .build() @@ -260,6 +264,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -300,6 +305,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchServiceImpl.kt index 51717e40..492b1a1a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchServiceImpl.kt @@ -65,6 +65,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -95,6 +96,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches", params._pathParam(0)) .build() .prepare(clientOptions, params, deploymentModel = null) @@ -122,6 +124,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches") .build() .prepare(clientOptions, params, deploymentModel = null) @@ -158,6 +161,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionServiceImpl.kt index 823c4da6..695f855b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionServiceImpl.kt @@ -61,6 +61,7 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("completions") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -90,6 +91,7 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("completions") .body( json( diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerServiceImpl.kt index 492db24c..39bd8838 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerServiceImpl.kt @@ -91,6 +91,7 @@ class ContainerServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -122,6 +123,7 @@ class ContainerServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers", params._pathParam(0)) .build() .prepare(clientOptions, params, deploymentModel = null) @@ -149,6 +151,7 @@ class ContainerServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers") .build() .prepare(clientOptions, params, deploymentModel = null) @@ -184,6 +187,7 @@ class ContainerServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingServiceImpl.kt index 7adf63d5..25ca6ce5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingServiceImpl.kt @@ -50,6 +50,7 @@ class EmbeddingServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("embeddings") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalServiceImpl.kt index 9fda99b9..6f8c5cfd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalServiceImpl.kt @@ -96,6 +96,7 @@ class EvalServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -127,6 +128,7 @@ class EvalServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0)) .build() .prepare(clientOptions, params, deploymentModel = null) @@ -156,6 +158,7 @@ class EvalServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -184,6 +187,7 @@ class EvalServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals") .build() .prepare(clientOptions, params, deploymentModel = null) @@ -220,6 +224,7 @@ class EvalServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileServiceImpl.kt index 0f997029..bb373c9f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileServiceImpl.kt @@ -72,6 +72,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -102,6 +103,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files", params._pathParam(0)) .build() .prepare(clientOptions, params, deploymentModel = null) @@ -129,6 +131,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files") .build() .prepare(clientOptions, params, deploymentModel = null) @@ -165,6 +168,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -192,6 +196,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("files", params._pathParam(0), "content") .build() .prepare(clientOptions, params, deploymentModel = null) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageServiceImpl.kt index 522844db..9fca243b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageServiceImpl.kt @@ -63,6 +63,7 @@ class ImageServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("images", "variations") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -94,6 +95,7 @@ class ImageServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("images", "edits") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -125,6 +127,7 @@ class ImageServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("images", "generations") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelServiceImpl.kt index 7104c2ed..0d907c80 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelServiceImpl.kt @@ -64,6 +64,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("models", params._pathParam(0)) .build() .prepare(clientOptions, params, params.model().get()) @@ -91,6 +92,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("models") .build() .prepare(clientOptions, params, deploymentModel = null) @@ -127,6 +129,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("models", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationServiceImpl.kt index d31d4129..fcff84c1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationServiceImpl.kt @@ -50,6 +50,7 @@ class ModerationServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("moderations") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt index dce14891..cc397d51 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt @@ -101,6 +101,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -130,6 +131,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses") .body( json( @@ -171,6 +173,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0)) .build() .prepare(clientOptions, params, deploymentModel = null) @@ -202,6 +205,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0)) .putQueryParam("stream", "true") .build() @@ -233,6 +237,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -255,6 +260,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadServiceImpl.kt index 6b2d7733..736dc6a4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadServiceImpl.kt @@ -70,6 +70,7 @@ class UploadServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("uploads") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -100,6 +101,7 @@ class UploadServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("uploads", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -130,6 +132,7 @@ class UploadServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("uploads", params._pathParam(0), "complete") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreServiceImpl.kt index 89327679..ef489635 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreServiceImpl.kt @@ -126,6 +126,7 @@ class VectorStoreServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores") .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) @@ -157,6 +158,7 @@ class VectorStoreServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0)) .putAllHeaders(DEFAULT_HEADERS) .build() @@ -187,6 +189,7 @@ class VectorStoreServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0)) .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) @@ -216,6 +219,7 @@ class VectorStoreServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores") .putAllHeaders(DEFAULT_HEADERS) .build() @@ -253,6 +257,7 @@ class VectorStoreServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0)) .putAllHeaders(DEFAULT_HEADERS) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } @@ -285,6 +290,7 @@ class VectorStoreServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0), "search") .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechServiceImpl.kt index 8c44e5da..82f8ab69 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechServiceImpl.kt @@ -39,6 +39,7 @@ class SpeechServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("audio", "speech") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt index 47f7e94a..804c81c2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt @@ -77,6 +77,7 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("audio", "transcriptions") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -109,6 +110,7 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("audio", "transcriptions") .body( multipartFormData( diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationServiceImpl.kt index c0e2af7a..af098de1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationServiceImpl.kt @@ -50,6 +50,7 @@ class TranslationServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("audio", "translations") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionServiceImpl.kt index b07c2c6c..96181de3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionServiceImpl.kt @@ -111,6 +111,7 @@ class ChatCompletionServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -140,6 +141,7 @@ class ChatCompletionServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions") .body( json( @@ -181,6 +183,7 @@ class ChatCompletionServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions", params._pathParam(0)) .build() .prepare(clientOptions, params, null) @@ -210,6 +213,7 @@ class ChatCompletionServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -238,6 +242,7 @@ class ChatCompletionServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions") .build() .prepare( @@ -279,6 +284,7 @@ class ChatCompletionServiceImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageServiceImpl.kt index 52b267d3..8298420a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageServiceImpl.kt @@ -52,6 +52,7 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("chat", "completions", params._pathParam(0), "messages") .build() .prepare(clientOptions, params, null) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileServiceImpl.kt index 64398e89..1887ed67 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileServiceImpl.kt @@ -90,6 +90,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers", params._pathParam(0), "files") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -121,6 +122,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "containers", params._pathParam(0), @@ -156,6 +158,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("containers", params._pathParam(0), "files") .build() .prepare(clientOptions, params, deploymentModel = null) @@ -191,6 +194,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "containers", params._pathParam(0), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentServiceImpl.kt index 8d2280c8..235d4ecd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentServiceImpl.kt @@ -46,6 +46,7 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "containers", params._pathParam(0), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunServiceImpl.kt index ee64dae6..f9448a04 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunServiceImpl.kt @@ -99,6 +99,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -130,6 +131,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs", params._pathParam(1)) .build() .prepare(clientOptions, params, deploymentModel = null) @@ -160,6 +162,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs") .build() .prepare(clientOptions, params, deploymentModel = null) @@ -196,6 +199,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs", params._pathParam(1)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -226,6 +230,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("evals", params._pathParam(0), "runs", params._pathParam(1)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemServiceImpl.kt index de2cfba3..97b281d9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemServiceImpl.kt @@ -64,6 +64,7 @@ class OutputItemServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "evals", params._pathParam(0), @@ -101,6 +102,7 @@ class OutputItemServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "evals", params._pathParam(0), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobServiceImpl.kt index ba95b5d3..3def437f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobServiceImpl.kt @@ -99,6 +99,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -129,6 +130,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0)) .build() .prepare(clientOptions, params, deploymentModel = null) @@ -156,6 +158,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs") .build() .prepare(clientOptions, params, deploymentModel = null) @@ -192,6 +195,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -223,6 +227,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "events") .build() .prepare(clientOptions, params, deploymentModel = null) @@ -259,6 +264,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "pause") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -289,6 +295,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "resume") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderServiceImpl.kt index 4a9e21fc..aadba554 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderServiceImpl.kt @@ -55,6 +55,7 @@ class GraderServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "alpha", "graders", "run") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -83,6 +84,7 @@ class GraderServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "alpha", "graders", "validate") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt index 6ac2f12e..5d0ec871 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt @@ -74,6 +74,7 @@ class PermissionServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "fine_tuning", "checkpoints", @@ -117,6 +118,7 @@ class PermissionServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "fine_tuning", "checkpoints", @@ -152,6 +154,7 @@ class PermissionServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "fine_tuning", "checkpoints", diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointServiceImpl.kt index 23fe2d2d..7b5134cc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointServiceImpl.kt @@ -55,6 +55,7 @@ class CheckpointServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("fine_tuning", "jobs", params._pathParam(0), "checkpoints") .build() .prepare(clientOptions, params, deploymentModel = null) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemServiceImpl.kt index aa535bbc..b9a2a79c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemServiceImpl.kt @@ -54,6 +54,7 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("responses", params._pathParam(0), "input_items") .build() .prepare(clientOptions, params, deploymentModel = null) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartServiceImpl.kt index 23bf0b68..526e2d7d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartServiceImpl.kt @@ -50,6 +50,7 @@ class PartServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("uploads", params._pathParam(0), "parts") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchServiceImpl.kt index edfa1dd2..385c500b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchServiceImpl.kt @@ -87,6 +87,7 @@ class FileBatchServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0), "file_batches") .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) @@ -119,6 +120,7 @@ class FileBatchServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -155,6 +157,7 @@ class FileBatchServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -193,6 +196,7 @@ class FileBatchServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileServiceImpl.kt index 971cf72e..dabf8f1e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileServiceImpl.kt @@ -95,6 +95,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0), "files") .putAllHeaders(DEFAULT_HEADERS) .body(json(clientOptions.jsonMapper, params._body())) @@ -126,6 +127,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -161,6 +163,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -198,6 +201,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vector_stores", params._pathParam(0), "files") .putAllHeaders(DEFAULT_HEADERS) .build() @@ -236,6 +240,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), @@ -273,6 +278,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "vector_stores", params._pathParam(0), diff --git a/openai-java-core/src/test/kotlin/com/openai/core/http/ClientOptionsTest.kt b/openai-java-core/src/test/kotlin/com/openai/core/http/ClientOptionsTest.kt index 7bba0f65..0e9c3152 100644 --- a/openai-java-core/src/test/kotlin/com/openai/core/http/ClientOptionsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/core/http/ClientOptionsTest.kt @@ -17,8 +17,8 @@ internal class ClientOptionsTest { private const val FAKE_API_KEY = "test-api-key" @JvmStatic - private fun createOkHttpClient(baseUrl: String): OkHttpClient { - return OkHttpClient.builder().baseUrl(baseUrl).build() + private fun createOkHttpClient(): OkHttpClient { + return OkHttpClient.builder().build() } @JvmStatic @@ -31,21 +31,19 @@ internal class ClientOptionsTest { } } - @ParameterizedTest - @MethodSource("provideBaseUrls") - fun clientOptionsWithoutBaseUrl(baseUrl: String) { + fun clientOptionsWithoutBaseUrl() { // Arrange val apiKey = FAKE_API_KEY // Act val clientOptions = ClientOptions.builder() - .httpClient(createOkHttpClient(baseUrl)) + .httpClient(createOkHttpClient()) .credential(BearerTokenCredential.create(apiKey)) .build() // Assert - assertThat(clientOptions.baseUrl).isEqualTo(ClientOptions.PRODUCTION_URL) + assertThat(clientOptions.baseUrl()).isEqualTo(ClientOptions.PRODUCTION_URL) } @ParameterizedTest @@ -53,7 +51,7 @@ internal class ClientOptionsTest { fun throwExceptionWhenNullCredential(baseUrl: String) { // Act val clientOptionsBuilder = - ClientOptions.builder().httpClient(createOkHttpClient(baseUrl)).baseUrl(baseUrl) + ClientOptions.builder().httpClient(createOkHttpClient()).baseUrl(baseUrl) // Assert assertThatThrownBy { clientOptionsBuilder.build() } diff --git a/openai-java-core/src/test/kotlin/com/openai/core/http/RetryingHttpClientTest.kt b/openai-java-core/src/test/kotlin/com/openai/core/http/RetryingHttpClientTest.kt index ed8d9675..8ef5ca29 100644 --- a/openai-java-core/src/test/kotlin/com/openai/core/http/RetryingHttpClientTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/core/http/RetryingHttpClientTest.kt @@ -20,11 +20,13 @@ import org.junit.jupiter.params.provider.ValueSource internal class RetryingHttpClientTest { private var openResponseCount = 0 + private lateinit var baseUrl: String private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().build() httpClient = object : HttpClient { @@ -75,7 +77,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -97,7 +103,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -139,7 +149,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -187,6 +201,7 @@ internal class RetryingHttpClientTest { retryingClient.execute( HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(baseUrl) .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), @@ -223,7 +238,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) From 3597aee95ae1956afbe8bd62b5a6946dd62256b3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 11:48:13 +0000 Subject: [PATCH 2/3] chore(internal): codegen related update --- README.md | 15 +++++++++++++ .../kotlin/com/openai/client/OpenAIClient.kt | 16 ++++++++++++++ .../com/openai/client/OpenAIClientAsync.kt | 18 +++++++++++++++ .../openai/client/OpenAIClientAsyncImpl.kt | 11 ++++++++++ .../com/openai/client/OpenAIClientImpl.kt | 11 ++++++++++ .../services/async/AudioServiceAsync.kt | 18 +++++++++++++++ .../services/async/AudioServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/BatchServiceAsync.kt | 18 +++++++++++++++ .../services/async/BatchServiceAsyncImpl.kt | 11 ++++++++++ .../openai/services/async/BetaServiceAsync.kt | 20 ++++++++++++++++- .../services/async/BetaServiceAsyncImpl.kt | 14 +++++++++++- .../openai/services/async/ChatServiceAsync.kt | 16 ++++++++++++++ .../services/async/ChatServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/CompletionServiceAsync.kt | 18 +++++++++++++++ .../async/CompletionServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/ContainerServiceAsync.kt | 18 +++++++++++++++ .../async/ContainerServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/EmbeddingServiceAsync.kt | 18 +++++++++++++++ .../async/EmbeddingServiceAsyncImpl.kt | 11 ++++++++++ .../openai/services/async/EvalServiceAsync.kt | 16 ++++++++++++++ .../services/async/EvalServiceAsyncImpl.kt | 11 ++++++++++ .../openai/services/async/FileServiceAsync.kt | 16 ++++++++++++++ .../services/async/FileServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/FineTuningServiceAsync.kt | 18 +++++++++++++++ .../async/FineTuningServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/GraderServiceAsync.kt | 18 +++++++++++++++ .../services/async/GraderServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/ImageServiceAsync.kt | 18 +++++++++++++++ .../services/async/ImageServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/ModelServiceAsync.kt | 18 +++++++++++++++ .../services/async/ModelServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/ModerationServiceAsync.kt | 18 +++++++++++++++ .../async/ModerationServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/ResponseServiceAsync.kt | 18 +++++++++++++++ .../async/ResponseServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/UploadServiceAsync.kt | 18 +++++++++++++++ .../services/async/UploadServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/VectorStoreServiceAsync.kt | 18 +++++++++++++++ .../async/VectorStoreServiceAsyncImpl.kt | 11 ++++++++++ .../async/audio/SpeechServiceAsync.kt | 18 +++++++++++++++ .../async/audio/SpeechServiceAsyncImpl.kt | 11 ++++++++++ .../async/audio/TranscriptionServiceAsync.kt | 18 +++++++++++++++ .../audio/TranscriptionServiceAsyncImpl.kt | 12 ++++++++++ .../async/audio/TranslationServiceAsync.kt | 18 +++++++++++++++ .../audio/TranslationServiceAsyncImpl.kt | 11 ++++++++++ .../async/chat/ChatCompletionServiceAsync.kt | 18 +++++++++++++++ .../chat/ChatCompletionServiceAsyncImpl.kt | 13 +++++++++++ .../chat/completions/MessageServiceAsync.kt | 18 +++++++++++++++ .../completions/MessageServiceAsyncImpl.kt | 11 ++++++++++ .../async/containers/FileServiceAsync.kt | 16 ++++++++++++++ .../async/containers/FileServiceAsyncImpl.kt | 11 ++++++++++ .../containers/files/ContentServiceAsync.kt | 18 +++++++++++++++ .../files/ContentServiceAsyncImpl.kt | 11 ++++++++++ .../services/async/evals/RunServiceAsync.kt | 16 ++++++++++++++ .../async/evals/RunServiceAsyncImpl.kt | 11 ++++++++++ .../evals/runs/OutputItemServiceAsync.kt | 18 +++++++++++++++ .../evals/runs/OutputItemServiceAsyncImpl.kt | 11 ++++++++++ .../async/finetuning/AlphaServiceAsync.kt | 18 +++++++++++++++ .../async/finetuning/AlphaServiceAsyncImpl.kt | 11 ++++++++++ .../finetuning/CheckpointServiceAsync.kt | 18 +++++++++++++++ .../finetuning/CheckpointServiceAsyncImpl.kt | 11 ++++++++++ .../async/finetuning/JobServiceAsync.kt | 16 ++++++++++++++ .../async/finetuning/JobServiceAsyncImpl.kt | 11 ++++++++++ .../async/finetuning/MethodServiceAsync.kt | 22 ++++++++++++++++++- .../finetuning/MethodServiceAsyncImpl.kt | 14 +++++++++++- .../finetuning/alpha/GraderServiceAsync.kt | 18 +++++++++++++++ .../alpha/GraderServiceAsyncImpl.kt | 11 ++++++++++ .../checkpoints/PermissionServiceAsync.kt | 18 +++++++++++++++ .../checkpoints/PermissionServiceAsyncImpl.kt | 11 ++++++++++ .../finetuning/jobs/CheckpointServiceAsync.kt | 18 +++++++++++++++ .../jobs/CheckpointServiceAsyncImpl.kt | 11 ++++++++++ .../async/graders/GraderModelServiceAsync.kt | 22 ++++++++++++++++++- .../graders/GraderModelServiceAsyncImpl.kt | 14 +++++++++++- .../async/responses/InputItemServiceAsync.kt | 18 +++++++++++++++ .../responses/InputItemServiceAsyncImpl.kt | 11 ++++++++++ .../async/uploads/PartServiceAsync.kt | 16 ++++++++++++++ .../async/uploads/PartServiceAsyncImpl.kt | 11 ++++++++++ .../vectorstores/FileBatchServiceAsync.kt | 18 +++++++++++++++ .../vectorstores/FileBatchServiceAsyncImpl.kt | 11 ++++++++++ .../async/vectorstores/FileServiceAsync.kt | 16 ++++++++++++++ .../vectorstores/FileServiceAsyncImpl.kt | 11 ++++++++++ .../openai/services/blocking/AudioService.kt | 16 ++++++++++++++ .../services/blocking/AudioServiceImpl.kt | 11 ++++++++++ .../openai/services/blocking/BatchService.kt | 16 ++++++++++++++ .../services/blocking/BatchServiceImpl.kt | 11 ++++++++++ .../openai/services/blocking/BetaService.kt | 20 ++++++++++++++++- .../services/blocking/BetaServiceImpl.kt | 14 +++++++++++- .../openai/services/blocking/ChatService.kt | 16 ++++++++++++++ .../services/blocking/ChatServiceImpl.kt | 11 ++++++++++ .../services/blocking/CompletionService.kt | 18 +++++++++++++++ .../blocking/CompletionServiceImpl.kt | 11 ++++++++++ .../services/blocking/ContainerService.kt | 16 ++++++++++++++ .../services/blocking/ContainerServiceImpl.kt | 11 ++++++++++ .../services/blocking/EmbeddingService.kt | 16 ++++++++++++++ .../services/blocking/EmbeddingServiceImpl.kt | 11 ++++++++++ .../openai/services/blocking/EvalService.kt | 16 ++++++++++++++ .../services/blocking/EvalServiceImpl.kt | 11 ++++++++++ .../openai/services/blocking/FileService.kt | 16 ++++++++++++++ .../services/blocking/FileServiceImpl.kt | 11 ++++++++++ .../services/blocking/FineTuningService.kt | 18 +++++++++++++++ .../blocking/FineTuningServiceImpl.kt | 11 ++++++++++ .../openai/services/blocking/GraderService.kt | 16 ++++++++++++++ .../services/blocking/GraderServiceImpl.kt | 11 ++++++++++ .../openai/services/blocking/ImageService.kt | 16 ++++++++++++++ .../services/blocking/ImageServiceImpl.kt | 11 ++++++++++ .../openai/services/blocking/ModelService.kt | 16 ++++++++++++++ .../services/blocking/ModelServiceImpl.kt | 11 ++++++++++ .../services/blocking/ModerationService.kt | 18 +++++++++++++++ .../blocking/ModerationServiceImpl.kt | 11 ++++++++++ .../services/blocking/ResponseService.kt | 16 ++++++++++++++ .../services/blocking/ResponseServiceImpl.kt | 11 ++++++++++ .../openai/services/blocking/UploadService.kt | 16 ++++++++++++++ .../services/blocking/UploadServiceImpl.kt | 11 ++++++++++ .../services/blocking/VectorStoreService.kt | 18 +++++++++++++++ .../blocking/VectorStoreServiceImpl.kt | 11 ++++++++++ .../services/blocking/audio/SpeechService.kt | 16 ++++++++++++++ .../blocking/audio/SpeechServiceImpl.kt | 11 ++++++++++ .../blocking/audio/TranscriptionService.kt | 18 +++++++++++++++ .../audio/TranscriptionServiceImpl.kt | 12 ++++++++++ .../blocking/audio/TranslationService.kt | 18 +++++++++++++++ .../blocking/audio/TranslationServiceImpl.kt | 11 ++++++++++ .../blocking/chat/ChatCompletionService.kt | 18 +++++++++++++++ .../chat/ChatCompletionServiceImpl.kt | 11 ++++++++++ .../chat/completions/MessageService.kt | 16 ++++++++++++++ .../chat/completions/MessageServiceImpl.kt | 11 ++++++++++ .../blocking/containers/FileService.kt | 16 ++++++++++++++ .../blocking/containers/FileServiceImpl.kt | 11 ++++++++++ .../containers/files/ContentService.kt | 16 ++++++++++++++ .../containers/files/ContentServiceImpl.kt | 11 ++++++++++ .../services/blocking/evals/RunService.kt | 16 ++++++++++++++ .../services/blocking/evals/RunServiceImpl.kt | 11 ++++++++++ .../blocking/evals/runs/OutputItemService.kt | 18 +++++++++++++++ .../evals/runs/OutputItemServiceImpl.kt | 11 ++++++++++ .../blocking/finetuning/AlphaService.kt | 16 ++++++++++++++ .../blocking/finetuning/AlphaServiceImpl.kt | 11 ++++++++++ .../blocking/finetuning/CheckpointService.kt | 18 +++++++++++++++ .../finetuning/CheckpointServiceImpl.kt | 11 ++++++++++ .../blocking/finetuning/JobService.kt | 16 ++++++++++++++ .../blocking/finetuning/JobServiceImpl.kt | 11 ++++++++++ .../blocking/finetuning/MethodService.kt | 20 ++++++++++++++++- .../blocking/finetuning/MethodServiceImpl.kt | 14 +++++++++++- .../finetuning/alpha/GraderService.kt | 16 ++++++++++++++ .../finetuning/alpha/GraderServiceImpl.kt | 11 ++++++++++ .../checkpoints/PermissionService.kt | 18 +++++++++++++++ .../checkpoints/PermissionServiceImpl.kt | 11 ++++++++++ .../finetuning/jobs/CheckpointService.kt | 18 +++++++++++++++ .../finetuning/jobs/CheckpointServiceImpl.kt | 11 ++++++++++ .../blocking/graders/GraderModelService.kt | 22 ++++++++++++++++++- .../graders/GraderModelServiceImpl.kt | 14 +++++++++++- .../blocking/responses/InputItemService.kt | 16 ++++++++++++++ .../responses/InputItemServiceImpl.kt | 11 ++++++++++ .../services/blocking/uploads/PartService.kt | 16 ++++++++++++++ .../blocking/uploads/PartServiceImpl.kt | 11 ++++++++++ .../blocking/vectorstores/FileBatchService.kt | 16 ++++++++++++++ .../vectorstores/FileBatchServiceImpl.kt | 11 ++++++++++ .../blocking/vectorstores/FileService.kt | 16 ++++++++++++++ .../blocking/vectorstores/FileServiceImpl.kt | 11 ++++++++++ 157 files changed, 2239 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d060cb00..deb79ab7 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,21 @@ See this table for the available options: > Don't create more than one client in the same application. Each client has a connection pool and > thread pools, which are more efficient to share between requests. +### Modifying configuration + +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: + +```java +import com.openai.client.OpenAIClient; + +OpenAIClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); +``` + +The `withOptions()` method does not affect the original client or service. + ## Requests and responses To send a request to the OpenAI API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. diff --git a/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClient.kt b/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClient.kt index ba9c1387..7744a980 100644 --- a/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClient.kt +++ b/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClient.kt @@ -2,6 +2,7 @@ package com.openai.client +import com.openai.core.ClientOptions import com.openai.services.blocking.AudioService import com.openai.services.blocking.BatchService import com.openai.services.blocking.BetaService @@ -19,6 +20,7 @@ import com.openai.services.blocking.ModerationService import com.openai.services.blocking.ResponseService import com.openai.services.blocking.UploadService import com.openai.services.blocking.VectorStoreService +import java.util.function.Consumer /** * A client for interacting with the OpenAI REST API synchronously. You can also switch to @@ -49,6 +51,13 @@ interface OpenAIClient { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OpenAIClient + fun completions(): CompletionService fun chat(): ChatService @@ -99,6 +108,13 @@ interface OpenAIClient { /** A view of [OpenAIClient] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OpenAIClient.WithRawResponse + fun completions(): CompletionService.WithRawResponse fun chat(): ChatService.WithRawResponse diff --git a/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsync.kt b/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsync.kt index fb810280..563b8ebd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsync.kt @@ -2,6 +2,7 @@ package com.openai.client +import com.openai.core.ClientOptions import com.openai.services.async.AudioServiceAsync import com.openai.services.async.BatchServiceAsync import com.openai.services.async.BetaServiceAsync @@ -19,6 +20,7 @@ import com.openai.services.async.ModerationServiceAsync import com.openai.services.async.ResponseServiceAsync import com.openai.services.async.UploadServiceAsync import com.openai.services.async.VectorStoreServiceAsync +import java.util.function.Consumer /** * A client for interacting with the OpenAI REST API asynchronously. You can also switch to @@ -49,6 +51,13 @@ interface OpenAIClientAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OpenAIClientAsync + fun completions(): CompletionServiceAsync fun chat(): ChatServiceAsync @@ -99,6 +108,15 @@ interface OpenAIClientAsync { /** A view of [OpenAIClientAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OpenAIClientAsync.WithRawResponse + fun completions(): CompletionServiceAsync.WithRawResponse fun chat(): ChatServiceAsync.WithRawResponse diff --git a/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsyncImpl.kt index b9402dc3..dea9aed2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsyncImpl.kt @@ -38,6 +38,7 @@ import com.openai.services.async.UploadServiceAsync import com.openai.services.async.UploadServiceAsyncImpl import com.openai.services.async.VectorStoreServiceAsync import com.openai.services.async.VectorStoreServiceAsyncImpl +import java.util.function.Consumer class OpenAIClientAsyncImpl(private val clientOptions: ClientOptions) : OpenAIClientAsync { @@ -120,6 +121,9 @@ class OpenAIClientAsyncImpl(private val clientOptions: ClientOptions) : OpenAICl override fun withRawResponse(): OpenAIClientAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OpenAIClientAsync = + OpenAIClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun completions(): CompletionServiceAsync = completions override fun chat(): ChatServiceAsync = chat @@ -227,6 +231,13 @@ class OpenAIClientAsyncImpl(private val clientOptions: ClientOptions) : OpenAICl ContainerServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): OpenAIClientAsync.WithRawResponse = + OpenAIClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun completions(): CompletionServiceAsync.WithRawResponse = completions override fun chat(): ChatServiceAsync.WithRawResponse = chat diff --git a/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientImpl.kt b/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientImpl.kt index 53d70f12..a20f1148 100644 --- a/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientImpl.kt @@ -38,6 +38,7 @@ import com.openai.services.blocking.UploadService import com.openai.services.blocking.UploadServiceImpl import com.openai.services.blocking.VectorStoreService import com.openai.services.blocking.VectorStoreServiceImpl +import java.util.function.Consumer class OpenAIClientImpl(private val clientOptions: ClientOptions) : OpenAIClient { @@ -108,6 +109,9 @@ class OpenAIClientImpl(private val clientOptions: ClientOptions) : OpenAIClient override fun withRawResponse(): OpenAIClient.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OpenAIClient = + OpenAIClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun completions(): CompletionService = completions override fun chat(): ChatService = chat @@ -215,6 +219,13 @@ class OpenAIClientImpl(private val clientOptions: ClientOptions) : OpenAIClient ContainerServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): OpenAIClient.WithRawResponse = + OpenAIClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun completions(): CompletionService.WithRawResponse = completions override fun chat(): ChatService.WithRawResponse = chat diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/AudioServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/AudioServiceAsync.kt index ee89ecfd..26212fd8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/AudioServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/AudioServiceAsync.kt @@ -2,9 +2,11 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.services.async.audio.SpeechServiceAsync import com.openai.services.async.audio.TranscriptionServiceAsync import com.openai.services.async.audio.TranslationServiceAsync +import java.util.function.Consumer interface AudioServiceAsync { @@ -13,6 +15,13 @@ interface AudioServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AudioServiceAsync + fun transcriptions(): TranscriptionServiceAsync fun translations(): TranslationServiceAsync @@ -22,6 +31,15 @@ interface AudioServiceAsync { /** A view of [AudioServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AudioServiceAsync.WithRawResponse + fun transcriptions(): TranscriptionServiceAsync.WithRawResponse fun translations(): TranslationServiceAsync.WithRawResponse diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/AudioServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/AudioServiceAsyncImpl.kt index d809c875..3434e60a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/AudioServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/AudioServiceAsyncImpl.kt @@ -9,6 +9,7 @@ import com.openai.services.async.audio.TranscriptionServiceAsync import com.openai.services.async.audio.TranscriptionServiceAsyncImpl import com.openai.services.async.audio.TranslationServiceAsync import com.openai.services.async.audio.TranslationServiceAsyncImpl +import java.util.function.Consumer class AudioServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AudioServiceAsync { @@ -29,6 +30,9 @@ class AudioServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): AudioServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AudioServiceAsync = + AudioServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun transcriptions(): TranscriptionServiceAsync = transcriptions override fun translations(): TranslationServiceAsync = translations @@ -50,6 +54,13 @@ class AudioServiceAsyncImpl internal constructor(private val clientOptions: Clie SpeechServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): AudioServiceAsync.WithRawResponse = + AudioServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun transcriptions(): TranscriptionServiceAsync.WithRawResponse = transcriptions override fun translations(): TranslationServiceAsync.WithRawResponse = translations diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsync.kt index cfe253af..1a8ab9f4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.batches.Batch @@ -11,6 +12,7 @@ import com.openai.models.batches.BatchListPageAsync import com.openai.models.batches.BatchListParams import com.openai.models.batches.BatchRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface BatchServiceAsync { @@ -19,6 +21,13 @@ interface BatchServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BatchServiceAsync + /** Creates and executes a batch from an uploaded file of requests */ fun create(params: BatchCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -118,6 +127,15 @@ interface BatchServiceAsync { /** A view of [BatchServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BatchServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /batches`, but is otherwise the same as * [BatchServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsyncImpl.kt index 575861d0..81fb29e1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsyncImpl.kt @@ -24,6 +24,7 @@ import com.openai.models.batches.BatchListPageResponse import com.openai.models.batches.BatchListParams import com.openai.models.batches.BatchRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BatchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -35,6 +36,9 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): BatchServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BatchServiceAsync = + BatchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: BatchCreateParams, requestOptions: RequestOptions, @@ -68,6 +72,13 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BatchServiceAsync.WithRawResponse = + BatchServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsync.kt index ba8f23f7..f430fc2c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsync.kt @@ -2,6 +2,9 @@ package com.openai.services.async +import com.openai.core.ClientOptions +import java.util.function.Consumer + interface BetaServiceAsync { /** @@ -9,6 +12,21 @@ interface BetaServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaServiceAsync + /** A view of [BetaServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaServiceAsync.WithRawResponse + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsyncImpl.kt index 873fb349..03e5c7c0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openai.services.async import com.openai.core.ClientOptions +import java.util.function.Consumer class BetaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BetaServiceAsync { @@ -13,6 +14,17 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): BetaServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BetaServiceAsync = + BetaServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BetaServiceAsync.WithRawResponse + BetaServiceAsync.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): BetaServiceAsync.WithRawResponse = + BetaServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ChatServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ChatServiceAsync.kt index c7667745..fb41011d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ChatServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ChatServiceAsync.kt @@ -2,7 +2,9 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.services.async.chat.ChatCompletionServiceAsync +import java.util.function.Consumer interface ChatServiceAsync { @@ -11,11 +13,25 @@ interface ChatServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatServiceAsync + fun completions(): ChatCompletionServiceAsync /** A view of [ChatServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatServiceAsync.WithRawResponse + fun completions(): ChatCompletionServiceAsync.WithRawResponse } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ChatServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ChatServiceAsyncImpl.kt index 4c60a64c..b59d0d2f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ChatServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ChatServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.openai.services.async import com.openai.core.ClientOptions import com.openai.services.async.chat.ChatCompletionServiceAsync import com.openai.services.async.chat.ChatCompletionServiceAsyncImpl +import java.util.function.Consumer class ChatServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ChatServiceAsync { @@ -19,6 +20,9 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): ChatServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ChatServiceAsync = + ChatServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun completions(): ChatCompletionServiceAsync = completions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +32,13 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien ChatCompletionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ChatServiceAsync.WithRawResponse = + ChatServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun completions(): ChatCompletionServiceAsync.WithRawResponse = completions } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsync.kt index 30b3eba1..24833d5a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsync.kt @@ -3,6 +3,7 @@ package com.openai.services.async import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.AsyncStreamResponse import com.openai.core.http.HttpResponseFor @@ -10,6 +11,7 @@ import com.openai.core.http.StreamResponse import com.openai.models.completions.Completion import com.openai.models.completions.CompletionCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CompletionServiceAsync { @@ -18,6 +20,13 @@ interface CompletionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompletionServiceAsync + /** Creates a completion for the provided prompt and parameters. */ fun create(params: CompletionCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -44,6 +53,15 @@ interface CompletionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompletionServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /completions`, but is otherwise the same as * [CompletionServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt index 30583bf1..a178172d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt @@ -25,6 +25,7 @@ import com.openai.models.ErrorObject import com.openai.models.completions.Completion import com.openai.models.completions.CompletionCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class CompletionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CompletionServiceAsync { @@ -35,6 +36,9 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): CompletionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompletionServiceAsync = + CompletionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -57,6 +61,13 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompletionServiceAsync.WithRawResponse = + CompletionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsync.kt index f4ba5ccb..004d0301 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponseFor @@ -14,6 +15,7 @@ import com.openai.models.containers.ContainerRetrieveParams import com.openai.models.containers.ContainerRetrieveResponse import com.openai.services.async.containers.FileServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ContainerServiceAsync { @@ -22,6 +24,13 @@ interface ContainerServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContainerServiceAsync + fun files(): FileServiceAsync /** Create Container */ @@ -125,6 +134,15 @@ interface ContainerServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ContainerServiceAsync.WithRawResponse + fun files(): FileServiceAsync.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsyncImpl.kt index 2953e9c7..fdda439b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsyncImpl.kt @@ -29,6 +29,7 @@ import com.openai.models.containers.ContainerRetrieveResponse import com.openai.services.async.containers.FileServiceAsync import com.openai.services.async.containers.FileServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ContainerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -42,6 +43,9 @@ class ContainerServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): ContainerServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ContainerServiceAsync = + ContainerServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun files(): FileServiceAsync = files override fun create( @@ -81,6 +85,13 @@ class ContainerServiceAsyncImpl internal constructor(private val clientOptions: FileServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ContainerServiceAsync.WithRawResponse = + ContainerServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun files(): FileServiceAsync.WithRawResponse = files private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsync.kt index 94582f88..40d70c52 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsync.kt @@ -2,11 +2,13 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.embeddings.CreateEmbeddingResponse import com.openai.models.embeddings.EmbeddingCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface EmbeddingServiceAsync { @@ -15,6 +17,13 @@ interface EmbeddingServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmbeddingServiceAsync + /** Creates an embedding vector representing the input text. */ fun create(params: EmbeddingCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -30,6 +39,15 @@ interface EmbeddingServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmbeddingServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /embeddings`, but is otherwise the same as * [EmbeddingServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsyncImpl.kt index ea70fd46..4f9f4888 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.openai.models.ErrorObject import com.openai.models.embeddings.CreateEmbeddingResponse import com.openai.models.embeddings.EmbeddingCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EmbeddingServiceAsync { @@ -28,6 +29,9 @@ class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): EmbeddingServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmbeddingServiceAsync = + EmbeddingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: EmbeddingCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmbeddingServiceAsync.WithRawResponse = + EmbeddingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsync.kt index 7ca10a5e..d44b0e72 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.evals.EvalCreateParams @@ -16,6 +17,7 @@ import com.openai.models.evals.EvalUpdateParams import com.openai.models.evals.EvalUpdateResponse import com.openai.services.async.evals.RunServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface EvalServiceAsync { @@ -24,6 +26,13 @@ interface EvalServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EvalServiceAsync + fun runs(): RunServiceAsync /** @@ -167,6 +176,13 @@ interface EvalServiceAsync { /** A view of [EvalServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EvalServiceAsync.WithRawResponse + fun runs(): RunServiceAsync.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsyncImpl.kt index f191f068..4bb6bfca 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsyncImpl.kt @@ -30,6 +30,7 @@ import com.openai.models.evals.EvalUpdateResponse import com.openai.services.async.evals.RunServiceAsync import com.openai.services.async.evals.RunServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EvalServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -43,6 +44,9 @@ class EvalServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): EvalServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EvalServiceAsync = + EvalServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun runs(): RunServiceAsync = runs override fun create( @@ -89,6 +93,13 @@ class EvalServiceAsyncImpl internal constructor(private val clientOptions: Clien RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): EvalServiceAsync.WithRawResponse = + EvalServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun runs(): RunServiceAsync.WithRawResponse = runs private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt index 7a871e76..7ffae619 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponseFor @@ -14,6 +15,7 @@ import com.openai.models.files.FileListParams import com.openai.models.files.FileObject import com.openai.models.files.FileRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface FileServiceAsync { @@ -22,6 +24,13 @@ interface FileServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileServiceAsync + /** * Upload a file that can be used across various endpoints. Individual files can be up to 512 * MB, and the size of all files uploaded by one organization can be up to 100 GB. @@ -166,6 +175,13 @@ interface FileServiceAsync { /** A view of [FileServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /files`, but is otherwise the same as * [FileServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsyncImpl.kt index f2068fbd..7f366622 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsyncImpl.kt @@ -28,6 +28,7 @@ import com.openai.models.files.FileListParams import com.openai.models.files.FileObject import com.openai.models.files.FileRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -39,6 +40,9 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): FileServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileServiceAsync = + FileServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: FileCreateParams, requestOptions: RequestOptions, @@ -79,6 +83,13 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): FileServiceAsync.WithRawResponse = + FileServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/FineTuningServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/FineTuningServiceAsync.kt index 920bcfcc..767c5027 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/FineTuningServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/FineTuningServiceAsync.kt @@ -2,10 +2,12 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.services.async.finetuning.AlphaServiceAsync import com.openai.services.async.finetuning.CheckpointServiceAsync import com.openai.services.async.finetuning.JobServiceAsync import com.openai.services.async.finetuning.MethodServiceAsync +import java.util.function.Consumer interface FineTuningServiceAsync { @@ -14,6 +16,13 @@ interface FineTuningServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FineTuningServiceAsync + fun methods(): MethodServiceAsync fun jobs(): JobServiceAsync @@ -28,6 +37,15 @@ interface FineTuningServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): FineTuningServiceAsync.WithRawResponse + fun methods(): MethodServiceAsync.WithRawResponse fun jobs(): JobServiceAsync.WithRawResponse diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/FineTuningServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/FineTuningServiceAsyncImpl.kt index 59413489..67f5d011 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/FineTuningServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/FineTuningServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.openai.services.async.finetuning.JobServiceAsync import com.openai.services.async.finetuning.JobServiceAsyncImpl import com.openai.services.async.finetuning.MethodServiceAsync import com.openai.services.async.finetuning.MethodServiceAsyncImpl +import java.util.function.Consumer class FineTuningServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : FineTuningServiceAsync { @@ -31,6 +32,9 @@ class FineTuningServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): FineTuningServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FineTuningServiceAsync = + FineTuningServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun methods(): MethodServiceAsync = methods override fun jobs(): JobServiceAsync = jobs @@ -58,6 +62,13 @@ class FineTuningServiceAsyncImpl internal constructor(private val clientOptions: AlphaServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FineTuningServiceAsync.WithRawResponse = + FineTuningServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun methods(): MethodServiceAsync.WithRawResponse = methods override fun jobs(): JobServiceAsync.WithRawResponse = jobs diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/GraderServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/GraderServiceAsync.kt index fdc63d85..3ea099a8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/GraderServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/GraderServiceAsync.kt @@ -2,7 +2,9 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.services.async.graders.GraderModelServiceAsync +import java.util.function.Consumer interface GraderServiceAsync { @@ -11,6 +13,13 @@ interface GraderServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GraderServiceAsync + fun graderModels(): GraderModelServiceAsync /** @@ -18,6 +27,15 @@ interface GraderServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): GraderServiceAsync.WithRawResponse + fun graderModels(): GraderModelServiceAsync.WithRawResponse } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/GraderServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/GraderServiceAsyncImpl.kt index 28ac64f3..2acfb9da 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/GraderServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/GraderServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.openai.services.async import com.openai.core.ClientOptions import com.openai.services.async.graders.GraderModelServiceAsync import com.openai.services.async.graders.GraderModelServiceAsyncImpl +import java.util.function.Consumer class GraderServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : GraderServiceAsync { @@ -19,6 +20,9 @@ class GraderServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): GraderServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GraderServiceAsync = + GraderServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun graderModels(): GraderModelServiceAsync = graderModels class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +32,13 @@ class GraderServiceAsyncImpl internal constructor(private val clientOptions: Cli GraderModelServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): GraderServiceAsync.WithRawResponse = + GraderServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun graderModels(): GraderModelServiceAsync.WithRawResponse = graderModels } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsync.kt index e1a9975f..946ddbaa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.images.ImageCreateVariationParams @@ -9,6 +10,7 @@ import com.openai.models.images.ImageEditParams import com.openai.models.images.ImageGenerateParams import com.openai.models.images.ImagesResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ImageServiceAsync { @@ -17,6 +19,13 @@ interface ImageServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ImageServiceAsync + /** Creates a variation of a given image. This endpoint only supports `dall-e-2`. */ fun createVariation(params: ImageCreateVariationParams): CompletableFuture = createVariation(params, RequestOptions.none()) @@ -56,6 +65,15 @@ interface ImageServiceAsync { /** A view of [ImageServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ImageServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /images/variations`, but is otherwise the same as * [ImageServiceAsync.createVariation]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt index a7cd8014..63b4e9a5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt @@ -21,6 +21,7 @@ import com.openai.models.images.ImageEditParams import com.openai.models.images.ImageGenerateParams import com.openai.models.images.ImagesResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ImageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ImageServiceAsync { @@ -31,6 +32,9 @@ class ImageServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ImageServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ImageServiceAsync = + ImageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun createVariation( params: ImageCreateVariationParams, requestOptions: RequestOptions, @@ -57,6 +61,13 @@ class ImageServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ImageServiceAsync.WithRawResponse = + ImageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createVariationHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsync.kt index cc9d0a0c..389e98eb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.models.Model @@ -11,6 +12,7 @@ import com.openai.models.models.ModelListPageAsync import com.openai.models.models.ModelListParams import com.openai.models.models.ModelRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ModelServiceAsync { @@ -19,6 +21,13 @@ interface ModelServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelServiceAsync + /** * Retrieves a model instance, providing basic information about the model such as the owner and * permissioning. @@ -112,6 +121,15 @@ interface ModelServiceAsync { /** A view of [ModelServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ModelServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /models/{model}`, but is otherwise the same as * [ModelServiceAsync.retrieve]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsyncImpl.kt index 9aa967ea..62ecc8b0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsyncImpl.kt @@ -24,6 +24,7 @@ import com.openai.models.models.ModelListPageResponse import com.openai.models.models.ModelListParams import com.openai.models.models.ModelRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ModelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -35,6 +36,9 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ModelServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModelServiceAsync = + ModelServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ModelRetrieveParams, requestOptions: RequestOptions, @@ -61,6 +65,13 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModelServiceAsync.WithRawResponse = + ModelServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsync.kt index 0d598ccf..1cef3d34 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsync.kt @@ -2,11 +2,13 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.moderations.ModerationCreateParams import com.openai.models.moderations.ModerationCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ModerationServiceAsync { @@ -15,6 +17,13 @@ interface ModerationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModerationServiceAsync + /** * Classifies if text and/or image inputs are potentially harmful. Learn more in the * [moderation guide](https://platform.openai.com/docs/guides/moderation). @@ -34,6 +43,15 @@ interface ModerationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ModerationServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /moderations`, but is otherwise the same as * [ModerationServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsyncImpl.kt index f86ab6e9..8aca6c89 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.openai.models.ErrorObject import com.openai.models.moderations.ModerationCreateParams import com.openai.models.moderations.ModerationCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ModerationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ModerationServiceAsync { @@ -28,6 +29,9 @@ class ModerationServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): ModerationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModerationServiceAsync = + ModerationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: ModerationCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ModerationServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModerationServiceAsync.WithRawResponse = + ModerationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt index 6c208cd5..0c01e42b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt @@ -3,6 +3,7 @@ package com.openai.services.async import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.AsyncStreamResponse import com.openai.core.http.HttpResponse @@ -16,6 +17,7 @@ import com.openai.models.responses.ResponseRetrieveParams import com.openai.models.responses.ResponseStreamEvent import com.openai.services.async.responses.InputItemServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ResponseServiceAsync { @@ -24,6 +26,13 @@ interface ResponseServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ResponseServiceAsync + fun inputItems(): InputItemServiceAsync /** @@ -208,6 +217,15 @@ interface ResponseServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ResponseServiceAsync.WithRawResponse + fun inputItems(): InputItemServiceAsync.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt index c74fedde..1ebda153 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt @@ -34,6 +34,7 @@ import com.openai.models.responses.ResponseStreamEvent import com.openai.services.async.responses.InputItemServiceAsync import com.openai.services.async.responses.InputItemServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ResponseServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -49,6 +50,9 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): ResponseServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ResponseServiceAsync = + ResponseServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun inputItems(): InputItemServiceAsync = inputItems override fun create( @@ -108,6 +112,13 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C InputItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ResponseServiceAsync.WithRawResponse = + ResponseServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun inputItems(): InputItemServiceAsync.WithRawResponse = inputItems private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsync.kt index fb500d7f..f812d4c1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.uploads.Upload @@ -10,6 +11,7 @@ import com.openai.models.uploads.UploadCompleteParams import com.openai.models.uploads.UploadCreateParams import com.openai.services.async.uploads.PartServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface UploadServiceAsync { @@ -18,6 +20,13 @@ interface UploadServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UploadServiceAsync + fun parts(): PartServiceAsync /** @@ -120,6 +129,15 @@ interface UploadServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): UploadServiceAsync.WithRawResponse + fun parts(): PartServiceAsync.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsyncImpl.kt index a2f24c9d..522f43c5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsyncImpl.kt @@ -23,6 +23,7 @@ import com.openai.models.uploads.UploadCreateParams import com.openai.services.async.uploads.PartServiceAsync import com.openai.services.async.uploads.PartServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class UploadServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -36,6 +37,9 @@ class UploadServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): UploadServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): UploadServiceAsync = + UploadServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun parts(): PartServiceAsync = parts override fun create( @@ -68,6 +72,13 @@ class UploadServiceAsyncImpl internal constructor(private val clientOptions: Cli PartServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): UploadServiceAsync.WithRawResponse = + UploadServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun parts(): PartServiceAsync.WithRawResponse = parts private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsync.kt index c6584162..f8f29055 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.vectorstores.VectorStore @@ -17,6 +18,7 @@ import com.openai.models.vectorstores.VectorStoreUpdateParams import com.openai.services.async.vectorstores.FileBatchServiceAsync import com.openai.services.async.vectorstores.FileServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface VectorStoreServiceAsync { @@ -25,6 +27,13 @@ interface VectorStoreServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VectorStoreServiceAsync + fun files(): FileServiceAsync fun fileBatches(): FileBatchServiceAsync @@ -201,6 +210,15 @@ interface VectorStoreServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): VectorStoreServiceAsync.WithRawResponse + fun files(): FileServiceAsync.WithRawResponse fun fileBatches(): FileBatchServiceAsync.WithRawResponse diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsyncImpl.kt index 3aabfacc..9b14d234 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsyncImpl.kt @@ -34,6 +34,7 @@ import com.openai.services.async.vectorstores.FileBatchServiceAsyncImpl import com.openai.services.async.vectorstores.FileServiceAsync import com.openai.services.async.vectorstores.FileServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class VectorStoreServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -56,6 +57,9 @@ class VectorStoreServiceAsyncImpl internal constructor(private val clientOptions override fun withRawResponse(): VectorStoreServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): VectorStoreServiceAsync = + VectorStoreServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun files(): FileServiceAsync = files override fun fileBatches(): FileBatchServiceAsync = fileBatches @@ -115,6 +119,13 @@ class VectorStoreServiceAsyncImpl internal constructor(private val clientOptions FileBatchServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): VectorStoreServiceAsync.WithRawResponse = + VectorStoreServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun files(): FileServiceAsync.WithRawResponse = files override fun fileBatches(): FileBatchServiceAsync.WithRawResponse = fileBatches diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsync.kt index 8a2ab2ae..f44e035f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsync.kt @@ -2,10 +2,12 @@ package com.openai.services.async.audio +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.models.audio.speech.SpeechCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface SpeechServiceAsync { @@ -14,6 +16,13 @@ interface SpeechServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpeechServiceAsync + /** Generates audio from the input text. */ fun create(params: SpeechCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -29,6 +38,15 @@ interface SpeechServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SpeechServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /audio/speech`, but is otherwise the same as * [SpeechServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsyncImpl.kt index 3b02a07d..bee7d0e1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsyncImpl.kt @@ -14,6 +14,7 @@ import com.openai.core.prepareAsync import com.openai.models.ErrorObject import com.openai.models.audio.speech.SpeechCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class SpeechServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SpeechServiceAsync { @@ -24,6 +25,9 @@ class SpeechServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): SpeechServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SpeechServiceAsync = + SpeechServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SpeechCreateParams, requestOptions: RequestOptions, @@ -36,6 +40,13 @@ class SpeechServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SpeechServiceAsync.WithRawResponse = + SpeechServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun create( params: SpeechCreateParams, requestOptions: RequestOptions, diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsync.kt index 0a39d98f..5ab98f01 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsync.kt @@ -3,6 +3,7 @@ package com.openai.services.async.audio import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.AsyncStreamResponse import com.openai.core.http.HttpResponseFor @@ -11,6 +12,7 @@ import com.openai.models.audio.transcriptions.TranscriptionCreateParams import com.openai.models.audio.transcriptions.TranscriptionCreateResponse import com.openai.models.audio.transcriptions.TranscriptionStreamEvent import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface TranscriptionServiceAsync { @@ -19,6 +21,13 @@ interface TranscriptionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TranscriptionServiceAsync + /** Transcribes audio into the input language. */ fun create(params: TranscriptionCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -47,6 +56,15 @@ interface TranscriptionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TranscriptionServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /audio/transcriptions`, but is otherwise the same * as [TranscriptionServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt index 9b595b73..7084472f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt @@ -31,6 +31,8 @@ import com.openai.models.audio.transcriptions.TranscriptionStreamEvent import java.util.concurrent.CompletableFuture import kotlin.jvm.optionals.getOrNull +import java.util.function.Consumer + class TranscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TranscriptionServiceAsync { @@ -40,6 +42,9 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio override fun withRawResponse(): TranscriptionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TranscriptionServiceAsync = + TranscriptionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: TranscriptionCreateParams, requestOptions: RequestOptions, @@ -62,6 +67,13 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TranscriptionServiceAsync.WithRawResponse = + TranscriptionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createJsonHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsync.kt index 8685bf75..bb756f67 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsync.kt @@ -2,11 +2,13 @@ package com.openai.services.async.audio +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.audio.translations.TranslationCreateParams import com.openai.models.audio.translations.TranslationCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface TranslationServiceAsync { @@ -15,6 +17,13 @@ interface TranslationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TranslationServiceAsync + /** Translates audio into English. */ fun create(params: TranslationCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -31,6 +40,15 @@ interface TranslationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TranslationServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /audio/translations`, but is otherwise the same as * [TranslationServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsyncImpl.kt index 222d7223..8a3f934d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.openai.models.ErrorObject import com.openai.models.audio.translations.TranslationCreateParams import com.openai.models.audio.translations.TranslationCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class TranslationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TranslationServiceAsync { @@ -28,6 +29,9 @@ class TranslationServiceAsyncImpl internal constructor(private val clientOptions override fun withRawResponse(): TranslationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TranslationServiceAsync = + TranslationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: TranslationCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class TranslationServiceAsyncImpl internal constructor(private val clientOptions private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TranslationServiceAsync.WithRawResponse = + TranslationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt index 3df83562..e29046f2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt @@ -3,6 +3,7 @@ package com.openai.services.async.chat import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.AsyncStreamResponse import com.openai.core.http.HttpResponseFor @@ -18,6 +19,7 @@ import com.openai.models.chat.completions.ChatCompletionRetrieveParams import com.openai.models.chat.completions.ChatCompletionUpdateParams import com.openai.services.async.chat.completions.MessageServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ChatCompletionServiceAsync { @@ -26,6 +28,13 @@ interface ChatCompletionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatCompletionServiceAsync + fun messages(): MessageServiceAsync /** @@ -216,6 +225,15 @@ interface ChatCompletionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ChatCompletionServiceAsync.WithRawResponse + fun messages(): MessageServiceAsync.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncImpl.kt index 86e2f38a..de60f5a3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncImpl.kt @@ -36,6 +36,7 @@ import com.openai.models.chat.completions.ChatCompletionUpdateParams import com.openai.services.async.chat.completions.MessageServiceAsync import com.openai.services.async.chat.completions.MessageServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ChatCompletionServiceAsyncImpl @@ -49,6 +50,11 @@ internal constructor(private val clientOptions: ClientOptions) : ChatCompletionS override fun withRawResponse(): ChatCompletionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): ChatCompletionServiceAsync = + ChatCompletionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun messages(): MessageServiceAsync = messages override fun create( @@ -105,6 +111,13 @@ internal constructor(private val clientOptions: ClientOptions) : ChatCompletionS MessageServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ChatCompletionServiceAsync.WithRawResponse = + ChatCompletionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun messages(): MessageServiceAsync.WithRawResponse = messages private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsync.kt index b6182dad..761ba94c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsync.kt @@ -2,11 +2,13 @@ package com.openai.services.async.chat.completions +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.chat.completions.messages.MessageListPageAsync import com.openai.models.chat.completions.messages.MessageListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface MessageServiceAsync { @@ -15,6 +17,13 @@ interface MessageServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MessageServiceAsync + /** * Get the messages in a stored chat completion. Only Chat Completions that have been created * with the `store` parameter set to `true` will be returned. @@ -58,6 +67,15 @@ interface MessageServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): MessageServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /chat/completions/{completion_id}/messages`, but is * otherwise the same as [MessageServiceAsync.list]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsyncImpl.kt index 022f17c8..2581be26 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.openai.models.chat.completions.messages.MessageListPageAsync import com.openai.models.chat.completions.messages.MessageListPageResponse import com.openai.models.chat.completions.messages.MessageListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class MessageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): MessageServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): MessageServiceAsync = + MessageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: MessageListParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): MessageServiceAsync.WithRawResponse = + MessageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsync.kt index 03f07130..7f68fbab 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async.containers +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponseFor @@ -14,6 +15,7 @@ import com.openai.models.containers.files.FileRetrieveParams import com.openai.models.containers.files.FileRetrieveResponse import com.openai.services.async.containers.files.ContentServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface FileServiceAsync { @@ -22,6 +24,13 @@ interface FileServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileServiceAsync + fun content(): ContentServiceAsync /** @@ -147,6 +156,13 @@ interface FileServiceAsync { /** A view of [FileServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileServiceAsync.WithRawResponse + fun content(): ContentServiceAsync.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsyncImpl.kt index e8da17e3..fbe52f89 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsyncImpl.kt @@ -30,6 +30,7 @@ import com.openai.models.containers.files.FileRetrieveResponse import com.openai.services.async.containers.files.ContentServiceAsync import com.openai.services.async.containers.files.ContentServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -43,6 +44,9 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): FileServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileServiceAsync = + FileServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun content(): ContentServiceAsync = content override fun create( @@ -82,6 +86,13 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien ContentServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FileServiceAsync.WithRawResponse = + FileServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun content(): ContentServiceAsync.WithRawResponse = content private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsync.kt index 00298b94..b714b59b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsync.kt @@ -2,10 +2,12 @@ package com.openai.services.async.containers.files +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.models.containers.files.content.ContentRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ContentServiceAsync { @@ -14,6 +16,13 @@ interface ContentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContentServiceAsync + /** Retrieve Container File Content */ fun retrieve(fileId: String, params: ContentRetrieveParams): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) @@ -41,6 +50,15 @@ interface ContentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ContentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /containers/{container_id}/files/{file_id}/content`, * but is otherwise the same as [ContentServiceAsync.retrieve]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt index d6e05fd2..cbd87e0e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt @@ -14,6 +14,7 @@ import com.openai.core.prepareAsync import com.openai.models.ErrorObject import com.openai.models.containers.files.content.ContentRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ContentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -25,6 +26,9 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): ContentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ContentServiceAsync = + ContentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions, @@ -37,6 +41,13 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ContentServiceAsync.WithRawResponse = + ContentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions, diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsync.kt index ba3b60c9..a64f2bc3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async.evals +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.evals.runs.RunCancelParams @@ -16,6 +17,7 @@ import com.openai.models.evals.runs.RunRetrieveParams import com.openai.models.evals.runs.RunRetrieveResponse import com.openai.services.async.evals.runs.OutputItemServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface RunServiceAsync { @@ -24,6 +26,13 @@ interface RunServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RunServiceAsync + fun outputItems(): OutputItemServiceAsync /** @@ -153,6 +162,13 @@ interface RunServiceAsync { /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RunServiceAsync.WithRawResponse + fun outputItems(): OutputItemServiceAsync.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsyncImpl.kt index 998be569..7e151c7f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsyncImpl.kt @@ -30,6 +30,7 @@ import com.openai.models.evals.runs.RunRetrieveResponse import com.openai.services.async.evals.runs.OutputItemServiceAsync import com.openai.services.async.evals.runs.OutputItemServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -45,6 +46,9 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RunServiceAsync = + RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun outputItems(): OutputItemServiceAsync = outputItems override fun create( @@ -91,6 +95,13 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client OutputItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): RunServiceAsync.WithRawResponse = + RunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun outputItems(): OutputItemServiceAsync.WithRawResponse = outputItems private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsync.kt index 3cb4c9c2..2b897e6c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async.evals.runs +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.evals.runs.outputitems.OutputItemListPageAsync @@ -9,6 +10,7 @@ import com.openai.models.evals.runs.outputitems.OutputItemListParams import com.openai.models.evals.runs.outputitems.OutputItemRetrieveParams import com.openai.models.evals.runs.outputitems.OutputItemRetrieveResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface OutputItemServiceAsync { @@ -17,6 +19,13 @@ interface OutputItemServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OutputItemServiceAsync + /** Get an evaluation run output item by ID. */ fun retrieve( outputItemId: String, @@ -72,6 +81,15 @@ interface OutputItemServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OutputItemServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get * /evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}`, but is otherwise the same diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsyncImpl.kt index 3f9dbf8f..32e6c0fe 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/runs/OutputItemServiceAsyncImpl.kt @@ -21,6 +21,7 @@ import com.openai.models.evals.runs.outputitems.OutputItemListParams import com.openai.models.evals.runs.outputitems.OutputItemRetrieveParams import com.openai.models.evals.runs.outputitems.OutputItemRetrieveResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class OutputItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -32,6 +33,9 @@ class OutputItemServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): OutputItemServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OutputItemServiceAsync = + OutputItemServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: OutputItemRetrieveParams, requestOptions: RequestOptions, @@ -51,6 +55,13 @@ class OutputItemServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): OutputItemServiceAsync.WithRawResponse = + OutputItemServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/AlphaServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/AlphaServiceAsync.kt index 58bc3d54..3ab4669f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/AlphaServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/AlphaServiceAsync.kt @@ -2,7 +2,9 @@ package com.openai.services.async.finetuning +import com.openai.core.ClientOptions import com.openai.services.async.finetuning.alpha.GraderServiceAsync +import java.util.function.Consumer interface AlphaServiceAsync { @@ -11,11 +13,27 @@ interface AlphaServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AlphaServiceAsync + fun graders(): GraderServiceAsync /** A view of [AlphaServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AlphaServiceAsync.WithRawResponse + fun graders(): GraderServiceAsync.WithRawResponse } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/AlphaServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/AlphaServiceAsyncImpl.kt index fff90acb..a5928ca1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/AlphaServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/AlphaServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.openai.services.async.finetuning import com.openai.core.ClientOptions import com.openai.services.async.finetuning.alpha.GraderServiceAsync import com.openai.services.async.finetuning.alpha.GraderServiceAsyncImpl +import java.util.function.Consumer class AlphaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AlphaServiceAsync { @@ -17,6 +18,9 @@ class AlphaServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): AlphaServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AlphaServiceAsync = + AlphaServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun graders(): GraderServiceAsync = graders class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class AlphaServiceAsyncImpl internal constructor(private val clientOptions: Clie GraderServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): AlphaServiceAsync.WithRawResponse = + AlphaServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun graders(): GraderServiceAsync.WithRawResponse = graders } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/CheckpointServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/CheckpointServiceAsync.kt index 5cb87870..4f074e78 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/CheckpointServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/CheckpointServiceAsync.kt @@ -2,7 +2,9 @@ package com.openai.services.async.finetuning +import com.openai.core.ClientOptions import com.openai.services.async.finetuning.checkpoints.PermissionServiceAsync +import java.util.function.Consumer interface CheckpointServiceAsync { @@ -11,6 +13,13 @@ interface CheckpointServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CheckpointServiceAsync + fun permissions(): PermissionServiceAsync /** @@ -19,6 +28,15 @@ interface CheckpointServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CheckpointServiceAsync.WithRawResponse + fun permissions(): PermissionServiceAsync.WithRawResponse } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/CheckpointServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/CheckpointServiceAsyncImpl.kt index 21149f07..bc4b76e4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/CheckpointServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/CheckpointServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.openai.services.async.finetuning import com.openai.core.ClientOptions import com.openai.services.async.finetuning.checkpoints.PermissionServiceAsync import com.openai.services.async.finetuning.checkpoints.PermissionServiceAsyncImpl +import java.util.function.Consumer class CheckpointServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CheckpointServiceAsync { @@ -19,6 +20,9 @@ class CheckpointServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): CheckpointServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CheckpointServiceAsync = + CheckpointServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun permissions(): PermissionServiceAsync = permissions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +32,13 @@ class CheckpointServiceAsyncImpl internal constructor(private val clientOptions: PermissionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): CheckpointServiceAsync.WithRawResponse = + CheckpointServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun permissions(): PermissionServiceAsync.WithRawResponse = permissions } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsync.kt index bda9839a..8bf79c20 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async.finetuning +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.finetuning.jobs.FineTuningJob @@ -16,6 +17,7 @@ import com.openai.models.finetuning.jobs.JobResumeParams import com.openai.models.finetuning.jobs.JobRetrieveParams import com.openai.services.async.finetuning.jobs.CheckpointServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface JobServiceAsync { @@ -24,6 +26,13 @@ interface JobServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync + fun checkpoints(): CheckpointServiceAsync /** @@ -244,6 +253,13 @@ interface JobServiceAsync { /** A view of [JobServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync.WithRawResponse + fun checkpoints(): CheckpointServiceAsync.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsyncImpl.kt index b8aa421f..d49c92ca 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/JobServiceAsyncImpl.kt @@ -31,6 +31,7 @@ import com.openai.models.finetuning.jobs.JobRetrieveParams import com.openai.services.async.finetuning.jobs.CheckpointServiceAsync import com.openai.services.async.finetuning.jobs.CheckpointServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class JobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -46,6 +47,9 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): JobServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobServiceAsync = + JobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun checkpoints(): CheckpointServiceAsync = checkpoints override fun create( @@ -106,6 +110,13 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client CheckpointServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobServiceAsync.WithRawResponse = + JobServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun checkpoints(): CheckpointServiceAsync.WithRawResponse = checkpoints private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/MethodServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/MethodServiceAsync.kt index 6c46a35d..d414ac50 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/MethodServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/MethodServiceAsync.kt @@ -2,6 +2,9 @@ package com.openai.services.async.finetuning +import com.openai.core.ClientOptions +import java.util.function.Consumer + interface MethodServiceAsync { /** @@ -9,8 +12,25 @@ interface MethodServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MethodServiceAsync + /** * A view of [MethodServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): MethodServiceAsync.WithRawResponse + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/MethodServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/MethodServiceAsyncImpl.kt index a2803029..908985a4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/MethodServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/MethodServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openai.services.async.finetuning import com.openai.core.ClientOptions +import java.util.function.Consumer class MethodServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MethodServiceAsync { @@ -13,6 +14,17 @@ class MethodServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): MethodServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): MethodServiceAsync = + MethodServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - MethodServiceAsync.WithRawResponse + MethodServiceAsync.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): MethodServiceAsync.WithRawResponse = + MethodServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsync.kt index d6b04a06..02f11d4f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async.finetuning.alpha +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.finetuning.alpha.graders.GraderRunParams @@ -9,6 +10,7 @@ import com.openai.models.finetuning.alpha.graders.GraderRunResponse import com.openai.models.finetuning.alpha.graders.GraderValidateParams import com.openai.models.finetuning.alpha.graders.GraderValidateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface GraderServiceAsync { @@ -17,6 +19,13 @@ interface GraderServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GraderServiceAsync + /** Run a grader. */ fun run(params: GraderRunParams): CompletableFuture = run(params, RequestOptions.none()) @@ -42,6 +51,15 @@ interface GraderServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): GraderServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /fine_tuning/alpha/graders/run`, but is otherwise * the same as [GraderServiceAsync.run]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsyncImpl.kt index 4023a138..dfedf9ba 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/alpha/GraderServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.openai.models.finetuning.alpha.graders.GraderRunResponse import com.openai.models.finetuning.alpha.graders.GraderValidateParams import com.openai.models.finetuning.alpha.graders.GraderValidateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class GraderServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : GraderServiceAsync { @@ -30,6 +31,9 @@ class GraderServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): GraderServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GraderServiceAsync = + GraderServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun run( params: GraderRunParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class GraderServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): GraderServiceAsync.WithRawResponse = + GraderServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val runHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsync.kt index 68829102..c1484779 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async.finetuning.checkpoints +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.finetuning.checkpoints.permissions.PermissionCreatePageAsync @@ -11,6 +12,7 @@ import com.openai.models.finetuning.checkpoints.permissions.PermissionDeleteResp import com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveParams import com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PermissionServiceAsync { @@ -19,6 +21,13 @@ interface PermissionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PermissionServiceAsync + /** * **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys). * @@ -132,6 +141,15 @@ interface PermissionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PermissionServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post * /fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions`, but is otherwise the diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt index 958c8071..10f6b97e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt @@ -24,6 +24,7 @@ import com.openai.models.finetuning.checkpoints.permissions.PermissionDeleteResp import com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveParams import com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PermissionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -35,6 +36,9 @@ class PermissionServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): PermissionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PermissionServiceAsync = + PermissionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: PermissionCreateParams, requestOptions: RequestOptions, @@ -61,6 +65,13 @@ class PermissionServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PermissionServiceAsync.WithRawResponse = + PermissionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsync.kt index d19ae077..23577702 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsync.kt @@ -2,11 +2,13 @@ package com.openai.services.async.finetuning.jobs +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.finetuning.jobs.checkpoints.CheckpointListPageAsync import com.openai.models.finetuning.jobs.checkpoints.CheckpointListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CheckpointServiceAsync { @@ -15,6 +17,13 @@ interface CheckpointServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CheckpointServiceAsync + /** List checkpoints for a fine-tuning job. */ fun list(fineTuningJobId: String): CompletableFuture = list(fineTuningJobId, CheckpointListParams.none()) @@ -57,6 +66,15 @@ interface CheckpointServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CheckpointServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints`, * but is otherwise the same as [CheckpointServiceAsync.list]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsyncImpl.kt index 1b470d1f..e033cb35 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/jobs/CheckpointServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.openai.models.finetuning.jobs.checkpoints.CheckpointListPageAsync import com.openai.models.finetuning.jobs.checkpoints.CheckpointListPageResponse import com.openai.models.finetuning.jobs.checkpoints.CheckpointListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CheckpointServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class CheckpointServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): CheckpointServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CheckpointServiceAsync = + CheckpointServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: CheckpointListParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class CheckpointServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CheckpointServiceAsync.WithRawResponse = + CheckpointServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/graders/GraderModelServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/graders/GraderModelServiceAsync.kt index e1d62600..c66e1978 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/graders/GraderModelServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/graders/GraderModelServiceAsync.kt @@ -2,6 +2,9 @@ package com.openai.services.async.graders +import com.openai.core.ClientOptions +import java.util.function.Consumer + interface GraderModelServiceAsync { /** @@ -9,9 +12,26 @@ interface GraderModelServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GraderModelServiceAsync + /** * A view of [GraderModelServiceAsync] that provides access to raw HTTP responses for each * method. */ - interface WithRawResponse + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): GraderModelServiceAsync.WithRawResponse + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/graders/GraderModelServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/graders/GraderModelServiceAsyncImpl.kt index 8132d3b8..58c21cbf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/graders/GraderModelServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/graders/GraderModelServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openai.services.async.graders import com.openai.core.ClientOptions +import java.util.function.Consumer class GraderModelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : GraderModelServiceAsync { @@ -13,6 +14,17 @@ class GraderModelServiceAsyncImpl internal constructor(private val clientOptions override fun withRawResponse(): GraderModelServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GraderModelServiceAsync = + GraderModelServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - GraderModelServiceAsync.WithRawResponse + GraderModelServiceAsync.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): GraderModelServiceAsync.WithRawResponse = + GraderModelServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsync.kt index 90be2ad5..599e2417 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsync.kt @@ -2,11 +2,13 @@ package com.openai.services.async.responses +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.responses.inputitems.InputItemListPageAsync import com.openai.models.responses.inputitems.InputItemListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface InputItemServiceAsync { @@ -15,6 +17,13 @@ interface InputItemServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InputItemServiceAsync + /** Returns a list of input items for a given response. */ fun list(responseId: String): CompletableFuture = list(responseId, InputItemListParams.none()) @@ -55,6 +64,15 @@ interface InputItemServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): InputItemServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /responses/{response_id}/input_items`, but is * otherwise the same as [InputItemServiceAsync.list]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsyncImpl.kt index 6bf746a5..22bed7ec 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/responses/InputItemServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.openai.models.responses.inputitems.InputItemListPageAsync import com.openai.models.responses.inputitems.InputItemListParams import com.openai.models.responses.inputitems.ResponseItemList import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class InputItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): InputItemServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): InputItemServiceAsync = + InputItemServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: InputItemListParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): InputItemServiceAsync.WithRawResponse = + InputItemServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsync.kt index 2d433f99..65b76bc5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsync.kt @@ -2,11 +2,13 @@ package com.openai.services.async.uploads +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.uploads.parts.PartCreateParams import com.openai.models.uploads.parts.UploadPart import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PartServiceAsync { @@ -15,6 +17,13 @@ interface PartServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PartServiceAsync + /** * Adds a [Part](https://platform.openai.com/docs/api-reference/uploads/part-object) to an * [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object. A Part @@ -51,6 +60,13 @@ interface PartServiceAsync { /** A view of [PartServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PartServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /uploads/{upload_id}/parts`, but is otherwise the * same as [PartServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsyncImpl.kt index 6d866edb..504741cf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/uploads/PartServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.openai.models.ErrorObject import com.openai.models.uploads.parts.PartCreateParams import com.openai.models.uploads.parts.UploadPart import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PartServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class PartServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): PartServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PartServiceAsync = + PartServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: PartCreateParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class PartServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PartServiceAsync.WithRawResponse = + PartServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsync.kt index d2b5adf0..05a1b7e6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async.vectorstores +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.vectorstores.filebatches.FileBatchCancelParams @@ -11,6 +12,7 @@ import com.openai.models.vectorstores.filebatches.FileBatchListFilesParams import com.openai.models.vectorstores.filebatches.FileBatchRetrieveParams import com.openai.models.vectorstores.filebatches.VectorStoreFileBatch import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface FileBatchServiceAsync { @@ -19,6 +21,13 @@ interface FileBatchServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileBatchServiceAsync + /** Create a vector store file batch. */ fun create( vectorStoreId: String, @@ -126,6 +135,15 @@ interface FileBatchServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): FileBatchServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /vector_stores/{vector_store_id}/file_batches`, but * is otherwise the same as [FileBatchServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsyncImpl.kt index 01d69ce9..f579924c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileBatchServiceAsyncImpl.kt @@ -25,6 +25,7 @@ import com.openai.models.vectorstores.filebatches.FileBatchListFilesParams import com.openai.models.vectorstores.filebatches.FileBatchRetrieveParams import com.openai.models.vectorstores.filebatches.VectorStoreFileBatch import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileBatchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -41,6 +42,9 @@ class FileBatchServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): FileBatchServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileBatchServiceAsync = + FileBatchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: FileBatchCreateParams, requestOptions: RequestOptions, @@ -74,6 +78,13 @@ class FileBatchServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): FileBatchServiceAsync.WithRawResponse = + FileBatchServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsync.kt index b4dd00c2..e3c1e6aa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsync.kt @@ -2,6 +2,7 @@ package com.openai.services.async.vectorstores +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.vectorstores.files.FileContentPageAsync @@ -15,6 +16,7 @@ import com.openai.models.vectorstores.files.FileUpdateParams import com.openai.models.vectorstores.files.VectorStoreFile import com.openai.models.vectorstores.files.VectorStoreFileDeleted import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface FileServiceAsync { @@ -23,6 +25,13 @@ interface FileServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileServiceAsync + /** * Create a vector store file by attaching a * [File](https://platform.openai.com/docs/api-reference/files) to a @@ -185,6 +194,13 @@ interface FileServiceAsync { /** A view of [FileServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /vector_stores/{vector_store_id}/files`, but is * otherwise the same as [FileServiceAsync.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsyncImpl.kt index b2c72ede..f8ac69ed 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/vectorstores/FileServiceAsyncImpl.kt @@ -30,6 +30,7 @@ import com.openai.models.vectorstores.files.FileUpdateParams import com.openai.models.vectorstores.files.VectorStoreFile import com.openai.models.vectorstores.files.VectorStoreFileDeleted import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -46,6 +47,9 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): FileServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileServiceAsync = + FileServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: FileCreateParams, requestOptions: RequestOptions, @@ -93,6 +97,13 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): FileServiceAsync.WithRawResponse = + FileServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/AudioService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/AudioService.kt index 857ff5bc..4bd4a0df 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/AudioService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/AudioService.kt @@ -2,9 +2,11 @@ package com.openai.services.blocking +import com.openai.core.ClientOptions import com.openai.services.blocking.audio.SpeechService import com.openai.services.blocking.audio.TranscriptionService import com.openai.services.blocking.audio.TranslationService +import java.util.function.Consumer interface AudioService { @@ -13,6 +15,13 @@ interface AudioService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AudioService + fun transcriptions(): TranscriptionService fun translations(): TranslationService @@ -22,6 +31,13 @@ interface AudioService { /** A view of [AudioService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AudioService.WithRawResponse + fun transcriptions(): TranscriptionService.WithRawResponse fun translations(): TranslationService.WithRawResponse diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/AudioServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/AudioServiceImpl.kt index 29fac3b2..a239ff6c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/AudioServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/AudioServiceImpl.kt @@ -9,6 +9,7 @@ import com.openai.services.blocking.audio.TranscriptionService import com.openai.services.blocking.audio.TranscriptionServiceImpl import com.openai.services.blocking.audio.TranslationService import com.openai.services.blocking.audio.TranslationServiceImpl +import java.util.function.Consumer class AudioServiceImpl internal constructor(private val clientOptions: ClientOptions) : AudioService { @@ -27,6 +28,9 @@ class AudioServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): AudioService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AudioService = + AudioServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun transcriptions(): TranscriptionService = transcriptions override fun translations(): TranslationService = translations @@ -48,6 +52,13 @@ class AudioServiceImpl internal constructor(private val clientOptions: ClientOpt SpeechServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): AudioService.WithRawResponse = + AudioServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun transcriptions(): TranscriptionService.WithRawResponse = transcriptions override fun translations(): TranslationService.WithRawResponse = translations diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchService.kt index 778efa58..0edaf486 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.batches.Batch @@ -11,6 +12,7 @@ import com.openai.models.batches.BatchCreateParams import com.openai.models.batches.BatchListPage import com.openai.models.batches.BatchListParams import com.openai.models.batches.BatchRetrieveParams +import java.util.function.Consumer interface BatchService { @@ -19,6 +21,13 @@ interface BatchService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BatchService + /** Creates and executes a batch from an uploaded file of requests */ fun create(params: BatchCreateParams): Batch = create(params, RequestOptions.none()) @@ -106,6 +115,13 @@ interface BatchService { /** A view of [BatchService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BatchService.WithRawResponse + /** * Returns a raw HTTP response for `post /batches`, but is otherwise the same as * [BatchService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchServiceImpl.kt index 492b1a1a..7302baba 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BatchServiceImpl.kt @@ -23,6 +23,7 @@ import com.openai.models.batches.BatchListPage import com.openai.models.batches.BatchListPageResponse import com.openai.models.batches.BatchListParams import com.openai.models.batches.BatchRetrieveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BatchServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,6 +35,9 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): BatchService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BatchService = + BatchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create(params: BatchCreateParams, requestOptions: RequestOptions): Batch = // post /batches withRawResponse().create(params, requestOptions).parse() @@ -55,6 +59,13 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BatchService.WithRawResponse = + BatchServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaService.kt index 60324516..937c5022 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaService.kt @@ -2,6 +2,9 @@ package com.openai.services.blocking +import com.openai.core.ClientOptions +import java.util.function.Consumer + interface BetaService { /** @@ -9,6 +12,21 @@ interface BetaService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaService + /** A view of [BetaService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaService.WithRawResponse + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaServiceImpl.kt index 50d31991..71bab0c3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaServiceImpl.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking import com.openai.core.ClientOptions +import java.util.function.Consumer class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService { @@ -12,6 +13,17 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): BetaService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BetaService = + BetaServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BetaService.WithRawResponse + BetaService.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): BetaService.WithRawResponse = + BetaServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ChatService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ChatService.kt index cf47e2e1..36bcc215 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ChatService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ChatService.kt @@ -2,7 +2,9 @@ package com.openai.services.blocking +import com.openai.core.ClientOptions import com.openai.services.blocking.chat.ChatCompletionService +import java.util.function.Consumer interface ChatService { @@ -11,11 +13,25 @@ interface ChatService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatService + fun completions(): ChatCompletionService /** A view of [ChatService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatService.WithRawResponse + fun completions(): ChatCompletionService.WithRawResponse } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ChatServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ChatServiceImpl.kt index 4b25d7f2..692514a5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ChatServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ChatServiceImpl.kt @@ -5,6 +5,7 @@ package com.openai.services.blocking import com.openai.core.ClientOptions import com.openai.services.blocking.chat.ChatCompletionService import com.openai.services.blocking.chat.ChatCompletionServiceImpl +import java.util.function.Consumer class ChatServiceImpl internal constructor(private val clientOptions: ClientOptions) : ChatService { @@ -18,6 +19,9 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): ChatService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ChatService = + ChatServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun completions(): ChatCompletionService = completions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -27,6 +31,13 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti ChatCompletionServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ChatService.WithRawResponse = + ChatServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun completions(): ChatCompletionService.WithRawResponse = completions } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionService.kt index 6f5c844e..66b3a4fb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionService.kt @@ -3,11 +3,13 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.core.http.StreamResponse import com.openai.models.completions.Completion import com.openai.models.completions.CompletionCreateParams +import java.util.function.Consumer interface CompletionService { @@ -16,6 +18,13 @@ interface CompletionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompletionService + /** Creates a completion for the provided prompt and parameters. */ fun create(params: CompletionCreateParams): Completion = create(params, RequestOptions.none()) @@ -40,6 +49,15 @@ interface CompletionService { /** A view of [CompletionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompletionService.WithRawResponse + /** * Returns a raw HTTP response for `post /completions`, but is otherwise the same as * [CompletionService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionServiceImpl.kt index 695f855b..65a4f09b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/CompletionServiceImpl.kt @@ -22,6 +22,7 @@ import com.openai.core.prepare import com.openai.models.ErrorObject import com.openai.models.completions.Completion import com.openai.models.completions.CompletionCreateParams +import java.util.function.Consumer class CompletionServiceImpl internal constructor(private val clientOptions: ClientOptions) : CompletionService { @@ -32,6 +33,9 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): CompletionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompletionService = + CompletionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -51,6 +55,13 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompletionService.WithRawResponse = + CompletionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerService.kt index 73d5768b..a12ce601 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponseFor @@ -14,6 +15,7 @@ import com.openai.models.containers.ContainerListParams import com.openai.models.containers.ContainerRetrieveParams import com.openai.models.containers.ContainerRetrieveResponse import com.openai.services.blocking.containers.FileService +import java.util.function.Consumer interface ContainerService { @@ -22,6 +24,13 @@ interface ContainerService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContainerService + fun files(): FileService /** Create Container */ @@ -113,6 +122,13 @@ interface ContainerService { /** A view of [ContainerService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContainerService.WithRawResponse + fun files(): FileService.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerServiceImpl.kt index 39bd8838..55da41c7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ContainerServiceImpl.kt @@ -28,6 +28,7 @@ import com.openai.models.containers.ContainerRetrieveParams import com.openai.models.containers.ContainerRetrieveResponse import com.openai.services.blocking.containers.FileService import com.openai.services.blocking.containers.FileServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ContainerServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -41,6 +42,9 @@ class ContainerServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): ContainerService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ContainerService = + ContainerServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun files(): FileService = files override fun create( @@ -78,6 +82,13 @@ class ContainerServiceImpl internal constructor(private val clientOptions: Clien FileServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ContainerService.WithRawResponse = + ContainerServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun files(): FileService.WithRawResponse = files private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingService.kt index 98fd7401..7ae09df6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingService.kt @@ -3,10 +3,12 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.embeddings.CreateEmbeddingResponse import com.openai.models.embeddings.EmbeddingCreateParams +import java.util.function.Consumer interface EmbeddingService { @@ -15,6 +17,13 @@ interface EmbeddingService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmbeddingService + /** Creates an embedding vector representing the input text. */ fun create(params: EmbeddingCreateParams): CreateEmbeddingResponse = create(params, RequestOptions.none()) @@ -28,6 +37,13 @@ interface EmbeddingService { /** A view of [EmbeddingService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmbeddingService.WithRawResponse + /** * Returns a raw HTTP response for `post /embeddings`, but is otherwise the same as * [EmbeddingService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingServiceImpl.kt index 25ca6ce5..f7d45a18 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EmbeddingServiceImpl.kt @@ -17,6 +17,7 @@ import com.openai.core.prepare import com.openai.models.ErrorObject import com.openai.models.embeddings.CreateEmbeddingResponse import com.openai.models.embeddings.EmbeddingCreateParams +import java.util.function.Consumer class EmbeddingServiceImpl internal constructor(private val clientOptions: ClientOptions) : EmbeddingService { @@ -27,6 +28,9 @@ class EmbeddingServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): EmbeddingService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmbeddingService = + EmbeddingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: EmbeddingCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class EmbeddingServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmbeddingService.WithRawResponse = + EmbeddingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalService.kt index c747c5ef..ae9f5c6a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.evals.EvalCreateParams @@ -16,6 +17,7 @@ import com.openai.models.evals.EvalRetrieveResponse import com.openai.models.evals.EvalUpdateParams import com.openai.models.evals.EvalUpdateResponse import com.openai.services.blocking.evals.RunService +import java.util.function.Consumer interface EvalService { @@ -24,6 +26,13 @@ interface EvalService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EvalService + fun runs(): RunService /** @@ -149,6 +158,13 @@ interface EvalService { /** A view of [EvalService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EvalService.WithRawResponse + fun runs(): RunService.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalServiceImpl.kt index 6f8c5cfd..06f5116d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/EvalServiceImpl.kt @@ -29,6 +29,7 @@ import com.openai.models.evals.EvalUpdateParams import com.openai.models.evals.EvalUpdateResponse import com.openai.services.blocking.evals.RunService import com.openai.services.blocking.evals.RunServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EvalServiceImpl internal constructor(private val clientOptions: ClientOptions) : EvalService { @@ -41,6 +42,9 @@ class EvalServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): EvalService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EvalService = + EvalServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun runs(): RunService = runs override fun create( @@ -84,6 +88,13 @@ class EvalServiceImpl internal constructor(private val clientOptions: ClientOpti RunServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): EvalService.WithRawResponse = + EvalServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun runs(): RunService.WithRawResponse = runs private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileService.kt index 3f4934c3..fbae3f0c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponseFor @@ -14,6 +15,7 @@ import com.openai.models.files.FileListPage import com.openai.models.files.FileListParams import com.openai.models.files.FileObject import com.openai.models.files.FileRetrieveParams +import java.util.function.Consumer interface FileService { @@ -22,6 +24,13 @@ interface FileService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileService + /** * Upload a file that can be used across various endpoints. Individual files can be up to 512 * MB, and the size of all files uploaded by one organization can be up to 100 GB. @@ -160,6 +169,13 @@ interface FileService { /** A view of [FileService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileService.WithRawResponse + /** * Returns a raw HTTP response for `post /files`, but is otherwise the same as * [FileService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileServiceImpl.kt index bb373c9f..92eadecc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileServiceImpl.kt @@ -27,6 +27,7 @@ import com.openai.models.files.FileListPageResponse import com.openai.models.files.FileListParams import com.openai.models.files.FileObject import com.openai.models.files.FileRetrieveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { @@ -37,6 +38,9 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): FileService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileService = + FileServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create(params: FileCreateParams, requestOptions: RequestOptions): FileObject = // post /files withRawResponse().create(params, requestOptions).parse() @@ -62,6 +66,13 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): FileService.WithRawResponse = + FileServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FineTuningService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FineTuningService.kt index 77f45a35..db712450 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FineTuningService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FineTuningService.kt @@ -2,10 +2,12 @@ package com.openai.services.blocking +import com.openai.core.ClientOptions import com.openai.services.blocking.finetuning.AlphaService import com.openai.services.blocking.finetuning.CheckpointService import com.openai.services.blocking.finetuning.JobService import com.openai.services.blocking.finetuning.MethodService +import java.util.function.Consumer interface FineTuningService { @@ -14,6 +16,13 @@ interface FineTuningService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FineTuningService + fun methods(): MethodService fun jobs(): JobService @@ -25,6 +34,15 @@ interface FineTuningService { /** A view of [FineTuningService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): FineTuningService.WithRawResponse + fun methods(): MethodService.WithRawResponse fun jobs(): JobService.WithRawResponse diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FineTuningServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FineTuningServiceImpl.kt index 0f8b31d3..7a4a3ff0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FineTuningServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FineTuningServiceImpl.kt @@ -11,6 +11,7 @@ import com.openai.services.blocking.finetuning.JobService import com.openai.services.blocking.finetuning.JobServiceImpl import com.openai.services.blocking.finetuning.MethodService import com.openai.services.blocking.finetuning.MethodServiceImpl +import java.util.function.Consumer class FineTuningServiceImpl internal constructor(private val clientOptions: ClientOptions) : FineTuningService { @@ -29,6 +30,9 @@ class FineTuningServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): FineTuningService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FineTuningService = + FineTuningServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun methods(): MethodService = methods override fun jobs(): JobService = jobs @@ -56,6 +60,13 @@ class FineTuningServiceImpl internal constructor(private val clientOptions: Clie AlphaServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FineTuningService.WithRawResponse = + FineTuningServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun methods(): MethodService.WithRawResponse = methods override fun jobs(): JobService.WithRawResponse = jobs diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/GraderService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/GraderService.kt index 2c9433a2..66a53460 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/GraderService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/GraderService.kt @@ -2,7 +2,9 @@ package com.openai.services.blocking +import com.openai.core.ClientOptions import com.openai.services.blocking.graders.GraderModelService +import java.util.function.Consumer interface GraderService { @@ -11,11 +13,25 @@ interface GraderService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GraderService + fun graderModels(): GraderModelService /** A view of [GraderService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GraderService.WithRawResponse + fun graderModels(): GraderModelService.WithRawResponse } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/GraderServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/GraderServiceImpl.kt index d6d74305..3ed1a141 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/GraderServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/GraderServiceImpl.kt @@ -5,6 +5,7 @@ package com.openai.services.blocking import com.openai.core.ClientOptions import com.openai.services.blocking.graders.GraderModelService import com.openai.services.blocking.graders.GraderModelServiceImpl +import java.util.function.Consumer class GraderServiceImpl internal constructor(private val clientOptions: ClientOptions) : GraderService { @@ -17,6 +18,9 @@ class GraderServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): GraderService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GraderService = + GraderServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun graderModels(): GraderModelService = graderModels class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class GraderServiceImpl internal constructor(private val clientOptions: ClientOp GraderModelServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): GraderService.WithRawResponse = + GraderServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun graderModels(): GraderModelService.WithRawResponse = graderModels } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageService.kt index 2286d9e7..fe6c391a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageService.kt @@ -3,12 +3,14 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.images.ImageCreateVariationParams import com.openai.models.images.ImageEditParams import com.openai.models.images.ImageGenerateParams import com.openai.models.images.ImagesResponse +import java.util.function.Consumer interface ImageService { @@ -17,6 +19,13 @@ interface ImageService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ImageService + /** Creates a variation of a given image. This endpoint only supports `dall-e-2`. */ fun createVariation(params: ImageCreateVariationParams): ImagesResponse = createVariation(params, RequestOptions.none()) @@ -55,6 +64,13 @@ interface ImageService { /** A view of [ImageService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ImageService.WithRawResponse + /** * Returns a raw HTTP response for `post /images/variations`, but is otherwise the same as * [ImageService.createVariation]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageServiceImpl.kt index 9fca243b..faa63d58 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ImageServiceImpl.kt @@ -20,6 +20,7 @@ import com.openai.models.images.ImageCreateVariationParams import com.openai.models.images.ImageEditParams import com.openai.models.images.ImageGenerateParams import com.openai.models.images.ImagesResponse +import java.util.function.Consumer class ImageServiceImpl internal constructor(private val clientOptions: ClientOptions) : ImageService { @@ -30,6 +31,9 @@ class ImageServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): ImageService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ImageService = + ImageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun createVariation( params: ImageCreateVariationParams, requestOptions: RequestOptions, @@ -53,6 +57,13 @@ class ImageServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ImageService.WithRawResponse = + ImageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createVariationHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelService.kt index d6550622..35660e67 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.models.Model @@ -11,6 +12,7 @@ import com.openai.models.models.ModelDeleted import com.openai.models.models.ModelListPage import com.openai.models.models.ModelListParams import com.openai.models.models.ModelRetrieveParams +import java.util.function.Consumer interface ModelService { @@ -19,6 +21,13 @@ interface ModelService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelService + /** * Retrieves a model instance, providing basic information about the model such as the owner and * permissioning. @@ -102,6 +111,13 @@ interface ModelService { /** A view of [ModelService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelService.WithRawResponse + /** * Returns a raw HTTP response for `get /models/{model}`, but is otherwise the same as * [ModelService.retrieve]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelServiceImpl.kt index 0d907c80..65f85ff2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModelServiceImpl.kt @@ -23,6 +23,7 @@ import com.openai.models.models.ModelListPage import com.openai.models.models.ModelListPageResponse import com.openai.models.models.ModelListParams import com.openai.models.models.ModelRetrieveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ModelServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,6 +35,9 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): ModelService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModelService = + ModelServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve(params: ModelRetrieveParams, requestOptions: RequestOptions): Model = // get /models/{model} withRawResponse().retrieve(params, requestOptions).parse() @@ -51,6 +55,13 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModelService.WithRawResponse = + ModelServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationService.kt index 502a1848..d0ce10f6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationService.kt @@ -3,10 +3,12 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.moderations.ModerationCreateParams import com.openai.models.moderations.ModerationCreateResponse +import java.util.function.Consumer interface ModerationService { @@ -15,6 +17,13 @@ interface ModerationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModerationService + /** * Classifies if text and/or image inputs are potentially harmful. Learn more in the * [moderation guide](https://platform.openai.com/docs/guides/moderation). @@ -31,6 +40,15 @@ interface ModerationService { /** A view of [ModerationService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ModerationService.WithRawResponse + /** * Returns a raw HTTP response for `post /moderations`, but is otherwise the same as * [ModerationService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationServiceImpl.kt index fcff84c1..7ace846f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ModerationServiceImpl.kt @@ -17,6 +17,7 @@ import com.openai.core.prepare import com.openai.models.ErrorObject import com.openai.models.moderations.ModerationCreateParams import com.openai.models.moderations.ModerationCreateResponse +import java.util.function.Consumer class ModerationServiceImpl internal constructor(private val clientOptions: ClientOptions) : ModerationService { @@ -27,6 +28,9 @@ class ModerationServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ModerationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModerationService = + ModerationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: ModerationCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class ModerationServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModerationService.WithRawResponse = + ModerationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt index 279ab91c..ec0283b2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponseFor @@ -16,6 +17,7 @@ import com.openai.models.responses.ResponseStreamEvent import com.openai.models.responses.StructuredResponse import com.openai.models.responses.StructuredResponseCreateParams import com.openai.services.blocking.responses.InputItemService +import java.util.function.Consumer interface ResponseService { @@ -24,6 +26,13 @@ interface ResponseService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ResponseService + fun inputItems(): InputItemService /** @@ -219,6 +228,13 @@ interface ResponseService { /** A view of [ResponseService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ResponseService.WithRawResponse + fun inputItems(): InputItemService.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt index cc397d51..c57ecd81 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt @@ -31,6 +31,7 @@ import com.openai.models.responses.ResponseRetrieveParams import com.openai.models.responses.ResponseStreamEvent import com.openai.services.blocking.responses.InputItemService import com.openai.services.blocking.responses.InputItemServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ResponseServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -44,6 +45,9 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): ResponseService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ResponseService = + ResponseServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun inputItems(): InputItemService = inputItems override fun create(params: ResponseCreateParams, requestOptions: RequestOptions): Response = @@ -89,6 +93,13 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client InputItemServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ResponseService.WithRawResponse = + ResponseServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun inputItems(): InputItemService.WithRawResponse = inputItems private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadService.kt index 17bc71b0..0f6e7eae 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.uploads.Upload @@ -10,6 +11,7 @@ import com.openai.models.uploads.UploadCancelParams import com.openai.models.uploads.UploadCompleteParams import com.openai.models.uploads.UploadCreateParams import com.openai.services.blocking.uploads.PartService +import java.util.function.Consumer interface UploadService { @@ -18,6 +20,13 @@ interface UploadService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UploadService + fun parts(): PartService /** @@ -110,6 +119,13 @@ interface UploadService { /** A view of [UploadService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UploadService.WithRawResponse + fun parts(): PartService.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadServiceImpl.kt index 736dc6a4..eef31eb6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/UploadServiceImpl.kt @@ -22,6 +22,7 @@ import com.openai.models.uploads.UploadCompleteParams import com.openai.models.uploads.UploadCreateParams import com.openai.services.blocking.uploads.PartService import com.openai.services.blocking.uploads.PartServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class UploadServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -35,6 +36,9 @@ class UploadServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): UploadService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): UploadService = + UploadServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun parts(): PartService = parts override fun create(params: UploadCreateParams, requestOptions: RequestOptions): Upload = @@ -58,6 +62,13 @@ class UploadServiceImpl internal constructor(private val clientOptions: ClientOp PartServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): UploadService.WithRawResponse = + UploadServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun parts(): PartService.WithRawResponse = parts private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreService.kt index e5256a03..ab0b6285 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.vectorstores.VectorStore @@ -17,6 +18,7 @@ import com.openai.models.vectorstores.VectorStoreSearchParams import com.openai.models.vectorstores.VectorStoreUpdateParams import com.openai.services.blocking.vectorstores.FileBatchService import com.openai.services.blocking.vectorstores.FileService +import java.util.function.Consumer interface VectorStoreService { @@ -25,6 +27,13 @@ interface VectorStoreService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VectorStoreService + fun files(): FileService fun fileBatches(): FileBatchService @@ -184,6 +193,15 @@ interface VectorStoreService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): VectorStoreService.WithRawResponse + fun files(): FileService.WithRawResponse fun fileBatches(): FileBatchService.WithRawResponse diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreServiceImpl.kt index ef489635..12f402a2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/VectorStoreServiceImpl.kt @@ -33,6 +33,7 @@ import com.openai.services.blocking.vectorstores.FileBatchService import com.openai.services.blocking.vectorstores.FileBatchServiceImpl import com.openai.services.blocking.vectorstores.FileService import com.openai.services.blocking.vectorstores.FileServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class VectorStoreServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -53,6 +54,9 @@ class VectorStoreServiceImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): VectorStoreService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): VectorStoreService = + VectorStoreServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun files(): FileService = files override fun fileBatches(): FileBatchService = fileBatches @@ -112,6 +116,13 @@ class VectorStoreServiceImpl internal constructor(private val clientOptions: Cli FileBatchServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): VectorStoreService.WithRawResponse = + VectorStoreServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun files(): FileService.WithRawResponse = files override fun fileBatches(): FileBatchService.WithRawResponse = fileBatches diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechService.kt index 4fcb2b15..70fe326b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechService.kt @@ -3,9 +3,11 @@ package com.openai.services.blocking.audio import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.models.audio.speech.SpeechCreateParams +import java.util.function.Consumer interface SpeechService { @@ -14,6 +16,13 @@ interface SpeechService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpeechService + /** Generates audio from the input text. */ @MustBeClosed fun create(params: SpeechCreateParams): HttpResponse = create(params, RequestOptions.none()) @@ -28,6 +37,13 @@ interface SpeechService { /** A view of [SpeechService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpeechService.WithRawResponse + /** * Returns a raw HTTP response for `post /audio/speech`, but is otherwise the same as * [SpeechService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechServiceImpl.kt index 82f8ab69..9d978c03 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/SpeechServiceImpl.kt @@ -13,6 +13,7 @@ import com.openai.core.http.json import com.openai.core.prepare import com.openai.models.ErrorObject import com.openai.models.audio.speech.SpeechCreateParams +import java.util.function.Consumer class SpeechServiceImpl internal constructor(private val clientOptions: ClientOptions) : SpeechService { @@ -23,6 +24,9 @@ class SpeechServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): SpeechService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SpeechService = + SpeechServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create(params: SpeechCreateParams, requestOptions: RequestOptions): HttpResponse = // post /audio/speech withRawResponse().create(params, requestOptions) @@ -32,6 +36,13 @@ class SpeechServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SpeechService.WithRawResponse = + SpeechServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun create( params: SpeechCreateParams, requestOptions: RequestOptions, diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionService.kt index 5636645d..25030c81 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionService.kt @@ -3,12 +3,14 @@ package com.openai.services.blocking.audio import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.core.http.StreamResponse import com.openai.models.audio.transcriptions.TranscriptionCreateParams import com.openai.models.audio.transcriptions.TranscriptionCreateResponse import com.openai.models.audio.transcriptions.TranscriptionStreamEvent +import java.util.function.Consumer interface TranscriptionService { @@ -17,6 +19,13 @@ interface TranscriptionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TranscriptionService + /** Transcribes audio into the input language. */ fun create(params: TranscriptionCreateParams): TranscriptionCreateResponse = create(params, RequestOptions.none()) @@ -45,6 +54,15 @@ interface TranscriptionService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TranscriptionService.WithRawResponse + /** * Returns a raw HTTP response for `post /audio/transcriptions`, but is otherwise the same * as [TranscriptionService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt index 804c81c2..fb222b54 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt @@ -28,6 +28,8 @@ import com.openai.models.audio.transcriptions.TranscriptionCreateResponse import com.openai.models.audio.transcriptions.TranscriptionStreamEvent import kotlin.jvm.optionals.getOrNull +import java.util.function.Consumer + class TranscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : TranscriptionService { @@ -37,6 +39,9 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C override fun withRawResponse(): TranscriptionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TranscriptionService = + TranscriptionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: TranscriptionCreateParams, requestOptions: RequestOptions, @@ -56,6 +61,13 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TranscriptionService.WithRawResponse = + TranscriptionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createJsonHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationService.kt index 2a86b906..35b73814 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationService.kt @@ -3,10 +3,12 @@ package com.openai.services.blocking.audio import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.audio.translations.TranslationCreateParams import com.openai.models.audio.translations.TranslationCreateResponse +import java.util.function.Consumer interface TranslationService { @@ -15,6 +17,13 @@ interface TranslationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TranslationService + /** Translates audio into English. */ fun create(params: TranslationCreateParams): TranslationCreateResponse = create(params, RequestOptions.none()) @@ -30,6 +39,15 @@ interface TranslationService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TranslationService.WithRawResponse + /** * Returns a raw HTTP response for `post /audio/translations`, but is otherwise the same as * [TranslationService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationServiceImpl.kt index af098de1..abc0dfe2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranslationServiceImpl.kt @@ -17,6 +17,7 @@ import com.openai.core.prepare import com.openai.models.ErrorObject import com.openai.models.audio.translations.TranslationCreateParams import com.openai.models.audio.translations.TranslationCreateResponse +import java.util.function.Consumer class TranslationServiceImpl internal constructor(private val clientOptions: ClientOptions) : TranslationService { @@ -27,6 +28,9 @@ class TranslationServiceImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): TranslationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TranslationService = + TranslationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: TranslationCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class TranslationServiceImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TranslationService.WithRawResponse = + TranslationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionService.kt index 43f372d2..1bacd22a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking.chat import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.core.http.StreamResponse @@ -18,6 +19,7 @@ import com.openai.models.chat.completions.ChatCompletionUpdateParams import com.openai.models.chat.completions.StructuredChatCompletion import com.openai.models.chat.completions.StructuredChatCompletionCreateParams import com.openai.services.blocking.chat.completions.MessageService +import java.util.function.Consumer interface ChatCompletionService { @@ -26,6 +28,13 @@ interface ChatCompletionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatCompletionService + fun messages(): MessageService /** @@ -230,6 +239,15 @@ interface ChatCompletionService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ChatCompletionService.WithRawResponse + fun messages(): MessageService.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionServiceImpl.kt index 96181de3..c9741de7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionServiceImpl.kt @@ -33,6 +33,7 @@ import com.openai.models.chat.completions.ChatCompletionRetrieveParams import com.openai.models.chat.completions.ChatCompletionUpdateParams import com.openai.services.blocking.chat.completions.MessageService import com.openai.services.blocking.chat.completions.MessageServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ChatCompletionServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -46,6 +47,9 @@ class ChatCompletionServiceImpl internal constructor(private val clientOptions: override fun withRawResponse(): ChatCompletionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ChatCompletionService = + ChatCompletionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun messages(): MessageService = messages override fun create( @@ -99,6 +103,13 @@ class ChatCompletionServiceImpl internal constructor(private val clientOptions: MessageServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ChatCompletionService.WithRawResponse = + ChatCompletionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun messages(): MessageService.WithRawResponse = messages private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageService.kt index d4fc968c..79320931 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageService.kt @@ -3,10 +3,12 @@ package com.openai.services.blocking.chat.completions import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.chat.completions.messages.MessageListPage import com.openai.models.chat.completions.messages.MessageListParams +import java.util.function.Consumer interface MessageService { @@ -15,6 +17,13 @@ interface MessageService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MessageService + /** * Get the messages in a stored chat completion. Only Chat Completions that have been created * with the `store` parameter set to `true` will be returned. @@ -50,6 +59,13 @@ interface MessageService { /** A view of [MessageService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MessageService.WithRawResponse + /** * Returns a raw HTTP response for `get /chat/completions/{completion_id}/messages`, but is * otherwise the same as [MessageService.list]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageServiceImpl.kt index 8298420a..249f1cbc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/completions/MessageServiceImpl.kt @@ -18,6 +18,7 @@ import com.openai.models.ErrorObject import com.openai.models.chat.completions.messages.MessageListPage import com.openai.models.chat.completions.messages.MessageListPageResponse import com.openai.models.chat.completions.messages.MessageListParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class MessageServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): MessageService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): MessageService = + MessageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list(params: MessageListParams, requestOptions: RequestOptions): MessageListPage = // get /chat/completions/{completion_id}/messages withRawResponse().list(params, requestOptions).parse() @@ -38,6 +42,13 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): MessageService.WithRawResponse = + MessageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileService.kt index 76075d3f..54fda2a4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking.containers import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponseFor @@ -14,6 +15,7 @@ import com.openai.models.containers.files.FileListParams import com.openai.models.containers.files.FileRetrieveParams import com.openai.models.containers.files.FileRetrieveResponse import com.openai.services.blocking.containers.files.ContentService +import java.util.function.Consumer interface FileService { @@ -22,6 +24,13 @@ interface FileService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileService + fun content(): ContentService /** @@ -128,6 +137,13 @@ interface FileService { /** A view of [FileService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileService.WithRawResponse + fun content(): ContentService.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileServiceImpl.kt index 1887ed67..31a5d1f1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/FileServiceImpl.kt @@ -29,6 +29,7 @@ import com.openai.models.containers.files.FileRetrieveParams import com.openai.models.containers.files.FileRetrieveResponse import com.openai.services.blocking.containers.files.ContentService import com.openai.services.blocking.containers.files.ContentServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { @@ -41,6 +42,9 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): FileService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileService = + FileServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun content(): ContentService = content override fun create( @@ -75,6 +79,13 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti ContentServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FileService.WithRawResponse = + FileServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun content(): ContentService.WithRawResponse = content private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentService.kt index ba508497..b6914e59 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentService.kt @@ -3,9 +3,11 @@ package com.openai.services.blocking.containers.files import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.models.containers.files.content.ContentRetrieveParams +import java.util.function.Consumer interface ContentService { @@ -14,6 +16,13 @@ interface ContentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContentService + /** Retrieve Container File Content */ @MustBeClosed fun retrieve(fileId: String, params: ContentRetrieveParams): HttpResponse = @@ -42,6 +51,13 @@ interface ContentService { /** A view of [ContentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContentService.WithRawResponse + /** * Returns a raw HTTP response for `get /containers/{container_id}/files/{file_id}/content`, * but is otherwise the same as [ContentService.retrieve]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentServiceImpl.kt index 235d4ecd..116a4d57 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/containers/files/ContentServiceImpl.kt @@ -13,6 +13,7 @@ import com.openai.core.http.HttpResponse.Handler import com.openai.core.prepare import com.openai.models.ErrorObject import com.openai.models.containers.files.content.ContentRetrieveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ContentServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -24,6 +25,9 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): ContentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ContentService = + ContentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions, @@ -36,6 +40,13 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ContentService.WithRawResponse = + ContentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions, diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunService.kt index 90dc28d4..9aa31705 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking.evals import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.evals.runs.RunCancelParams @@ -16,6 +17,7 @@ import com.openai.models.evals.runs.RunListParams import com.openai.models.evals.runs.RunRetrieveParams import com.openai.models.evals.runs.RunRetrieveResponse import com.openai.services.blocking.evals.runs.OutputItemService +import java.util.function.Consumer interface RunService { @@ -24,6 +26,13 @@ interface RunService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RunService + fun outputItems(): OutputItemService /** @@ -141,6 +150,13 @@ interface RunService { /** A view of [RunService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RunService.WithRawResponse + fun outputItems(): OutputItemService.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunServiceImpl.kt index f9448a04..101762a3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/RunServiceImpl.kt @@ -29,6 +29,7 @@ import com.openai.models.evals.runs.RunRetrieveParams import com.openai.models.evals.runs.RunRetrieveResponse import com.openai.services.blocking.evals.runs.OutputItemService import com.openai.services.blocking.evals.runs.OutputItemServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { @@ -41,6 +42,9 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): RunService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RunService = + RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun outputItems(): OutputItemService = outputItems override fun create( @@ -84,6 +88,13 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio OutputItemServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): RunService.WithRawResponse = + RunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun outputItems(): OutputItemService.WithRawResponse = outputItems private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemService.kt index 59468f9e..578f2ae1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemService.kt @@ -3,12 +3,14 @@ package com.openai.services.blocking.evals.runs import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.evals.runs.outputitems.OutputItemListPage import com.openai.models.evals.runs.outputitems.OutputItemListParams import com.openai.models.evals.runs.outputitems.OutputItemRetrieveParams import com.openai.models.evals.runs.outputitems.OutputItemRetrieveResponse +import java.util.function.Consumer interface OutputItemService { @@ -17,6 +19,13 @@ interface OutputItemService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OutputItemService + /** Get an evaluation run output item by ID. */ fun retrieve( outputItemId: String, @@ -64,6 +73,15 @@ interface OutputItemService { /** A view of [OutputItemService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OutputItemService.WithRawResponse + /** * Returns a raw HTTP response for `get * /evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}`, but is otherwise the same diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemServiceImpl.kt index 97b281d9..5658996c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/evals/runs/OutputItemServiceImpl.kt @@ -20,6 +20,7 @@ import com.openai.models.evals.runs.outputitems.OutputItemListPageResponse import com.openai.models.evals.runs.outputitems.OutputItemListParams import com.openai.models.evals.runs.outputitems.OutputItemRetrieveParams import com.openai.models.evals.runs.outputitems.OutputItemRetrieveResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class OutputItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,6 +32,9 @@ class OutputItemServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): OutputItemService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OutputItemService = + OutputItemServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: OutputItemRetrieveParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class OutputItemServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): OutputItemService.WithRawResponse = + OutputItemServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/AlphaService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/AlphaService.kt index 6f892364..f0b56cc0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/AlphaService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/AlphaService.kt @@ -2,7 +2,9 @@ package com.openai.services.blocking.finetuning +import com.openai.core.ClientOptions import com.openai.services.blocking.finetuning.alpha.GraderService +import java.util.function.Consumer interface AlphaService { @@ -11,11 +13,25 @@ interface AlphaService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AlphaService + fun graders(): GraderService /** A view of [AlphaService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AlphaService.WithRawResponse + fun graders(): GraderService.WithRawResponse } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/AlphaServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/AlphaServiceImpl.kt index 372892c0..dd3cb428 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/AlphaServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/AlphaServiceImpl.kt @@ -5,6 +5,7 @@ package com.openai.services.blocking.finetuning import com.openai.core.ClientOptions import com.openai.services.blocking.finetuning.alpha.GraderService import com.openai.services.blocking.finetuning.alpha.GraderServiceImpl +import java.util.function.Consumer class AlphaServiceImpl internal constructor(private val clientOptions: ClientOptions) : AlphaService { @@ -17,6 +18,9 @@ class AlphaServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): AlphaService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AlphaService = + AlphaServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun graders(): GraderService = graders class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class AlphaServiceImpl internal constructor(private val clientOptions: ClientOpt GraderServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): AlphaService.WithRawResponse = + AlphaServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun graders(): GraderService.WithRawResponse = graders } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/CheckpointService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/CheckpointService.kt index 0d8957e5..c3a12b55 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/CheckpointService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/CheckpointService.kt @@ -2,7 +2,9 @@ package com.openai.services.blocking.finetuning +import com.openai.core.ClientOptions import com.openai.services.blocking.finetuning.checkpoints.PermissionService +import java.util.function.Consumer interface CheckpointService { @@ -11,11 +13,27 @@ interface CheckpointService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CheckpointService + fun permissions(): PermissionService /** A view of [CheckpointService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CheckpointService.WithRawResponse + fun permissions(): PermissionService.WithRawResponse } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/CheckpointServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/CheckpointServiceImpl.kt index 24dbbf24..fc5a01d5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/CheckpointServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/CheckpointServiceImpl.kt @@ -5,6 +5,7 @@ package com.openai.services.blocking.finetuning import com.openai.core.ClientOptions import com.openai.services.blocking.finetuning.checkpoints.PermissionService import com.openai.services.blocking.finetuning.checkpoints.PermissionServiceImpl +import java.util.function.Consumer class CheckpointServiceImpl internal constructor(private val clientOptions: ClientOptions) : CheckpointService { @@ -17,6 +18,9 @@ class CheckpointServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): CheckpointService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CheckpointService = + CheckpointServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun permissions(): PermissionService = permissions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class CheckpointServiceImpl internal constructor(private val clientOptions: Clie PermissionServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): CheckpointService.WithRawResponse = + CheckpointServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun permissions(): PermissionService.WithRawResponse = permissions } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobService.kt index 785543c0..d1e2edbb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking.finetuning import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.finetuning.jobs.FineTuningJob @@ -16,6 +17,7 @@ import com.openai.models.finetuning.jobs.JobPauseParams import com.openai.models.finetuning.jobs.JobResumeParams import com.openai.models.finetuning.jobs.JobRetrieveParams import com.openai.services.blocking.finetuning.jobs.CheckpointService +import java.util.function.Consumer interface JobService { @@ -24,6 +26,13 @@ interface JobService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService + fun checkpoints(): CheckpointService /** @@ -223,6 +232,13 @@ interface JobService { /** A view of [JobService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService.WithRawResponse + fun checkpoints(): CheckpointService.WithRawResponse /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobServiceImpl.kt index 3def437f..286b0546 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/JobServiceImpl.kt @@ -30,6 +30,7 @@ import com.openai.models.finetuning.jobs.JobResumeParams import com.openai.models.finetuning.jobs.JobRetrieveParams import com.openai.services.blocking.finetuning.jobs.CheckpointService import com.openai.services.blocking.finetuning.jobs.CheckpointServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class JobServiceImpl internal constructor(private val clientOptions: ClientOptions) : JobService { @@ -42,6 +43,9 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): JobService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobService = + JobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun checkpoints(): CheckpointService = checkpoints override fun create(params: JobCreateParams, requestOptions: RequestOptions): FineTuningJob = @@ -87,6 +91,13 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio CheckpointServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobService.WithRawResponse = + JobServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun checkpoints(): CheckpointService.WithRawResponse = checkpoints private val createHandler: Handler = diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/MethodService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/MethodService.kt index 7d829c06..acee9546 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/MethodService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/MethodService.kt @@ -2,6 +2,9 @@ package com.openai.services.blocking.finetuning +import com.openai.core.ClientOptions +import java.util.function.Consumer + interface MethodService { /** @@ -9,6 +12,21 @@ interface MethodService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MethodService + /** A view of [MethodService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MethodService.WithRawResponse + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/MethodServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/MethodServiceImpl.kt index a7750b2c..d7b1437e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/MethodServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/MethodServiceImpl.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking.finetuning import com.openai.core.ClientOptions +import java.util.function.Consumer class MethodServiceImpl internal constructor(private val clientOptions: ClientOptions) : MethodService { @@ -13,6 +14,17 @@ class MethodServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): MethodService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): MethodService = + MethodServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - MethodService.WithRawResponse + MethodService.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): MethodService.WithRawResponse = + MethodServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderService.kt index f6e4fe7c..a73fe374 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderService.kt @@ -3,12 +3,14 @@ package com.openai.services.blocking.finetuning.alpha import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.finetuning.alpha.graders.GraderRunParams import com.openai.models.finetuning.alpha.graders.GraderRunResponse import com.openai.models.finetuning.alpha.graders.GraderValidateParams import com.openai.models.finetuning.alpha.graders.GraderValidateResponse +import java.util.function.Consumer interface GraderService { @@ -17,6 +19,13 @@ interface GraderService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GraderService + /** Run a grader. */ fun run(params: GraderRunParams): GraderRunResponse = run(params, RequestOptions.none()) @@ -39,6 +48,13 @@ interface GraderService { /** A view of [GraderService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GraderService.WithRawResponse + /** * Returns a raw HTTP response for `post /fine_tuning/alpha/graders/run`, but is otherwise * the same as [GraderService.run]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderServiceImpl.kt index aadba554..059e9536 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/alpha/GraderServiceImpl.kt @@ -19,6 +19,7 @@ import com.openai.models.finetuning.alpha.graders.GraderRunParams import com.openai.models.finetuning.alpha.graders.GraderRunResponse import com.openai.models.finetuning.alpha.graders.GraderValidateParams import com.openai.models.finetuning.alpha.graders.GraderValidateResponse +import java.util.function.Consumer class GraderServiceImpl internal constructor(private val clientOptions: ClientOptions) : GraderService { @@ -29,6 +30,9 @@ class GraderServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): GraderService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GraderService = + GraderServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun run(params: GraderRunParams, requestOptions: RequestOptions): GraderRunResponse = // post /fine_tuning/alpha/graders/run withRawResponse().run(params, requestOptions).parse() @@ -45,6 +49,13 @@ class GraderServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): GraderService.WithRawResponse = + GraderServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val runHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionService.kt index 547aa265..b6821391 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking.finetuning.checkpoints import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.finetuning.checkpoints.permissions.PermissionCreatePage @@ -11,6 +12,7 @@ import com.openai.models.finetuning.checkpoints.permissions.PermissionDeletePara import com.openai.models.finetuning.checkpoints.permissions.PermissionDeleteResponse import com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveParams import com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveResponse +import java.util.function.Consumer interface PermissionService { @@ -19,6 +21,13 @@ interface PermissionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PermissionService + /** * **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys). * @@ -125,6 +134,15 @@ interface PermissionService { /** A view of [PermissionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PermissionService.WithRawResponse + /** * Returns a raw HTTP response for `post * /fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions`, but is otherwise the diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt index 5d0ec871..9cada335 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt @@ -23,6 +23,7 @@ import com.openai.models.finetuning.checkpoints.permissions.PermissionDeletePara import com.openai.models.finetuning.checkpoints.permissions.PermissionDeleteResponse import com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveParams import com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PermissionServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,6 +35,9 @@ class PermissionServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): PermissionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PermissionService = + PermissionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: PermissionCreateParams, requestOptions: RequestOptions, @@ -60,6 +64,13 @@ class PermissionServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PermissionService.WithRawResponse = + PermissionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointService.kt index 48717773..e1e4e42e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointService.kt @@ -3,10 +3,12 @@ package com.openai.services.blocking.finetuning.jobs import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.finetuning.jobs.checkpoints.CheckpointListPage import com.openai.models.finetuning.jobs.checkpoints.CheckpointListParams +import java.util.function.Consumer interface CheckpointService { @@ -15,6 +17,13 @@ interface CheckpointService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CheckpointService + /** List checkpoints for a fine-tuning job. */ fun list(fineTuningJobId: String): CheckpointListPage = list(fineTuningJobId, CheckpointListParams.none()) @@ -49,6 +58,15 @@ interface CheckpointService { /** A view of [CheckpointService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CheckpointService.WithRawResponse + /** * Returns a raw HTTP response for `get /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints`, * but is otherwise the same as [CheckpointService.list]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointServiceImpl.kt index 7b5134cc..2807c36c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/jobs/CheckpointServiceImpl.kt @@ -18,6 +18,7 @@ import com.openai.models.ErrorObject import com.openai.models.finetuning.jobs.checkpoints.CheckpointListPage import com.openai.models.finetuning.jobs.checkpoints.CheckpointListPageResponse import com.openai.models.finetuning.jobs.checkpoints.CheckpointListParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CheckpointServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class CheckpointServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): CheckpointService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CheckpointService = + CheckpointServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: CheckpointListParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class CheckpointServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CheckpointService.WithRawResponse = + CheckpointServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/graders/GraderModelService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/graders/GraderModelService.kt index 40f334c4..9a303bf4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/graders/GraderModelService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/graders/GraderModelService.kt @@ -2,6 +2,9 @@ package com.openai.services.blocking.graders +import com.openai.core.ClientOptions +import java.util.function.Consumer + interface GraderModelService { /** @@ -9,8 +12,25 @@ interface GraderModelService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GraderModelService + /** * A view of [GraderModelService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): GraderModelService.WithRawResponse + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/graders/GraderModelServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/graders/GraderModelServiceImpl.kt index 01f3f0d1..be6f584f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/graders/GraderModelServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/graders/GraderModelServiceImpl.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking.graders import com.openai.core.ClientOptions +import java.util.function.Consumer class GraderModelServiceImpl internal constructor(private val clientOptions: ClientOptions) : GraderModelService { @@ -13,6 +14,17 @@ class GraderModelServiceImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): GraderModelService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GraderModelService = + GraderModelServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - GraderModelService.WithRawResponse + GraderModelService.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): GraderModelService.WithRawResponse = + GraderModelServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemService.kt index 81690e16..7715ad52 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemService.kt @@ -3,10 +3,12 @@ package com.openai.services.blocking.responses import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.responses.inputitems.InputItemListPage import com.openai.models.responses.inputitems.InputItemListParams +import java.util.function.Consumer interface InputItemService { @@ -15,6 +17,13 @@ interface InputItemService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InputItemService + /** Returns a list of input items for a given response. */ fun list(responseId: String): InputItemListPage = list(responseId, InputItemListParams.none()) @@ -47,6 +56,13 @@ interface InputItemService { /** A view of [InputItemService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InputItemService.WithRawResponse + /** * Returns a raw HTTP response for `get /responses/{response_id}/input_items`, but is * otherwise the same as [InputItemService.list]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemServiceImpl.kt index b9a2a79c..5f11218e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/responses/InputItemServiceImpl.kt @@ -18,6 +18,7 @@ import com.openai.models.ErrorObject import com.openai.models.responses.inputitems.InputItemListPage import com.openai.models.responses.inputitems.InputItemListParams import com.openai.models.responses.inputitems.ResponseItemList +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class InputItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): InputItemService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): InputItemService = + InputItemServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: InputItemListParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): InputItemService.WithRawResponse = + InputItemServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartService.kt index a1990493..1b2fcb4e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartService.kt @@ -3,10 +3,12 @@ package com.openai.services.blocking.uploads import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.uploads.parts.PartCreateParams import com.openai.models.uploads.parts.UploadPart +import java.util.function.Consumer interface PartService { @@ -15,6 +17,13 @@ interface PartService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PartService + /** * Adds a [Part](https://platform.openai.com/docs/api-reference/uploads/part-object) to an * [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object. A Part @@ -49,6 +58,13 @@ interface PartService { /** A view of [PartService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PartService.WithRawResponse + /** * Returns a raw HTTP response for `post /uploads/{upload_id}/parts`, but is otherwise the * same as [PartService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartServiceImpl.kt index 526e2d7d..24d63a7d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/uploads/PartServiceImpl.kt @@ -18,6 +18,7 @@ import com.openai.core.prepare import com.openai.models.ErrorObject import com.openai.models.uploads.parts.PartCreateParams import com.openai.models.uploads.parts.UploadPart +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PartServiceImpl internal constructor(private val clientOptions: ClientOptions) : PartService { @@ -28,6 +29,9 @@ class PartServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): PartService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PartService = + PartServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create(params: PartCreateParams, requestOptions: RequestOptions): UploadPart = // post /uploads/{upload_id}/parts withRawResponse().create(params, requestOptions).parse() @@ -37,6 +41,13 @@ class PartServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PartService.WithRawResponse = + PartServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchService.kt index 2f9f55f5..8f08fa08 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking.vectorstores import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.vectorstores.filebatches.FileBatchCancelParams @@ -11,6 +12,7 @@ import com.openai.models.vectorstores.filebatches.FileBatchListFilesPage import com.openai.models.vectorstores.filebatches.FileBatchListFilesParams import com.openai.models.vectorstores.filebatches.FileBatchRetrieveParams import com.openai.models.vectorstores.filebatches.VectorStoreFileBatch +import java.util.function.Consumer interface FileBatchService { @@ -19,6 +21,13 @@ interface FileBatchService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileBatchService + /** Create a vector store file batch. */ fun create(vectorStoreId: String, params: FileBatchCreateParams): VectorStoreFileBatch = create(vectorStoreId, params, RequestOptions.none()) @@ -111,6 +120,13 @@ interface FileBatchService { /** A view of [FileBatchService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileBatchService.WithRawResponse + /** * Returns a raw HTTP response for `post /vector_stores/{vector_store_id}/file_batches`, but * is otherwise the same as [FileBatchService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchServiceImpl.kt index 385c500b..69523faf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileBatchServiceImpl.kt @@ -24,6 +24,7 @@ import com.openai.models.vectorstores.filebatches.FileBatchListFilesPageResponse import com.openai.models.vectorstores.filebatches.FileBatchListFilesParams import com.openai.models.vectorstores.filebatches.FileBatchRetrieveParams import com.openai.models.vectorstores.filebatches.VectorStoreFileBatch +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileBatchServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -40,6 +41,9 @@ class FileBatchServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): FileBatchService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileBatchService = + FileBatchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: FileBatchCreateParams, requestOptions: RequestOptions, @@ -73,6 +77,13 @@ class FileBatchServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): FileBatchService.WithRawResponse = + FileBatchServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileService.kt index 9cb49b69..addf04ee 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileService.kt @@ -3,6 +3,7 @@ package com.openai.services.blocking.vectorstores import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions import com.openai.core.RequestOptions import com.openai.core.http.HttpResponseFor import com.openai.models.vectorstores.files.FileContentPage @@ -15,6 +16,7 @@ import com.openai.models.vectorstores.files.FileRetrieveParams import com.openai.models.vectorstores.files.FileUpdateParams import com.openai.models.vectorstores.files.VectorStoreFile import com.openai.models.vectorstores.files.VectorStoreFileDeleted +import java.util.function.Consumer interface FileService { @@ -23,6 +25,13 @@ interface FileService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileService + /** * Create a vector store file by attaching a * [File](https://platform.openai.com/docs/api-reference/files) to a @@ -164,6 +173,13 @@ interface FileService { /** A view of [FileService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileService.WithRawResponse + /** * Returns a raw HTTP response for `post /vector_stores/{vector_store_id}/files`, but is * otherwise the same as [FileService.create]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileServiceImpl.kt index dabf8f1e..5f7b6b54 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/vectorstores/FileServiceImpl.kt @@ -29,6 +29,7 @@ import com.openai.models.vectorstores.files.FileRetrieveParams import com.openai.models.vectorstores.files.FileUpdateParams import com.openai.models.vectorstores.files.VectorStoreFile import com.openai.models.vectorstores.files.VectorStoreFileDeleted +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { @@ -44,6 +45,9 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): FileService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileService = + FileServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create(params: FileCreateParams, requestOptions: RequestOptions): VectorStoreFile = // post /vector_stores/{vector_store_id}/files withRawResponse().create(params, requestOptions).parse() @@ -82,6 +86,13 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): FileService.WithRawResponse = + FileServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) From b84e6ad395d0ad5210e36261df1c5fc541cc17eb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 15 Jun 2025 05:04:38 +0000 Subject: [PATCH 3/3] release: 2.8.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 13 +++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d1328ca9..64f9ff41 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.7.0" + ".": "2.8.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0119d5f9..c93fc414 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 2.8.0 (2025-06-15) + +Full Changelog: [v2.7.0...v2.8.0](https://github.com/openai/openai-java/compare/v2.7.0...v2.8.0) + +### Features + +* **client:** implement per-endpoint base URL support ([c87f1af](https://github.com/openai/openai-java/commit/c87f1af80b1f3d898a5a1553be48ee87ea4e7b4f)) + + +### Chores + +* **internal:** codegen related update ([3597aee](https://github.com/openai/openai-java/commit/3597aee95ae1956afbe8bd62b5a6946dd62256b3)) + ## 2.7.0 (2025-06-10) Full Changelog: [v2.6.0...v2.7.0](https://github.com/openai/openai-java/compare/v2.6.0...v2.7.0) diff --git a/README.md b/README.md index deb79ab7..fe4616ca 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/2.7.0) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/2.7.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/2.7.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/2.8.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/2.8.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/2.8.0) @@ -11,7 +11,7 @@ The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https:// -The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/2.7.0). +The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/2.8.0). @@ -22,7 +22,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor ### Gradle ```kotlin -implementation("com.openai:openai-java:2.7.0") +implementation("com.openai:openai-java:2.8.0") ``` ### Maven @@ -31,7 +31,7 @@ implementation("com.openai:openai-java:2.7.0") com.openai openai-java - 2.7.0 + 2.8.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index feaa5d99..70c5f3fd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "2.7.0" // x-release-please-version + version = "2.8.0" // x-release-please-version } subprojects {