diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a211506d..b99ad05d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,12 +1,14 @@
name: CI
on:
push:
- branches-ignore:
- - 'generated'
- - 'codegen/**'
- - 'integrated/**'
- - 'stl-preview-head/**'
- - 'stl-preview-base/**'
+ branches:
+ - '**'
+ - '!integrated/**'
+ - '!stl-preview-head/**'
+ - '!stl-preview-base/**'
+ - '!generated'
+ - '!codegen/**'
+ - 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
@@ -65,14 +67,18 @@ jobs:
run: ./scripts/build
- name: Get GitHub OIDC Token
- if: github.repository == 'stainless-sdks/hanzo-ai-java'
+ if: |-
+ github.repository == 'stainless-sdks/hanzo-ai-java' &&
+ !startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());
- name: Build and upload Maven artifacts
- if: github.repository == 'stainless-sdks/hanzo-ai-java'
+ if: |-
+ github.repository == 'stainless-sdks/hanzo-ai-java' &&
+ !startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index aaf968a1..b56c3d0b 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.1.0-alpha.3"
+ ".": "0.1.0-alpha.4"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index e829d1ef..94ff552b 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 187
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-971e209e1a47262e17483e5ac0d91e8013d10237ac89d6392ffabb5912ce83b9.yml
-openapi_spec_hash: 029e800ed42f138d5b63bb4f40181c55
+configured_endpoints: 188
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-d0c3bcb70e093f6a3686ec328c34326cfb56a6aca336e00d6320816879a16c53.yml
+openapi_spec_hash: 9b3181f901ec76a860173f57341b7f62
config_hash: e927bafd76a1eace11894efc3517d245
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 04a77b11..aa206819 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,39 @@
# Changelog
+## 0.1.0-alpha.4 (2026-03-18)
+
+Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/hanzoai/java-sdk/compare/v0.1.0-alpha.3...v0.1.0-alpha.4)
+
+### Features
+
+* **api:** api update ([516867f](https://github.com/hanzoai/java-sdk/commit/516867ff30ef49f05b4ea521ece41b859bfdc69a))
+* **client:** add connection pooling option ([f5d9ecf](https://github.com/hanzoai/java-sdk/commit/f5d9ecf6a189cebacb90e0112e38f74f7c21b4c6))
+
+
+### Bug Fixes
+
+* **client:** allow updating header/query affecting fields in `toBuilder()` ([9c703a8](https://github.com/hanzoai/java-sdk/commit/9c703a8e00802819887c375f51b71379d03d81a9))
+* **client:** incorrect `Retry-After` parsing ([590dc56](https://github.com/hanzoai/java-sdk/commit/590dc56b689c59917603c02b19cf606df04d0ca5))
+
+
+### Chores
+
+* **ci:** skip uploading artifacts on stainless-internal branches ([518e89e](https://github.com/hanzoai/java-sdk/commit/518e89ecbc5dc90d189312727e28ba1a29cc2932))
+* drop apache dependency ([a731078](https://github.com/hanzoai/java-sdk/commit/a7310782fb45257f66b1b2b9a4c997c5dce4fcb7))
+* **internal:** allow passing args to `./scripts/test` ([7046bb0](https://github.com/hanzoai/java-sdk/commit/7046bb0f7bd5dab1e7c68276cbd44d829067ec20))
+* **internal:** bump palantir-java-format ([157af95](https://github.com/hanzoai/java-sdk/commit/157af950ef5a51a3dbec7df93d6543a4c2af6c17))
+* **internal:** codegen related update ([9e96831](https://github.com/hanzoai/java-sdk/commit/9e96831d0175f7ea2c1bbcb16ee4d8ee9feb07a4))
+* **internal:** expand imports ([289645a](https://github.com/hanzoai/java-sdk/commit/289645a44cbec69d268cc2fc119ad26495716667))
+* **internal:** make `OkHttp` constructor internal ([3bb5be8](https://github.com/hanzoai/java-sdk/commit/3bb5be8732a6b7092ae8adaf39883b346cd15d2b))
+* **internal:** remove mock server code ([ced1658](https://github.com/hanzoai/java-sdk/commit/ced165845717b3674b54b54f0de1673d5bea9fb8))
+* **internal:** tweak CI branches ([631e85b](https://github.com/hanzoai/java-sdk/commit/631e85b0a6d859f5207bcc6ef95494ae7aad9fd0))
+* **internal:** update `TestServerExtension` comment ([bfba32f](https://github.com/hanzoai/java-sdk/commit/bfba32f48b43a0b7f5f9cc7a487e0847659e5a87))
+* **internal:** update retry delay tests ([921f2d2](https://github.com/hanzoai/java-sdk/commit/921f2d275c90cffa959fc6e520281cfa1832be08))
+* **internal:** upgrade AssertJ ([700e78b](https://github.com/hanzoai/java-sdk/commit/700e78b1d30fc27e7f6fb9f8b6e10e83c79302d0))
+* make `Properties` more resilient to `null` ([680bdff](https://github.com/hanzoai/java-sdk/commit/680bdff1158b01efb4d08e4aa511298be9f7b1a0))
+* update mock server docs ([638f89e](https://github.com/hanzoai/java-sdk/commit/638f89ea6bd52a27a072c6ab5835441558e5e444))
+* update placeholder string ([3724180](https://github.com/hanzoai/java-sdk/commit/37241806179aeb9f18c29f38a7b47d20b3e8512f))
+
## 0.1.0-alpha.3 (2026-01-28)
Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/hanzoai/java-sdk/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)
diff --git a/README.md b/README.md
index 502f6147..31f6e870 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/ai.hanzo.api/hanzo-java/0.1.0-alpha.3)
-[](https://javadoc.io/doc/ai.hanzo.api/hanzo-java/0.1.0-alpha.3)
+[](https://central.sonatype.com/artifact/ai.hanzo.api/hanzo-java/0.1.0-alpha.4)
+[](https://javadoc.io/doc/ai.hanzo.api/hanzo-java/0.1.0-alpha.4)
@@ -24,7 +24,7 @@ Use the Hanzo MCP Server to enable AI assistants to interact with this API, allo
-The REST API documentation can be found on [docs.hanzo.ai](https://docs.hanzo.ai). Javadocs are available on [javadoc.io](https://javadoc.io/doc/ai.hanzo.api/hanzo-java/0.1.0-alpha.3).
+The REST API documentation can be found on [docs.hanzo.ai](https://docs.hanzo.ai). Javadocs are available on [javadoc.io](https://javadoc.io/doc/ai.hanzo.api/hanzo-java/0.1.0-alpha.4).
@@ -35,7 +35,7 @@ The REST API documentation can be found on [docs.hanzo.ai](https://docs.hanzo.ai
### Gradle
```kotlin
-implementation("ai.hanzo.api:hanzo-java:0.1.0-alpha.3")
+implementation("ai.hanzo.api:hanzo-java:0.1.0-alpha.4")
```
### Maven
@@ -44,7 +44,7 @@ implementation("ai.hanzo.api:hanzo-java:0.1.0-alpha.3")
ai.hanzo.api
hanzo-java
- 0.1.0-alpha.3
+ 0.1.0-alpha.4
```
@@ -404,6 +404,25 @@ HanzoClient client = HanzoOkHttpClient.builder()
.build();
```
+### Connection pooling
+
+To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:
+
+```java
+import ai.hanzo.api.client.HanzoClient;
+import ai.hanzo.api.client.okhttp.HanzoOkHttpClient;
+import java.time.Duration;
+
+HanzoClient client = HanzoOkHttpClient.builder()
+ .fromEnv()
+ // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.
+ .maxIdleConnections(10)
+ .keepAliveDuration(Duration.ofMinutes(2))
+ .build();
+```
+
+If both options are unset, OkHttp's default connection pool settings are used.
+
### HTTPS
> [!NOTE]
@@ -503,7 +522,7 @@ import ai.hanzo.api.core.JsonValue;
import ai.hanzo.api.models.model.ModelCreateParams;
ModelCreateParams params = ModelCreateParams.builder()
- .litellmParams(ModelCreateParams.LitellmParams.builder()
+ .llmParams(ModelCreateParams.LlmParams.builder()
.putAdditionalProperty("secretProperty", JsonValue.from("42"))
.build())
.build();
diff --git a/build.gradle.kts b/build.gradle.kts
index 83d42120..0e9f648f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "ai.hanzo.api"
- version = "0.1.0-alpha.3" // x-release-please-version
+ version = "0.1.0-alpha.4" // x-release-please-version
}
subprojects {
diff --git a/buildSrc/src/main/kotlin/hanzo.java.gradle.kts b/buildSrc/src/main/kotlin/hanzo.java.gradle.kts
index 70fc33f4..8f4f902a 100644
--- a/buildSrc/src/main/kotlin/hanzo.java.gradle.kts
+++ b/buildSrc/src/main/kotlin/hanzo.java.gradle.kts
@@ -45,7 +45,7 @@ tasks.withType().configureEach {
val palantir by configurations.creating
dependencies {
- palantir("com.palantir.javaformat:palantir-java-format:2.73.0")
+ palantir("com.palantir.javaformat:palantir-java-format:2.89.0")
}
fun registerPalantir(
diff --git a/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts b/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts
index 2e3484a9..f84af2dd 100644
--- a/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts
+++ b/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts
@@ -42,8 +42,8 @@ configure {
)
pom {
- name.set("LiteLLM API")
- description.set("Proxy Server to call 100+ LLMs in the OpenAI format.\n[**Customize Swagger Docs**](https://docs.litellm.ai/docs/proxy/enterprise#swagger-docs---custom-routes--branding)\n\nš [`LiteLLM Admin Panel on /ui`](/ui). Create, Edit Keys with SSO. Having\nissues? Try [`Fallback Login`](/fallback/login)\n\nšø [`LiteLLM Model Cost Map`](https://models.litellm.ai/).\n\nš [`LiteLLM Model Hub`](/ui/model_hub_table). See available models on the\nproxy. [**Docs**](https://docs.litellm.ai/docs/proxy/ai_hub)")
+ name.set("Hanzo API")
+ description.set("API documentation for Hanzo")
url.set("https://docs.hanzo.ai")
licenses {
diff --git a/hanzo-java-client-okhttp/build.gradle.kts b/hanzo-java-client-okhttp/build.gradle.kts
index 4307d79f..dd6bd74b 100644
--- a/hanzo-java-client-okhttp/build.gradle.kts
+++ b/hanzo-java-client-okhttp/build.gradle.kts
@@ -10,6 +10,6 @@ dependencies {
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
testImplementation(kotlin("test"))
- testImplementation("org.assertj:assertj-core:3.25.3")
+ testImplementation("org.assertj:assertj-core:3.27.7")
testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2")
}
diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt
index 139f16c1..bef33f91 100644
--- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt
+++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt
@@ -47,6 +47,8 @@ class HanzoOkHttpClient private constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var dispatcherExecutorService: ExecutorService? = null
private var proxy: Proxy? = null
+ private var maxIdleConnections: Int? = null
+ private var keepAliveDuration: Duration? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null
@@ -75,6 +77,46 @@ class HanzoOkHttpClient private constructor() {
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
fun proxy(proxy: Optional) = proxy(proxy.getOrNull())
+ /**
+ * The maximum number of idle connections kept by the underlying OkHttp connection pool.
+ *
+ * If this is set, then [keepAliveDuration] must also be set.
+ *
+ * If unset, then OkHttp's default is used.
+ */
+ fun maxIdleConnections(maxIdleConnections: Int?) = apply {
+ this.maxIdleConnections = maxIdleConnections
+ }
+
+ /**
+ * Alias for [Builder.maxIdleConnections].
+ *
+ * This unboxed primitive overload exists for backwards compatibility.
+ */
+ fun maxIdleConnections(maxIdleConnections: Int) =
+ maxIdleConnections(maxIdleConnections as Int?)
+
+ /**
+ * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`.
+ */
+ fun maxIdleConnections(maxIdleConnections: Optional) =
+ maxIdleConnections(maxIdleConnections.getOrNull())
+
+ /**
+ * The keep-alive duration for idle connections in the underlying OkHttp connection pool.
+ *
+ * If this is set, then [maxIdleConnections] must also be set.
+ *
+ * If unset, then OkHttp's default is used.
+ */
+ fun keepAliveDuration(keepAliveDuration: Duration?) = apply {
+ this.keepAliveDuration = keepAliveDuration
+ }
+
+ /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */
+ fun keepAliveDuration(keepAliveDuration: Optional) =
+ keepAliveDuration(keepAliveDuration.getOrNull())
+
/**
* The socket factory used to secure HTTPS connections.
*
@@ -324,6 +366,8 @@ class HanzoOkHttpClient private constructor() {
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
+ .maxIdleConnections(maxIdleConnections)
+ .keepAliveDuration(keepAliveDuration)
.dispatcherExecutorService(dispatcherExecutorService)
.sslSocketFactory(sslSocketFactory)
.trustManager(trustManager)
diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt
index d6689bbc..9b03e817 100644
--- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt
+++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt
@@ -47,6 +47,8 @@ class HanzoOkHttpClientAsync private constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var dispatcherExecutorService: ExecutorService? = null
private var proxy: Proxy? = null
+ private var maxIdleConnections: Int? = null
+ private var keepAliveDuration: Duration? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null
@@ -75,6 +77,46 @@ class HanzoOkHttpClientAsync private constructor() {
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
fun proxy(proxy: Optional) = proxy(proxy.getOrNull())
+ /**
+ * The maximum number of idle connections kept by the underlying OkHttp connection pool.
+ *
+ * If this is set, then [keepAliveDuration] must also be set.
+ *
+ * If unset, then OkHttp's default is used.
+ */
+ fun maxIdleConnections(maxIdleConnections: Int?) = apply {
+ this.maxIdleConnections = maxIdleConnections
+ }
+
+ /**
+ * Alias for [Builder.maxIdleConnections].
+ *
+ * This unboxed primitive overload exists for backwards compatibility.
+ */
+ fun maxIdleConnections(maxIdleConnections: Int) =
+ maxIdleConnections(maxIdleConnections as Int?)
+
+ /**
+ * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`.
+ */
+ fun maxIdleConnections(maxIdleConnections: Optional) =
+ maxIdleConnections(maxIdleConnections.getOrNull())
+
+ /**
+ * The keep-alive duration for idle connections in the underlying OkHttp connection pool.
+ *
+ * If this is set, then [maxIdleConnections] must also be set.
+ *
+ * If unset, then OkHttp's default is used.
+ */
+ fun keepAliveDuration(keepAliveDuration: Duration?) = apply {
+ this.keepAliveDuration = keepAliveDuration
+ }
+
+ /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */
+ fun keepAliveDuration(keepAliveDuration: Optional) =
+ keepAliveDuration(keepAliveDuration.getOrNull())
+
/**
* The socket factory used to secure HTTPS connections.
*
@@ -324,6 +366,8 @@ class HanzoOkHttpClientAsync private constructor() {
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
+ .maxIdleConnections(maxIdleConnections)
+ .keepAliveDuration(keepAliveDuration)
.dispatcherExecutorService(dispatcherExecutorService)
.sslSocketFactory(sslSocketFactory)
.trustManager(trustManager)
diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt
index 3dc8e1a6..8722c999 100644
--- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt
+++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt
@@ -16,11 +16,13 @@ import java.time.Duration
import java.util.concurrent.CancellationException
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ExecutorService
+import java.util.concurrent.TimeUnit
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
import okhttp3.Call
import okhttp3.Callback
+import okhttp3.ConnectionPool
import okhttp3.Dispatcher
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
@@ -33,7 +35,7 @@ import okhttp3.logging.HttpLoggingInterceptor
import okio.BufferedSink
class OkHttpClient
-private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient {
+internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient {
override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
val call = newCall(request, requestOptions)
@@ -94,7 +96,7 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien
if (logLevel != null) {
clientBuilder.addNetworkInterceptor(
HttpLoggingInterceptor().setLevel(logLevel).apply {
- redactHeader("x-litellm-api-key")
+ redactHeader("Ocp-Apim-Subscription-Key")
}
)
}
@@ -202,6 +204,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien
private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null
+ private var maxIdleConnections: Int? = null
+ private var keepAliveDuration: Duration? = null
private var dispatcherExecutorService: ExecutorService? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
@@ -213,6 +217,28 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
+ /**
+ * Sets the maximum number of idle connections kept by the underlying [ConnectionPool].
+ *
+ * If this is set, then [keepAliveDuration] must also be set.
+ *
+ * If unset, then OkHttp's default is used.
+ */
+ fun maxIdleConnections(maxIdleConnections: Int?) = apply {
+ this.maxIdleConnections = maxIdleConnections
+ }
+
+ /**
+ * Sets the keep-alive duration for idle connections in the underlying [ConnectionPool].
+ *
+ * If this is set, then [maxIdleConnections] must also be set.
+ *
+ * If unset, then OkHttp's default is used.
+ */
+ fun keepAliveDuration(keepAliveDuration: Duration?) = apply {
+ this.keepAliveDuration = keepAliveDuration
+ }
+
fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply {
this.dispatcherExecutorService = dispatcherExecutorService
}
@@ -242,6 +268,22 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien
.apply {
dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) }
+ val maxIdleConnections = maxIdleConnections
+ val keepAliveDuration = keepAliveDuration
+ if (maxIdleConnections != null && keepAliveDuration != null) {
+ connectionPool(
+ ConnectionPool(
+ maxIdleConnections,
+ keepAliveDuration.toNanos(),
+ TimeUnit.NANOSECONDS,
+ )
+ )
+ } else {
+ check((maxIdleConnections != null) == (keepAliveDuration != null)) {
+ "Both or none of `maxIdleConnections` and `keepAliveDuration` must be set, but only one was set"
+ }
+ }
+
val sslSocketFactory = sslSocketFactory
val trustManager = trustManager
if (sslSocketFactory != null && trustManager != null) {
diff --git a/hanzo-java-core/build.gradle.kts b/hanzo-java-core/build.gradle.kts
index 4d1c6331..46430891 100644
--- a/hanzo-java-core/build.gradle.kts
+++ b/hanzo-java-core/build.gradle.kts
@@ -27,13 +27,11 @@ dependencies {
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2")
- implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4")
- implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1")
testImplementation(kotlin("test"))
testImplementation(project(":hanzo-java-client-okhttp"))
testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2")
- testImplementation("org.assertj:assertj-core:3.25.3")
+ testImplementation("org.assertj:assertj-core:3.27.7")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3")
testImplementation("org.junit-pioneer:junit-pioneer:1.9.1")
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt
index 66631ea7..82eb7646 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt
@@ -416,13 +416,14 @@ private constructor(
headers.put("X-Stainless-Runtime", "JRE")
headers.put("X-Stainless-Runtime-Version", getJavaVersion())
headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString())
+ // We replace after all the default headers to allow end-users to overwrite them.
+ headers.replaceAll(this.headers.build())
+ queryParams.replaceAll(this.queryParams.build())
apiKey.let {
if (!it.isEmpty()) {
- headers.put("x-litellm-api-key", it)
+ headers.replace("Ocp-Apim-Subscription-Key", it)
}
}
- headers.replaceAll(this.headers.build())
- queryParams.replaceAll(this.queryParams.build())
return ClientOptions(
httpClient,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Properties.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Properties.kt
index 70e2d21a..20a574d0 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Properties.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Properties.kt
@@ -34,9 +34,9 @@ fun getOsName(): String {
}
}
-fun getOsVersion(): String = System.getProperty("os.version", "unknown")
+fun getOsVersion(): String = System.getProperty("os.version", "unknown") ?: "unknown"
fun getPackageVersion(): String =
- HanzoClient::class.java.`package`.implementationVersion ?: "unknown"
+ HanzoClient::class.java.`package`?.implementationVersion ?: "unknown"
-fun getJavaVersion(): String = System.getProperty("java.version", "unknown")
+fun getJavaVersion(): String = System.getProperty("java.version", "unknown") ?: "unknown"
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequestBodies.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequestBodies.kt
index a7b49259..e8f34578 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequestBodies.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequestBodies.kt
@@ -5,16 +5,16 @@
package ai.hanzo.api.core.http
import ai.hanzo.api.core.MultipartField
+import ai.hanzo.api.core.toImmutable
import ai.hanzo.api.errors.HanzoInvalidDataException
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.databind.node.JsonNodeType
+import java.io.ByteArrayInputStream
import java.io.InputStream
import java.io.OutputStream
+import java.util.UUID
import kotlin.jvm.optionals.getOrNull
-import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder
-import org.apache.hc.core5.http.ContentType
-import org.apache.hc.core5.http.HttpEntity
@JvmSynthetic
internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody =
@@ -37,92 +37,231 @@ internal fun multipartFormData(
jsonMapper: JsonMapper,
fields: Map>,
): HttpRequestBody =
- object : HttpRequestBody {
- private val entity: HttpEntity by lazy {
- MultipartEntityBuilder.create()
- .apply {
- fields.forEach { (name, field) ->
- val knownValue = field.value.asKnown().getOrNull()
- val parts =
- if (knownValue is InputStream) {
- // Read directly from the `InputStream` instead of reading it all
- // into memory due to the `jsonMapper` serialization below.
- sequenceOf(name to knownValue)
- } else {
- val node = jsonMapper.valueToTree(field.value)
- serializePart(name, node)
+ MultipartBody.Builder()
+ .apply {
+ fields.forEach { (name, field) ->
+ val knownValue = field.value.asKnown().getOrNull()
+ val parts =
+ if (knownValue is InputStream) {
+ // Read directly from the `InputStream` instead of reading it all
+ // into memory due to the `jsonMapper` serialization below.
+ sequenceOf(name to knownValue)
+ } else {
+ val node = jsonMapper.valueToTree(field.value)
+ serializePart(name, node)
+ }
+
+ parts.forEach { (name, bytes) ->
+ val partBody =
+ if (bytes is ByteArrayInputStream) {
+ val byteArray = bytes.readBytes()
+
+ object : HttpRequestBody {
+
+ override fun writeTo(outputStream: OutputStream) {
+ outputStream.write(byteArray)
+ }
+
+ override fun contentType(): String = field.contentType
+
+ override fun contentLength(): Long = byteArray.size.toLong()
+
+ override fun repeatable(): Boolean = true
+
+ override fun close() {}
}
+ } else {
+ object : HttpRequestBody {
+
+ override fun writeTo(outputStream: OutputStream) {
+ bytes.copyTo(outputStream)
+ }
+
+ override fun contentType(): String = field.contentType
+
+ override fun contentLength(): Long = -1L
- parts.forEach { (name, bytes) ->
- addBinaryBody(
- name,
- bytes,
- ContentType.parseLenient(field.contentType),
- field.filename().getOrNull(),
- )
+ override fun repeatable(): Boolean = false
+
+ override fun close() = bytes.close()
+ }
}
- }
+
+ addPart(
+ MultipartBody.Part.create(
+ name,
+ field.filename().getOrNull(),
+ field.contentType,
+ partBody,
+ )
+ )
}
- .build()
+ }
}
+ .build()
- private fun serializePart(
- name: String,
- node: JsonNode,
- ): Sequence> =
- when (node.nodeType) {
- JsonNodeType.MISSING,
- JsonNodeType.NULL -> emptySequence()
- JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream())
- JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream())
- JsonNodeType.BOOLEAN ->
- sequenceOf(name to node.booleanValue().toString().inputStream())
- JsonNodeType.NUMBER ->
- sequenceOf(name to node.numberValue().toString().inputStream())
- JsonNodeType.ARRAY ->
- sequenceOf(
- name to
- node
- .elements()
- .asSequence()
- .mapNotNull { element ->
- when (element.nodeType) {
- JsonNodeType.MISSING,
- JsonNodeType.NULL -> null
- JsonNodeType.STRING -> node.textValue()
- JsonNodeType.BOOLEAN -> node.booleanValue().toString()
- JsonNodeType.NUMBER -> node.numberValue().toString()
- null,
- JsonNodeType.BINARY,
- JsonNodeType.ARRAY,
- JsonNodeType.OBJECT,
- JsonNodeType.POJO ->
- throw HanzoInvalidDataException(
- "Unexpected JsonNode type in array: ${node.nodeType}"
- )
- }
- }
- .joinToString(",")
- .inputStream()
- )
- JsonNodeType.OBJECT ->
- node.fields().asSequence().flatMap { (key, value) ->
- serializePart("$name[$key]", value)
- }
- JsonNodeType.POJO,
- null ->
- throw HanzoInvalidDataException("Unexpected JsonNode type: ${node.nodeType}")
+private fun serializePart(name: String, node: JsonNode): Sequence> =
+ when (node.nodeType) {
+ JsonNodeType.MISSING,
+ JsonNodeType.NULL -> emptySequence()
+ JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream())
+ JsonNodeType.STRING -> sequenceOf(name to node.textValue().byteInputStream())
+ JsonNodeType.BOOLEAN -> sequenceOf(name to node.booleanValue().toString().byteInputStream())
+ JsonNodeType.NUMBER -> sequenceOf(name to node.numberValue().toString().byteInputStream())
+ JsonNodeType.ARRAY ->
+ sequenceOf(
+ name to
+ node
+ .elements()
+ .asSequence()
+ .mapNotNull { element ->
+ when (element.nodeType) {
+ JsonNodeType.MISSING,
+ JsonNodeType.NULL -> null
+ JsonNodeType.STRING -> element.textValue()
+ JsonNodeType.BOOLEAN -> element.booleanValue().toString()
+ JsonNodeType.NUMBER -> element.numberValue().toString()
+ null,
+ JsonNodeType.BINARY,
+ JsonNodeType.ARRAY,
+ JsonNodeType.OBJECT,
+ JsonNodeType.POJO ->
+ throw HanzoInvalidDataException(
+ "Unexpected JsonNode type in array: ${element.nodeType}"
+ )
+ }
+ }
+ .joinToString(",")
+ .byteInputStream()
+ )
+ JsonNodeType.OBJECT ->
+ node.fields().asSequence().flatMap { (key, value) ->
+ serializePart("$name[$key]", value)
+ }
+ JsonNodeType.POJO,
+ null -> throw HanzoInvalidDataException("Unexpected JsonNode type: ${node.nodeType}")
+ }
+
+private class MultipartBody
+private constructor(private val boundary: String, private val parts: List) : HttpRequestBody {
+ private val boundaryBytes: ByteArray = boundary.toByteArray()
+ private val contentType = "multipart/form-data; boundary=$boundary"
+
+ // This must remain in sync with `contentLength`.
+ override fun writeTo(outputStream: OutputStream) {
+ parts.forEach { part ->
+ outputStream.write(DASHDASH)
+ outputStream.write(boundaryBytes)
+ outputStream.write(CRLF)
+
+ outputStream.write(CONTENT_DISPOSITION)
+ outputStream.write(part.contentDisposition.toByteArray())
+ outputStream.write(CRLF)
+
+ outputStream.write(CONTENT_TYPE)
+ outputStream.write(part.contentType.toByteArray())
+ outputStream.write(CRLF)
+
+ outputStream.write(CRLF)
+ part.body.writeTo(outputStream)
+ outputStream.write(CRLF)
+ }
+
+ outputStream.write(DASHDASH)
+ outputStream.write(boundaryBytes)
+ outputStream.write(DASHDASH)
+ outputStream.write(CRLF)
+ }
+
+ override fun contentType(): String = contentType
+
+ // This must remain in sync with `writeTo`.
+ override fun contentLength(): Long {
+ var byteCount = 0L
+
+ parts.forEach { part ->
+ val contentLength = part.body.contentLength()
+ if (contentLength == -1L) {
+ return -1L
}
- private fun String.inputStream(): InputStream = toByteArray().inputStream()
+ byteCount +=
+ DASHDASH.size +
+ boundaryBytes.size +
+ CRLF.size +
+ CONTENT_DISPOSITION.size +
+ part.contentDisposition.toByteArray().size +
+ CRLF.size +
+ CONTENT_TYPE.size +
+ part.contentType.toByteArray().size +
+ CRLF.size +
+ CRLF.size +
+ contentLength +
+ CRLF.size
+ }
- override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream)
+ byteCount += DASHDASH.size + boundaryBytes.size + DASHDASH.size + CRLF.size
+ return byteCount
+ }
- override fun contentType(): String = entity.contentType
+ override fun repeatable(): Boolean = parts.all { it.body.repeatable() }
- override fun contentLength(): Long = entity.contentLength
+ override fun close() {
+ parts.forEach { it.body.close() }
+ }
- override fun repeatable(): Boolean = entity.isRepeatable
+ class Builder {
+ private val boundary = UUID.randomUUID().toString()
+ private val parts: MutableList = mutableListOf()
- override fun close() = entity.close()
+ fun addPart(part: Part) = apply { parts.add(part) }
+
+ fun build() = MultipartBody(boundary, parts.toImmutable())
+ }
+
+ class Part
+ private constructor(
+ val contentDisposition: String,
+ val contentType: String,
+ val body: HttpRequestBody,
+ ) {
+ companion object {
+ fun create(
+ name: String,
+ filename: String?,
+ contentType: String,
+ body: HttpRequestBody,
+ ): Part {
+ val disposition = buildString {
+ append("form-data; name=")
+ appendQuotedString(name)
+ if (filename != null) {
+ append("; filename=")
+ appendQuotedString(filename)
+ }
+ }
+ return Part(disposition, contentType, body)
+ }
+ }
+ }
+
+ companion object {
+ private val CRLF = byteArrayOf('\r'.code.toByte(), '\n'.code.toByte())
+ private val DASHDASH = byteArrayOf('-'.code.toByte(), '-'.code.toByte())
+ private val CONTENT_DISPOSITION = "Content-Disposition: ".toByteArray()
+ private val CONTENT_TYPE = "Content-Type: ".toByteArray()
+
+ private fun StringBuilder.appendQuotedString(key: String) {
+ append('"')
+ for (ch in key) {
+ when (ch) {
+ '\n' -> append("%0A")
+ '\r' -> append("%0D")
+ '"' -> append("%22")
+ else -> append(ch)
+ }
+ }
+ append('"')
+ }
}
+}
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt
index e17cec71..5e6968a1 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt
@@ -1,3 +1,5 @@
+// File generated from our OpenAPI spec by Stainless.
+
package ai.hanzo.api.core.http
import ai.hanzo.api.core.DefaultSleeper
@@ -199,7 +201,7 @@ private constructor(
?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter ->
retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1))
?: try {
- ChronoUnit.MILLIS.between(
+ ChronoUnit.NANOS.between(
OffsetDateTime.now(clock),
OffsetDateTime.parse(
retryAfter,
@@ -212,13 +214,8 @@ private constructor(
}
}
?.let { retryAfterNanos ->
- // If the API asks us to wait a certain amount of time (and it's a reasonable
- // amount), just
- // do what it says.
- val retryAfter = Duration.ofNanos(retryAfterNanos.toLong())
- if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) {
- return retryAfter
- }
+ // If the API asks us to wait a certain amount of time, do what it says.
+ return Duration.ofNanos(retryAfterNanos.toLong())
}
// Apply exponential backoff, but not more than the max.
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParams.kt
index e8002193..e2932265 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParams.kt
@@ -8,7 +8,7 @@ import ai.hanzo.api.core.http.QueryParams
import java.util.Objects
/**
- * Returns a list of litellm level settings
+ * Returns a list of llm level settings
*
* This is useful for debugging and ensuring the proxy server is configured correctly.
*
@@ -16,17 +16,17 @@ import java.util.Objects
* ```
* {
* "alerting": _alerting,
- * "litellm.callbacks": litellm_callbacks,
- * "litellm.input_callback": litellm_input_callbacks,
- * "litellm.failure_callback": litellm_failure_callbacks,
- * "litellm.success_callback": litellm_success_callbacks,
- * "litellm._async_success_callback": litellm_async_success_callbacks,
- * "litellm._async_failure_callback": litellm_async_failure_callbacks,
- * "litellm._async_input_callback": litellm_async_input_callbacks,
- * "all_litellm_callbacks": all_litellm_callbacks,
- * "num_callbacks": len(all_litellm_callbacks),
+ * "llm.callbacks": llm_callbacks,
+ * "llm.input_callback": llm_input_callbacks,
+ * "llm.failure_callback": llm_failure_callbacks,
+ * "llm.success_callback": llm_success_callbacks,
+ * "llm._async_success_callback": llm_async_success_callbacks,
+ * "llm._async_failure_callback": llm_async_failure_callbacks,
+ * "llm._async_input_callback": llm_async_input_callbacks,
+ * "all_llm_callbacks": all_llm_callbacks,
+ * "num_callbacks": len(all_llm_callbacks),
* "num_alerting": _num_alerting,
- * "litellm.request_timeout": litellm.request_timeout,
+ * "llm.request_timeout": llm.request_timeout,
* }
* ```
*/
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt
index 1a355f7d..64e2fe3c 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt
@@ -11,7 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */
+/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */
class AnthropicCreateParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt
index e9ed26cd..06021e70 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt
@@ -11,7 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */
+/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */
class AnthropicDeleteParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt
index 00086d48..bd52aa0e 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt
@@ -11,7 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */
+/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */
class AnthropicModifyParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt
index 51ed59a2..0b927414 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt
@@ -9,7 +9,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */
+/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */
class AnthropicRetrieveParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt
index 541c66ee..f6110089 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt
@@ -11,7 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */
+/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */
class AnthropicUpdateParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt
index add1f0e2..1f041c32 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt
@@ -13,9 +13,6 @@ import kotlin.jvm.optionals.getOrNull
* Call any azure endpoint using the proxy.
*
* Just use `{PROXY_BASE_URL}/azure/{endpoint:path}`
- *
- * Checks if the deployment id in the url is a litellm model name. If so, it will route using the
- * llm_router.allm_passthrough_route.
*/
class AzureCallParams
private constructor(
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt
index 807e0ede..d26340a5 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt
@@ -15,9 +15,6 @@ import kotlin.jvm.optionals.getOrNull
* Call any azure endpoint using the proxy.
*
* Just use `{PROXY_BASE_URL}/azure/{endpoint:path}`
- *
- * Checks if the deployment id in the url is a litellm model name. If so, it will route using the
- * llm_router.allm_passthrough_route.
*/
class AzureCreateParams
private constructor(
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt
index 09278e4d..026e2cce 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt
@@ -15,9 +15,6 @@ import kotlin.jvm.optionals.getOrNull
* Call any azure endpoint using the proxy.
*
* Just use `{PROXY_BASE_URL}/azure/{endpoint:path}`
- *
- * Checks if the deployment id in the url is a litellm model name. If so, it will route using the
- * llm_router.allm_passthrough_route.
*/
class AzureDeleteParams
private constructor(
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt
index 512eca15..bd8229c3 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt
@@ -15,9 +15,6 @@ import kotlin.jvm.optionals.getOrNull
* Call any azure endpoint using the proxy.
*
* Just use `{PROXY_BASE_URL}/azure/{endpoint:path}`
- *
- * Checks if the deployment id in the url is a litellm model name. If so, it will route using the
- * llm_router.allm_passthrough_route.
*/
class AzurePatchParams
private constructor(
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt
index 0a551f28..988950be 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt
@@ -15,9 +15,6 @@ import kotlin.jvm.optionals.getOrNull
* Call any azure endpoint using the proxy.
*
* Just use `{PROXY_BASE_URL}/azure/{endpoint:path}`
- *
- * Checks if the deployment id in the url is a litellm model name. If so, it will route using the
- * llm_router.allm_passthrough_route.
*/
class AzureUpdateParams
private constructor(
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListParams.kt
index 0c2da8f8..a78f103f 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListParams.kt
@@ -24,7 +24,6 @@ private constructor(
private val after: String?,
private val limit: Long?,
private val provider: String?,
- private val targetModelNames: String?,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
) : Params {
@@ -35,8 +34,6 @@ private constructor(
fun provider(): Optional = Optional.ofNullable(provider)
- fun targetModelNames(): Optional = Optional.ofNullable(targetModelNames)
-
/** Additional headers to send with the request. */
fun _additionalHeaders(): Headers = additionalHeaders
@@ -59,7 +56,6 @@ private constructor(
private var after: String? = null
private var limit: Long? = null
private var provider: String? = null
- private var targetModelNames: String? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@@ -68,7 +64,6 @@ private constructor(
after = batchListParams.after
limit = batchListParams.limit
provider = batchListParams.provider
- targetModelNames = batchListParams.targetModelNames
additionalHeaders = batchListParams.additionalHeaders.toBuilder()
additionalQueryParams = batchListParams.additionalQueryParams.toBuilder()
}
@@ -95,14 +90,6 @@ private constructor(
/** Alias for calling [Builder.provider] with `provider.orElse(null)`. */
fun provider(provider: Optional) = provider(provider.getOrNull())
- fun targetModelNames(targetModelNames: String?) = apply {
- this.targetModelNames = targetModelNames
- }
-
- /** Alias for calling [Builder.targetModelNames] with `targetModelNames.orElse(null)`. */
- fun targetModelNames(targetModelNames: Optional) =
- targetModelNames(targetModelNames.getOrNull())
-
fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -211,7 +198,6 @@ private constructor(
after,
limit,
provider,
- targetModelNames,
additionalHeaders.build(),
additionalQueryParams.build(),
)
@@ -225,7 +211,6 @@ private constructor(
after?.let { put("after", it) }
limit?.let { put("limit", it.toString()) }
provider?.let { put("provider", it) }
- targetModelNames?.let { put("target_model_names", it) }
putAll(additionalQueryParams)
}
.build()
@@ -239,21 +224,13 @@ private constructor(
after == other.after &&
limit == other.limit &&
provider == other.provider &&
- targetModelNames == other.targetModelNames &&
additionalHeaders == other.additionalHeaders &&
additionalQueryParams == other.additionalQueryParams
}
override fun hashCode(): Int =
- Objects.hash(
- after,
- limit,
- provider,
- targetModelNames,
- additionalHeaders,
- additionalQueryParams,
- )
+ Objects.hash(after, limit, provider, additionalHeaders, additionalQueryParams)
override fun toString() =
- "BatchListParams{after=$after, limit=$limit, provider=$provider, targetModelNames=$targetModelNames, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
+ "BatchListParams{after=$after, limit=$limit, provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt
index 2a1cfe58..fb3075b9 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt
@@ -24,7 +24,6 @@ private constructor(
private val provider: String?,
private val after: String?,
private val limit: Long?,
- private val targetModelNames: String?,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
) : Params {
@@ -35,8 +34,6 @@ private constructor(
fun limit(): Optional = Optional.ofNullable(limit)
- fun targetModelNames(): Optional = Optional.ofNullable(targetModelNames)
-
/** Additional headers to send with the request. */
fun _additionalHeaders(): Headers = additionalHeaders
@@ -61,7 +58,6 @@ private constructor(
private var provider: String? = null
private var after: String? = null
private var limit: Long? = null
- private var targetModelNames: String? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@@ -70,7 +66,6 @@ private constructor(
provider = batchListWithProviderParams.provider
after = batchListWithProviderParams.after
limit = batchListWithProviderParams.limit
- targetModelNames = batchListWithProviderParams.targetModelNames
additionalHeaders = batchListWithProviderParams.additionalHeaders.toBuilder()
additionalQueryParams = batchListWithProviderParams.additionalQueryParams.toBuilder()
}
@@ -97,14 +92,6 @@ private constructor(
/** Alias for calling [Builder.limit] with `limit.orElse(null)`. */
fun limit(limit: Optional) = limit(limit.getOrNull())
- fun targetModelNames(targetModelNames: String?) = apply {
- this.targetModelNames = targetModelNames
- }
-
- /** Alias for calling [Builder.targetModelNames] with `targetModelNames.orElse(null)`. */
- fun targetModelNames(targetModelNames: Optional) =
- targetModelNames(targetModelNames.getOrNull())
-
fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -213,7 +200,6 @@ private constructor(
provider,
after,
limit,
- targetModelNames,
additionalHeaders.build(),
additionalQueryParams.build(),
)
@@ -232,7 +218,6 @@ private constructor(
.apply {
after?.let { put("after", it) }
limit?.let { put("limit", it.toString()) }
- targetModelNames?.let { put("target_model_names", it) }
putAll(additionalQueryParams)
}
.build()
@@ -246,21 +231,13 @@ private constructor(
provider == other.provider &&
after == other.after &&
limit == other.limit &&
- targetModelNames == other.targetModelNames &&
additionalHeaders == other.additionalHeaders &&
additionalQueryParams == other.additionalQueryParams
}
override fun hashCode(): Int =
- Objects.hash(
- provider,
- after,
- limit,
- targetModelNames,
- additionalHeaders,
- additionalQueryParams,
- )
+ Objects.hash(provider, after, limit, additionalHeaders, additionalQueryParams)
override fun toString() =
- "BatchListWithProviderParams{provider=$provider, after=$after, limit=$limit, targetModelNames=$targetModelNames, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
+ "BatchListWithProviderParams{provider=$provider, after=$after, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt
index f500a6a9..00a3d2ea 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt
@@ -11,10 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/**
- * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint.
- * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock)
- */
+/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */
class BedrockCreateParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt
index c690ef16..4d91fe27 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt
@@ -11,10 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/**
- * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint.
- * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock)
- */
+/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */
class BedrockDeleteParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt
index 13a6caef..b13b8b78 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt
@@ -11,10 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/**
- * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint.
- * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock)
- */
+/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */
class BedrockPatchParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt
index 71031606..dbd34dad 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt
@@ -9,10 +9,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/**
- * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint.
- * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock)
- */
+/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */
class BedrockRetrieveParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt
index 6667c553..f4159be3 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt
@@ -11,10 +11,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
-/**
- * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint.
- * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock)
- */
+/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */
class BedrockUpdateParams
private constructor(
private val endpoint: String?,
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt
index 4595af23..a5aa51f1 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt
@@ -23,8 +23,6 @@ import java.util.Objects
* - model_max_budget: Optional[dict] - Specify max budget for a given model. Example:
* {"openai/gpt-4o-mini": {"max_budget": 100.0, "budget_duration": "1d", "tpm_limit": 100000,
* "rpm_limit": 100000}}
- * - budget_reset_at: Optional[datetime] - Datetime when the initial budget is reset. Default is
- * now.
*/
class BudgetCreateParams
private constructor(
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt
index 1af94bbc..50994fa8 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt
@@ -12,7 +12,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import java.time.OffsetDateTime
import java.util.Collections
import java.util.Objects
import java.util.Optional
@@ -23,7 +22,6 @@ class BudgetNew
private constructor(
private val budgetDuration: JsonField,
private val budgetId: JsonField,
- private val budgetResetAt: JsonField,
private val maxBudget: JsonField,
private val maxParallelRequests: JsonField,
private val modelMaxBudget: JsonField,
@@ -39,9 +37,6 @@ private constructor(
@ExcludeMissing
budgetDuration: JsonField = JsonMissing.of(),
@JsonProperty("budget_id") @ExcludeMissing budgetId: JsonField = JsonMissing.of(),
- @JsonProperty("budget_reset_at")
- @ExcludeMissing
- budgetResetAt: JsonField = JsonMissing.of(),
@JsonProperty("max_budget") @ExcludeMissing maxBudget: JsonField = JsonMissing.of(),
@JsonProperty("max_parallel_requests")
@ExcludeMissing
@@ -57,7 +52,6 @@ private constructor(
) : this(
budgetDuration,
budgetId,
- budgetResetAt,
maxBudget,
maxParallelRequests,
modelMaxBudget,
@@ -83,14 +77,6 @@ private constructor(
*/
fun budgetId(): Optional = budgetId.getOptional("budget_id")
- /**
- * Datetime when the budget is reset
- *
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at")
-
/**
* Requests will fail if this budget (in USD) is exceeded.
*
@@ -157,15 +143,6 @@ private constructor(
*/
@JsonProperty("budget_id") @ExcludeMissing fun _budgetId(): JsonField = budgetId
- /**
- * Returns the raw JSON value of [budgetResetAt].
- *
- * Unlike [budgetResetAt], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("budget_reset_at")
- @ExcludeMissing
- fun _budgetResetAt(): JsonField = budgetResetAt
-
/**
* Returns the raw JSON value of [maxBudget].
*
@@ -236,7 +213,6 @@ private constructor(
private var budgetDuration: JsonField = JsonMissing.of()
private var budgetId: JsonField = JsonMissing.of()
- private var budgetResetAt: JsonField = JsonMissing.of()
private var maxBudget: JsonField = JsonMissing.of()
private var maxParallelRequests: JsonField = JsonMissing.of()
private var modelMaxBudget: JsonField = JsonMissing.of()
@@ -249,7 +225,6 @@ private constructor(
internal fun from(budgetNew: BudgetNew) = apply {
budgetDuration = budgetNew.budgetDuration
budgetId = budgetNew.budgetId
- budgetResetAt = budgetNew.budgetResetAt
maxBudget = budgetNew.maxBudget
maxParallelRequests = budgetNew.maxParallelRequests
modelMaxBudget = budgetNew.modelMaxBudget
@@ -292,25 +267,6 @@ private constructor(
*/
fun budgetId(budgetId: JsonField) = apply { this.budgetId = budgetId }
- /** Datetime when the budget is reset */
- fun budgetResetAt(budgetResetAt: OffsetDateTime?) =
- budgetResetAt(JsonField.ofNullable(budgetResetAt))
-
- /** Alias for calling [Builder.budgetResetAt] with `budgetResetAt.orElse(null)`. */
- fun budgetResetAt(budgetResetAt: Optional) =
- budgetResetAt(budgetResetAt.getOrNull())
-
- /**
- * Sets [Builder.budgetResetAt] to an arbitrary JSON value.
- *
- * You should usually call [Builder.budgetResetAt] with a well-typed [OffsetDateTime] value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun budgetResetAt(budgetResetAt: JsonField) = apply {
- this.budgetResetAt = budgetResetAt
- }
-
/** Requests will fail if this budget (in USD) is exceeded. */
fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget))
@@ -476,7 +432,6 @@ private constructor(
BudgetNew(
budgetDuration,
budgetId,
- budgetResetAt,
maxBudget,
maxParallelRequests,
modelMaxBudget,
@@ -496,7 +451,6 @@ private constructor(
budgetDuration()
budgetId()
- budgetResetAt()
maxBudget()
maxParallelRequests()
modelMaxBudget().ifPresent { it.validate() }
@@ -523,7 +477,6 @@ private constructor(
internal fun validity(): Int =
(if (budgetDuration.asKnown().isPresent) 1 else 0) +
(if (budgetId.asKnown().isPresent) 1 else 0) +
- (if (budgetResetAt.asKnown().isPresent) 1 else 0) +
(if (maxBudget.asKnown().isPresent) 1 else 0) +
(if (maxParallelRequests.asKnown().isPresent) 1 else 0) +
(modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) +
@@ -642,7 +595,6 @@ private constructor(
return other is BudgetNew &&
budgetDuration == other.budgetDuration &&
budgetId == other.budgetId &&
- budgetResetAt == other.budgetResetAt &&
maxBudget == other.maxBudget &&
maxParallelRequests == other.maxParallelRequests &&
modelMaxBudget == other.modelMaxBudget &&
@@ -656,7 +608,6 @@ private constructor(
Objects.hash(
budgetDuration,
budgetId,
- budgetResetAt,
maxBudget,
maxParallelRequests,
modelMaxBudget,
@@ -670,5 +621,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "BudgetNew{budgetDuration=$budgetDuration, budgetId=$budgetId, budgetResetAt=$budgetResetAt, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, modelMaxBudget=$modelMaxBudget, rpmLimit=$rpmLimit, softBudget=$softBudget, tpmLimit=$tpmLimit, additionalProperties=$additionalProperties}"
+ "BudgetNew{budgetDuration=$budgetDuration, budgetId=$budgetId, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, modelMaxBudget=$modelMaxBudget, rpmLimit=$rpmLimit, softBudget=$softBudget, tpmLimit=$tpmLimit, additionalProperties=$additionalProperties}"
}
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt
index 4464bddc..0cd47a5d 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt
@@ -23,7 +23,6 @@ import java.util.Objects
* - model_max_budget: Optional[dict] - Specify max budget for a given model. Example:
* {"openai/gpt-4o-mini": {"max_budget": 100.0, "budget_duration": "1d", "tpm_limit": 100000,
* "rpm_limit": 100000}}
- * - budget_reset_at: Optional[datetime] - Update the Datetime when the budget was last reset.
*/
class BudgetUpdateParams
private constructor(
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt
index 88acb3cd..17253ed3 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt
@@ -11,8 +11,8 @@ import java.util.Objects
import java.util.Optional
/**
- * Endpoint for deleting a key from the cache. All responses from litellm proxy have
- * `x-litellm-cache-key` in the headers
+ * Endpoint for deleting a key from the cache. All responses from llm proxy have `x-llm-cache-key`
+ * in the headers
*
* Parameters:
* - **keys**: *Optional[List[str]]* - A list of keys to delete from the cache. Example {"keys":
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt
index 1606d05a..69b94239 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt
@@ -7,7 +7,6 @@ import ai.hanzo.api.core.JsonField
import ai.hanzo.api.core.JsonMissing
import ai.hanzo.api.core.JsonValue
import ai.hanzo.api.core.checkRequired
-import ai.hanzo.api.core.toImmutable
import ai.hanzo.api.errors.HanzoInvalidDataException
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
@@ -23,8 +22,8 @@ class CachePingResponse
private constructor(
private val cacheType: JsonField,
private val status: JsonField,
- private val healthCheckCacheParams: JsonField,
- private val litellmCacheParams: JsonField,
+ private val healthCheckCacheParams: JsonValue,
+ private val llmCacheParams: JsonField,
private val pingResponse: JsonField,
private val setCacheResponse: JsonField,
private val additionalProperties: MutableMap,
@@ -36,10 +35,10 @@ private constructor(
@JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(),
@JsonProperty("health_check_cache_params")
@ExcludeMissing
- healthCheckCacheParams: JsonField = JsonMissing.of(),
- @JsonProperty("litellm_cache_params")
+ healthCheckCacheParams: JsonValue = JsonMissing.of(),
+ @JsonProperty("llm_cache_params")
@ExcludeMissing
- litellmCacheParams: JsonField = JsonMissing.of(),
+ llmCacheParams: JsonField = JsonMissing.of(),
@JsonProperty("ping_response")
@ExcludeMissing
pingResponse: JsonField = JsonMissing.of(),
@@ -50,7 +49,7 @@ private constructor(
cacheType,
status,
healthCheckCacheParams,
- litellmCacheParams,
+ llmCacheParams,
pingResponse,
setCacheResponse,
mutableMapOf(),
@@ -69,18 +68,20 @@ private constructor(
fun status(): String = status.getRequired("status")
/**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
+ * This arbitrary value can be deserialized into a custom type using the `convert` method:
+ * ```java
+ * MyClass myObject = cachePingResponse.healthCheckCacheParams().convert(MyClass.class);
+ * ```
*/
- fun healthCheckCacheParams(): Optional =
- healthCheckCacheParams.getOptional("health_check_cache_params")
+ @JsonProperty("health_check_cache_params")
+ @ExcludeMissing
+ fun _healthCheckCacheParams(): JsonValue = healthCheckCacheParams
/**
* @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
- fun litellmCacheParams(): Optional =
- litellmCacheParams.getOptional("litellm_cache_params")
+ fun llmCacheParams(): Optional = llmCacheParams.getOptional("llm_cache_params")
/**
* @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
@@ -109,24 +110,13 @@ private constructor(
@JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status
/**
- * Returns the raw JSON value of [healthCheckCacheParams].
+ * Returns the raw JSON value of [llmCacheParams].
*
- * Unlike [healthCheckCacheParams], this method doesn't throw if the JSON field has an
- * unexpected type.
+ * Unlike [llmCacheParams], this method doesn't throw if the JSON field has an unexpected type.
*/
- @JsonProperty("health_check_cache_params")
+ @JsonProperty("llm_cache_params")
@ExcludeMissing
- fun _healthCheckCacheParams(): JsonField = healthCheckCacheParams
-
- /**
- * Returns the raw JSON value of [litellmCacheParams].
- *
- * Unlike [litellmCacheParams], this method doesn't throw if the JSON field has an unexpected
- * type.
- */
- @JsonProperty("litellm_cache_params")
- @ExcludeMissing
- fun _litellmCacheParams(): JsonField = litellmCacheParams
+ fun _llmCacheParams(): JsonField = llmCacheParams
/**
* Returns the raw JSON value of [pingResponse].
@@ -178,8 +168,8 @@ private constructor(
private var cacheType: JsonField? = null
private var status: JsonField? = null
- private var healthCheckCacheParams: JsonField = JsonMissing.of()
- private var litellmCacheParams: JsonField = JsonMissing.of()
+ private var healthCheckCacheParams: JsonValue = JsonMissing.of()
+ private var llmCacheParams: JsonField = JsonMissing.of()
private var pingResponse: JsonField = JsonMissing.of()
private var setCacheResponse: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
@@ -189,7 +179,7 @@ private constructor(
cacheType = cachePingResponse.cacheType
status = cachePingResponse.status
healthCheckCacheParams = cachePingResponse.healthCheckCacheParams
- litellmCacheParams = cachePingResponse.litellmCacheParams
+ llmCacheParams = cachePingResponse.llmCacheParams
pingResponse = cachePingResponse.pingResponse
setCacheResponse = cachePingResponse.setCacheResponse
additionalProperties = cachePingResponse.additionalProperties.toMutableMap()
@@ -216,46 +206,26 @@ private constructor(
*/
fun status(status: JsonField) = apply { this.status = status }
- fun healthCheckCacheParams(healthCheckCacheParams: HealthCheckCacheParams?) =
- healthCheckCacheParams(JsonField.ofNullable(healthCheckCacheParams))
-
- /**
- * Alias for calling [Builder.healthCheckCacheParams] with
- * `healthCheckCacheParams.orElse(null)`.
- */
- fun healthCheckCacheParams(healthCheckCacheParams: Optional) =
- healthCheckCacheParams(healthCheckCacheParams.getOrNull())
-
- /**
- * Sets [Builder.healthCheckCacheParams] to an arbitrary JSON value.
- *
- * You should usually call [Builder.healthCheckCacheParams] with a well-typed
- * [HealthCheckCacheParams] value instead. This method is primarily for setting the field to
- * an undocumented or not yet supported value.
- */
- fun healthCheckCacheParams(healthCheckCacheParams: JsonField) =
- apply {
- this.healthCheckCacheParams = healthCheckCacheParams
- }
+ fun healthCheckCacheParams(healthCheckCacheParams: JsonValue) = apply {
+ this.healthCheckCacheParams = healthCheckCacheParams
+ }
- fun litellmCacheParams(litellmCacheParams: String?) =
- litellmCacheParams(JsonField.ofNullable(litellmCacheParams))
+ fun llmCacheParams(llmCacheParams: String?) =
+ llmCacheParams(JsonField.ofNullable(llmCacheParams))
- /**
- * Alias for calling [Builder.litellmCacheParams] with `litellmCacheParams.orElse(null)`.
- */
- fun litellmCacheParams(litellmCacheParams: Optional) =
- litellmCacheParams(litellmCacheParams.getOrNull())
+ /** Alias for calling [Builder.llmCacheParams] with `llmCacheParams.orElse(null)`. */
+ fun llmCacheParams(llmCacheParams: Optional) =
+ llmCacheParams(llmCacheParams.getOrNull())
/**
- * Sets [Builder.litellmCacheParams] to an arbitrary JSON value.
+ * Sets [Builder.llmCacheParams] to an arbitrary JSON value.
*
- * You should usually call [Builder.litellmCacheParams] with a well-typed [String] value
+ * You should usually call [Builder.llmCacheParams] with a well-typed [String] value
* instead. This method is primarily for setting the field to an undocumented or not yet
* supported value.
*/
- fun litellmCacheParams(litellmCacheParams: JsonField) = apply {
- this.litellmCacheParams = litellmCacheParams
+ fun llmCacheParams(llmCacheParams: JsonField) = apply {
+ this.llmCacheParams = llmCacheParams
}
fun pingResponse(pingResponse: Boolean?) = pingResponse(JsonField.ofNullable(pingResponse))
@@ -336,7 +306,7 @@ private constructor(
checkRequired("cacheType", cacheType),
checkRequired("status", status),
healthCheckCacheParams,
- litellmCacheParams,
+ llmCacheParams,
pingResponse,
setCacheResponse,
additionalProperties.toMutableMap(),
@@ -352,8 +322,7 @@ private constructor(
cacheType()
status()
- healthCheckCacheParams().ifPresent { it.validate() }
- litellmCacheParams()
+ llmCacheParams()
pingResponse()
setCacheResponse()
validated = true
@@ -376,115 +345,10 @@ private constructor(
internal fun validity(): Int =
(if (cacheType.asKnown().isPresent) 1 else 0) +
(if (status.asKnown().isPresent) 1 else 0) +
- (healthCheckCacheParams.asKnown().getOrNull()?.validity() ?: 0) +
- (if (litellmCacheParams.asKnown().isPresent) 1 else 0) +
+ (if (llmCacheParams.asKnown().isPresent) 1 else 0) +
(if (pingResponse.asKnown().isPresent) 1 else 0) +
(if (setCacheResponse.asKnown().isPresent) 1 else 0)
- class HealthCheckCacheParams
- @JsonCreator
- private constructor(
- @com.fasterxml.jackson.annotation.JsonValue
- private val additionalProperties: Map
- ) {
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [HealthCheckCacheParams].
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [HealthCheckCacheParams]. */
- class Builder internal constructor() {
-
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(healthCheckCacheParams: HealthCheckCacheParams) = apply {
- additionalProperties = healthCheckCacheParams.additionalProperties.toMutableMap()
- }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [HealthCheckCacheParams].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- */
- fun build(): HealthCheckCacheParams =
- HealthCheckCacheParams(additionalProperties.toImmutable())
- }
-
- private var validated: Boolean = false
-
- fun validate(): HealthCheckCacheParams = apply {
- if (validated) {
- return@apply
- }
-
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: HanzoInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object
- * recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is HealthCheckCacheParams &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "HealthCheckCacheParams{additionalProperties=$additionalProperties}"
- }
-
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -494,7 +358,7 @@ private constructor(
cacheType == other.cacheType &&
status == other.status &&
healthCheckCacheParams == other.healthCheckCacheParams &&
- litellmCacheParams == other.litellmCacheParams &&
+ llmCacheParams == other.llmCacheParams &&
pingResponse == other.pingResponse &&
setCacheResponse == other.setCacheResponse &&
additionalProperties == other.additionalProperties
@@ -505,7 +369,7 @@ private constructor(
cacheType,
status,
healthCheckCacheParams,
- litellmCacheParams,
+ llmCacheParams,
pingResponse,
setCacheResponse,
additionalProperties,
@@ -515,5 +379,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "CachePingResponse{cacheType=$cacheType, status=$status, healthCheckCacheParams=$healthCheckCacheParams, litellmCacheParams=$litellmCacheParams, pingResponse=$pingResponse, setCacheResponse=$setCacheResponse, additionalProperties=$additionalProperties}"
+ "CachePingResponse{cacheType=$cacheType, status=$status, healthCheckCacheParams=$healthCheckCacheParams, llmCacheParams=$llmCacheParams, pingResponse=$pingResponse, setCacheResponse=$setCacheResponse, additionalProperties=$additionalProperties}"
}
diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt
index 2f9ac31f..f417ec47 100644
--- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt
+++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt
@@ -2,34 +2,11 @@
package ai.hanzo.api.models.chat.completions
-import ai.hanzo.api.core.BaseDeserializer
-import ai.hanzo.api.core.BaseSerializer
-import ai.hanzo.api.core.Enum
-import ai.hanzo.api.core.ExcludeMissing
-import ai.hanzo.api.core.JsonField
-import ai.hanzo.api.core.JsonMissing
import ai.hanzo.api.core.JsonValue
import ai.hanzo.api.core.Params
-import ai.hanzo.api.core.allMaxBy
-import ai.hanzo.api.core.checkKnown
-import ai.hanzo.api.core.checkRequired
-import ai.hanzo.api.core.getOrThrow
import ai.hanzo.api.core.http.Headers
import ai.hanzo.api.core.http.QueryParams
import ai.hanzo.api.core.toImmutable
-import ai.hanzo.api.errors.HanzoInvalidDataException
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.core.JsonGenerator
-import com.fasterxml.jackson.core.ObjectCodec
-import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.SerializerProvider
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
-import com.fasterxml.jackson.databind.annotation.JsonSerialize
-import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
-import java.util.Collections
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
@@ -55,394 +32,16 @@ import kotlin.jvm.optionals.getOrNull
*/
class CompletionCreateParams
private constructor(
- private val body: Body,
+ private val model: String?,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
+ private val additionalBodyProperties: Map,
) : Params {
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly
- * missing or null (e.g. if the server responded with an unexpected value).
- */
- fun messages(): List = body.messages()
+ fun model(): Optional = Optional.ofNullable(model)
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly
- * missing or null (e.g. if the server responded with an unexpected value).
- */
- fun model(): String = body.model()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun caching(): Optional = body.caching()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun contextWindowFallbackDict(): Optional =
- body.contextWindowFallbackDict()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun fallbacks(): Optional> = body.fallbacks()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun frequencyPenalty(): Optional = body.frequencyPenalty()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun functionCall(): Optional = body.functionCall()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun functions(): Optional> = body.functions()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun guardrails(): Optional> = body.guardrails()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun logitBias(): Optional = body.logitBias()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun logprobs(): Optional = body.logprobs()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun maxTokens(): Optional = body.maxTokens()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun metadata(): Optional = body.metadata()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun n(): Optional = body.n()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun numRetries(): Optional = body.numRetries()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun parallelToolCalls(): Optional = body.parallelToolCalls()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun presencePenalty(): Optional = body.presencePenalty()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun responseFormat(): Optional = body.responseFormat()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun seed(): Optional = body.seed()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun serviceTier(): Optional = body.serviceTier()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun stop(): Optional = body.stop()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun stream(): Optional = body.stream()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun streamOptions(): Optional = body.streamOptions()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun temperature(): Optional = body.temperature()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun toolChoice(): Optional = body.toolChoice()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun tools(): Optional> = body.tools()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun topLogprobs(): Optional = body.topLogprobs()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun topP(): Optional = body.topP()
-
- /**
- * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun user(): Optional = body.user()
-
- /**
- * Returns the raw JSON value of [messages].
- *
- * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _messages(): JsonField> = body._messages()
-
- /**
- * Returns the raw JSON value of [model].
- *
- * Unlike [model], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _model(): JsonField = body._model()
-
- /**
- * Returns the raw JSON value of [caching].
- *
- * Unlike [caching], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _caching(): JsonField = body._caching()
-
- /**
- * Returns the raw JSON value of [contextWindowFallbackDict].
- *
- * Unlike [contextWindowFallbackDict], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- fun _contextWindowFallbackDict(): JsonField =
- body._contextWindowFallbackDict()
-
- /**
- * Returns the raw JSON value of [fallbacks].
- *
- * Unlike [fallbacks], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _fallbacks(): JsonField> = body._fallbacks()
-
- /**
- * Returns the raw JSON value of [frequencyPenalty].
- *
- * Unlike [frequencyPenalty], this method doesn't throw if the JSON field has an unexpected
- * type.
- */
- fun _frequencyPenalty(): JsonField = body._frequencyPenalty()
-
- /**
- * Returns the raw JSON value of [functionCall].
- *
- * Unlike [functionCall], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _functionCall(): JsonField = body._functionCall()
-
- /**
- * Returns the raw JSON value of [functions].
- *
- * Unlike [functions], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _functions(): JsonField> = body._functions()
-
- /**
- * Returns the raw JSON value of [guardrails].
- *
- * Unlike [guardrails], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _guardrails(): JsonField> = body._guardrails()
-
- /**
- * Returns the raw JSON value of [logitBias].
- *
- * Unlike [logitBias], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _logitBias(): JsonField = body._logitBias()
-
- /**
- * Returns the raw JSON value of [logprobs].
- *
- * Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _logprobs(): JsonField = body._logprobs()
-
- /**
- * Returns the raw JSON value of [maxTokens].
- *
- * Unlike [maxTokens], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _maxTokens(): JsonField = body._maxTokens()
-
- /**
- * Returns the raw JSON value of [metadata].
- *
- * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _metadata(): JsonField = body._metadata()
-
- /**
- * Returns the raw JSON value of [n].
- *
- * Unlike [n], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _n(): JsonField = body._n()
-
- /**
- * Returns the raw JSON value of [numRetries].
- *
- * Unlike [numRetries], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _numRetries(): JsonField = body._numRetries()
-
- /**
- * Returns the raw JSON value of [parallelToolCalls].
- *
- * Unlike [parallelToolCalls], this method doesn't throw if the JSON field has an unexpected
- * type.
- */
- fun _parallelToolCalls(): JsonField = body._parallelToolCalls()
-
- /**
- * Returns the raw JSON value of [presencePenalty].
- *
- * Unlike [presencePenalty], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _presencePenalty(): JsonField = body._presencePenalty()
-
- /**
- * Returns the raw JSON value of [responseFormat].
- *
- * Unlike [responseFormat], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _responseFormat(): JsonField = body._responseFormat()
-
- /**
- * Returns the raw JSON value of [seed].
- *
- * Unlike [seed], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _seed(): JsonField = body._seed()
-
- /**
- * Returns the raw JSON value of [serviceTier].
- *
- * Unlike [serviceTier], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _serviceTier(): JsonField = body._serviceTier()
-
- /**
- * Returns the raw JSON value of [stop].
- *
- * Unlike [stop], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _stop(): JsonField = body._stop()
-
- /**
- * Returns the raw JSON value of [stream].
- *
- * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _stream(): JsonField = body._stream()
-
- /**
- * Returns the raw JSON value of [streamOptions].
- *
- * Unlike [streamOptions], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _streamOptions(): JsonField = body._streamOptions()
-
- /**
- * Returns the raw JSON value of [temperature].
- *
- * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _temperature(): JsonField = body._temperature()
-
- /**
- * Returns the raw JSON value of [toolChoice].
- *
- * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _toolChoice(): JsonField = body._toolChoice()
-
- /**
- * Returns the raw JSON value of [tools].
- *
- * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _tools(): JsonField> = body._tools()
-
- /**
- * Returns the raw JSON value of [topLogprobs].
- *
- * Unlike [topLogprobs], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _topLogprobs(): JsonField = body._topLogprobs()
-
- /**
- * Returns the raw JSON value of [topP].
- *
- * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _topP(): JsonField = body._topP()
-
- /**
- * Returns the raw JSON value of [user].
- *
- * Unlike [user], this method doesn't throw if the JSON field has an unexpected type.
- */
- fun _user(): JsonField = body._user()
-
- fun _additionalBodyProperties(): Map = body._additionalProperties()
+ /** Additional body properties to send with the request. */
+ fun _additionalBodyProperties(): Map = additionalBodyProperties
/** Additional headers to send with the request. */
fun _additionalHeaders(): Headers = additionalHeaders
@@ -454,16448 +53,180 @@ private constructor(
companion object {
- /**
- * Returns a mutable builder for constructing an instance of [CompletionCreateParams].
- *
- * The following fields are required:
- * ```java
- * .messages()
- * .model()
- * ```
- */
+ @JvmStatic fun none(): CompletionCreateParams = builder().build()
+
+ /** Returns a mutable builder for constructing an instance of [CompletionCreateParams]. */
@JvmStatic fun builder() = Builder()
}
/** A builder for [CompletionCreateParams]. */
class Builder internal constructor() {
- private var body: Body.Builder = Body.builder()
+ private var model: String? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
+ private var additionalBodyProperties: MutableMap = mutableMapOf()
@JvmSynthetic
internal fun from(completionCreateParams: CompletionCreateParams) = apply {
- body = completionCreateParams.body.toBuilder()
+ model = completionCreateParams.model
additionalHeaders = completionCreateParams.additionalHeaders.toBuilder()
additionalQueryParams = completionCreateParams.additionalQueryParams.toBuilder()
+ additionalBodyProperties =
+ completionCreateParams.additionalBodyProperties.toMutableMap()
}
- /**
- * Sets the entire request body.
- *
- * This is generally only useful if you are already constructing the body separately.
- * Otherwise, it's more convenient to use the top-level setters instead:
- * - [messages]
- * - [model]
- * - [caching]
- * - [contextWindowFallbackDict]
- * - [fallbacks]
- * - etc.
- */
- fun body(body: Body) = apply { this.body = body.toBuilder() }
-
- fun messages(messages: List) = apply { body.messages(messages) }
-
- /**
- * Sets [Builder.messages] to an arbitrary JSON value.
- *
- * You should usually call [Builder.messages] with a well-typed `List` value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun messages(messages: JsonField>) = apply { body.messages(messages) }
+ fun model(model: String?) = apply { this.model = model }
- /**
- * Adds a single [Message] to [messages].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addMessage(message: Message) = apply { body.addMessage(message) }
+ /** Alias for calling [Builder.model] with `model.orElse(null)`. */
+ fun model(model: Optional) = model(model.getOrNull())
- /**
- * Alias for calling [addMessage] with `Message.ofChatCompletionUser(chatCompletionUser)`.
- */
- fun addMessage(chatCompletionUser: Message.ChatCompletionUserMessage) = apply {
- body.addMessage(chatCompletionUser)
+ fun additionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
}
- /**
- * Alias for calling [addMessage] with
- * `Message.ofChatCompletionAssistant(chatCompletionAssistant)`.
- */
- fun addMessage(chatCompletionAssistant: Message.ChatCompletionAssistantMessage) = apply {
- body.addMessage(chatCompletionAssistant)
+ fun additionalHeaders(additionalHeaders: Map>) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
}
- /**
- * Alias for calling [addMessage] with `Message.ofChatCompletionTool(chatCompletionTool)`.
- */
- fun addMessage(chatCompletionTool: Message.ChatCompletionToolMessage) = apply {
- body.addMessage(chatCompletionTool)
+ fun putAdditionalHeader(name: String, value: String) = apply {
+ additionalHeaders.put(name, value)
}
- /**
- * Alias for calling [addMessage] with
- * `Message.ofChatCompletionSystem(chatCompletionSystem)`.
- */
- fun addMessage(chatCompletionSystem: Message.ChatCompletionSystemMessage) = apply {
- body.addMessage(chatCompletionSystem)
+ fun putAdditionalHeaders(name: String, values: Iterable) = apply {
+ additionalHeaders.put(name, values)
}
- /**
- * Alias for calling [addMessage] with
- * `Message.ofChatCompletionFunction(chatCompletionFunction)`.
- */
- fun addMessage(chatCompletionFunction: Message.ChatCompletionFunctionMessage) = apply {
- body.addMessage(chatCompletionFunction)
+ fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
}
- /**
- * Alias for calling [addMessage] with
- * `Message.ofChatCompletionDeveloper(chatCompletionDeveloper)`.
- */
- fun addMessage(chatCompletionDeveloper: Message.ChatCompletionDeveloperMessage) = apply {
- body.addMessage(chatCompletionDeveloper)
+ fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
}
- fun model(model: String) = apply { body.model(model) }
-
- /**
- * Sets [Builder.model] to an arbitrary JSON value.
- *
- * You should usually call [Builder.model] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun model(model: JsonField) = apply { body.model(model) }
-
- fun caching(caching: Boolean?) = apply { body.caching(caching) }
-
- /**
- * Alias for [Builder.caching].
- *
- * This unboxed primitive overload exists for backwards compatibility.
- */
- fun caching(caching: Boolean) = caching(caching as Boolean?)
-
- /** Alias for calling [Builder.caching] with `caching.orElse(null)`. */
- fun caching(caching: Optional) = caching(caching.getOrNull())
-
- /**
- * Sets [Builder.caching] to an arbitrary JSON value.
- *
- * You should usually call [Builder.caching] with a well-typed [Boolean] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun caching(caching: JsonField) = apply { body.caching(caching) }
-
- fun contextWindowFallbackDict(contextWindowFallbackDict: ContextWindowFallbackDict?) =
- apply {
- body.contextWindowFallbackDict(contextWindowFallbackDict)
- }
-
- /**
- * Alias for calling [Builder.contextWindowFallbackDict] with
- * `contextWindowFallbackDict.orElse(null)`.
- */
- fun contextWindowFallbackDict(
- contextWindowFallbackDict: Optional
- ) = contextWindowFallbackDict(contextWindowFallbackDict.getOrNull())
-
- /**
- * Sets [Builder.contextWindowFallbackDict] to an arbitrary JSON value.
- *
- * You should usually call [Builder.contextWindowFallbackDict] with a well-typed
- * [ContextWindowFallbackDict] value instead. This method is primarily for setting the field
- * to an undocumented or not yet supported value.
- */
- fun contextWindowFallbackDict(
- contextWindowFallbackDict: JsonField
- ) = apply { body.contextWindowFallbackDict(contextWindowFallbackDict) }
-
- fun fallbacks(fallbacks: List?) = apply { body.fallbacks(fallbacks) }
-
- /** Alias for calling [Builder.fallbacks] with `fallbacks.orElse(null)`. */
- fun fallbacks(fallbacks: Optional>) = fallbacks(fallbacks.getOrNull())
-
- /**
- * Sets [Builder.fallbacks] to an arbitrary JSON value.
- *
- * You should usually call [Builder.fallbacks] with a well-typed `List` value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun fallbacks(fallbacks: JsonField>) = apply { body.fallbacks(fallbacks) }
-
- /**
- * Adds a single [String] to [fallbacks].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addFallback(fallback: String) = apply { body.addFallback(fallback) }
-
- fun frequencyPenalty(frequencyPenalty: Double?) = apply {
- body.frequencyPenalty(frequencyPenalty)
+ fun replaceAdditionalHeaders(name: String, value: String) = apply {
+ additionalHeaders.replace(name, value)
}
- /**
- * Alias for [Builder.frequencyPenalty].
- *
- * This unboxed primitive overload exists for backwards compatibility.
- */
- fun frequencyPenalty(frequencyPenalty: Double) =
- frequencyPenalty(frequencyPenalty as Double?)
-
- /** Alias for calling [Builder.frequencyPenalty] with `frequencyPenalty.orElse(null)`. */
- fun frequencyPenalty(frequencyPenalty: Optional) =
- frequencyPenalty(frequencyPenalty.getOrNull())
-
- /**
- * Sets [Builder.frequencyPenalty] to an arbitrary JSON value.
- *
- * You should usually call [Builder.frequencyPenalty] with a well-typed [Double] value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun frequencyPenalty(frequencyPenalty: JsonField) = apply {
- body.frequencyPenalty(frequencyPenalty)
+ fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
+ additionalHeaders.replace(name, values)
}
- fun functionCall(functionCall: FunctionCall?) = apply { body.functionCall(functionCall) }
-
- /** Alias for calling [Builder.functionCall] with `functionCall.orElse(null)`. */
- fun functionCall(functionCall: Optional) =
- functionCall(functionCall.getOrNull())
-
- /**
- * Sets [Builder.functionCall] to an arbitrary JSON value.
- *
- * You should usually call [Builder.functionCall] with a well-typed [FunctionCall] value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun functionCall(functionCall: JsonField) = apply {
- body.functionCall(functionCall)
+ fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
- /** Alias for calling [functionCall] with `FunctionCall.ofString(string)`. */
- fun functionCall(string: String) = apply { body.functionCall(string) }
-
- /** Alias for calling [functionCall] with `FunctionCall.ofUnionMember1(unionMember1)`. */
- fun functionCall(unionMember1: FunctionCall.UnionMember1) = apply {
- body.functionCall(unionMember1)
+ fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
- fun functions(functions: List?) = apply { body.functions(functions) }
-
- /** Alias for calling [Builder.functions] with `functions.orElse(null)`. */
- fun functions(functions: Optional>) = functions(functions.getOrNull())
-
- /**
- * Sets [Builder.functions] to an arbitrary JSON value.
- *
- * You should usually call [Builder.functions] with a well-typed `List` value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun functions(functions: JsonField>) = apply { body.functions(functions) }
-
- /**
- * Adds a single [Function] to [functions].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addFunction(function: Function) = apply { body.addFunction(function) }
-
- fun guardrails(guardrails: List?) = apply { body.guardrails(guardrails) }
+ fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
- /** Alias for calling [Builder.guardrails] with `guardrails.orElse(null)`. */
- fun guardrails(guardrails: Optional>) = guardrails(guardrails.getOrNull())
+ fun removeAllAdditionalHeaders(names: Set) = apply {
+ additionalHeaders.removeAll(names)
+ }
- /**
- * Sets [Builder.guardrails] to an arbitrary JSON value.
- *
- * You should usually call [Builder.guardrails] with a well-typed `List` value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun guardrails(guardrails: JsonField>) = apply { body.guardrails(guardrails) }
+ fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
+ }
- /**
- * Adds a single [String] to [guardrails].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addGuardrail(guardrail: String) = apply { body.addGuardrail(guardrail) }
+ fun additionalQueryParams(additionalQueryParams: Map>) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
+ }
- fun logitBias(logitBias: LogitBias?) = apply { body.logitBias(logitBias) }
+ fun putAdditionalQueryParam(key: String, value: String) = apply {
+ additionalQueryParams.put(key, value)
+ }
- /** Alias for calling [Builder.logitBias] with `logitBias.orElse(null)`. */
- fun logitBias(logitBias: Optional) = logitBias(logitBias.getOrNull())
+ fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
+ additionalQueryParams.put(key, values)
+ }
- /**
- * Sets [Builder.logitBias] to an arbitrary JSON value.
- *
- * You should usually call [Builder.logitBias] with a well-typed [LogitBias] value instead.
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun logitBias(logitBias: JsonField) = apply { body.logitBias(logitBias) }
+ fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
+ }
- fun logprobs(logprobs: Boolean?) = apply { body.logprobs(logprobs) }
+ fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
+ apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
+ }
- /**
- * Alias for [Builder.logprobs].
- *
- * This unboxed primitive overload exists for backwards compatibility.
- */
- fun logprobs(logprobs: Boolean) = logprobs(logprobs as Boolean?)
+ fun replaceAdditionalQueryParams(key: String, value: String) = apply {
+ additionalQueryParams.replace(key, value)
+ }
- /** Alias for calling [Builder.logprobs] with `logprobs.orElse(null)`. */
- fun logprobs(logprobs: Optional) = logprobs(logprobs.getOrNull())
+ fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
+ additionalQueryParams.replace(key, values)
+ }
- /**
- * Sets [Builder.logprobs] to an arbitrary JSON value.
- *
- * You should usually call [Builder.logprobs] with a well-typed [Boolean] value instead.
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun logprobs(logprobs: JsonField) = apply { body.logprobs(logprobs) }
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
+ }
- fun maxTokens(maxTokens: Long?) = apply { body.maxTokens(maxTokens) }
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
+ apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
+ }
- /**
- * Alias for [Builder.maxTokens].
- *
- * This unboxed primitive overload exists for backwards compatibility.
- */
- fun maxTokens(maxTokens: Long) = maxTokens(maxTokens as Long?)
+ fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
- /** Alias for calling [Builder.maxTokens] with `maxTokens.orElse(null)`. */
- fun maxTokens(maxTokens: Optional) = maxTokens(maxTokens.getOrNull())
+ fun removeAllAdditionalQueryParams(keys: Set) = apply {
+ additionalQueryParams.removeAll(keys)
+ }
- /**
- * Sets [Builder.maxTokens] to an arbitrary JSON value.
- *
- * You should usually call [Builder.maxTokens] with a well-typed [Long] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun maxTokens(maxTokens: JsonField) = apply { body.maxTokens(maxTokens) }
+ fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
+ this.additionalBodyProperties.clear()
+ putAllAdditionalBodyProperties(additionalBodyProperties)
+ }
- fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) }
+ fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
+ additionalBodyProperties.put(key, value)
+ }
- /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */
- fun metadata(metadata: Optional) = metadata(metadata.getOrNull())
+ fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) =
+ apply {
+ this.additionalBodyProperties.putAll(additionalBodyProperties)
+ }
- /**
- * Sets [Builder.metadata] to an arbitrary JSON value.
- *
- * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead.
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun metadata(metadata: JsonField) = apply { body.metadata(metadata) }
+ fun removeAdditionalBodyProperty(key: String) = apply {
+ additionalBodyProperties.remove(key)
+ }
- fun n(n: Long?) = apply { body.n(n) }
+ fun removeAllAdditionalBodyProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalBodyProperty)
+ }
/**
- * Alias for [Builder.n].
+ * Returns an immutable instance of [CompletionCreateParams].
*
- * This unboxed primitive overload exists for backwards compatibility.
+ * Further updates to this [Builder] will not mutate the returned instance.
*/
- fun n(n: Long) = n(n as Long?)
-
- /** Alias for calling [Builder.n] with `n.orElse(null)`. */
- fun n(n: Optional) = n(n.getOrNull())
+ fun build(): CompletionCreateParams =
+ CompletionCreateParams(
+ model,
+ additionalHeaders.build(),
+ additionalQueryParams.build(),
+ additionalBodyProperties.toImmutable(),
+ )
+ }
- /**
- * Sets [Builder.n] to an arbitrary JSON value.
- *
- * You should usually call [Builder.n] with a well-typed [Long] value instead. This method
- * is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun n(n: JsonField) = apply { body.n(n) }
+ fun _body(): Optional