diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 0765f04d7..55c74a194 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -24,6 +24,37 @@ jobs: - name: Set up Gradle uses: gradle/gradle-build-action@v2 + - name: Compile the openai-java-core project + run: | + ./gradlew :openai-java-core:compileJava :openai-java-core:compileTestJava -x test + + - name: Run the Prism server + run: | + ./scripts/mock --daemon + + - name: Setup GraalVM + uses: graalvm/setup-graalvm@v1 + with: + java-version: 21 + distribution: 'graalvm-community' + cache: gradle + + - name: Run tests on the openai-java-core project with the GraalVM native-image agent + run: | + ./gradlew :openai-java-core:test -x compileJava -x compileTestJava -x compileKotlin -x compileTestKotlin -PgraalvmAgent + + - name: Check generated GraalVM file + run: | + echo "Checking for GraalVM agent metadata files..." + DIRECTORY=openai-java-core/src/main/resources/META-INF/native-image + if [ -d "$DIRECTORY" ] && [ "$(ls -A $DIRECTORY)" ]; then + echo "Files found in $DIRECTORY:" + ls -l $DIRECTORY + else + echo "No files found in $DIRECTORY" + exit 1 + fi + - name: Publish to Sonatype run: |- export -- GPG_SIGNING_KEY_ID diff --git a/.release-please-manifest.json b/.release-please-manifest.json index c1a7e63f6..ca3496a3e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.17.0" + ".": "2.18.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 100cfb7c7..ce73e8087 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 88 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-670ea0d2cc44f52a87dd3cadea45632953283e0636ba30788fdbdb22a232ccac.yml -openapi_spec_hash: d8b7d38911fead545adf3e4297956410 -config_hash: b2a4028fdbb27a08de89831ed310e244 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-b2a451656ca64d30d174391ebfd94806b4de3ab76dc55b92843cfb7f1a54ecb6.yml +openapi_spec_hash: 27d9691b400f28c17ef063a1374048b0 +config_hash: e822d0c9082c8b312264403949243179 diff --git a/CHANGELOG.md b/CHANGELOG.md index 26c1f7504..ade6649a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 2.18.0 (2025-07-22) + +Full Changelog: [v2.17.0...v2.18.0](https://github.com/openai/openai-java/compare/v2.17.0...v2.18.0) + +### Features + +* **client:** add `{QueryParams,Headers}#put(String, JsonValue)` methods ([1973f9a](https://github.com/openai/openai-java/commit/1973f9a7049505a27a7ec908549254f192d74be0)) +* **client:** allow configuring env via system properties ([5f8deb3](https://github.com/openai/openai-java/commit/5f8deb34ebe2982dee1aa6fd1bb1a08122a80a8d)) + + +### Chores + +* **api:** event shapes more accurate ([b7ba592](https://github.com/openai/openai-java/commit/b7ba592a4b0ebdcf53719017afb064227136d59d)) + ## 2.17.0 (2025-07-21) Full Changelog: [v2.16.0...v2.17.0](https://github.com/openai/openai-java/compare/v2.16.0...v2.17.0) diff --git a/README.md b/README.md index 3a908e5e6..dafcd8268 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/2.17.0) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/2.17.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/2.17.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/2.18.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/2.18.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/2.18.0) @@ -11,7 +11,7 @@ The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https:// -The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/2.17.0). +The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/2.18.0). @@ -19,10 +19,12 @@ The REST API documentation can be found on [platform.openai.com](https://platfor +[_Try `openai-java-spring-boot-starter` if you're using Spring Boot!_](#spring-boot) + ### Gradle ```kotlin -implementation("com.openai:openai-java:2.17.0") +implementation("com.openai:openai-java:2.18.0") ``` ### Maven @@ -31,7 +33,7 @@ implementation("com.openai:openai-java:2.17.0") com.openai openai-java - 2.17.0 + 2.18.0 ``` @@ -73,7 +75,8 @@ import com.openai.models.ChatModel; import com.openai.models.chat.completions.ChatCompletion; import com.openai.models.chat.completions.ChatCompletionCreateParams; -// Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables +// Configures using the `openai.apiKey`, `openai.orgId`, `openai.projectId`, `openai.webhookSecret` and `openai.baseUrl` system properties +// Or configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables OpenAIClient client = OpenAIOkHttpClient.fromEnv(); ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() @@ -85,13 +88,14 @@ ChatCompletion chatCompletion = client.chat().completions().create(params); ## Client configuration -Configure the client using environment variables: +Configure the client using system properties or environment variables: ```java import com.openai.client.OpenAIClient; import com.openai.client.okhttp.OpenAIOkHttpClient; -// Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables +// Configures using the `openai.apiKey`, `openai.orgId`, `openai.projectId`, `openai.webhookSecret` and `openai.baseUrl` system properties +// Or configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables OpenAIClient client = OpenAIOkHttpClient.fromEnv(); ``` @@ -113,7 +117,8 @@ import com.openai.client.OpenAIClient; import com.openai.client.okhttp.OpenAIOkHttpClient; OpenAIClient client = OpenAIOkHttpClient.builder() - // Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables + // Configures using the `openai.apiKey`, `openai.orgId`, `openai.projectId`, `openai.webhookSecret` and `openai.baseUrl` system properties + Or configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables .fromEnv() .apiKey("My API Key") .build(); @@ -121,13 +126,15 @@ OpenAIClient client = OpenAIOkHttpClient.builder() See this table for the available options: -| Setter | Environment variable | Required | Default value | -| --------------- | ----------------------- | -------- | ----------------------------- | -| `apiKey` | `OPENAI_API_KEY` | true | - | -| `organization` | `OPENAI_ORG_ID` | false | - | -| `project` | `OPENAI_PROJECT_ID` | false | - | -| `webhookSecret` | `OPENAI_WEBHOOK_SECRET` | false | - | -| `baseUrl` | `OPENAI_BASE_URL` | true | `"https://api.openai.com/v1"` | +| Setter | System property | Environment variable | Required | Default value | +| --------------- | ---------------------- | ----------------------- | -------- | ----------------------------- | +| `apiKey` | `openai.apiKey` | `OPENAI_API_KEY` | true | - | +| `organization` | `openai.orgId` | `OPENAI_ORG_ID` | false | - | +| `project` | `openai.projectId` | `OPENAI_PROJECT_ID` | false | - | +| `webhookSecret` | `openai.webhookSecret` | `OPENAI_WEBHOOK_SECRET` | false | - | +| `baseUrl` | `openai.baseUrl` | `OPENAI_BASE_URL` | true | `"https://api.openai.com/v1"` | + +System properties take precedence over environment variables. > [!TIP] > Don't create more than one client in the same application. Each client has a connection pool and @@ -174,7 +181,8 @@ import com.openai.models.chat.completions.ChatCompletion; import com.openai.models.chat.completions.ChatCompletionCreateParams; import java.util.concurrent.CompletableFuture; -// Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables +// Configures using the `openai.apiKey`, `openai.orgId`, `openai.projectId`, `openai.webhookSecret` and `openai.baseUrl` system properties +// Or configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables OpenAIClient client = OpenAIOkHttpClient.fromEnv(); ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() @@ -194,7 +202,8 @@ import com.openai.models.chat.completions.ChatCompletion; import com.openai.models.chat.completions.ChatCompletionCreateParams; import java.util.concurrent.CompletableFuture; -// Configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables +// Configures using the `openai.apiKey`, `openai.orgId`, `openai.projectId`, `openai.webhookSecret` and `openai.baseUrl` system properties +// Or configures using the `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`, `OPENAI_WEBHOOK_SECRET` and `OPENAI_BASE_URL` environment variables OpenAIClientAsync client = OpenAIOkHttpClientAsync.fromEnv(); ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() @@ -1295,6 +1304,85 @@ Or to `debug` for more verbose logging: $ export OPENAI_LOG=debug ``` +## GraalVM + +Although the SDK uses reflection, it is still usable in [GraalVM](https://www.graalvm.org) because `openai-java-core` is published with [reachability metadata](https://www.graalvm.org/latest/reference-manual/native-image/metadata/). + +GraalVM should automatically detect and use the published metadata, but [manual configuration](https://www.graalvm.org/jdk24/reference-manual/native-image/overview/BuildConfiguration/) is also available. + +## Spring Boot + +If you're using Spring Boot, then you can use the SDK's [Spring Boot starter](https://docs.spring.io/spring-boot/docs/2.7.18/reference/htmlsingle/#using.build-systems.starters) to simplify configuration and get set up quickly. + +### Installation + + + +#### Gradle + +```kotlin +implementation("com.openai:openai-java-spring-boot-starter:2.18.0") +``` + +#### Maven + +```xml + + com.openai + openai-java-spring-boot-starter + 2.18.0 + +``` + + + +### Configuration + +The [client's environment variable options](#client-configuration) can be configured in [`application.properties` or `application.yml`](https://docs.spring.io/spring-boot/how-to/properties-and-configuration.html). + +#### `application.properties` + +```properties +openai.base-url=https://api.openai.com/v1 +openai.api-key=My API Key +openai.org-id=My Organization +openai.project-id=My Project +openai.webhook-secret=My Webhook Secret +``` + +#### `application.yml` + +```yaml +openai: + base-url: https://api.openai.com/v1 + api-key: My API Key + org-id: My Organization + project-id: My Project + webhook-secret: My Webhook Secret +``` + +#### Other configuration + +Configure any other client option by providing one or more instances of [`OpenAIClientCustomizer`](openai-java-core/src/main/kotlin/com/openai/springboot/OpenAIClientCustomizer.kt). For example, here's how you'd set [`maxRetries`](#retries): + +```java +import com.openai.springboot.OpenAIClientCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OpenAIConfig { + @Bean + public OpenAIClientCustomizer customizer() { + return builder -> builder.maxRetries(3); + } +} +``` + +### Usage + +[Inject](https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-collaborators.html) [`OpenAIClient`](openai-java-core/src/main/kotlin/com/openai/client/OpenAIClient.kt) anywhere and start using it! + ## Jackson The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. diff --git a/build.gradle.kts b/build.gradle.kts index b08877411..28be3335a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "2.17.0" // x-release-please-version + version = "2.18.0" // x-release-please-version } subprojects { diff --git a/openai-java-core/src/main/kotlin/com/openai/core/http/Headers.kt b/openai-java-core/src/main/kotlin/com/openai/core/http/Headers.kt index ba5b242fb..2f217023b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/http/Headers.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/http/Headers.kt @@ -1,5 +1,15 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openai.core.http +import com.openai.core.JsonArray +import com.openai.core.JsonBoolean +import com.openai.core.JsonMissing +import com.openai.core.JsonNull +import com.openai.core.JsonNumber +import com.openai.core.JsonObject +import com.openai.core.JsonString +import com.openai.core.JsonValue import com.openai.core.toImmutable import java.util.TreeMap @@ -28,6 +38,19 @@ private constructor( TreeMap(String.CASE_INSENSITIVE_ORDER) private var size: Int = 0 + fun put(name: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(name, value.value.toString()) + is JsonNumber -> put(name, value.value.toString()) + is JsonString -> put(name, value.value) + is JsonArray -> value.values.forEach { put(name, it) } + is JsonObject -> + value.values.forEach { (nestedName, value) -> put("$name.$nestedName", value) } + } + } + fun put(name: String, value: String) = apply { map.getOrPut(name) { mutableListOf() }.add(value) size++ @@ -41,15 +64,6 @@ private constructor( headers.names().forEach { put(it, headers.values(it)) } } - fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } - - fun removeAll(names: Set) = apply { names.forEach(::remove) } - - fun clear() = apply { - map.clear() - size = 0 - } - fun replace(name: String, value: String) = apply { remove(name) put(name, value) @@ -68,6 +82,15 @@ private constructor( headers.names().forEach { replace(it, headers.values(it)) } } + fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } + + fun removeAll(names: Set) = apply { names.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + fun build() = Headers( map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) -> diff --git a/openai-java-core/src/main/kotlin/com/openai/core/http/QueryParams.kt b/openai-java-core/src/main/kotlin/com/openai/core/http/QueryParams.kt index 10a2dabba..5f671fb3e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/http/QueryParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/http/QueryParams.kt @@ -2,6 +2,14 @@ package com.openai.core.http +import com.openai.core.JsonArray +import com.openai.core.JsonBoolean +import com.openai.core.JsonMissing +import com.openai.core.JsonNull +import com.openai.core.JsonNumber +import com.openai.core.JsonObject +import com.openai.core.JsonString +import com.openai.core.JsonValue import com.openai.core.toImmutable class QueryParams @@ -28,6 +36,19 @@ private constructor( private val map: MutableMap> = mutableMapOf() private var size: Int = 0 + fun put(key: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(key, value.value.toString()) + is JsonNumber -> put(key, value.value.toString()) + is JsonString -> put(key, value.value) + is JsonArray -> value.values.forEach { put("$key[]", it) } + is JsonObject -> + value.values.forEach { (nestedKey, value) -> put("$key[$nestedKey]", value) } + } + } + fun put(key: String, value: String) = apply { map.getOrPut(key) { mutableListOf() }.add(value) size++ diff --git a/openai-java-core/src/main/kotlin/com/openai/helpers/ResponseAccumulator.kt b/openai-java-core/src/main/kotlin/com/openai/helpers/ResponseAccumulator.kt index 485442bad..3f17c2301 100644 --- a/openai-java-core/src/main/kotlin/com/openai/helpers/ResponseAccumulator.kt +++ b/openai-java-core/src/main/kotlin/com/openai/helpers/ResponseAccumulator.kt @@ -40,8 +40,6 @@ import com.openai.models.responses.ResponseOutputItemAddedEvent import com.openai.models.responses.ResponseOutputItemDoneEvent import com.openai.models.responses.ResponseOutputTextAnnotationAddedEvent import com.openai.models.responses.ResponseQueuedEvent -import com.openai.models.responses.ResponseReasoningDeltaEvent -import com.openai.models.responses.ResponseReasoningDoneEvent import com.openai.models.responses.ResponseReasoningSummaryDeltaEvent import com.openai.models.responses.ResponseReasoningSummaryDoneEvent import com.openai.models.responses.ResponseReasoningSummaryPartAddedEvent @@ -306,10 +304,6 @@ class ResponseAccumulator private constructor() { outputTextAnnotationAdded: ResponseOutputTextAnnotationAddedEvent ) {} - override fun visitReasoningDelta(reasoningDelta: ResponseReasoningDeltaEvent) {} - - override fun visitReasoningDone(reasoningDone: ResponseReasoningDoneEvent) {} - override fun visitReasoningSummaryDelta( reasoningSummaryDelta: ResponseReasoningSummaryDeltaEvent ) {} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/FunctionDefinition.kt b/openai-java-core/src/main/kotlin/com/openai/models/FunctionDefinition.kt index 164ae03fc..8fe90d41e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/FunctionDefinition.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/FunctionDefinition.kt @@ -73,7 +73,7 @@ private constructor( * Whether to enable strict schema adherence when generating the function call. If set to true, * the model will follow the exact schema defined in the `parameters` field. Only a subset of * JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the - * [function calling guide](docs/guides/function-calling). + * [function calling guide](https://platform.openai.com/docs/guides/function-calling). * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -207,7 +207,8 @@ private constructor( * Whether to enable strict schema adherence when generating the function call. If set to * true, the model will follow the exact schema defined in the `parameters` field. Only a * subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured - * Outputs in the [function calling guide](docs/guides/function-calling). + * Outputs in the + * [function calling guide](https://platform.openai.com/docs/guides/function-calling). */ fun strict(strict: Boolean?) = strict(JsonField.ofNullable(strict)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt index ec774298f..2b85f8cd8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt @@ -937,12 +937,6 @@ private constructor( @JvmField val ECHO = of("echo") - @JvmField val FABLE = of("fable") - - @JvmField val ONYX = of("onyx") - - @JvmField val NOVA = of("nova") - @JvmField val SAGE = of("sage") @JvmField val SHIMMER = of("shimmer") @@ -959,9 +953,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -982,9 +973,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -1006,9 +994,6 @@ private constructor( BALLAD -> Value.BALLAD CORAL -> Value.CORAL ECHO -> Value.ECHO - FABLE -> Value.FABLE - ONYX -> Value.ONYX - NOVA -> Value.NOVA SAGE -> Value.SAGE SHIMMER -> Value.SHIMMER VERSE -> Value.VERSE @@ -1031,9 +1016,6 @@ private constructor( BALLAD -> Known.BALLAD CORAL -> Known.CORAL ECHO -> Known.ECHO - FABLE -> Known.FABLE - ONYX -> Known.ONYX - NOVA -> Known.NOVA SAGE -> Known.SAGE SHIMMER -> Known.SHIMMER VERSE -> Known.VERSE diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/RealtimeResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/RealtimeResponse.kt index 303bfc17e..3e3f08b68 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/RealtimeResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/RealtimeResponse.kt @@ -214,7 +214,7 @@ private constructor( /** * The voice the model used to respond. Current voice options are `alloy`, `ash`, `ballad`, - * `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `coral`, `echo`, `sage`, `shimmer`, and `verse`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -600,7 +600,7 @@ private constructor( /** * The voice the model used to respond. Current voice options are `alloy`, `ash`, `ballad`, - * `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ fun voice(voice: Voice) = voice(JsonField.of(voice)) @@ -1535,7 +1535,7 @@ private constructor( /** * The voice the model used to respond. Current voice options are `alloy`, `ash`, `ballad`, - * `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ class Voice @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1561,12 +1561,6 @@ private constructor( @JvmField val ECHO = of("echo") - @JvmField val FABLE = of("fable") - - @JvmField val ONYX = of("onyx") - - @JvmField val NOVA = of("nova") - @JvmField val SAGE = of("sage") @JvmField val SHIMMER = of("shimmer") @@ -1583,9 +1577,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -1606,9 +1597,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -1630,9 +1618,6 @@ private constructor( BALLAD -> Value.BALLAD CORAL -> Value.CORAL ECHO -> Value.ECHO - FABLE -> Value.FABLE - ONYX -> Value.ONYX - NOVA -> Value.NOVA SAGE -> Value.SAGE SHIMMER -> Value.SHIMMER VERSE -> Value.VERSE @@ -1655,9 +1640,6 @@ private constructor( BALLAD -> Known.BALLAD CORAL -> Known.CORAL ECHO -> Known.ECHO - FABLE -> Known.FABLE - ONYX -> Known.ONYX - NOVA -> Known.NOVA SAGE -> Known.SAGE SHIMMER -> Known.SHIMMER VERSE -> Known.VERSE diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/ResponseCreateEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/ResponseCreateEvent.kt index e961ccbec..008f24cbd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/ResponseCreateEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/ResponseCreateEvent.kt @@ -407,7 +407,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -802,8 +802,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once * the model has responded with audio at least once. Current voice options are `alloy`, - * `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and - * `verse`. + * `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ fun voice(voice: Voice) = voice(JsonField.of(voice)) @@ -1983,7 +1982,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ class Voice @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2009,12 +2008,6 @@ private constructor( @JvmField val ECHO = of("echo") - @JvmField val FABLE = of("fable") - - @JvmField val ONYX = of("onyx") - - @JvmField val NOVA = of("nova") - @JvmField val SAGE = of("sage") @JvmField val SHIMMER = of("shimmer") @@ -2031,9 +2024,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -2054,9 +2044,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -2080,9 +2067,6 @@ private constructor( BALLAD -> Value.BALLAD CORAL -> Value.CORAL ECHO -> Value.ECHO - FABLE -> Value.FABLE - ONYX -> Value.ONYX - NOVA -> Value.NOVA SAGE -> Value.SAGE SHIMMER -> Value.SHIMMER VERSE -> Value.VERSE @@ -2105,9 +2089,6 @@ private constructor( BALLAD -> Known.BALLAD CORAL -> Known.CORAL ECHO -> Known.ECHO - FABLE -> Known.FABLE - ONYX -> Known.ONYX - NOVA -> Known.NOVA SAGE -> Known.SAGE SHIMMER -> Known.SHIMMER VERSE -> Known.VERSE diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/SessionUpdateEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/SessionUpdateEvent.kt index 57e390dfd..efcf0af5f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/SessionUpdateEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/SessionUpdateEvent.kt @@ -501,7 +501,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1034,8 +1034,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once * the model has responded with audio at least once. Current voice options are `alloy`, - * `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and - * `verse`. + * `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ fun voice(voice: Voice) = voice(JsonField.of(voice)) @@ -4491,7 +4490,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ class Voice @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4517,12 +4516,6 @@ private constructor( @JvmField val ECHO = of("echo") - @JvmField val FABLE = of("fable") - - @JvmField val ONYX = of("onyx") - - @JvmField val NOVA = of("nova") - @JvmField val SAGE = of("sage") @JvmField val SHIMMER = of("shimmer") @@ -4539,9 +4532,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -4562,9 +4552,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -4588,9 +4575,6 @@ private constructor( BALLAD -> Value.BALLAD CORAL -> Value.CORAL ECHO -> Value.ECHO - FABLE -> Value.FABLE - ONYX -> Value.ONYX - NOVA -> Value.NOVA SAGE -> Value.SAGE SHIMMER -> Value.SHIMMER VERSE -> Value.VERSE @@ -4613,9 +4597,6 @@ private constructor( BALLAD -> Known.BALLAD CORAL -> Known.CORAL ECHO -> Known.ECHO - FABLE -> Known.FABLE - ONYX -> Known.ONYX - NOVA -> Known.NOVA SAGE -> Known.SAGE SHIMMER -> Known.SHIMMER VERSE -> Known.VERSE diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/Session.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/Session.kt index 95577a6f5..224c91142 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/Session.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/Session.kt @@ -275,7 +275,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -781,7 +781,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ fun voice(voice: Voice) = voice(JsonField.of(voice)) @@ -3666,7 +3666,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ class Voice @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3692,12 +3692,6 @@ private constructor( @JvmField val ECHO = of("echo") - @JvmField val FABLE = of("fable") - - @JvmField val ONYX = of("onyx") - - @JvmField val NOVA = of("nova") - @JvmField val SAGE = of("sage") @JvmField val SHIMMER = of("shimmer") @@ -3714,9 +3708,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -3737,9 +3728,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -3761,9 +3749,6 @@ private constructor( BALLAD -> Value.BALLAD CORAL -> Value.CORAL ECHO -> Value.ECHO - FABLE -> Value.FABLE - ONYX -> Value.ONYX - NOVA -> Value.NOVA SAGE -> Value.SAGE SHIMMER -> Value.SHIMMER VERSE -> Value.VERSE @@ -3786,9 +3771,6 @@ private constructor( BALLAD -> Known.BALLAD CORAL -> Known.CORAL ECHO -> Known.ECHO - FABLE -> Known.FABLE - ONYX -> Known.ONYX - NOVA -> Known.NOVA SAGE -> Known.SAGE SHIMMER -> Known.SHIMMER VERSE -> Known.VERSE diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/SessionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/SessionCreateParams.kt index 34dde63c8..9c3d8c4bb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/SessionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/SessionCreateParams.kt @@ -211,7 +211,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -688,7 +688,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ fun voice(voice: Voice) = apply { body.voice(voice) } @@ -1093,7 +1093,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1626,8 +1626,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once * the model has responded with audio at least once. Current voice options are `alloy`, - * `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and - * `verse`. + * `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ fun voice(voice: Voice) = voice(JsonField.of(voice)) @@ -5021,7 +5020,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ class Voice @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5047,12 +5046,6 @@ private constructor( @JvmField val ECHO = of("echo") - @JvmField val FABLE = of("fable") - - @JvmField val ONYX = of("onyx") - - @JvmField val NOVA = of("nova") - @JvmField val SAGE = of("sage") @JvmField val SHIMMER = of("shimmer") @@ -5069,9 +5062,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -5092,9 +5082,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -5116,9 +5103,6 @@ private constructor( BALLAD -> Value.BALLAD CORAL -> Value.CORAL ECHO -> Value.ECHO - FABLE -> Value.FABLE - ONYX -> Value.ONYX - NOVA -> Value.NOVA SAGE -> Value.SAGE SHIMMER -> Value.SHIMMER VERSE -> Value.VERSE @@ -5141,9 +5125,6 @@ private constructor( BALLAD -> Known.BALLAD CORAL -> Known.CORAL ECHO -> Known.ECHO - FABLE -> Known.FABLE - ONYX -> Known.ONYX - NOVA -> Known.NOVA SAGE -> Known.SAGE SHIMMER -> Known.SHIMMER VERSE -> Known.VERSE diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/SessionCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/SessionCreateResponse.kt index 32daeeb62..c745c4f5b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/SessionCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/sessions/SessionCreateResponse.kt @@ -237,7 +237,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo` `sage`, `shimmer` and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -684,7 +684,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo` `sage`, `shimmer` and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ fun voice(voice: Voice) = voice(JsonField.of(voice)) @@ -2532,7 +2532,7 @@ private constructor( /** * The voice the model uses to respond. Voice cannot be changed during the session once the * model has responded with audio at least once. Current voice options are `alloy`, `ash`, - * `ballad`, `coral`, `echo` `sage`, `shimmer` and `verse`. + * `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. */ class Voice @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2558,12 +2558,6 @@ private constructor( @JvmField val ECHO = of("echo") - @JvmField val FABLE = of("fable") - - @JvmField val ONYX = of("onyx") - - @JvmField val NOVA = of("nova") - @JvmField val SAGE = of("sage") @JvmField val SHIMMER = of("shimmer") @@ -2580,9 +2574,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -2603,9 +2594,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -2627,9 +2615,6 @@ private constructor( BALLAD -> Value.BALLAD CORAL -> Value.CORAL ECHO -> Value.ECHO - FABLE -> Value.FABLE - ONYX -> Value.ONYX - NOVA -> Value.NOVA SAGE -> Value.SAGE SHIMMER -> Value.SHIMMER VERSE -> Value.VERSE @@ -2652,9 +2637,6 @@ private constructor( BALLAD -> Known.BALLAD CORAL -> Known.CORAL ECHO -> Known.ECHO - FABLE -> Known.FABLE - ONYX -> Known.ONYX - NOVA -> Known.NOVA SAGE -> Known.SAGE SHIMMER -> Known.SHIMMER VERSE -> Known.VERSE diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletion.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletion.kt index 48eaa20a2..f84ef9541 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletion.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletion.kt @@ -112,7 +112,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. @@ -332,7 +332,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured * in the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or * 'priority', then the request will be processed with the corresponding service tier. @@ -1190,7 +1190,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudioParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudioParam.kt index e9208547c..a26a908a3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudioParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudioParam.kt @@ -390,12 +390,6 @@ private constructor( @JvmField val ECHO = of("echo") - @JvmField val FABLE = of("fable") - - @JvmField val ONYX = of("onyx") - - @JvmField val NOVA = of("nova") - @JvmField val SAGE = of("sage") @JvmField val SHIMMER = of("shimmer") @@ -412,9 +406,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -435,9 +426,6 @@ private constructor( BALLAD, CORAL, ECHO, - FABLE, - ONYX, - NOVA, SAGE, SHIMMER, VERSE, @@ -459,9 +447,6 @@ private constructor( BALLAD -> Value.BALLAD CORAL -> Value.CORAL ECHO -> Value.ECHO - FABLE -> Value.FABLE - ONYX -> Value.ONYX - NOVA -> Value.NOVA SAGE -> Value.SAGE SHIMMER -> Value.SHIMMER VERSE -> Value.VERSE @@ -484,9 +469,6 @@ private constructor( BALLAD -> Known.BALLAD CORAL -> Known.CORAL ECHO -> Known.ECHO - FABLE -> Known.FABLE - ONYX -> Known.ONYX - NOVA -> Known.NOVA SAGE -> Known.SAGE SHIMMER -> Known.SHIMMER VERSE -> Known.VERSE diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionChunk.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionChunk.kt index bab694c9b..59de7b35c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionChunk.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionChunk.kt @@ -118,7 +118,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. @@ -349,7 +349,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured * in the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or * 'priority', then the request will be processed with the corresponding service tier. @@ -2485,7 +2485,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt index f248a6216..849e0f84d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt @@ -298,7 +298,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. @@ -1389,7 +1389,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured * in the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or * 'priority', then the request will be processed with the corresponding service tier. @@ -2207,7 +2207,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured * in the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or * 'priority', then the request will be processed with the corresponding service tier. @@ -3430,7 +3430,7 @@ private constructor( * - If set to 'auto', then the request will be processed with the service tier * configured in the Project settings. Unless otherwise configured, the Project will * use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing + * - If set to 'default', then the request will be processed with the standard pricing * and performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or * 'priority', then the request will be processed with the corresponding service tier. @@ -5122,7 +5122,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt index 18fe5c9d3..6f5d199b0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt @@ -146,6 +146,9 @@ private constructor( * return partial images. Value must be between 0 and 3. When set to 0, the response will be a * single image sent in one streaming event. * + * Note that the final image may be sent before the full number of partial images are generated + * if the full image is generated more quickly. + * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -591,6 +594,9 @@ private constructor( * The number of partial images to generate. This parameter is used for streaming responses * that return partial images. Value must be between 0 and 3. When set to 0, the response * will be a single image sent in one streaming event. + * + * Note that the final image may be sent before the full number of partial images are + * generated if the full image is generated more quickly. */ fun partialImages(partialImages: Long?) = apply { body.partialImages(partialImages) } @@ -967,6 +973,9 @@ private constructor( * that return partial images. Value must be between 0 and 3. When set to 0, the response * will be a single image sent in one streaming event. * + * Note that the final image may be sent before the full number of partial images are + * generated if the full image is generated more quickly. + * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -1462,6 +1471,9 @@ private constructor( * The number of partial images to generate. This parameter is used for streaming * responses that return partial images. Value must be between 0 and 3. When set to 0, * the response will be a single image sent in one streaming event. + * + * Note that the final image may be sent before the full number of partial images are + * generated if the full image is generated more quickly. */ fun partialImages(partialImages: Long?) = partialImages(MultipartField.of(partialImages)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt index 5a6f7febd..aac8c9783 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt @@ -104,6 +104,9 @@ private constructor( * return partial images. Value must be between 0 and 3. When set to 0, the response will be a * single image sent in one streaming event. * + * Note that the final image may be sent before the full number of partial images are generated + * if the full image is generated more quickly. + * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -466,6 +469,9 @@ private constructor( * The number of partial images to generate. This parameter is used for streaming responses * that return partial images. Value must be between 0 and 3. When set to 0, the response * will be a single image sent in one streaming event. + * + * Note that the final image may be sent before the full number of partial images are + * generated if the full image is generated more quickly. */ fun partialImages(partialImages: Long?) = apply { body.partialImages(partialImages) } @@ -867,6 +873,9 @@ private constructor( * that return partial images. Value must be between 0 and 3. When set to 0, the response * will be a single image sent in one streaming event. * + * Note that the final image may be sent before the full number of partial images are + * generated if the full image is generated more quickly. + * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -1268,6 +1277,9 @@ private constructor( * The number of partial images to generate. This parameter is used for streaming * responses that return partial images. Value must be between 0 and 3. When set to 0, * the response will be a single image sent in one streaming event. + * + * Note that the final image may be sent before the full number of partial images are + * generated if the full image is generated more quickly. */ fun partialImages(partialImages: Long?) = partialImages(JsonField.ofNullable(partialImages)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImagesResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImagesResponse.kt index 4b6e3aa5e..a852c18bf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImagesResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImagesResponse.kt @@ -959,7 +959,7 @@ private constructor( inputTokensDetails.getRequired("input_tokens_details") /** - * The number of image tokens in the output image. + * The number of output tokens generated by the model. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -1085,7 +1085,7 @@ private constructor( this.inputTokensDetails = inputTokensDetails } - /** The number of image tokens in the output image. */ + /** The number of output tokens generated by the model. */ fun outputTokens(outputTokens: Long) = outputTokens(JsonField.of(outputTokens)) /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt index dcb924110..397bcd41d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt @@ -375,7 +375,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. @@ -1352,7 +1352,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured * in the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or * 'priority', then the request will be processed with the corresponding service tier. @@ -2520,7 +2520,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCodeInterpreterToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCodeInterpreterToolCall.kt index 77c5a4a2a..9bcb7a8e9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCodeInterpreterToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCodeInterpreterToolCall.kt @@ -90,7 +90,8 @@ private constructor( fun outputs(): Optional> = outputs.getOptional("outputs") /** - * The status of the code interpreter tool call. + * The status of the code interpreter tool call. Valid values are `in_progress`, `completed`, + * `incomplete`, `interpreting`, and `failed`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -296,7 +297,10 @@ private constructor( */ fun addImageOutput(url: String) = addOutput(Output.Image.builder().url(url).build()) - /** The status of the code interpreter tool call. */ + /** + * The status of the code interpreter tool call. Valid values are `in_progress`, + * `completed`, `incomplete`, `interpreting`, and `failed`. + */ fun status(status: Status) = status(JsonField.of(status)) /** @@ -981,7 +985,10 @@ private constructor( } } - /** The status of the code interpreter tool call. */ + /** + * The status of the code interpreter tool call. Valid values are `in_progress`, `completed`, + * `incomplete`, `interpreting`, and `failed`. + */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt index 292e0766a..1410de6f1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt @@ -197,7 +197,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. @@ -827,7 +827,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured * in the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or * 'priority', then the request will be processed with the corresponding service tier. @@ -1560,7 +1560,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured * in the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or * 'priority', then the request will be processed with the corresponding service tier. @@ -2262,7 +2262,7 @@ private constructor( * - If set to 'auto', then the request will be processed with the service tier * configured in the Project settings. Unless otherwise configured, the Project will * use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing + * - If set to 'default', then the request will be processed with the standard pricing * and performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or * 'priority', then the request will be processed with the corresponding service tier. @@ -3037,7 +3037,7 @@ private constructor( * Specifies the processing type used for serving the request. * - If set to 'auto', then the request will be processed with the service tier configured in * the Project settings. Unless otherwise configured, the Project will use 'default'. - * - If set to 'default', then the requset will be processed with the standard pricing and + * - If set to 'default', then the request will be processed with the standard pricing and * performance for the selected model. * - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or 'priority', * then the request will be processed with the corresponding service tier. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDeltaEvent.kt index c26fb3375..b730a26c4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDeltaEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDeltaEvent.kt @@ -18,7 +18,7 @@ import java.util.Objects /** Emitted when there is a delta (partial update) to the arguments of an MCP tool call. */ class ResponseMcpCallArgumentsDeltaEvent private constructor( - private val delta: JsonValue, + private val delta: JsonField, private val itemId: JsonField, private val outputIndex: JsonField, private val sequenceNumber: JsonField, @@ -28,7 +28,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("delta") @ExcludeMissing delta: JsonValue = JsonMissing.of(), + @JsonProperty("delta") @ExcludeMissing delta: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @JsonProperty("output_index") @ExcludeMissing @@ -39,8 +39,13 @@ private constructor( @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(delta, itemId, outputIndex, sequenceNumber, type, mutableMapOf()) - /** The partial update to the arguments for the MCP tool call. */ - @JsonProperty("delta") @ExcludeMissing fun _delta(): JsonValue = delta + /** + * A JSON string containing the partial update to the arguments for the MCP tool call. + * + * @throws OpenAIInvalidDataException 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 delta(): String = delta.getRequired("delta") /** * The unique identifier of the MCP tool call item being processed. @@ -79,6 +84,13 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns the raw JSON value of [delta]. + * + * Unlike [delta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delta") @ExcludeMissing fun _delta(): JsonField = delta + /** * Returns the raw JSON value of [itemId]. * @@ -134,7 +146,7 @@ private constructor( /** A builder for [ResponseMcpCallArgumentsDeltaEvent]. */ class Builder internal constructor() { - private var delta: JsonValue? = null + private var delta: JsonField? = null private var itemId: JsonField? = null private var outputIndex: JsonField? = null private var sequenceNumber: JsonField? = null @@ -153,8 +165,16 @@ private constructor( responseMcpCallArgumentsDeltaEvent.additionalProperties.toMutableMap() } - /** The partial update to the arguments for the MCP tool call. */ - fun delta(delta: JsonValue) = apply { this.delta = delta } + /** A JSON string containing the partial update to the arguments for the MCP tool call. */ + fun delta(delta: String) = delta(JsonField.of(delta)) + + /** + * Sets [Builder.delta] to an arbitrary JSON value. + * + * You should usually call [Builder.delta] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun delta(delta: JsonField) = apply { this.delta = delta } /** The unique identifier of the MCP tool call item being processed. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -259,6 +279,7 @@ private constructor( return@apply } + delta() itemId() outputIndex() sequenceNumber() @@ -285,7 +306,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (itemId.asKnown().isPresent) 1 else 0) + + (if (delta.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + (if (outputIndex.asKnown().isPresent) 1 else 0) + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.mcp_call_arguments.delta")) 1 else 0 } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDoneEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDoneEvent.kt index ffffe0e61..7b52808cb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDoneEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDoneEvent.kt @@ -18,7 +18,7 @@ import java.util.Objects /** Emitted when the arguments for an MCP tool call are finalized. */ class ResponseMcpCallArgumentsDoneEvent private constructor( - private val arguments: JsonValue, + private val arguments: JsonField, private val itemId: JsonField, private val outputIndex: JsonField, private val sequenceNumber: JsonField, @@ -28,7 +28,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("arguments") @ExcludeMissing arguments: JsonValue = JsonMissing.of(), + @JsonProperty("arguments") @ExcludeMissing arguments: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @JsonProperty("output_index") @ExcludeMissing @@ -39,8 +39,13 @@ private constructor( @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(arguments, itemId, outputIndex, sequenceNumber, type, mutableMapOf()) - /** The finalized arguments for the MCP tool call. */ - @JsonProperty("arguments") @ExcludeMissing fun _arguments(): JsonValue = arguments + /** + * A JSON string containing the finalized arguments for the MCP tool call. + * + * @throws OpenAIInvalidDataException 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 arguments(): String = arguments.getRequired("arguments") /** * The unique identifier of the MCP tool call item being processed. @@ -79,6 +84,13 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns the raw JSON value of [arguments]. + * + * Unlike [arguments], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("arguments") @ExcludeMissing fun _arguments(): JsonField = arguments + /** * Returns the raw JSON value of [itemId]. * @@ -134,7 +146,7 @@ private constructor( /** A builder for [ResponseMcpCallArgumentsDoneEvent]. */ class Builder internal constructor() { - private var arguments: JsonValue? = null + private var arguments: JsonField? = null private var itemId: JsonField? = null private var outputIndex: JsonField? = null private var sequenceNumber: JsonField? = null @@ -153,8 +165,17 @@ private constructor( responseMcpCallArgumentsDoneEvent.additionalProperties.toMutableMap() } - /** The finalized arguments for the MCP tool call. */ - fun arguments(arguments: JsonValue) = apply { this.arguments = arguments } + /** A JSON string containing the finalized arguments for the MCP tool call. */ + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + /** + * Sets [Builder.arguments] to an arbitrary JSON value. + * + * You should usually call [Builder.arguments] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun arguments(arguments: JsonField) = apply { this.arguments = arguments } /** The unique identifier of the MCP tool call item being processed. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -259,6 +280,7 @@ private constructor( return@apply } + arguments() itemId() outputIndex() sequenceNumber() @@ -285,7 +307,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (itemId.asKnown().isPresent) 1 else 0) + + (if (arguments.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + (if (outputIndex.asKnown().isPresent) 1 else 0) + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.mcp_call_arguments.done")) 1 else 0 } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallCompletedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallCompletedEvent.kt index 816dabedf..18ef82ad4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallCompletedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallCompletedEvent.kt @@ -18,6 +18,8 @@ import java.util.Objects /** Emitted when an MCP tool call has completed successfully. */ class ResponseMcpCallCompletedEvent private constructor( + private val itemId: JsonField, + private val outputIndex: JsonField, private val sequenceNumber: JsonField, private val type: JsonValue, private val additionalProperties: MutableMap, @@ -25,11 +27,31 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("output_index") + @ExcludeMissing + outputIndex: JsonField = JsonMissing.of(), @JsonProperty("sequence_number") @ExcludeMissing sequenceNumber: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(sequenceNumber, type, mutableMapOf()) + ) : this(itemId, outputIndex, sequenceNumber, type, mutableMapOf()) + + /** + * The ID of the MCP tool call item that completed. + * + * @throws OpenAIInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The index of the output item that completed. + * + * @throws OpenAIInvalidDataException 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 outputIndex(): Long = outputIndex.getRequired("output_index") /** * The sequence number of this event. @@ -52,6 +74,20 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [outputIndex]. + * + * Unlike [outputIndex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("output_index") @ExcludeMissing fun _outputIndex(): JsonField = outputIndex + /** * Returns the raw JSON value of [sequenceNumber]. * @@ -81,6 +117,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` */ @@ -90,17 +128,44 @@ private constructor( /** A builder for [ResponseMcpCallCompletedEvent]. */ class Builder internal constructor() { + private var itemId: JsonField? = null + private var outputIndex: JsonField? = null private var sequenceNumber: JsonField? = null private var type: JsonValue = JsonValue.from("response.mcp_call.completed") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(responseMcpCallCompletedEvent: ResponseMcpCallCompletedEvent) = apply { + itemId = responseMcpCallCompletedEvent.itemId + outputIndex = responseMcpCallCompletedEvent.outputIndex sequenceNumber = responseMcpCallCompletedEvent.sequenceNumber type = responseMcpCallCompletedEvent.type additionalProperties = responseMcpCallCompletedEvent.additionalProperties.toMutableMap() } + /** The ID of the MCP tool call item that completed. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** The index of the output item that completed. */ + fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex)) + + /** + * Sets [Builder.outputIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.outputIndex] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun outputIndex(outputIndex: JsonField) = apply { this.outputIndex = outputIndex } + /** The sequence number of this event. */ fun sequenceNumber(sequenceNumber: Long) = sequenceNumber(JsonField.of(sequenceNumber)) @@ -155,6 +220,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` * @@ -162,6 +229,8 @@ private constructor( */ fun build(): ResponseMcpCallCompletedEvent = ResponseMcpCallCompletedEvent( + checkRequired("itemId", itemId), + checkRequired("outputIndex", outputIndex), checkRequired("sequenceNumber", sequenceNumber), type, additionalProperties.toMutableMap(), @@ -175,6 +244,8 @@ private constructor( return@apply } + itemId() + outputIndex() sequenceNumber() _type().let { if (it != JsonValue.from("response.mcp_call.completed")) { @@ -199,7 +270,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (sequenceNumber.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (outputIndex.asKnown().isPresent) 1 else 0) + + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.mcp_call.completed")) 1 else 0 } override fun equals(other: Any?): Boolean { @@ -207,15 +280,15 @@ private constructor( return true } - return /* spotless:off */ other is ResponseMcpCallCompletedEvent && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ResponseMcpCallCompletedEvent && itemId == other.itemId && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(sequenceNumber, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(itemId, outputIndex, sequenceNumber, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ResponseMcpCallCompletedEvent{sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" + "ResponseMcpCallCompletedEvent{itemId=$itemId, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallFailedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallFailedEvent.kt index 391dd8d55..61cf99e03 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallFailedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpCallFailedEvent.kt @@ -18,6 +18,8 @@ import java.util.Objects /** Emitted when an MCP tool call has failed. */ class ResponseMcpCallFailedEvent private constructor( + private val itemId: JsonField, + private val outputIndex: JsonField, private val sequenceNumber: JsonField, private val type: JsonValue, private val additionalProperties: MutableMap, @@ -25,11 +27,31 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("output_index") + @ExcludeMissing + outputIndex: JsonField = JsonMissing.of(), @JsonProperty("sequence_number") @ExcludeMissing sequenceNumber: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(sequenceNumber, type, mutableMapOf()) + ) : this(itemId, outputIndex, sequenceNumber, type, mutableMapOf()) + + /** + * The ID of the MCP tool call item that failed. + * + * @throws OpenAIInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The index of the output item that failed. + * + * @throws OpenAIInvalidDataException 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 outputIndex(): Long = outputIndex.getRequired("output_index") /** * The sequence number of this event. @@ -52,6 +74,20 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [outputIndex]. + * + * Unlike [outputIndex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("output_index") @ExcludeMissing fun _outputIndex(): JsonField = outputIndex + /** * Returns the raw JSON value of [sequenceNumber]. * @@ -80,6 +116,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` */ @@ -89,17 +127,44 @@ private constructor( /** A builder for [ResponseMcpCallFailedEvent]. */ class Builder internal constructor() { + private var itemId: JsonField? = null + private var outputIndex: JsonField? = null private var sequenceNumber: JsonField? = null private var type: JsonValue = JsonValue.from("response.mcp_call.failed") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(responseMcpCallFailedEvent: ResponseMcpCallFailedEvent) = apply { + itemId = responseMcpCallFailedEvent.itemId + outputIndex = responseMcpCallFailedEvent.outputIndex sequenceNumber = responseMcpCallFailedEvent.sequenceNumber type = responseMcpCallFailedEvent.type additionalProperties = responseMcpCallFailedEvent.additionalProperties.toMutableMap() } + /** The ID of the MCP tool call item that failed. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** The index of the output item that failed. */ + fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex)) + + /** + * Sets [Builder.outputIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.outputIndex] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun outputIndex(outputIndex: JsonField) = apply { this.outputIndex = outputIndex } + /** The sequence number of this event. */ fun sequenceNumber(sequenceNumber: Long) = sequenceNumber(JsonField.of(sequenceNumber)) @@ -154,6 +219,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` * @@ -161,6 +228,8 @@ private constructor( */ fun build(): ResponseMcpCallFailedEvent = ResponseMcpCallFailedEvent( + checkRequired("itemId", itemId), + checkRequired("outputIndex", outputIndex), checkRequired("sequenceNumber", sequenceNumber), type, additionalProperties.toMutableMap(), @@ -174,6 +243,8 @@ private constructor( return@apply } + itemId() + outputIndex() sequenceNumber() _type().let { if (it != JsonValue.from("response.mcp_call.failed")) { @@ -198,7 +269,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (sequenceNumber.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (outputIndex.asKnown().isPresent) 1 else 0) + + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.mcp_call.failed")) 1 else 0 } override fun equals(other: Any?): Boolean { @@ -206,15 +279,15 @@ private constructor( return true } - return /* spotless:off */ other is ResponseMcpCallFailedEvent && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ResponseMcpCallFailedEvent && itemId == other.itemId && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(sequenceNumber, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(itemId, outputIndex, sequenceNumber, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ResponseMcpCallFailedEvent{sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" + "ResponseMcpCallFailedEvent{itemId=$itemId, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsCompletedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsCompletedEvent.kt index 5579d7352..3c3ded995 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsCompletedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsCompletedEvent.kt @@ -18,6 +18,8 @@ import java.util.Objects /** Emitted when the list of available MCP tools has been successfully retrieved. */ class ResponseMcpListToolsCompletedEvent private constructor( + private val itemId: JsonField, + private val outputIndex: JsonField, private val sequenceNumber: JsonField, private val type: JsonValue, private val additionalProperties: MutableMap, @@ -25,11 +27,31 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("output_index") + @ExcludeMissing + outputIndex: JsonField = JsonMissing.of(), @JsonProperty("sequence_number") @ExcludeMissing sequenceNumber: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(sequenceNumber, type, mutableMapOf()) + ) : this(itemId, outputIndex, sequenceNumber, type, mutableMapOf()) + + /** + * The ID of the MCP tool call item that produced this output. + * + * @throws OpenAIInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The index of the output item that was processed. + * + * @throws OpenAIInvalidDataException 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 outputIndex(): Long = outputIndex.getRequired("output_index") /** * The sequence number of this event. @@ -52,6 +74,20 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [outputIndex]. + * + * Unlike [outputIndex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("output_index") @ExcludeMissing fun _outputIndex(): JsonField = outputIndex + /** * Returns the raw JSON value of [sequenceNumber]. * @@ -81,6 +117,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` */ @@ -90,6 +128,8 @@ private constructor( /** A builder for [ResponseMcpListToolsCompletedEvent]. */ class Builder internal constructor() { + private var itemId: JsonField? = null + private var outputIndex: JsonField? = null private var sequenceNumber: JsonField? = null private var type: JsonValue = JsonValue.from("response.mcp_list_tools.completed") private var additionalProperties: MutableMap = mutableMapOf() @@ -97,12 +137,37 @@ private constructor( @JvmSynthetic internal fun from(responseMcpListToolsCompletedEvent: ResponseMcpListToolsCompletedEvent) = apply { + itemId = responseMcpListToolsCompletedEvent.itemId + outputIndex = responseMcpListToolsCompletedEvent.outputIndex sequenceNumber = responseMcpListToolsCompletedEvent.sequenceNumber type = responseMcpListToolsCompletedEvent.type additionalProperties = responseMcpListToolsCompletedEvent.additionalProperties.toMutableMap() } + /** The ID of the MCP tool call item that produced this output. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** The index of the output item that was processed. */ + fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex)) + + /** + * Sets [Builder.outputIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.outputIndex] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun outputIndex(outputIndex: JsonField) = apply { this.outputIndex = outputIndex } + /** The sequence number of this event. */ fun sequenceNumber(sequenceNumber: Long) = sequenceNumber(JsonField.of(sequenceNumber)) @@ -157,6 +222,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` * @@ -164,6 +231,8 @@ private constructor( */ fun build(): ResponseMcpListToolsCompletedEvent = ResponseMcpListToolsCompletedEvent( + checkRequired("itemId", itemId), + checkRequired("outputIndex", outputIndex), checkRequired("sequenceNumber", sequenceNumber), type, additionalProperties.toMutableMap(), @@ -177,6 +246,8 @@ private constructor( return@apply } + itemId() + outputIndex() sequenceNumber() _type().let { if (it != JsonValue.from("response.mcp_list_tools.completed")) { @@ -201,7 +272,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (sequenceNumber.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (outputIndex.asKnown().isPresent) 1 else 0) + + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.mcp_list_tools.completed")) 1 else 0 } override fun equals(other: Any?): Boolean { @@ -209,15 +282,15 @@ private constructor( return true } - return /* spotless:off */ other is ResponseMcpListToolsCompletedEvent && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ResponseMcpListToolsCompletedEvent && itemId == other.itemId && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(sequenceNumber, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(itemId, outputIndex, sequenceNumber, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ResponseMcpListToolsCompletedEvent{sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" + "ResponseMcpListToolsCompletedEvent{itemId=$itemId, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsFailedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsFailedEvent.kt index ede2b1eca..c519ea4df 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsFailedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsFailedEvent.kt @@ -18,6 +18,8 @@ import java.util.Objects /** Emitted when the attempt to list available MCP tools has failed. */ class ResponseMcpListToolsFailedEvent private constructor( + private val itemId: JsonField, + private val outputIndex: JsonField, private val sequenceNumber: JsonField, private val type: JsonValue, private val additionalProperties: MutableMap, @@ -25,11 +27,31 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("output_index") + @ExcludeMissing + outputIndex: JsonField = JsonMissing.of(), @JsonProperty("sequence_number") @ExcludeMissing sequenceNumber: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(sequenceNumber, type, mutableMapOf()) + ) : this(itemId, outputIndex, sequenceNumber, type, mutableMapOf()) + + /** + * The ID of the MCP tool call item that failed. + * + * @throws OpenAIInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The index of the output item that failed. + * + * @throws OpenAIInvalidDataException 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 outputIndex(): Long = outputIndex.getRequired("output_index") /** * The sequence number of this event. @@ -52,6 +74,20 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [outputIndex]. + * + * Unlike [outputIndex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("output_index") @ExcludeMissing fun _outputIndex(): JsonField = outputIndex + /** * Returns the raw JSON value of [sequenceNumber]. * @@ -81,6 +117,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` */ @@ -90,6 +128,8 @@ private constructor( /** A builder for [ResponseMcpListToolsFailedEvent]. */ class Builder internal constructor() { + private var itemId: JsonField? = null + private var outputIndex: JsonField? = null private var sequenceNumber: JsonField? = null private var type: JsonValue = JsonValue.from("response.mcp_list_tools.failed") private var additionalProperties: MutableMap = mutableMapOf() @@ -97,12 +137,37 @@ private constructor( @JvmSynthetic internal fun from(responseMcpListToolsFailedEvent: ResponseMcpListToolsFailedEvent) = apply { + itemId = responseMcpListToolsFailedEvent.itemId + outputIndex = responseMcpListToolsFailedEvent.outputIndex sequenceNumber = responseMcpListToolsFailedEvent.sequenceNumber type = responseMcpListToolsFailedEvent.type additionalProperties = responseMcpListToolsFailedEvent.additionalProperties.toMutableMap() } + /** The ID of the MCP tool call item that failed. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** The index of the output item that failed. */ + fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex)) + + /** + * Sets [Builder.outputIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.outputIndex] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun outputIndex(outputIndex: JsonField) = apply { this.outputIndex = outputIndex } + /** The sequence number of this event. */ fun sequenceNumber(sequenceNumber: Long) = sequenceNumber(JsonField.of(sequenceNumber)) @@ -157,6 +222,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` * @@ -164,6 +231,8 @@ private constructor( */ fun build(): ResponseMcpListToolsFailedEvent = ResponseMcpListToolsFailedEvent( + checkRequired("itemId", itemId), + checkRequired("outputIndex", outputIndex), checkRequired("sequenceNumber", sequenceNumber), type, additionalProperties.toMutableMap(), @@ -177,6 +246,8 @@ private constructor( return@apply } + itemId() + outputIndex() sequenceNumber() _type().let { if (it != JsonValue.from("response.mcp_list_tools.failed")) { @@ -201,7 +272,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (sequenceNumber.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (outputIndex.asKnown().isPresent) 1 else 0) + + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.mcp_list_tools.failed")) 1 else 0 } override fun equals(other: Any?): Boolean { @@ -209,15 +282,15 @@ private constructor( return true } - return /* spotless:off */ other is ResponseMcpListToolsFailedEvent && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ResponseMcpListToolsFailedEvent && itemId == other.itemId && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(sequenceNumber, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(itemId, outputIndex, sequenceNumber, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ResponseMcpListToolsFailedEvent{sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" + "ResponseMcpListToolsFailedEvent{itemId=$itemId, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsInProgressEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsInProgressEvent.kt index 6a0ceccda..ad591dadc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsInProgressEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseMcpListToolsInProgressEvent.kt @@ -18,6 +18,8 @@ import java.util.Objects /** Emitted when the system is in the process of retrieving the list of available MCP tools. */ class ResponseMcpListToolsInProgressEvent private constructor( + private val itemId: JsonField, + private val outputIndex: JsonField, private val sequenceNumber: JsonField, private val type: JsonValue, private val additionalProperties: MutableMap, @@ -25,11 +27,31 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("output_index") + @ExcludeMissing + outputIndex: JsonField = JsonMissing.of(), @JsonProperty("sequence_number") @ExcludeMissing sequenceNumber: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(sequenceNumber, type, mutableMapOf()) + ) : this(itemId, outputIndex, sequenceNumber, type, mutableMapOf()) + + /** + * The ID of the MCP tool call item that is being processed. + * + * @throws OpenAIInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The index of the output item that is being processed. + * + * @throws OpenAIInvalidDataException 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 outputIndex(): Long = outputIndex.getRequired("output_index") /** * The sequence number of this event. @@ -52,6 +74,20 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [outputIndex]. + * + * Unlike [outputIndex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("output_index") @ExcludeMissing fun _outputIndex(): JsonField = outputIndex + /** * Returns the raw JSON value of [sequenceNumber]. * @@ -81,6 +117,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` */ @@ -90,6 +128,8 @@ private constructor( /** A builder for [ResponseMcpListToolsInProgressEvent]. */ class Builder internal constructor() { + private var itemId: JsonField? = null + private var outputIndex: JsonField? = null private var sequenceNumber: JsonField? = null private var type: JsonValue = JsonValue.from("response.mcp_list_tools.in_progress") private var additionalProperties: MutableMap = mutableMapOf() @@ -98,12 +138,37 @@ private constructor( internal fun from( responseMcpListToolsInProgressEvent: ResponseMcpListToolsInProgressEvent ) = apply { + itemId = responseMcpListToolsInProgressEvent.itemId + outputIndex = responseMcpListToolsInProgressEvent.outputIndex sequenceNumber = responseMcpListToolsInProgressEvent.sequenceNumber type = responseMcpListToolsInProgressEvent.type additionalProperties = responseMcpListToolsInProgressEvent.additionalProperties.toMutableMap() } + /** The ID of the MCP tool call item that is being processed. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** The index of the output item that is being processed. */ + fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex)) + + /** + * Sets [Builder.outputIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.outputIndex] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun outputIndex(outputIndex: JsonField) = apply { this.outputIndex = outputIndex } + /** The sequence number of this event. */ fun sequenceNumber(sequenceNumber: Long) = sequenceNumber(JsonField.of(sequenceNumber)) @@ -158,6 +223,8 @@ private constructor( * * The following fields are required: * ```java + * .itemId() + * .outputIndex() * .sequenceNumber() * ``` * @@ -165,6 +232,8 @@ private constructor( */ fun build(): ResponseMcpListToolsInProgressEvent = ResponseMcpListToolsInProgressEvent( + checkRequired("itemId", itemId), + checkRequired("outputIndex", outputIndex), checkRequired("sequenceNumber", sequenceNumber), type, additionalProperties.toMutableMap(), @@ -178,6 +247,8 @@ private constructor( return@apply } + itemId() + outputIndex() sequenceNumber() _type().let { if (it != JsonValue.from("response.mcp_list_tools.in_progress")) { @@ -202,7 +273,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (sequenceNumber.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (outputIndex.asKnown().isPresent) 1 else 0) + + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.mcp_list_tools.in_progress")) 1 else 0 } override fun equals(other: Any?): Boolean { @@ -210,15 +283,15 @@ private constructor( return true } - return /* spotless:off */ other is ResponseMcpListToolsInProgressEvent && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ResponseMcpListToolsInProgressEvent && itemId == other.itemId && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(sequenceNumber, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(itemId, outputIndex, sequenceNumber, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ResponseMcpListToolsInProgressEvent{sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" + "ResponseMcpListToolsInProgressEvent{itemId=$itemId, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningDeltaEvent.kt deleted file mode 100644 index 4ea69fda3..000000000 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningDeltaEvent.kt +++ /dev/null @@ -1,346 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openai.models.responses - -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.openai.core.ExcludeMissing -import com.openai.core.JsonField -import com.openai.core.JsonMissing -import com.openai.core.JsonValue -import com.openai.core.checkRequired -import com.openai.errors.OpenAIInvalidDataException -import java.util.Collections -import java.util.Objects - -/** Emitted when there is a delta (partial update) to the reasoning content. */ -class ResponseReasoningDeltaEvent -private constructor( - private val contentIndex: JsonField, - private val delta: JsonValue, - private val itemId: JsonField, - private val outputIndex: JsonField, - private val sequenceNumber: JsonField, - private val type: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("content_index") - @ExcludeMissing - contentIndex: JsonField = JsonMissing.of(), - @JsonProperty("delta") @ExcludeMissing delta: JsonValue = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("output_index") - @ExcludeMissing - outputIndex: JsonField = JsonMissing.of(), - @JsonProperty("sequence_number") - @ExcludeMissing - sequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(contentIndex, delta, itemId, outputIndex, sequenceNumber, type, mutableMapOf()) - - /** - * The index of the reasoning content part within the output item. - * - * @throws OpenAIInvalidDataException 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 contentIndex(): Long = contentIndex.getRequired("content_index") - - /** The partial update to the reasoning content. */ - @JsonProperty("delta") @ExcludeMissing fun _delta(): JsonValue = delta - - /** - * The unique identifier of the item for which reasoning is being updated. - * - * @throws OpenAIInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") - - /** - * The index of the output item in the response's output array. - * - * @throws OpenAIInvalidDataException 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 outputIndex(): Long = outputIndex.getRequired("output_index") - - /** - * The sequence number of this event. - * - * @throws OpenAIInvalidDataException 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 sequenceNumber(): Long = sequenceNumber.getRequired("sequence_number") - - /** - * The type of the event. Always 'response.reasoning.delta'. - * - * Expected to always return the following: - * ```java - * JsonValue.from("response.reasoning.delta") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [contentIndex]. - * - * Unlike [contentIndex], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content_index") - @ExcludeMissing - fun _contentIndex(): JsonField = contentIndex - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [outputIndex]. - * - * Unlike [outputIndex], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("output_index") @ExcludeMissing fun _outputIndex(): JsonField = outputIndex - - /** - * Returns the raw JSON value of [sequenceNumber]. - * - * Unlike [sequenceNumber], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("sequence_number") - @ExcludeMissing - fun _sequenceNumber(): JsonField = sequenceNumber - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ResponseReasoningDeltaEvent]. - * - * The following fields are required: - * ```java - * .contentIndex() - * .delta() - * .itemId() - * .outputIndex() - * .sequenceNumber() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ResponseReasoningDeltaEvent]. */ - class Builder internal constructor() { - - private var contentIndex: JsonField? = null - private var delta: JsonValue? = null - private var itemId: JsonField? = null - private var outputIndex: JsonField? = null - private var sequenceNumber: JsonField? = null - private var type: JsonValue = JsonValue.from("response.reasoning.delta") - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(responseReasoningDeltaEvent: ResponseReasoningDeltaEvent) = apply { - contentIndex = responseReasoningDeltaEvent.contentIndex - delta = responseReasoningDeltaEvent.delta - itemId = responseReasoningDeltaEvent.itemId - outputIndex = responseReasoningDeltaEvent.outputIndex - sequenceNumber = responseReasoningDeltaEvent.sequenceNumber - type = responseReasoningDeltaEvent.type - additionalProperties = responseReasoningDeltaEvent.additionalProperties.toMutableMap() - } - - /** The index of the reasoning content part within the output item. */ - fun contentIndex(contentIndex: Long) = contentIndex(JsonField.of(contentIndex)) - - /** - * Sets [Builder.contentIndex] to an arbitrary JSON value. - * - * You should usually call [Builder.contentIndex] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun contentIndex(contentIndex: JsonField) = apply { this.contentIndex = contentIndex } - - /** The partial update to the reasoning content. */ - fun delta(delta: JsonValue) = apply { this.delta = delta } - - /** The unique identifier of the item for which reasoning is being updated. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** The index of the output item in the response's output array. */ - fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex)) - - /** - * Sets [Builder.outputIndex] to an arbitrary JSON value. - * - * You should usually call [Builder.outputIndex] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun outputIndex(outputIndex: JsonField) = apply { this.outputIndex = outputIndex } - - /** The sequence number of this event. */ - fun sequenceNumber(sequenceNumber: Long) = sequenceNumber(JsonField.of(sequenceNumber)) - - /** - * Sets [Builder.sequenceNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.sequenceNumber] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun sequenceNumber(sequenceNumber: JsonField) = apply { - this.sequenceNumber = sequenceNumber - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("response.reasoning.delta") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - 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 [ResponseReasoningDeltaEvent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .contentIndex() - * .delta() - * .itemId() - * .outputIndex() - * .sequenceNumber() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ResponseReasoningDeltaEvent = - ResponseReasoningDeltaEvent( - checkRequired("contentIndex", contentIndex), - checkRequired("delta", delta), - checkRequired("itemId", itemId), - checkRequired("outputIndex", outputIndex), - checkRequired("sequenceNumber", sequenceNumber), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ResponseReasoningDeltaEvent = apply { - if (validated) { - return@apply - } - - contentIndex() - itemId() - outputIndex() - sequenceNumber() - _type().let { - if (it != JsonValue.from("response.reasoning.delta")) { - throw OpenAIInvalidDataException("'type' is invalid, received $it") - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - 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 = - (if (contentIndex.asKnown().isPresent) 1 else 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (if (outputIndex.asKnown().isPresent) 1 else 0) + - (if (sequenceNumber.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("response.reasoning.delta")) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ResponseReasoningDeltaEvent && contentIndex == other.contentIndex && delta == other.delta && itemId == other.itemId && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(contentIndex, delta, itemId, outputIndex, sequenceNumber, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ResponseReasoningDeltaEvent{contentIndex=$contentIndex, delta=$delta, itemId=$itemId, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" -} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningDoneEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningDoneEvent.kt deleted file mode 100644 index 6bdfd94d1..000000000 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningDoneEvent.kt +++ /dev/null @@ -1,368 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openai.models.responses - -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.openai.core.ExcludeMissing -import com.openai.core.JsonField -import com.openai.core.JsonMissing -import com.openai.core.JsonValue -import com.openai.core.checkRequired -import com.openai.errors.OpenAIInvalidDataException -import java.util.Collections -import java.util.Objects - -/** Emitted when the reasoning content is finalized for an item. */ -class ResponseReasoningDoneEvent -private constructor( - private val contentIndex: JsonField, - private val itemId: JsonField, - private val outputIndex: JsonField, - private val sequenceNumber: JsonField, - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("content_index") - @ExcludeMissing - contentIndex: JsonField = JsonMissing.of(), - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("output_index") - @ExcludeMissing - outputIndex: JsonField = JsonMissing.of(), - @JsonProperty("sequence_number") - @ExcludeMissing - sequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(contentIndex, itemId, outputIndex, sequenceNumber, text, type, mutableMapOf()) - - /** - * The index of the reasoning content part within the output item. - * - * @throws OpenAIInvalidDataException 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 contentIndex(): Long = contentIndex.getRequired("content_index") - - /** - * The unique identifier of the item for which reasoning is finalized. - * - * @throws OpenAIInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") - - /** - * The index of the output item in the response's output array. - * - * @throws OpenAIInvalidDataException 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 outputIndex(): Long = outputIndex.getRequired("output_index") - - /** - * The sequence number of this event. - * - * @throws OpenAIInvalidDataException 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 sequenceNumber(): Long = sequenceNumber.getRequired("sequence_number") - - /** - * The finalized reasoning text. - * - * @throws OpenAIInvalidDataException 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 text(): String = text.getRequired("text") - - /** - * The type of the event. Always 'response.reasoning.done'. - * - * Expected to always return the following: - * ```java - * JsonValue.from("response.reasoning.done") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [contentIndex]. - * - * Unlike [contentIndex], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content_index") - @ExcludeMissing - fun _contentIndex(): JsonField = contentIndex - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [outputIndex]. - * - * Unlike [outputIndex], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("output_index") @ExcludeMissing fun _outputIndex(): JsonField = outputIndex - - /** - * Returns the raw JSON value of [sequenceNumber]. - * - * Unlike [sequenceNumber], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("sequence_number") - @ExcludeMissing - fun _sequenceNumber(): JsonField = sequenceNumber - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ResponseReasoningDoneEvent]. - * - * The following fields are required: - * ```java - * .contentIndex() - * .itemId() - * .outputIndex() - * .sequenceNumber() - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ResponseReasoningDoneEvent]. */ - class Builder internal constructor() { - - private var contentIndex: JsonField? = null - private var itemId: JsonField? = null - private var outputIndex: JsonField? = null - private var sequenceNumber: JsonField? = null - private var text: JsonField? = null - private var type: JsonValue = JsonValue.from("response.reasoning.done") - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(responseReasoningDoneEvent: ResponseReasoningDoneEvent) = apply { - contentIndex = responseReasoningDoneEvent.contentIndex - itemId = responseReasoningDoneEvent.itemId - outputIndex = responseReasoningDoneEvent.outputIndex - sequenceNumber = responseReasoningDoneEvent.sequenceNumber - text = responseReasoningDoneEvent.text - type = responseReasoningDoneEvent.type - additionalProperties = responseReasoningDoneEvent.additionalProperties.toMutableMap() - } - - /** The index of the reasoning content part within the output item. */ - fun contentIndex(contentIndex: Long) = contentIndex(JsonField.of(contentIndex)) - - /** - * Sets [Builder.contentIndex] to an arbitrary JSON value. - * - * You should usually call [Builder.contentIndex] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun contentIndex(contentIndex: JsonField) = apply { this.contentIndex = contentIndex } - - /** The unique identifier of the item for which reasoning is finalized. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** The index of the output item in the response's output array. */ - fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex)) - - /** - * Sets [Builder.outputIndex] to an arbitrary JSON value. - * - * You should usually call [Builder.outputIndex] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun outputIndex(outputIndex: JsonField) = apply { this.outputIndex = outputIndex } - - /** The sequence number of this event. */ - fun sequenceNumber(sequenceNumber: Long) = sequenceNumber(JsonField.of(sequenceNumber)) - - /** - * Sets [Builder.sequenceNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.sequenceNumber] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun sequenceNumber(sequenceNumber: JsonField) = apply { - this.sequenceNumber = sequenceNumber - } - - /** The finalized reasoning text. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun text(text: JsonField) = apply { this.text = text } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("response.reasoning.done") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - 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 [ResponseReasoningDoneEvent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .contentIndex() - * .itemId() - * .outputIndex() - * .sequenceNumber() - * .text() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ResponseReasoningDoneEvent = - ResponseReasoningDoneEvent( - checkRequired("contentIndex", contentIndex), - checkRequired("itemId", itemId), - checkRequired("outputIndex", outputIndex), - checkRequired("sequenceNumber", sequenceNumber), - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ResponseReasoningDoneEvent = apply { - if (validated) { - return@apply - } - - contentIndex() - itemId() - outputIndex() - sequenceNumber() - text() - _type().let { - if (it != JsonValue.from("response.reasoning.done")) { - throw OpenAIInvalidDataException("'type' is invalid, received $it") - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - 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 = - (if (contentIndex.asKnown().isPresent) 1 else 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (if (outputIndex.asKnown().isPresent) 1 else 0) + - (if (sequenceNumber.asKnown().isPresent) 1 else 0) + - (if (text.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("response.reasoning.done")) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ResponseReasoningDoneEvent && contentIndex == other.contentIndex && itemId == other.itemId && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && text == other.text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(contentIndex, itemId, outputIndex, sequenceNumber, text, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ResponseReasoningDoneEvent{contentIndex=$contentIndex, itemId=$itemId, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, text=$text, type=$type, additionalProperties=$additionalProperties}" -} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseStreamEvent.kt index 65c55b235..5bbf16fd2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseStreamEvent.kt @@ -73,8 +73,6 @@ private constructor( private val mcpListToolsInProgress: ResponseMcpListToolsInProgressEvent? = null, private val outputTextAnnotationAdded: ResponseOutputTextAnnotationAddedEvent? = null, private val queued: ResponseQueuedEvent? = null, - private val reasoningDelta: ResponseReasoningDeltaEvent? = null, - private val reasoningDone: ResponseReasoningDoneEvent? = null, private val reasoningSummaryDelta: ResponseReasoningSummaryDeltaEvent? = null, private val reasoningSummaryDone: ResponseReasoningSummaryDoneEvent? = null, private val _json: JsonValue? = null, @@ -267,13 +265,6 @@ private constructor( /** Emitted when a response is queued and waiting to be processed. */ fun queued(): Optional = Optional.ofNullable(queued) - /** Emitted when there is a delta (partial update) to the reasoning content. */ - fun reasoningDelta(): Optional = - Optional.ofNullable(reasoningDelta) - - /** Emitted when the reasoning content is finalized for an item. */ - fun reasoningDone(): Optional = Optional.ofNullable(reasoningDone) - /** Emitted when there is a delta (partial update) to the reasoning summary content. */ fun reasoningSummaryDelta(): Optional = Optional.ofNullable(reasoningSummaryDelta) @@ -380,10 +371,6 @@ private constructor( fun isQueued(): Boolean = queued != null - fun isReasoningDelta(): Boolean = reasoningDelta != null - - fun isReasoningDone(): Boolean = reasoningDone != null - fun isReasoningSummaryDelta(): Boolean = reasoningSummaryDelta != null fun isReasoningSummaryDone(): Boolean = reasoningSummaryDone != null @@ -575,13 +562,6 @@ private constructor( /** Emitted when a response is queued and waiting to be processed. */ fun asQueued(): ResponseQueuedEvent = queued.getOrThrow("queued") - /** Emitted when there is a delta (partial update) to the reasoning content. */ - fun asReasoningDelta(): ResponseReasoningDeltaEvent = - reasoningDelta.getOrThrow("reasoningDelta") - - /** Emitted when the reasoning content is finalized for an item. */ - fun asReasoningDone(): ResponseReasoningDoneEvent = reasoningDone.getOrThrow("reasoningDone") - /** Emitted when there is a delta (partial update) to the reasoning summary content. */ fun asReasoningSummaryDelta(): ResponseReasoningSummaryDeltaEvent = reasoningSummaryDelta.getOrThrow("reasoningSummaryDelta") @@ -668,8 +648,6 @@ private constructor( outputTextAnnotationAdded != null -> visitor.visitOutputTextAnnotationAdded(outputTextAnnotationAdded) queued != null -> visitor.visitQueued(queued) - reasoningDelta != null -> visitor.visitReasoningDelta(reasoningDelta) - reasoningDone != null -> visitor.visitReasoningDone(reasoningDone) reasoningSummaryDelta != null -> visitor.visitReasoningSummaryDelta(reasoningSummaryDelta) reasoningSummaryDone != null -> visitor.visitReasoningSummaryDone(reasoningSummaryDone) @@ -945,14 +923,6 @@ private constructor( queued.validate() } - override fun visitReasoningDelta(reasoningDelta: ResponseReasoningDeltaEvent) { - reasoningDelta.validate() - } - - override fun visitReasoningDone(reasoningDone: ResponseReasoningDoneEvent) { - reasoningDone.validate() - } - override fun visitReasoningSummaryDelta( reasoningSummaryDelta: ResponseReasoningSummaryDeltaEvent ) { @@ -1161,12 +1131,6 @@ private constructor( override fun visitQueued(queued: ResponseQueuedEvent) = queued.validity() - override fun visitReasoningDelta(reasoningDelta: ResponseReasoningDeltaEvent) = - reasoningDelta.validity() - - override fun visitReasoningDone(reasoningDone: ResponseReasoningDoneEvent) = - reasoningDone.validity() - override fun visitReasoningSummaryDelta( reasoningSummaryDelta: ResponseReasoningSummaryDeltaEvent ) = reasoningSummaryDelta.validity() @@ -1184,10 +1148,10 @@ private constructor( return true } - return /* spotless:off */ other is ResponseStreamEvent && audioDelta == other.audioDelta && audioDone == other.audioDone && audioTranscriptDelta == other.audioTranscriptDelta && audioTranscriptDone == other.audioTranscriptDone && codeInterpreterCallCodeDelta == other.codeInterpreterCallCodeDelta && codeInterpreterCallCodeDone == other.codeInterpreterCallCodeDone && codeInterpreterCallCompleted == other.codeInterpreterCallCompleted && codeInterpreterCallInProgress == other.codeInterpreterCallInProgress && codeInterpreterCallInterpreting == other.codeInterpreterCallInterpreting && completed == other.completed && contentPartAdded == other.contentPartAdded && contentPartDone == other.contentPartDone && created == other.created && error == other.error && fileSearchCallCompleted == other.fileSearchCallCompleted && fileSearchCallInProgress == other.fileSearchCallInProgress && fileSearchCallSearching == other.fileSearchCallSearching && functionCallArgumentsDelta == other.functionCallArgumentsDelta && functionCallArgumentsDone == other.functionCallArgumentsDone && inProgress == other.inProgress && failed == other.failed && incomplete == other.incomplete && outputItemAdded == other.outputItemAdded && outputItemDone == other.outputItemDone && reasoningSummaryPartAdded == other.reasoningSummaryPartAdded && reasoningSummaryPartDone == other.reasoningSummaryPartDone && reasoningSummaryTextDelta == other.reasoningSummaryTextDelta && reasoningSummaryTextDone == other.reasoningSummaryTextDone && refusalDelta == other.refusalDelta && refusalDone == other.refusalDone && outputTextDelta == other.outputTextDelta && outputTextDone == other.outputTextDone && webSearchCallCompleted == other.webSearchCallCompleted && webSearchCallInProgress == other.webSearchCallInProgress && webSearchCallSearching == other.webSearchCallSearching && imageGenerationCallCompleted == other.imageGenerationCallCompleted && imageGenerationCallGenerating == other.imageGenerationCallGenerating && imageGenerationCallInProgress == other.imageGenerationCallInProgress && imageGenerationCallPartialImage == other.imageGenerationCallPartialImage && mcpCallArgumentsDelta == other.mcpCallArgumentsDelta && mcpCallArgumentsDone == other.mcpCallArgumentsDone && mcpCallCompleted == other.mcpCallCompleted && mcpCallFailed == other.mcpCallFailed && mcpCallInProgress == other.mcpCallInProgress && mcpListToolsCompleted == other.mcpListToolsCompleted && mcpListToolsFailed == other.mcpListToolsFailed && mcpListToolsInProgress == other.mcpListToolsInProgress && outputTextAnnotationAdded == other.outputTextAnnotationAdded && queued == other.queued && reasoningDelta == other.reasoningDelta && reasoningDone == other.reasoningDone && reasoningSummaryDelta == other.reasoningSummaryDelta && reasoningSummaryDone == other.reasoningSummaryDone /* spotless:on */ + return /* spotless:off */ other is ResponseStreamEvent && audioDelta == other.audioDelta && audioDone == other.audioDone && audioTranscriptDelta == other.audioTranscriptDelta && audioTranscriptDone == other.audioTranscriptDone && codeInterpreterCallCodeDelta == other.codeInterpreterCallCodeDelta && codeInterpreterCallCodeDone == other.codeInterpreterCallCodeDone && codeInterpreterCallCompleted == other.codeInterpreterCallCompleted && codeInterpreterCallInProgress == other.codeInterpreterCallInProgress && codeInterpreterCallInterpreting == other.codeInterpreterCallInterpreting && completed == other.completed && contentPartAdded == other.contentPartAdded && contentPartDone == other.contentPartDone && created == other.created && error == other.error && fileSearchCallCompleted == other.fileSearchCallCompleted && fileSearchCallInProgress == other.fileSearchCallInProgress && fileSearchCallSearching == other.fileSearchCallSearching && functionCallArgumentsDelta == other.functionCallArgumentsDelta && functionCallArgumentsDone == other.functionCallArgumentsDone && inProgress == other.inProgress && failed == other.failed && incomplete == other.incomplete && outputItemAdded == other.outputItemAdded && outputItemDone == other.outputItemDone && reasoningSummaryPartAdded == other.reasoningSummaryPartAdded && reasoningSummaryPartDone == other.reasoningSummaryPartDone && reasoningSummaryTextDelta == other.reasoningSummaryTextDelta && reasoningSummaryTextDone == other.reasoningSummaryTextDone && refusalDelta == other.refusalDelta && refusalDone == other.refusalDone && outputTextDelta == other.outputTextDelta && outputTextDone == other.outputTextDone && webSearchCallCompleted == other.webSearchCallCompleted && webSearchCallInProgress == other.webSearchCallInProgress && webSearchCallSearching == other.webSearchCallSearching && imageGenerationCallCompleted == other.imageGenerationCallCompleted && imageGenerationCallGenerating == other.imageGenerationCallGenerating && imageGenerationCallInProgress == other.imageGenerationCallInProgress && imageGenerationCallPartialImage == other.imageGenerationCallPartialImage && mcpCallArgumentsDelta == other.mcpCallArgumentsDelta && mcpCallArgumentsDone == other.mcpCallArgumentsDone && mcpCallCompleted == other.mcpCallCompleted && mcpCallFailed == other.mcpCallFailed && mcpCallInProgress == other.mcpCallInProgress && mcpListToolsCompleted == other.mcpListToolsCompleted && mcpListToolsFailed == other.mcpListToolsFailed && mcpListToolsInProgress == other.mcpListToolsInProgress && outputTextAnnotationAdded == other.outputTextAnnotationAdded && queued == other.queued && reasoningSummaryDelta == other.reasoningSummaryDelta && reasoningSummaryDone == other.reasoningSummaryDone /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(audioDelta, audioDone, audioTranscriptDelta, audioTranscriptDone, codeInterpreterCallCodeDelta, codeInterpreterCallCodeDone, codeInterpreterCallCompleted, codeInterpreterCallInProgress, codeInterpreterCallInterpreting, completed, contentPartAdded, contentPartDone, created, error, fileSearchCallCompleted, fileSearchCallInProgress, fileSearchCallSearching, functionCallArgumentsDelta, functionCallArgumentsDone, inProgress, failed, incomplete, outputItemAdded, outputItemDone, reasoningSummaryPartAdded, reasoningSummaryPartDone, reasoningSummaryTextDelta, reasoningSummaryTextDone, refusalDelta, refusalDone, outputTextDelta, outputTextDone, webSearchCallCompleted, webSearchCallInProgress, webSearchCallSearching, imageGenerationCallCompleted, imageGenerationCallGenerating, imageGenerationCallInProgress, imageGenerationCallPartialImage, mcpCallArgumentsDelta, mcpCallArgumentsDone, mcpCallCompleted, mcpCallFailed, mcpCallInProgress, mcpListToolsCompleted, mcpListToolsFailed, mcpListToolsInProgress, outputTextAnnotationAdded, queued, reasoningDelta, reasoningDone, reasoningSummaryDelta, reasoningSummaryDone) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(audioDelta, audioDone, audioTranscriptDelta, audioTranscriptDone, codeInterpreterCallCodeDelta, codeInterpreterCallCodeDone, codeInterpreterCallCompleted, codeInterpreterCallInProgress, codeInterpreterCallInterpreting, completed, contentPartAdded, contentPartDone, created, error, fileSearchCallCompleted, fileSearchCallInProgress, fileSearchCallSearching, functionCallArgumentsDelta, functionCallArgumentsDone, inProgress, failed, incomplete, outputItemAdded, outputItemDone, reasoningSummaryPartAdded, reasoningSummaryPartDone, reasoningSummaryTextDelta, reasoningSummaryTextDone, refusalDelta, refusalDone, outputTextDelta, outputTextDone, webSearchCallCompleted, webSearchCallInProgress, webSearchCallSearching, imageGenerationCallCompleted, imageGenerationCallGenerating, imageGenerationCallInProgress, imageGenerationCallPartialImage, mcpCallArgumentsDelta, mcpCallArgumentsDone, mcpCallCompleted, mcpCallFailed, mcpCallInProgress, mcpListToolsCompleted, mcpListToolsFailed, mcpListToolsInProgress, outputTextAnnotationAdded, queued, reasoningSummaryDelta, reasoningSummaryDone) /* spotless:on */ override fun toString(): String = when { @@ -1269,8 +1233,6 @@ private constructor( outputTextAnnotationAdded != null -> "ResponseStreamEvent{outputTextAnnotationAdded=$outputTextAnnotationAdded}" queued != null -> "ResponseStreamEvent{queued=$queued}" - reasoningDelta != null -> "ResponseStreamEvent{reasoningDelta=$reasoningDelta}" - reasoningDone != null -> "ResponseStreamEvent{reasoningDone=$reasoningDone}" reasoningSummaryDelta != null -> "ResponseStreamEvent{reasoningSummaryDelta=$reasoningSummaryDelta}" reasoningSummaryDone != null -> @@ -1547,16 +1509,6 @@ private constructor( /** Emitted when a response is queued and waiting to be processed. */ @JvmStatic fun ofQueued(queued: ResponseQueuedEvent) = ResponseStreamEvent(queued = queued) - /** Emitted when there is a delta (partial update) to the reasoning content. */ - @JvmStatic - fun ofReasoningDelta(reasoningDelta: ResponseReasoningDeltaEvent) = - ResponseStreamEvent(reasoningDelta = reasoningDelta) - - /** Emitted when the reasoning content is finalized for an item. */ - @JvmStatic - fun ofReasoningDone(reasoningDone: ResponseReasoningDoneEvent) = - ResponseStreamEvent(reasoningDone = reasoningDone) - /** Emitted when there is a delta (partial update) to the reasoning summary content. */ @JvmStatic fun ofReasoningSummaryDelta(reasoningSummaryDelta: ResponseReasoningSummaryDeltaEvent) = @@ -1775,12 +1727,6 @@ private constructor( /** Emitted when a response is queued and waiting to be processed. */ fun visitQueued(queued: ResponseQueuedEvent): T - /** Emitted when there is a delta (partial update) to the reasoning content. */ - fun visitReasoningDelta(reasoningDelta: ResponseReasoningDeltaEvent): T - - /** Emitted when the reasoning content is finalized for an item. */ - fun visitReasoningDone(reasoningDone: ResponseReasoningDoneEvent): T - /** Emitted when there is a delta (partial update) to the reasoning summary content. */ fun visitReasoningSummaryDelta(reasoningSummaryDelta: ResponseReasoningSummaryDeltaEvent): T @@ -2139,16 +2085,6 @@ private constructor( ResponseStreamEvent(queued = it, _json = json) } ?: ResponseStreamEvent(_json = json) } - "response.reasoning.delta" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { ResponseStreamEvent(reasoningDelta = it, _json = json) } - ?: ResponseStreamEvent(_json = json) - } - "response.reasoning.done" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - ResponseStreamEvent(reasoningDone = it, _json = json) - } ?: ResponseStreamEvent(_json = json) - } "response.reasoning_summary.delta" -> { return tryDeserialize( node, @@ -2253,8 +2189,6 @@ private constructor( value.outputTextAnnotationAdded != null -> generator.writeObject(value.outputTextAnnotationAdded) value.queued != null -> generator.writeObject(value.queued) - value.reasoningDelta != null -> generator.writeObject(value.reasoningDelta) - value.reasoningDone != null -> generator.writeObject(value.reasoningDone) value.reasoningSummaryDelta != null -> generator.writeObject(value.reasoningSummaryDelta) value.reasoningSummaryDone != null -> diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextDeltaEvent.kt index aa4ba7723..64507fcf2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextDeltaEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextDeltaEvent.kt @@ -10,10 +10,14 @@ import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue +import com.openai.core.checkKnown import com.openai.core.checkRequired +import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Emitted when there is an additional text delta. */ class ResponseTextDeltaEvent @@ -21,6 +25,7 @@ private constructor( private val contentIndex: JsonField, private val delta: JsonField, private val itemId: JsonField, + private val logprobs: JsonField>, private val outputIndex: JsonField, private val sequenceNumber: JsonField, private val type: JsonValue, @@ -34,6 +39,9 @@ private constructor( contentIndex: JsonField = JsonMissing.of(), @JsonProperty("delta") @ExcludeMissing delta: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("logprobs") + @ExcludeMissing + logprobs: JsonField> = JsonMissing.of(), @JsonProperty("output_index") @ExcludeMissing outputIndex: JsonField = JsonMissing.of(), @@ -41,7 +49,16 @@ private constructor( @ExcludeMissing sequenceNumber: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(contentIndex, delta, itemId, outputIndex, sequenceNumber, type, mutableMapOf()) + ) : this( + contentIndex, + delta, + itemId, + logprobs, + outputIndex, + sequenceNumber, + type, + mutableMapOf(), + ) /** * The index of the content part that the text delta was added to. @@ -67,6 +84,14 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * The log probabilities of the tokens in the delta. + * + * @throws OpenAIInvalidDataException 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 logprobs(): List = logprobs.getRequired("logprobs") + /** * The index of the output item that the text delta was added to. * @@ -119,6 +144,13 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [logprobs]. + * + * Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logprobs") @ExcludeMissing fun _logprobs(): JsonField> = logprobs + /** * Returns the raw JSON value of [outputIndex]. * @@ -157,6 +189,7 @@ private constructor( * .contentIndex() * .delta() * .itemId() + * .logprobs() * .outputIndex() * .sequenceNumber() * ``` @@ -170,6 +203,7 @@ private constructor( private var contentIndex: JsonField? = null private var delta: JsonField? = null private var itemId: JsonField? = null + private var logprobs: JsonField>? = null private var outputIndex: JsonField? = null private var sequenceNumber: JsonField? = null private var type: JsonValue = JsonValue.from("response.output_text.delta") @@ -180,6 +214,7 @@ private constructor( contentIndex = responseTextDeltaEvent.contentIndex delta = responseTextDeltaEvent.delta itemId = responseTextDeltaEvent.itemId + logprobs = responseTextDeltaEvent.logprobs.map { it.toMutableList() } outputIndex = responseTextDeltaEvent.outputIndex sequenceNumber = responseTextDeltaEvent.sequenceNumber type = responseTextDeltaEvent.type @@ -220,6 +255,32 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The log probabilities of the tokens in the delta. */ + fun logprobs(logprobs: List) = logprobs(JsonField.of(logprobs)) + + /** + * Sets [Builder.logprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.logprobs] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun logprobs(logprobs: JsonField>) = apply { + this.logprobs = logprobs.map { it.toMutableList() } + } + + /** + * Adds a single [Logprob] to [logprobs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLogprob(logprob: Logprob) = apply { + logprobs = + (logprobs ?: JsonField.of(mutableListOf())).also { + checkKnown("logprobs", it).add(logprob) + } + } + /** The index of the output item that the text delta was added to. */ fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex)) @@ -289,6 +350,7 @@ private constructor( * .contentIndex() * .delta() * .itemId() + * .logprobs() * .outputIndex() * .sequenceNumber() * ``` @@ -300,6 +362,7 @@ private constructor( checkRequired("contentIndex", contentIndex), checkRequired("delta", delta), checkRequired("itemId", itemId), + checkRequired("logprobs", logprobs).map { it.toImmutable() }, checkRequired("outputIndex", outputIndex), checkRequired("sequenceNumber", sequenceNumber), type, @@ -317,6 +380,7 @@ private constructor( contentIndex() delta() itemId() + logprobs().forEach { it.validate() } outputIndex() sequenceNumber() _type().let { @@ -345,24 +409,459 @@ private constructor( (if (contentIndex.asKnown().isPresent) 1 else 0) + (if (delta.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (logprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (outputIndex.asKnown().isPresent) 1 else 0) + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.output_text.delta")) 1 else 0 } + /** + * A logprob is the logarithmic probability that the model assigns to producing a particular + * token at a given position in the sequence. Less-negative (higher) logprob values indicate + * greater model confidence in that token choice. + */ + class Logprob + private constructor( + private val token: JsonField, + private val logprob: JsonField, + private val topLogprobs: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("logprob") @ExcludeMissing logprob: JsonField = JsonMissing.of(), + @JsonProperty("top_logprobs") + @ExcludeMissing + topLogprobs: JsonField> = JsonMissing.of(), + ) : this(token, logprob, topLogprobs, mutableMapOf()) + + /** + * A possible text token. + * + * @throws OpenAIInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * The log probability of this token. + * + * @throws OpenAIInvalidDataException 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 logprob(): Double = logprob.getRequired("logprob") + + /** + * The log probability of the top 20 most likely tokens. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topLogprobs(): Optional> = topLogprobs.getOptional("top_logprobs") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [logprob]. + * + * Unlike [logprob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logprob") @ExcludeMissing fun _logprob(): JsonField = logprob + + /** + * Returns the raw JSON value of [topLogprobs]. + * + * Unlike [topLogprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("top_logprobs") + @ExcludeMissing + fun _topLogprobs(): JsonField> = topLogprobs + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Logprob]. + * + * The following fields are required: + * ```java + * .token() + * .logprob() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Logprob]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var logprob: JsonField? = null + private var topLogprobs: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(logprob: Logprob) = apply { + token = logprob.token + this.logprob = logprob.logprob + topLogprobs = logprob.topLogprobs.map { it.toMutableList() } + additionalProperties = logprob.additionalProperties.toMutableMap() + } + + /** A possible text token. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The log probability of this token. */ + fun logprob(logprob: Double) = logprob(JsonField.of(logprob)) + + /** + * Sets [Builder.logprob] to an arbitrary JSON value. + * + * You should usually call [Builder.logprob] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun logprob(logprob: JsonField) = apply { this.logprob = logprob } + + /** The log probability of the top 20 most likely tokens. */ + fun topLogprobs(topLogprobs: List) = topLogprobs(JsonField.of(topLogprobs)) + + /** + * Sets [Builder.topLogprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.topLogprobs] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun topLogprobs(topLogprobs: JsonField>) = apply { + this.topLogprobs = topLogprobs.map { it.toMutableList() } + } + + /** + * Adds a single [TopLogprob] to [topLogprobs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTopLogprob(topLogprob: TopLogprob) = apply { + topLogprobs = + (topLogprobs ?: JsonField.of(mutableListOf())).also { + checkKnown("topLogprobs", it).add(topLogprob) + } + } + + 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 [Logprob]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .logprob() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Logprob = + Logprob( + checkRequired("token", token), + checkRequired("logprob", logprob), + (topLogprobs ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Logprob = apply { + if (validated) { + return@apply + } + + token() + logprob() + topLogprobs().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (logprob.asKnown().isPresent) 1 else 0) + + (topLogprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class TopLogprob + private constructor( + private val token: JsonField, + private val logprob: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("logprob") + @ExcludeMissing + logprob: JsonField = JsonMissing.of(), + ) : this(token, logprob, mutableMapOf()) + + /** + * A possible text token. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * The log probability of this token. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun logprob(): Optional = logprob.getOptional("logprob") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [logprob]. + * + * Unlike [logprob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logprob") @ExcludeMissing fun _logprob(): JsonField = logprob + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TopLogprob]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopLogprob]. */ + class Builder internal constructor() { + + private var token: JsonField = JsonMissing.of() + private var logprob: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topLogprob: TopLogprob) = apply { + token = topLogprob.token + logprob = topLogprob.logprob + additionalProperties = topLogprob.additionalProperties.toMutableMap() + } + + /** A possible text token. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The log probability of this token. */ + fun logprob(logprob: Double) = logprob(JsonField.of(logprob)) + + /** + * Sets [Builder.logprob] to an arbitrary JSON value. + * + * You should usually call [Builder.logprob] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun logprob(logprob: JsonField) = apply { this.logprob = logprob } + + 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 [TopLogprob]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TopLogprob = + TopLogprob(token, logprob, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TopLogprob = apply { + if (validated) { + return@apply + } + + token() + logprob() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (logprob.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TopLogprob && token == other.token && logprob == other.logprob && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, logprob, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopLogprob{token=$token, logprob=$logprob, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Logprob && token == other.token && logprob == other.logprob && topLogprobs == other.topLogprobs && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, logprob, topLogprobs, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Logprob{token=$token, logprob=$logprob, topLogprobs=$topLogprobs, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ResponseTextDeltaEvent && contentIndex == other.contentIndex && delta == other.delta && itemId == other.itemId && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ResponseTextDeltaEvent && contentIndex == other.contentIndex && delta == other.delta && itemId == other.itemId && logprobs == other.logprobs && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(contentIndex, delta, itemId, outputIndex, sequenceNumber, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(contentIndex, delta, itemId, logprobs, outputIndex, sequenceNumber, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ResponseTextDeltaEvent{contentIndex=$contentIndex, delta=$delta, itemId=$itemId, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" + "ResponseTextDeltaEvent{contentIndex=$contentIndex, delta=$delta, itemId=$itemId, logprobs=$logprobs, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, type=$type, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextDoneEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextDoneEvent.kt index a779c42a0..cf2c69b9f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextDoneEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextDoneEvent.kt @@ -10,16 +10,21 @@ import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue +import com.openai.core.checkKnown import com.openai.core.checkRequired +import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Emitted when text content is finalized. */ class ResponseTextDoneEvent private constructor( private val contentIndex: JsonField, private val itemId: JsonField, + private val logprobs: JsonField>, private val outputIndex: JsonField, private val sequenceNumber: JsonField, private val text: JsonField, @@ -33,6 +38,9 @@ private constructor( @ExcludeMissing contentIndex: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("logprobs") + @ExcludeMissing + logprobs: JsonField> = JsonMissing.of(), @JsonProperty("output_index") @ExcludeMissing outputIndex: JsonField = JsonMissing.of(), @@ -41,7 +49,16 @@ private constructor( sequenceNumber: JsonField = JsonMissing.of(), @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(contentIndex, itemId, outputIndex, sequenceNumber, text, type, mutableMapOf()) + ) : this( + contentIndex, + itemId, + logprobs, + outputIndex, + sequenceNumber, + text, + type, + mutableMapOf(), + ) /** * The index of the content part that the text content is finalized. @@ -59,6 +76,14 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * The log probabilities of the tokens in the delta. + * + * @throws OpenAIInvalidDataException 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 logprobs(): List = logprobs.getRequired("logprobs") + /** * The index of the output item that the text content is finalized. * @@ -112,6 +137,13 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [logprobs]. + * + * Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logprobs") @ExcludeMissing fun _logprobs(): JsonField> = logprobs + /** * Returns the raw JSON value of [outputIndex]. * @@ -156,6 +188,7 @@ private constructor( * ```java * .contentIndex() * .itemId() + * .logprobs() * .outputIndex() * .sequenceNumber() * .text() @@ -169,6 +202,7 @@ private constructor( private var contentIndex: JsonField? = null private var itemId: JsonField? = null + private var logprobs: JsonField>? = null private var outputIndex: JsonField? = null private var sequenceNumber: JsonField? = null private var text: JsonField? = null @@ -179,6 +213,7 @@ private constructor( internal fun from(responseTextDoneEvent: ResponseTextDoneEvent) = apply { contentIndex = responseTextDoneEvent.contentIndex itemId = responseTextDoneEvent.itemId + logprobs = responseTextDoneEvent.logprobs.map { it.toMutableList() } outputIndex = responseTextDoneEvent.outputIndex sequenceNumber = responseTextDoneEvent.sequenceNumber text = responseTextDoneEvent.text @@ -209,6 +244,32 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The log probabilities of the tokens in the delta. */ + fun logprobs(logprobs: List) = logprobs(JsonField.of(logprobs)) + + /** + * Sets [Builder.logprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.logprobs] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun logprobs(logprobs: JsonField>) = apply { + this.logprobs = logprobs.map { it.toMutableList() } + } + + /** + * Adds a single [Logprob] to [logprobs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLogprob(logprob: Logprob) = apply { + logprobs = + (logprobs ?: JsonField.of(mutableListOf())).also { + checkKnown("logprobs", it).add(logprob) + } + } + /** The index of the output item that the text content is finalized. */ fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex)) @@ -288,6 +349,7 @@ private constructor( * ```java * .contentIndex() * .itemId() + * .logprobs() * .outputIndex() * .sequenceNumber() * .text() @@ -299,6 +361,7 @@ private constructor( ResponseTextDoneEvent( checkRequired("contentIndex", contentIndex), checkRequired("itemId", itemId), + checkRequired("logprobs", logprobs).map { it.toImmutable() }, checkRequired("outputIndex", outputIndex), checkRequired("sequenceNumber", sequenceNumber), checkRequired("text", text), @@ -316,6 +379,7 @@ private constructor( contentIndex() itemId() + logprobs().forEach { it.validate() } outputIndex() sequenceNumber() text() @@ -344,25 +408,460 @@ private constructor( internal fun validity(): Int = (if (contentIndex.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (logprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (outputIndex.asKnown().isPresent) 1 else 0) + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + (if (text.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.output_text.done")) 1 else 0 } + /** + * A logprob is the logarithmic probability that the model assigns to producing a particular + * token at a given position in the sequence. Less-negative (higher) logprob values indicate + * greater model confidence in that token choice. + */ + class Logprob + private constructor( + private val token: JsonField, + private val logprob: JsonField, + private val topLogprobs: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("logprob") @ExcludeMissing logprob: JsonField = JsonMissing.of(), + @JsonProperty("top_logprobs") + @ExcludeMissing + topLogprobs: JsonField> = JsonMissing.of(), + ) : this(token, logprob, topLogprobs, mutableMapOf()) + + /** + * A possible text token. + * + * @throws OpenAIInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * The log probability of this token. + * + * @throws OpenAIInvalidDataException 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 logprob(): Double = logprob.getRequired("logprob") + + /** + * The log probability of the top 20 most likely tokens. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topLogprobs(): Optional> = topLogprobs.getOptional("top_logprobs") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [logprob]. + * + * Unlike [logprob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logprob") @ExcludeMissing fun _logprob(): JsonField = logprob + + /** + * Returns the raw JSON value of [topLogprobs]. + * + * Unlike [topLogprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("top_logprobs") + @ExcludeMissing + fun _topLogprobs(): JsonField> = topLogprobs + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Logprob]. + * + * The following fields are required: + * ```java + * .token() + * .logprob() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Logprob]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var logprob: JsonField? = null + private var topLogprobs: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(logprob: Logprob) = apply { + token = logprob.token + this.logprob = logprob.logprob + topLogprobs = logprob.topLogprobs.map { it.toMutableList() } + additionalProperties = logprob.additionalProperties.toMutableMap() + } + + /** A possible text token. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The log probability of this token. */ + fun logprob(logprob: Double) = logprob(JsonField.of(logprob)) + + /** + * Sets [Builder.logprob] to an arbitrary JSON value. + * + * You should usually call [Builder.logprob] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun logprob(logprob: JsonField) = apply { this.logprob = logprob } + + /** The log probability of the top 20 most likely tokens. */ + fun topLogprobs(topLogprobs: List) = topLogprobs(JsonField.of(topLogprobs)) + + /** + * Sets [Builder.topLogprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.topLogprobs] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun topLogprobs(topLogprobs: JsonField>) = apply { + this.topLogprobs = topLogprobs.map { it.toMutableList() } + } + + /** + * Adds a single [TopLogprob] to [topLogprobs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTopLogprob(topLogprob: TopLogprob) = apply { + topLogprobs = + (topLogprobs ?: JsonField.of(mutableListOf())).also { + checkKnown("topLogprobs", it).add(topLogprob) + } + } + + 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 [Logprob]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .logprob() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Logprob = + Logprob( + checkRequired("token", token), + checkRequired("logprob", logprob), + (topLogprobs ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Logprob = apply { + if (validated) { + return@apply + } + + token() + logprob() + topLogprobs().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (logprob.asKnown().isPresent) 1 else 0) + + (topLogprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class TopLogprob + private constructor( + private val token: JsonField, + private val logprob: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("logprob") + @ExcludeMissing + logprob: JsonField = JsonMissing.of(), + ) : this(token, logprob, mutableMapOf()) + + /** + * A possible text token. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * The log probability of this token. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun logprob(): Optional = logprob.getOptional("logprob") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [logprob]. + * + * Unlike [logprob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logprob") @ExcludeMissing fun _logprob(): JsonField = logprob + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TopLogprob]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopLogprob]. */ + class Builder internal constructor() { + + private var token: JsonField = JsonMissing.of() + private var logprob: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topLogprob: TopLogprob) = apply { + token = topLogprob.token + logprob = topLogprob.logprob + additionalProperties = topLogprob.additionalProperties.toMutableMap() + } + + /** A possible text token. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The log probability of this token. */ + fun logprob(logprob: Double) = logprob(JsonField.of(logprob)) + + /** + * Sets [Builder.logprob] to an arbitrary JSON value. + * + * You should usually call [Builder.logprob] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun logprob(logprob: JsonField) = apply { this.logprob = logprob } + + 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 [TopLogprob]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TopLogprob = + TopLogprob(token, logprob, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TopLogprob = apply { + if (validated) { + return@apply + } + + token() + logprob() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (logprob.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TopLogprob && token == other.token && logprob == other.logprob && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, logprob, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopLogprob{token=$token, logprob=$logprob, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Logprob && token == other.token && logprob == other.logprob && topLogprobs == other.topLogprobs && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, logprob, topLogprobs, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Logprob{token=$token, logprob=$logprob, topLogprobs=$topLogprobs, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ResponseTextDoneEvent && contentIndex == other.contentIndex && itemId == other.itemId && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && text == other.text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ResponseTextDoneEvent && contentIndex == other.contentIndex && itemId == other.itemId && logprobs == other.logprobs && outputIndex == other.outputIndex && sequenceNumber == other.sequenceNumber && text == other.text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(contentIndex, itemId, outputIndex, sequenceNumber, text, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(contentIndex, itemId, logprobs, outputIndex, sequenceNumber, text, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ResponseTextDoneEvent{contentIndex=$contentIndex, itemId=$itemId, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, text=$text, type=$type, additionalProperties=$additionalProperties}" + "ResponseTextDoneEvent{contentIndex=$contentIndex, itemId=$itemId, logprobs=$logprobs, outputIndex=$outputIndex, sequenceNumber=$sequenceNumber, text=$text, type=$type, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDeltaEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDeltaEventTest.kt index 76020c82c..9abab829c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDeltaEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDeltaEventTest.kt @@ -3,7 +3,6 @@ package com.openai.models.responses import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.openai.core.JsonValue import com.openai.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,14 +13,13 @@ internal class ResponseMcpCallArgumentsDeltaEventTest { fun create() { val responseMcpCallArgumentsDeltaEvent = ResponseMcpCallArgumentsDeltaEvent.builder() - .delta(JsonValue.from(mapOf())) + .delta("delta") .itemId("item_id") .outputIndex(0L) .sequenceNumber(0L) .build() - assertThat(responseMcpCallArgumentsDeltaEvent._delta()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(responseMcpCallArgumentsDeltaEvent.delta()).isEqualTo("delta") assertThat(responseMcpCallArgumentsDeltaEvent.itemId()).isEqualTo("item_id") assertThat(responseMcpCallArgumentsDeltaEvent.outputIndex()).isEqualTo(0L) assertThat(responseMcpCallArgumentsDeltaEvent.sequenceNumber()).isEqualTo(0L) @@ -32,7 +30,7 @@ internal class ResponseMcpCallArgumentsDeltaEventTest { val jsonMapper = jsonMapper() val responseMcpCallArgumentsDeltaEvent = ResponseMcpCallArgumentsDeltaEvent.builder() - .delta(JsonValue.from(mapOf())) + .delta("delta") .itemId("item_id") .outputIndex(0L) .sequenceNumber(0L) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDoneEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDoneEventTest.kt index 2bab7792b..d0ede38b0 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDoneEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallArgumentsDoneEventTest.kt @@ -3,7 +3,6 @@ package com.openai.models.responses import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.openai.core.JsonValue import com.openai.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,14 +13,13 @@ internal class ResponseMcpCallArgumentsDoneEventTest { fun create() { val responseMcpCallArgumentsDoneEvent = ResponseMcpCallArgumentsDoneEvent.builder() - .arguments(JsonValue.from(mapOf())) + .arguments("arguments") .itemId("item_id") .outputIndex(0L) .sequenceNumber(0L) .build() - assertThat(responseMcpCallArgumentsDoneEvent._arguments()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(responseMcpCallArgumentsDoneEvent.arguments()).isEqualTo("arguments") assertThat(responseMcpCallArgumentsDoneEvent.itemId()).isEqualTo("item_id") assertThat(responseMcpCallArgumentsDoneEvent.outputIndex()).isEqualTo(0L) assertThat(responseMcpCallArgumentsDoneEvent.sequenceNumber()).isEqualTo(0L) @@ -32,7 +30,7 @@ internal class ResponseMcpCallArgumentsDoneEventTest { val jsonMapper = jsonMapper() val responseMcpCallArgumentsDoneEvent = ResponseMcpCallArgumentsDoneEvent.builder() - .arguments(JsonValue.from(mapOf())) + .arguments("arguments") .itemId("item_id") .outputIndex(0L) .sequenceNumber(0L) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallCompletedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallCompletedEventTest.kt index da2f971ed..3c72eccb4 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallCompletedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallCompletedEventTest.kt @@ -12,8 +12,14 @@ internal class ResponseMcpCallCompletedEventTest { @Test fun create() { val responseMcpCallCompletedEvent = - ResponseMcpCallCompletedEvent.builder().sequenceNumber(0L).build() - + ResponseMcpCallCompletedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() + + assertThat(responseMcpCallCompletedEvent.itemId()).isEqualTo("item_id") + assertThat(responseMcpCallCompletedEvent.outputIndex()).isEqualTo(0L) assertThat(responseMcpCallCompletedEvent.sequenceNumber()).isEqualTo(0L) } @@ -21,7 +27,11 @@ internal class ResponseMcpCallCompletedEventTest { fun roundtrip() { val jsonMapper = jsonMapper() val responseMcpCallCompletedEvent = - ResponseMcpCallCompletedEvent.builder().sequenceNumber(0L).build() + ResponseMcpCallCompletedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val roundtrippedResponseMcpCallCompletedEvent = jsonMapper.readValue( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallFailedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallFailedEventTest.kt index f67e8de33..c6319b6b3 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallFailedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpCallFailedEventTest.kt @@ -12,8 +12,14 @@ internal class ResponseMcpCallFailedEventTest { @Test fun create() { val responseMcpCallFailedEvent = - ResponseMcpCallFailedEvent.builder().sequenceNumber(0L).build() - + ResponseMcpCallFailedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() + + assertThat(responseMcpCallFailedEvent.itemId()).isEqualTo("item_id") + assertThat(responseMcpCallFailedEvent.outputIndex()).isEqualTo(0L) assertThat(responseMcpCallFailedEvent.sequenceNumber()).isEqualTo(0L) } @@ -21,7 +27,11 @@ internal class ResponseMcpCallFailedEventTest { fun roundtrip() { val jsonMapper = jsonMapper() val responseMcpCallFailedEvent = - ResponseMcpCallFailedEvent.builder().sequenceNumber(0L).build() + ResponseMcpCallFailedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val roundtrippedResponseMcpCallFailedEvent = jsonMapper.readValue( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsCompletedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsCompletedEventTest.kt index d660de5c3..3ecf75b15 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsCompletedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsCompletedEventTest.kt @@ -12,8 +12,14 @@ internal class ResponseMcpListToolsCompletedEventTest { @Test fun create() { val responseMcpListToolsCompletedEvent = - ResponseMcpListToolsCompletedEvent.builder().sequenceNumber(0L).build() - + ResponseMcpListToolsCompletedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() + + assertThat(responseMcpListToolsCompletedEvent.itemId()).isEqualTo("item_id") + assertThat(responseMcpListToolsCompletedEvent.outputIndex()).isEqualTo(0L) assertThat(responseMcpListToolsCompletedEvent.sequenceNumber()).isEqualTo(0L) } @@ -21,7 +27,11 @@ internal class ResponseMcpListToolsCompletedEventTest { fun roundtrip() { val jsonMapper = jsonMapper() val responseMcpListToolsCompletedEvent = - ResponseMcpListToolsCompletedEvent.builder().sequenceNumber(0L).build() + ResponseMcpListToolsCompletedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val roundtrippedResponseMcpListToolsCompletedEvent = jsonMapper.readValue( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsFailedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsFailedEventTest.kt index e2fde1d03..9889efa2f 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsFailedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsFailedEventTest.kt @@ -12,8 +12,14 @@ internal class ResponseMcpListToolsFailedEventTest { @Test fun create() { val responseMcpListToolsFailedEvent = - ResponseMcpListToolsFailedEvent.builder().sequenceNumber(0L).build() - + ResponseMcpListToolsFailedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() + + assertThat(responseMcpListToolsFailedEvent.itemId()).isEqualTo("item_id") + assertThat(responseMcpListToolsFailedEvent.outputIndex()).isEqualTo(0L) assertThat(responseMcpListToolsFailedEvent.sequenceNumber()).isEqualTo(0L) } @@ -21,7 +27,11 @@ internal class ResponseMcpListToolsFailedEventTest { fun roundtrip() { val jsonMapper = jsonMapper() val responseMcpListToolsFailedEvent = - ResponseMcpListToolsFailedEvent.builder().sequenceNumber(0L).build() + ResponseMcpListToolsFailedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val roundtrippedResponseMcpListToolsFailedEvent = jsonMapper.readValue( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsInProgressEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsInProgressEventTest.kt index 183839a04..9dc90f086 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsInProgressEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseMcpListToolsInProgressEventTest.kt @@ -12,8 +12,14 @@ internal class ResponseMcpListToolsInProgressEventTest { @Test fun create() { val responseMcpListToolsInProgressEvent = - ResponseMcpListToolsInProgressEvent.builder().sequenceNumber(0L).build() - + ResponseMcpListToolsInProgressEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() + + assertThat(responseMcpListToolsInProgressEvent.itemId()).isEqualTo("item_id") + assertThat(responseMcpListToolsInProgressEvent.outputIndex()).isEqualTo(0L) assertThat(responseMcpListToolsInProgressEvent.sequenceNumber()).isEqualTo(0L) } @@ -21,7 +27,11 @@ internal class ResponseMcpListToolsInProgressEventTest { fun roundtrip() { val jsonMapper = jsonMapper() val responseMcpListToolsInProgressEvent = - ResponseMcpListToolsInProgressEvent.builder().sequenceNumber(0L).build() + ResponseMcpListToolsInProgressEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val roundtrippedResponseMcpListToolsInProgressEvent = jsonMapper.readValue( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseReasoningDeltaEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseReasoningDeltaEventTest.kt deleted file mode 100644 index 1c0a95470..000000000 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseReasoningDeltaEventTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openai.models.responses - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.openai.core.JsonValue -import com.openai.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ResponseReasoningDeltaEventTest { - - @Test - fun create() { - val responseReasoningDeltaEvent = - ResponseReasoningDeltaEvent.builder() - .contentIndex(0L) - .delta(JsonValue.from(mapOf())) - .itemId("item_id") - .outputIndex(0L) - .sequenceNumber(0L) - .build() - - assertThat(responseReasoningDeltaEvent.contentIndex()).isEqualTo(0L) - assertThat(responseReasoningDeltaEvent._delta()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(responseReasoningDeltaEvent.itemId()).isEqualTo("item_id") - assertThat(responseReasoningDeltaEvent.outputIndex()).isEqualTo(0L) - assertThat(responseReasoningDeltaEvent.sequenceNumber()).isEqualTo(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val responseReasoningDeltaEvent = - ResponseReasoningDeltaEvent.builder() - .contentIndex(0L) - .delta(JsonValue.from(mapOf())) - .itemId("item_id") - .outputIndex(0L) - .sequenceNumber(0L) - .build() - - val roundtrippedResponseReasoningDeltaEvent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(responseReasoningDeltaEvent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedResponseReasoningDeltaEvent).isEqualTo(responseReasoningDeltaEvent) - } -} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseReasoningDoneEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseReasoningDoneEventTest.kt deleted file mode 100644 index 7b308490c..000000000 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseReasoningDoneEventTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openai.models.responses - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.openai.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ResponseReasoningDoneEventTest { - - @Test - fun create() { - val responseReasoningDoneEvent = - ResponseReasoningDoneEvent.builder() - .contentIndex(0L) - .itemId("item_id") - .outputIndex(0L) - .sequenceNumber(0L) - .text("text") - .build() - - assertThat(responseReasoningDoneEvent.contentIndex()).isEqualTo(0L) - assertThat(responseReasoningDoneEvent.itemId()).isEqualTo("item_id") - assertThat(responseReasoningDoneEvent.outputIndex()).isEqualTo(0L) - assertThat(responseReasoningDoneEvent.sequenceNumber()).isEqualTo(0L) - assertThat(responseReasoningDoneEvent.text()).isEqualTo("text") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val responseReasoningDoneEvent = - ResponseReasoningDoneEvent.builder() - .contentIndex(0L) - .itemId("item_id") - .outputIndex(0L) - .sequenceNumber(0L) - .text("text") - .build() - - val roundtrippedResponseReasoningDoneEvent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(responseReasoningDoneEvent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedResponseReasoningDoneEvent).isEqualTo(responseReasoningDoneEvent) - } -} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt index c9a55162b..053307fd8 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt @@ -73,8 +73,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -151,8 +149,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -230,8 +226,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -312,8 +306,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -398,8 +390,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -489,8 +479,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -579,8 +567,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -668,8 +654,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -757,8 +741,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -963,8 +945,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -1197,8 +1177,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -1338,8 +1316,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -1571,8 +1547,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -1779,8 +1753,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -1868,8 +1840,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -1957,8 +1927,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -2045,8 +2013,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -2135,8 +2101,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -2226,8 +2190,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -2433,8 +2395,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -2759,8 +2719,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -3085,8 +3043,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -3323,8 +3279,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -3472,8 +3426,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -3594,8 +3546,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -3689,8 +3639,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -3782,8 +3730,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -3875,8 +3821,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -3966,8 +3910,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4057,8 +3999,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4093,6 +4033,18 @@ internal class ResponseStreamEventTest { .contentIndex(0L) .delta("delta") .itemId("item_id") + .addLogprob( + ResponseTextDeltaEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDeltaEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) .outputIndex(0L) .sequenceNumber(0L) .build() @@ -4148,8 +4100,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4163,6 +4113,18 @@ internal class ResponseStreamEventTest { .contentIndex(0L) .delta("delta") .itemId("item_id") + .addLogprob( + ResponseTextDeltaEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDeltaEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) .outputIndex(0L) .sequenceNumber(0L) .build() @@ -4183,6 +4145,18 @@ internal class ResponseStreamEventTest { ResponseTextDoneEvent.builder() .contentIndex(0L) .itemId("item_id") + .addLogprob( + ResponseTextDoneEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDoneEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) .outputIndex(0L) .sequenceNumber(0L) .text("text") @@ -4239,8 +4213,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4253,6 +4225,18 @@ internal class ResponseStreamEventTest { ResponseTextDoneEvent.builder() .contentIndex(0L) .itemId("item_id") + .addLogprob( + ResponseTextDoneEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDoneEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) .outputIndex(0L) .sequenceNumber(0L) .text("text") @@ -4329,8 +4313,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4417,8 +4399,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4505,8 +4485,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4594,8 +4572,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4683,8 +4659,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4772,8 +4746,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4863,8 +4835,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4896,7 +4866,7 @@ internal class ResponseStreamEventTest { fun ofMcpCallArgumentsDelta() { val mcpCallArgumentsDelta = ResponseMcpCallArgumentsDeltaEvent.builder() - .delta(JsonValue.from(mapOf())) + .delta("delta") .itemId("item_id") .outputIndex(0L) .sequenceNumber(0L) @@ -4953,8 +4923,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -4965,7 +4933,7 @@ internal class ResponseStreamEventTest { val responseStreamEvent = ResponseStreamEvent.ofMcpCallArgumentsDelta( ResponseMcpCallArgumentsDeltaEvent.builder() - .delta(JsonValue.from(mapOf())) + .delta("delta") .itemId("item_id") .outputIndex(0L) .sequenceNumber(0L) @@ -4985,7 +4953,7 @@ internal class ResponseStreamEventTest { fun ofMcpCallArgumentsDone() { val mcpCallArgumentsDone = ResponseMcpCallArgumentsDoneEvent.builder() - .arguments(JsonValue.from(mapOf())) + .arguments("arguments") .itemId("item_id") .outputIndex(0L) .sequenceNumber(0L) @@ -5042,8 +5010,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -5054,7 +5020,7 @@ internal class ResponseStreamEventTest { val responseStreamEvent = ResponseStreamEvent.ofMcpCallArgumentsDone( ResponseMcpCallArgumentsDoneEvent.builder() - .arguments(JsonValue.from(mapOf())) + .arguments("arguments") .itemId("item_id") .outputIndex(0L) .sequenceNumber(0L) @@ -5072,7 +5038,12 @@ internal class ResponseStreamEventTest { @Test fun ofMcpCallCompleted() { - val mcpCallCompleted = ResponseMcpCallCompletedEvent.builder().sequenceNumber(0L).build() + val mcpCallCompleted = + ResponseMcpCallCompletedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val responseStreamEvent = ResponseStreamEvent.ofMcpCallCompleted(mcpCallCompleted) @@ -5125,8 +5096,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -5136,7 +5105,11 @@ internal class ResponseStreamEventTest { val jsonMapper = jsonMapper() val responseStreamEvent = ResponseStreamEvent.ofMcpCallCompleted( - ResponseMcpCallCompletedEvent.builder().sequenceNumber(0L).build() + ResponseMcpCallCompletedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() ) val roundtrippedResponseStreamEvent = @@ -5150,7 +5123,12 @@ internal class ResponseStreamEventTest { @Test fun ofMcpCallFailed() { - val mcpCallFailed = ResponseMcpCallFailedEvent.builder().sequenceNumber(0L).build() + val mcpCallFailed = + ResponseMcpCallFailedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val responseStreamEvent = ResponseStreamEvent.ofMcpCallFailed(mcpCallFailed) @@ -5203,8 +5181,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -5214,7 +5190,11 @@ internal class ResponseStreamEventTest { val jsonMapper = jsonMapper() val responseStreamEvent = ResponseStreamEvent.ofMcpCallFailed( - ResponseMcpCallFailedEvent.builder().sequenceNumber(0L).build() + ResponseMcpCallFailedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() ) val roundtrippedResponseStreamEvent = @@ -5286,8 +5266,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -5316,7 +5294,11 @@ internal class ResponseStreamEventTest { @Test fun ofMcpListToolsCompleted() { val mcpListToolsCompleted = - ResponseMcpListToolsCompletedEvent.builder().sequenceNumber(0L).build() + ResponseMcpListToolsCompletedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val responseStreamEvent = ResponseStreamEvent.ofMcpListToolsCompleted(mcpListToolsCompleted) @@ -5369,8 +5351,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -5380,7 +5360,11 @@ internal class ResponseStreamEventTest { val jsonMapper = jsonMapper() val responseStreamEvent = ResponseStreamEvent.ofMcpListToolsCompleted( - ResponseMcpListToolsCompletedEvent.builder().sequenceNumber(0L).build() + ResponseMcpListToolsCompletedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() ) val roundtrippedResponseStreamEvent = @@ -5395,7 +5379,11 @@ internal class ResponseStreamEventTest { @Test fun ofMcpListToolsFailed() { val mcpListToolsFailed = - ResponseMcpListToolsFailedEvent.builder().sequenceNumber(0L).build() + ResponseMcpListToolsFailedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val responseStreamEvent = ResponseStreamEvent.ofMcpListToolsFailed(mcpListToolsFailed) @@ -5448,8 +5436,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -5459,7 +5445,11 @@ internal class ResponseStreamEventTest { val jsonMapper = jsonMapper() val responseStreamEvent = ResponseStreamEvent.ofMcpListToolsFailed( - ResponseMcpListToolsFailedEvent.builder().sequenceNumber(0L).build() + ResponseMcpListToolsFailedEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() ) val roundtrippedResponseStreamEvent = @@ -5474,7 +5464,11 @@ internal class ResponseStreamEventTest { @Test fun ofMcpListToolsInProgress() { val mcpListToolsInProgress = - ResponseMcpListToolsInProgressEvent.builder().sequenceNumber(0L).build() + ResponseMcpListToolsInProgressEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() val responseStreamEvent = ResponseStreamEvent.ofMcpListToolsInProgress(mcpListToolsInProgress) @@ -5528,8 +5522,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).contains(mcpListToolsInProgress) assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -5539,7 +5531,11 @@ internal class ResponseStreamEventTest { val jsonMapper = jsonMapper() val responseStreamEvent = ResponseStreamEvent.ofMcpListToolsInProgress( - ResponseMcpListToolsInProgressEvent.builder().sequenceNumber(0L).build() + ResponseMcpListToolsInProgressEvent.builder() + .itemId("item_id") + .outputIndex(0L) + .sequenceNumber(0L) + .build() ) val roundtrippedResponseStreamEvent = @@ -5616,8 +5612,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.outputTextAnnotationAdded()) .contains(outputTextAnnotationAdded) assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -5825,8 +5819,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).contains(queued) - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -5972,188 +5964,6 @@ internal class ResponseStreamEventTest { assertThat(roundtrippedResponseStreamEvent).isEqualTo(responseStreamEvent) } - @Test - fun ofReasoningDelta() { - val reasoningDelta = - ResponseReasoningDeltaEvent.builder() - .contentIndex(0L) - .delta(JsonValue.from(mapOf())) - .itemId("item_id") - .outputIndex(0L) - .sequenceNumber(0L) - .build() - - val responseStreamEvent = ResponseStreamEvent.ofReasoningDelta(reasoningDelta) - - assertThat(responseStreamEvent.audioDelta()).isEmpty - assertThat(responseStreamEvent.audioDone()).isEmpty - assertThat(responseStreamEvent.audioTranscriptDelta()).isEmpty - assertThat(responseStreamEvent.audioTranscriptDone()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallCodeDelta()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallCodeDone()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallCompleted()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallInProgress()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallInterpreting()).isEmpty - assertThat(responseStreamEvent.completed()).isEmpty - assertThat(responseStreamEvent.contentPartAdded()).isEmpty - assertThat(responseStreamEvent.contentPartDone()).isEmpty - assertThat(responseStreamEvent.created()).isEmpty - assertThat(responseStreamEvent.error()).isEmpty - assertThat(responseStreamEvent.fileSearchCallCompleted()).isEmpty - assertThat(responseStreamEvent.fileSearchCallInProgress()).isEmpty - assertThat(responseStreamEvent.fileSearchCallSearching()).isEmpty - assertThat(responseStreamEvent.functionCallArgumentsDelta()).isEmpty - assertThat(responseStreamEvent.functionCallArgumentsDone()).isEmpty - assertThat(responseStreamEvent.inProgress()).isEmpty - assertThat(responseStreamEvent.failed()).isEmpty - assertThat(responseStreamEvent.incomplete()).isEmpty - assertThat(responseStreamEvent.outputItemAdded()).isEmpty - assertThat(responseStreamEvent.outputItemDone()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryPartAdded()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryPartDone()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryTextDelta()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryTextDone()).isEmpty - assertThat(responseStreamEvent.refusalDelta()).isEmpty - assertThat(responseStreamEvent.refusalDone()).isEmpty - assertThat(responseStreamEvent.outputTextDelta()).isEmpty - assertThat(responseStreamEvent.outputTextDone()).isEmpty - assertThat(responseStreamEvent.webSearchCallCompleted()).isEmpty - assertThat(responseStreamEvent.webSearchCallInProgress()).isEmpty - assertThat(responseStreamEvent.webSearchCallSearching()).isEmpty - assertThat(responseStreamEvent.imageGenerationCallCompleted()).isEmpty - assertThat(responseStreamEvent.imageGenerationCallGenerating()).isEmpty - assertThat(responseStreamEvent.imageGenerationCallInProgress()).isEmpty - assertThat(responseStreamEvent.imageGenerationCallPartialImage()).isEmpty - assertThat(responseStreamEvent.mcpCallArgumentsDelta()).isEmpty - assertThat(responseStreamEvent.mcpCallArgumentsDone()).isEmpty - assertThat(responseStreamEvent.mcpCallCompleted()).isEmpty - assertThat(responseStreamEvent.mcpCallFailed()).isEmpty - assertThat(responseStreamEvent.mcpCallInProgress()).isEmpty - assertThat(responseStreamEvent.mcpListToolsCompleted()).isEmpty - assertThat(responseStreamEvent.mcpListToolsFailed()).isEmpty - assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty - assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty - assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).contains(reasoningDelta) - assertThat(responseStreamEvent.reasoningDone()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty - } - - @Test - fun ofReasoningDeltaRoundtrip() { - val jsonMapper = jsonMapper() - val responseStreamEvent = - ResponseStreamEvent.ofReasoningDelta( - ResponseReasoningDeltaEvent.builder() - .contentIndex(0L) - .delta(JsonValue.from(mapOf())) - .itemId("item_id") - .outputIndex(0L) - .sequenceNumber(0L) - .build() - ) - - val roundtrippedResponseStreamEvent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(responseStreamEvent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedResponseStreamEvent).isEqualTo(responseStreamEvent) - } - - @Test - fun ofReasoningDone() { - val reasoningDone = - ResponseReasoningDoneEvent.builder() - .contentIndex(0L) - .itemId("item_id") - .outputIndex(0L) - .sequenceNumber(0L) - .text("text") - .build() - - val responseStreamEvent = ResponseStreamEvent.ofReasoningDone(reasoningDone) - - assertThat(responseStreamEvent.audioDelta()).isEmpty - assertThat(responseStreamEvent.audioDone()).isEmpty - assertThat(responseStreamEvent.audioTranscriptDelta()).isEmpty - assertThat(responseStreamEvent.audioTranscriptDone()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallCodeDelta()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallCodeDone()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallCompleted()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallInProgress()).isEmpty - assertThat(responseStreamEvent.codeInterpreterCallInterpreting()).isEmpty - assertThat(responseStreamEvent.completed()).isEmpty - assertThat(responseStreamEvent.contentPartAdded()).isEmpty - assertThat(responseStreamEvent.contentPartDone()).isEmpty - assertThat(responseStreamEvent.created()).isEmpty - assertThat(responseStreamEvent.error()).isEmpty - assertThat(responseStreamEvent.fileSearchCallCompleted()).isEmpty - assertThat(responseStreamEvent.fileSearchCallInProgress()).isEmpty - assertThat(responseStreamEvent.fileSearchCallSearching()).isEmpty - assertThat(responseStreamEvent.functionCallArgumentsDelta()).isEmpty - assertThat(responseStreamEvent.functionCallArgumentsDone()).isEmpty - assertThat(responseStreamEvent.inProgress()).isEmpty - assertThat(responseStreamEvent.failed()).isEmpty - assertThat(responseStreamEvent.incomplete()).isEmpty - assertThat(responseStreamEvent.outputItemAdded()).isEmpty - assertThat(responseStreamEvent.outputItemDone()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryPartAdded()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryPartDone()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryTextDelta()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryTextDone()).isEmpty - assertThat(responseStreamEvent.refusalDelta()).isEmpty - assertThat(responseStreamEvent.refusalDone()).isEmpty - assertThat(responseStreamEvent.outputTextDelta()).isEmpty - assertThat(responseStreamEvent.outputTextDone()).isEmpty - assertThat(responseStreamEvent.webSearchCallCompleted()).isEmpty - assertThat(responseStreamEvent.webSearchCallInProgress()).isEmpty - assertThat(responseStreamEvent.webSearchCallSearching()).isEmpty - assertThat(responseStreamEvent.imageGenerationCallCompleted()).isEmpty - assertThat(responseStreamEvent.imageGenerationCallGenerating()).isEmpty - assertThat(responseStreamEvent.imageGenerationCallInProgress()).isEmpty - assertThat(responseStreamEvent.imageGenerationCallPartialImage()).isEmpty - assertThat(responseStreamEvent.mcpCallArgumentsDelta()).isEmpty - assertThat(responseStreamEvent.mcpCallArgumentsDone()).isEmpty - assertThat(responseStreamEvent.mcpCallCompleted()).isEmpty - assertThat(responseStreamEvent.mcpCallFailed()).isEmpty - assertThat(responseStreamEvent.mcpCallInProgress()).isEmpty - assertThat(responseStreamEvent.mcpListToolsCompleted()).isEmpty - assertThat(responseStreamEvent.mcpListToolsFailed()).isEmpty - assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty - assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty - assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).contains(reasoningDone) - assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty - assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty - } - - @Test - fun ofReasoningDoneRoundtrip() { - val jsonMapper = jsonMapper() - val responseStreamEvent = - ResponseStreamEvent.ofReasoningDone( - ResponseReasoningDoneEvent.builder() - .contentIndex(0L) - .itemId("item_id") - .outputIndex(0L) - .sequenceNumber(0L) - .text("text") - .build() - ) - - val roundtrippedResponseStreamEvent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(responseStreamEvent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedResponseStreamEvent).isEqualTo(responseStreamEvent) - } - @Test fun ofReasoningSummaryDelta() { val reasoningSummaryDelta = @@ -6216,8 +6026,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).contains(reasoningSummaryDelta) assertThat(responseStreamEvent.reasoningSummaryDone()).isEmpty } @@ -6307,8 +6115,6 @@ internal class ResponseStreamEventTest { assertThat(responseStreamEvent.mcpListToolsInProgress()).isEmpty assertThat(responseStreamEvent.outputTextAnnotationAdded()).isEmpty assertThat(responseStreamEvent.queued()).isEmpty - assertThat(responseStreamEvent.reasoningDelta()).isEmpty - assertThat(responseStreamEvent.reasoningDone()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDelta()).isEmpty assertThat(responseStreamEvent.reasoningSummaryDone()).contains(reasoningSummaryDone) } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTextDeltaEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTextDeltaEventTest.kt index c68f4f572..de196137c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTextDeltaEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTextDeltaEventTest.kt @@ -16,6 +16,18 @@ internal class ResponseTextDeltaEventTest { .contentIndex(0L) .delta("delta") .itemId("item_id") + .addLogprob( + ResponseTextDeltaEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDeltaEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) .outputIndex(0L) .sequenceNumber(0L) .build() @@ -23,6 +35,19 @@ internal class ResponseTextDeltaEventTest { assertThat(responseTextDeltaEvent.contentIndex()).isEqualTo(0L) assertThat(responseTextDeltaEvent.delta()).isEqualTo("delta") assertThat(responseTextDeltaEvent.itemId()).isEqualTo("item_id") + assertThat(responseTextDeltaEvent.logprobs()) + .containsExactly( + ResponseTextDeltaEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDeltaEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) assertThat(responseTextDeltaEvent.outputIndex()).isEqualTo(0L) assertThat(responseTextDeltaEvent.sequenceNumber()).isEqualTo(0L) } @@ -35,6 +60,18 @@ internal class ResponseTextDeltaEventTest { .contentIndex(0L) .delta("delta") .itemId("item_id") + .addLogprob( + ResponseTextDeltaEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDeltaEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) .outputIndex(0L) .sequenceNumber(0L) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTextDoneEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTextDoneEventTest.kt index a7a6b69e3..e5220b1d8 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTextDoneEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTextDoneEventTest.kt @@ -15,6 +15,18 @@ internal class ResponseTextDoneEventTest { ResponseTextDoneEvent.builder() .contentIndex(0L) .itemId("item_id") + .addLogprob( + ResponseTextDoneEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDoneEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) .outputIndex(0L) .sequenceNumber(0L) .text("text") @@ -22,6 +34,19 @@ internal class ResponseTextDoneEventTest { assertThat(responseTextDoneEvent.contentIndex()).isEqualTo(0L) assertThat(responseTextDoneEvent.itemId()).isEqualTo("item_id") + assertThat(responseTextDoneEvent.logprobs()) + .containsExactly( + ResponseTextDoneEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDoneEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) assertThat(responseTextDoneEvent.outputIndex()).isEqualTo(0L) assertThat(responseTextDoneEvent.sequenceNumber()).isEqualTo(0L) assertThat(responseTextDoneEvent.text()).isEqualTo("text") @@ -34,6 +59,18 @@ internal class ResponseTextDoneEventTest { ResponseTextDoneEvent.builder() .contentIndex(0L) .itemId("item_id") + .addLogprob( + ResponseTextDoneEvent.Logprob.builder() + .token("token") + .logprob(0.0) + .addTopLogprob( + ResponseTextDoneEvent.Logprob.TopLogprob.builder() + .token("token") + .logprob(0.0) + .build() + ) + .build() + ) .outputIndex(0L) .sequenceNumber(0L) .text("text") diff --git a/openai-java-spring-boot-starter/build.gradle.kts b/openai-java-spring-boot-starter/build.gradle.kts new file mode 100644 index 000000000..20c06d076 --- /dev/null +++ b/openai-java-spring-boot-starter/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id("openai.kotlin") + id("openai.publish") +} + +repositories { + mavenCentral() +} + +dependencies { + api(project(":openai-java")) + implementation("org.springframework.boot:spring-boot-autoconfigure:2.7.18") + annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:2.7.18") + + testImplementation("org.springframework.boot:spring-boot-starter-test:2.7.18") + testImplementation("org.assertj:assertj-core:3.25.3") +} diff --git a/openai-java-spring-boot-starter/src/main/kotlin/com/openai/springboot/OpenAIClientAutoConfiguration.kt b/openai-java-spring-boot-starter/src/main/kotlin/com/openai/springboot/OpenAIClientAutoConfiguration.kt new file mode 100644 index 000000000..52c2a818a --- /dev/null +++ b/openai-java-spring-boot-starter/src/main/kotlin/com/openai/springboot/OpenAIClientAutoConfiguration.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.springboot + +import com.openai.client.OpenAIClient +import com.openai.client.okhttp.OpenAIOkHttpClient +import org.springframework.beans.factory.ObjectProvider +import org.springframework.boot.autoconfigure.AutoConfiguration +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.Bean + +@AutoConfiguration +@ConditionalOnClass(OpenAIClient::class) +@EnableConfigurationProperties(OpenAIClientProperties::class) +class OpenAIClientAutoConfiguration { + + @Bean + @ConditionalOnMissingBean + internal fun client( + properties: OpenAIClientProperties, + customizers: ObjectProvider, + ): OpenAIClient = + OpenAIOkHttpClient.builder() + .apply { + properties.baseUrl?.let { baseUrl(it) } + properties.apiKey?.let { apiKey(it) } + properties.organization?.let { organization(it) } + properties.project?.let { project(it) } + properties.webhookSecret?.let { webhookSecret(it) } + customizers.orderedStream().forEach { it.customize(this) } + } + .build() +} diff --git a/openai-java-spring-boot-starter/src/main/kotlin/com/openai/springboot/OpenAIClientCustomizer.kt b/openai-java-spring-boot-starter/src/main/kotlin/com/openai/springboot/OpenAIClientCustomizer.kt new file mode 100644 index 000000000..b86c4b7d7 --- /dev/null +++ b/openai-java-spring-boot-starter/src/main/kotlin/com/openai/springboot/OpenAIClientCustomizer.kt @@ -0,0 +1,10 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.springboot + +import com.openai.client.okhttp.OpenAIOkHttpClient + +fun interface OpenAIClientCustomizer { + + fun customize(builder: OpenAIOkHttpClient.Builder) +} diff --git a/openai-java-spring-boot-starter/src/main/kotlin/com/openai/springboot/OpenAIClientProperties.kt b/openai-java-spring-boot-starter/src/main/kotlin/com/openai/springboot/OpenAIClientProperties.kt new file mode 100644 index 000000000..db410a6b6 --- /dev/null +++ b/openai-java-spring-boot-starter/src/main/kotlin/com/openai/springboot/OpenAIClientProperties.kt @@ -0,0 +1,18 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.springboot + +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.boot.context.properties.ConstructorBinding +import org.springframework.boot.context.properties.bind.Name + +@ConfigurationProperties(prefix = "openai") +internal data class OpenAIClientProperties +@ConstructorBinding +constructor( + @Name("base-url") val baseUrl: String? = null, + @Name("api-key") val apiKey: String? = null, + @Name("org-id") val organization: String? = null, + @Name("project-id") val project: String? = null, + @Name("webhook-secret") val webhookSecret: String? = null, +) diff --git a/openai-java-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/openai-java-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 000000000..d718d25a9 --- /dev/null +++ b/openai-java-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,30 @@ +{ + "properties": [ + { + "name": "openai.base-url", + "type": "java.lang.String", + "defaultValue": "https://api.openai.com/v1", + "sourceType": "com.openai.springboot.OpenAIClientProperties" + }, + { + "name": "openai.api-key", + "type": "java.lang.String", + "sourceType": "com.openai.springboot.OpenAIClientProperties" + }, + { + "name": "openai.org-id", + "type": "java.lang.String", + "sourceType": "com.openai.springboot.OpenAIClientProperties" + }, + { + "name": "openai.project-id", + "type": "java.lang.String", + "sourceType": "com.openai.springboot.OpenAIClientProperties" + }, + { + "name": "openai.webhook-secret", + "type": "java.lang.String", + "sourceType": "com.openai.springboot.OpenAIClientProperties" + } + ] +} \ No newline at end of file diff --git a/openai-java-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/openai-java-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 000000000..d1d2e241e --- /dev/null +++ b/openai-java-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.openai.springboot.OpenAIClientAutoConfiguration \ No newline at end of file diff --git a/openai-java-spring-boot-starter/src/test/kotlin/com/openai/springboot/OpenAIClientAutoConfigurationTest.kt b/openai-java-spring-boot-starter/src/test/kotlin/com/openai/springboot/OpenAIClientAutoConfigurationTest.kt new file mode 100644 index 000000000..18701d8b4 --- /dev/null +++ b/openai-java-spring-boot-starter/src/test/kotlin/com/openai/springboot/OpenAIClientAutoConfigurationTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.springboot + +import com.openai.client.OpenAIClient +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.getBean +import org.springframework.boot.autoconfigure.AutoConfigurations +import org.springframework.boot.test.context.runner.ApplicationContextRunner + +internal class OpenAIClientAutoConfigurationTest { + + private val contextRunner = + ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(OpenAIClientAutoConfiguration::class.java)) + + @Test + fun properties() { + contextRunner + .withPropertyValues( + "openai.base-url=https://api.openai.com/v1", + "openai.api-key=My API Key", + "openai.org-id=My Organization", + "openai.project-id=My Project", + "openai.webhook-secret=My Webhook Secret", + ) + .run { context -> + val properties = context.getBean() + assertThat(properties.baseUrl).isEqualTo("https://api.openai.com/v1") + assertThat(properties.apiKey).isEqualTo("My API Key") + assertThat(properties.organization).isEqualTo("My Organization") + assertThat(properties.project).isEqualTo("My Project") + assertThat(properties.webhookSecret).isEqualTo("My Webhook Secret") + } + } + + @Test + fun client() { + contextRunner + .withPropertyValues( + "openai.base-url=https://api.openai.com/v1", + "openai.api-key=My API Key", + "openai.org-id=My Organization", + "openai.project-id=My Project", + "openai.webhook-secret=My Webhook Secret", + ) + .run { it.getBean() } + } + + @Test + fun clientWithoutRequiredProperties() { + val throwable = catchThrowable { + contextRunner + .withPropertyValues( + "openai.base-url=https://api.openai.com/v1", + "openai.org-id=My Organization", + "openai.project-id=My Project", + "openai.webhook-secret=My Webhook Secret", + ) + .run { it.getBean() } + } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + } + + @Test + fun clientWithCustomizers() { + var customized = false + contextRunner + .withPropertyValues( + "openai.base-url=https://api.openai.com/v1", + "openai.api-key=My API Key", + "openai.org-id=My Organization", + "openai.project-id=My Project", + "openai.webhook-secret=My Webhook Secret", + ) + .withBean( + OpenAIClientCustomizer::class.java, + { OpenAIClientCustomizer { customized = true } }, + ) + .run { + it.getBean() + assertThat(customized).isTrue() + } + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 3c5725fb3..bb5cb08a8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,4 +3,5 @@ rootProject.name = "openai-java-root" include("openai-java") include("openai-java-client-okhttp") include("openai-java-core") +include("openai-java-spring-boot-starter") include("openai-java-example")