diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d52d2b974..a26ebfc1e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.13.0" + ".": "0.14.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b0707b6..88dd14573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## 0.14.0 (2025-01-24) + +Full Changelog: [v0.13.0...v0.14.0](https://github.com/openai/openai-java/compare/v0.13.0...v0.14.0) + +### ⚠ BREAKING CHANGES + +* **client:** better union variant method and variable names ([#157](https://github.com/openai/openai-java/issues/157)) + +### Features + +* **client:** better union variant method and variable names ([#157](https://github.com/openai/openai-java/issues/157)) ([da5bce5](https://github.com/openai/openai-java/commit/da5bce5d00af53d7297133af09352a7176c2f83e)) + + +### Bug Fixes + +* examples ([3473781](https://github.com/openai/openai-java/commit/3473781ca26d25531f368485291f9972e600631b)) + + +### Chores + +* **internal:** swap `checkNotNull` to `checkRequired` ([#156](https://github.com/openai/openai-java/issues/156)) ([d6f65f7](https://github.com/openai/openai-java/commit/d6f65f7c0e25adbce97b22f7a649f6c3eaeb61ed)) + + +### Documentation + +* move up requirements section ([#154](https://github.com/openai/openai-java/issues/154)) ([48fc646](https://github.com/openai/openai-java/commit/48fc646957ad4ff69c93b40d59ea9d5e8a22eece)) +* update readme ([#152](https://github.com/openai/openai-java/issues/152)) ([293dc47](https://github.com/openai/openai-java/commit/293dc47b242e204b6c6e419002dbb560cb455169)) + ## 0.13.0 (2025-01-22) Full Changelog: [v0.12.0...v0.13.0](https://github.com/openai/openai-java/compare/v0.12.0...v0.13.0) diff --git a/README.md b/README.md index 0a0be5921..56426634b 100644 --- a/README.md +++ b/README.md @@ -9,43 +9,43 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.13.0) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.13.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.13.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.14.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.14.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.14.0) -The OpenAI Java SDK provides convenient access to the OpenAI REST API from applications written in Java. It includes helper classes with helpful types and documentation for every request and response property. +The OpenAI Java SDK provides convenient access to the OpenAI REST API from applications written in Java. -## Documentation +The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/0.0.1). -The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). - ---- - -## Getting started - -### Install dependencies - -#### Gradle +## Installation +### Gradle + ```kotlin -implementation("com.openai:openai-java:0.13.0") +implementation("com.openai:openai-java:0.14.0") ``` -#### Maven +### Maven ```xml com.openai openai-java - 0.13.0 + 0.14.0 ``` +## Requirements + +This library requires Java 8 or later. + +## Usage + ### Configure the client Use `OpenAIOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`: @@ -418,7 +418,3 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. We are keen for your feedback; please open an [issue](https://www.github.com/openai/openai-java/issues) with questions, bugs, or suggestions. - -## Requirements - -This library requires Java 8 or later. diff --git a/build.gradle.kts b/build.gradle.kts index 787da4cab..49d6ac4ba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "0.13.0" // x-release-please-version + version = "0.14.0" // x-release-please-version } subprojects { diff --git a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExample.java b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExample.java index 962d69fb6..5ebe02832 100644 --- a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExample.java +++ b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExample.java @@ -31,10 +31,10 @@ public static void main(String[] args) { OpenAIClient client = clientBuilder.build(); ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() - .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( + .addMessage( ChatCompletionUserMessageParam.builder() - .content(ChatCompletionUserMessageParam.Content.ofTextContent("Who won the world series in 2020?")) - .build())) + .content("Who won the world series in 2020?") + .build()) .model("gpt-4o") .build(); diff --git a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExampleAsync.java b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExampleAsync.java index 1ab865906..c567697ef 100644 --- a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExampleAsync.java +++ b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExampleAsync.java @@ -32,10 +32,10 @@ public static void main(String[] args) { OpenAIClientAsync client = asyncClientBuilder.build(); ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() - .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( + .addMessage( ChatCompletionUserMessageParam.builder() - .content(ChatCompletionUserMessageParam.Content.ofTextContent("Who won the world series in 2020?")) - .build())) + .content("Who won the world series in 2020?") + .build()) .model("gpt-4o") .build(); diff --git a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExample.java b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExample.java index e27ecdd46..a7cc2cfad 100644 --- a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExample.java +++ b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExample.java @@ -37,10 +37,10 @@ public static void main(String[] args) { OpenAIClient client = clientBuilder.build(); ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() - .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( + .addMessage( ChatCompletionUserMessageParam.builder() - .content(ChatCompletionUserMessageParam.Content.ofTextContent("Who won the world series in 2020?")) - .build())) + .content("Who won the world series in 2020?") + .build()) .model("gpt-4o") .build(); diff --git a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExampleAsync.java b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExampleAsync.java index e526bdc9c..b557e2337 100644 --- a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExampleAsync.java +++ b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExampleAsync.java @@ -37,10 +37,10 @@ public static void main(String[] args) { OpenAIClientAsync asyncClient = asyncClientBuilder.build(); ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() - .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( + .addMessage( ChatCompletionUserMessageParam.builder() - .content(ChatCompletionUserMessageParam.Content.ofTextContent("Who won the world series in 2020?")) - .build())) + .content("Who won the world series in 2020?") + .build()) .model("gpt-4o") .build(); diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt index 8862168e1..01fe5e8a6 100644 --- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt +++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt @@ -1,6 +1,7 @@ package com.openai.client.okhttp import com.openai.core.RequestOptions +import com.openai.core.checkRequired import com.openai.core.http.Headers import com.openai.core.http.HttpClient import com.openai.core.http.HttpMethod @@ -192,7 +193,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) .proxy(proxy) .build(), - checkNotNull(baseUrl) { "`baseUrl` is required but was not set" }, + checkRequired("baseUrl", baseUrl), ) } } diff --git a/openai-java-core/src/main/kotlin/com/openai/core/Check.kt b/openai-java-core/src/main/kotlin/com/openai/core/Check.kt index 6c9f5e18b..1ff8c724b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/Check.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/Check.kt @@ -2,8 +2,7 @@ package com.openai.core -@JvmSynthetic -internal fun checkRequired(name: String, value: T?): T = +fun checkRequired(name: String, value: T?): T = checkNotNull(value) { "`$name` is required, but was not set" } @JvmSynthetic diff --git a/openai-java-core/src/main/kotlin/com/openai/core/http/HttpRequest.kt b/openai-java-core/src/main/kotlin/com/openai/core/http/HttpRequest.kt index f83460af0..2bafe1107 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/http/HttpRequest.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/http/HttpRequest.kt @@ -1,5 +1,6 @@ package com.openai.core.http +import com.openai.core.checkRequired import com.openai.core.toImmutable class HttpRequest @@ -134,7 +135,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( - checkNotNull(method) { "`method` is required but was not set" }, + checkRequired("method", method), url, pathSegments.toImmutable(), headers.build(), diff --git a/openai-java-core/src/main/kotlin/com/openai/core/http/RetryingHttpClient.kt b/openai-java-core/src/main/kotlin/com/openai/core/http/RetryingHttpClient.kt index 5402fd52b..a20fd1a56 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/http/RetryingHttpClient.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/http/RetryingHttpClient.kt @@ -1,6 +1,7 @@ package com.openai.core.http import com.openai.core.RequestOptions +import com.openai.core.checkRequired import com.openai.errors.OpenAIIoException import java.io.IOException import java.time.Clock @@ -259,7 +260,7 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( - checkNotNull(httpClient) { "`httpClient` is required but was not set" }, + checkRequired("httpClient", httpClient), clock, maxRetries, idempotencyHeader, diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Annotation.kt b/openai-java-core/src/main/kotlin/com/openai/models/Annotation.kt index c88dd472d..ad46efd1f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Annotation.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Annotation.kt @@ -27,8 +27,8 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = Annotation.Serializer::class) class Annotation private constructor( - private val fileCitationAnnotation: FileCitationAnnotation? = null, - private val filePathAnnotation: FilePathAnnotation? = null, + private val fileCitation: FileCitationAnnotation? = null, + private val filePath: FilePathAnnotation? = null, private val _json: JsonValue? = null, ) { @@ -37,41 +37,37 @@ private constructor( * with the assistant or the message. Generated when the assistant uses the "file_search" tool * to search files. */ - fun fileCitationAnnotation(): Optional = - Optional.ofNullable(fileCitationAnnotation) + fun fileCitation(): Optional = Optional.ofNullable(fileCitation) /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool to * generate a file. */ - fun filePathAnnotation(): Optional = Optional.ofNullable(filePathAnnotation) + fun filePath(): Optional = Optional.ofNullable(filePath) - fun isFileCitationAnnotation(): Boolean = fileCitationAnnotation != null + fun isFileCitation(): Boolean = fileCitation != null - fun isFilePathAnnotation(): Boolean = filePathAnnotation != null + fun isFilePath(): Boolean = filePath != null /** * A citation within the message that points to a specific quote from a specific File associated * with the assistant or the message. Generated when the assistant uses the "file_search" tool * to search files. */ - fun asFileCitationAnnotation(): FileCitationAnnotation = - fileCitationAnnotation.getOrThrow("fileCitationAnnotation") + fun asFileCitation(): FileCitationAnnotation = fileCitation.getOrThrow("fileCitation") /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool to * generate a file. */ - fun asFilePathAnnotation(): FilePathAnnotation = - filePathAnnotation.getOrThrow("filePathAnnotation") + fun asFilePath(): FilePathAnnotation = filePath.getOrThrow("filePath") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - fileCitationAnnotation != null -> - visitor.visitFileCitationAnnotation(fileCitationAnnotation) - filePathAnnotation != null -> visitor.visitFilePathAnnotation(filePathAnnotation) + fileCitation != null -> visitor.visitFileCitation(fileCitation) + filePath != null -> visitor.visitFilePath(filePath) else -> visitor.unknown(_json) } } @@ -85,14 +81,12 @@ private constructor( accept( object : Visitor { - override fun visitFileCitationAnnotation( - fileCitationAnnotation: FileCitationAnnotation - ) { - fileCitationAnnotation.validate() + override fun visitFileCitation(fileCitation: FileCitationAnnotation) { + fileCitation.validate() } - override fun visitFilePathAnnotation(filePathAnnotation: FilePathAnnotation) { - filePathAnnotation.validate() + override fun visitFilePath(filePath: FilePathAnnotation) { + filePath.validate() } } ) @@ -104,16 +98,15 @@ private constructor( return true } - return /* spotless:off */ other is Annotation && fileCitationAnnotation == other.fileCitationAnnotation && filePathAnnotation == other.filePathAnnotation /* spotless:on */ + return /* spotless:off */ other is Annotation && fileCitation == other.fileCitation && filePath == other.filePath /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(fileCitationAnnotation, filePathAnnotation) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(fileCitation, filePath) /* spotless:on */ override fun toString(): String = when { - fileCitationAnnotation != null -> - "Annotation{fileCitationAnnotation=$fileCitationAnnotation}" - filePathAnnotation != null -> "Annotation{filePathAnnotation=$filePathAnnotation}" + fileCitation != null -> "Annotation{fileCitation=$fileCitation}" + filePath != null -> "Annotation{filePath=$filePath}" _json != null -> "Annotation{_unknown=$_json}" else -> throw IllegalStateException("Invalid Annotation") } @@ -126,16 +119,14 @@ private constructor( * "file_search" tool to search files. */ @JvmStatic - fun ofFileCitationAnnotation(fileCitationAnnotation: FileCitationAnnotation) = - Annotation(fileCitationAnnotation = fileCitationAnnotation) + fun ofFileCitation(fileCitation: FileCitationAnnotation) = + Annotation(fileCitation = fileCitation) /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool * to generate a file. */ - @JvmStatic - fun ofFilePathAnnotation(filePathAnnotation: FilePathAnnotation) = - Annotation(filePathAnnotation = filePathAnnotation) + @JvmStatic fun ofFilePath(filePath: FilePathAnnotation) = Annotation(filePath = filePath) } interface Visitor { @@ -145,13 +136,13 @@ private constructor( * associated with the assistant or the message. Generated when the assistant uses the * "file_search" tool to search files. */ - fun visitFileCitationAnnotation(fileCitationAnnotation: FileCitationAnnotation): T + fun visitFileCitation(fileCitation: FileCitationAnnotation): T /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool * to generate a file. */ - fun visitFilePathAnnotation(filePathAnnotation: FilePathAnnotation): T + fun visitFilePath(filePath: FilePathAnnotation): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown Annotation: $json") @@ -168,13 +159,13 @@ private constructor( "file_citation" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Annotation(fileCitationAnnotation = it, _json = json) + return Annotation(fileCitation = it, _json = json) } } "file_path" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Annotation(filePathAnnotation = it, _json = json) + return Annotation(filePath = it, _json = json) } } } @@ -191,9 +182,8 @@ private constructor( provider: SerializerProvider ) { when { - value.fileCitationAnnotation != null -> - generator.writeObject(value.fileCitationAnnotation) - value.filePathAnnotation != null -> generator.writeObject(value.filePathAnnotation) + value.fileCitation != null -> generator.writeObject(value.fileCitation) + value.filePath != null -> generator.writeObject(value.filePath) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Annotation") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/AnnotationDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/AnnotationDelta.kt index 76bfbfadd..43367d2ee 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AnnotationDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AnnotationDelta.kt @@ -27,8 +27,8 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = AnnotationDelta.Serializer::class) class AnnotationDelta private constructor( - private val fileCitationDeltaAnnotation: FileCitationDeltaAnnotation? = null, - private val filePathDeltaAnnotation: FilePathDeltaAnnotation? = null, + private val fileCitation: FileCitationDeltaAnnotation? = null, + private val filePath: FilePathDeltaAnnotation? = null, private val _json: JsonValue? = null, ) { @@ -37,43 +37,37 @@ private constructor( * with the assistant or the message. Generated when the assistant uses the "file_search" tool * to search files. */ - fun fileCitationDeltaAnnotation(): Optional = - Optional.ofNullable(fileCitationDeltaAnnotation) + fun fileCitation(): Optional = Optional.ofNullable(fileCitation) /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool to * generate a file. */ - fun filePathDeltaAnnotation(): Optional = - Optional.ofNullable(filePathDeltaAnnotation) + fun filePath(): Optional = Optional.ofNullable(filePath) - fun isFileCitationDeltaAnnotation(): Boolean = fileCitationDeltaAnnotation != null + fun isFileCitation(): Boolean = fileCitation != null - fun isFilePathDeltaAnnotation(): Boolean = filePathDeltaAnnotation != null + fun isFilePath(): Boolean = filePath != null /** * A citation within the message that points to a specific quote from a specific File associated * with the assistant or the message. Generated when the assistant uses the "file_search" tool * to search files. */ - fun asFileCitationDeltaAnnotation(): FileCitationDeltaAnnotation = - fileCitationDeltaAnnotation.getOrThrow("fileCitationDeltaAnnotation") + fun asFileCitation(): FileCitationDeltaAnnotation = fileCitation.getOrThrow("fileCitation") /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool to * generate a file. */ - fun asFilePathDeltaAnnotation(): FilePathDeltaAnnotation = - filePathDeltaAnnotation.getOrThrow("filePathDeltaAnnotation") + fun asFilePath(): FilePathDeltaAnnotation = filePath.getOrThrow("filePath") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - fileCitationDeltaAnnotation != null -> - visitor.visitFileCitationDeltaAnnotation(fileCitationDeltaAnnotation) - filePathDeltaAnnotation != null -> - visitor.visitFilePathDeltaAnnotation(filePathDeltaAnnotation) + fileCitation != null -> visitor.visitFileCitation(fileCitation) + filePath != null -> visitor.visitFilePath(filePath) else -> visitor.unknown(_json) } } @@ -87,16 +81,12 @@ private constructor( accept( object : Visitor { - override fun visitFileCitationDeltaAnnotation( - fileCitationDeltaAnnotation: FileCitationDeltaAnnotation - ) { - fileCitationDeltaAnnotation.validate() + override fun visitFileCitation(fileCitation: FileCitationDeltaAnnotation) { + fileCitation.validate() } - override fun visitFilePathDeltaAnnotation( - filePathDeltaAnnotation: FilePathDeltaAnnotation - ) { - filePathDeltaAnnotation.validate() + override fun visitFilePath(filePath: FilePathDeltaAnnotation) { + filePath.validate() } } ) @@ -108,17 +98,15 @@ private constructor( return true } - return /* spotless:off */ other is AnnotationDelta && fileCitationDeltaAnnotation == other.fileCitationDeltaAnnotation && filePathDeltaAnnotation == other.filePathDeltaAnnotation /* spotless:on */ + return /* spotless:off */ other is AnnotationDelta && fileCitation == other.fileCitation && filePath == other.filePath /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(fileCitationDeltaAnnotation, filePathDeltaAnnotation) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(fileCitation, filePath) /* spotless:on */ override fun toString(): String = when { - fileCitationDeltaAnnotation != null -> - "AnnotationDelta{fileCitationDeltaAnnotation=$fileCitationDeltaAnnotation}" - filePathDeltaAnnotation != null -> - "AnnotationDelta{filePathDeltaAnnotation=$filePathDeltaAnnotation}" + fileCitation != null -> "AnnotationDelta{fileCitation=$fileCitation}" + filePath != null -> "AnnotationDelta{filePath=$filePath}" _json != null -> "AnnotationDelta{_unknown=$_json}" else -> throw IllegalStateException("Invalid AnnotationDelta") } @@ -131,17 +119,15 @@ private constructor( * "file_search" tool to search files. */ @JvmStatic - fun ofFileCitationDeltaAnnotation( - fileCitationDeltaAnnotation: FileCitationDeltaAnnotation - ) = AnnotationDelta(fileCitationDeltaAnnotation = fileCitationDeltaAnnotation) + fun ofFileCitation(fileCitation: FileCitationDeltaAnnotation) = + AnnotationDelta(fileCitation = fileCitation) /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool * to generate a file. */ @JvmStatic - fun ofFilePathDeltaAnnotation(filePathDeltaAnnotation: FilePathDeltaAnnotation) = - AnnotationDelta(filePathDeltaAnnotation = filePathDeltaAnnotation) + fun ofFilePath(filePath: FilePathDeltaAnnotation) = AnnotationDelta(filePath = filePath) } interface Visitor { @@ -151,15 +137,13 @@ private constructor( * associated with the assistant or the message. Generated when the assistant uses the * "file_search" tool to search files. */ - fun visitFileCitationDeltaAnnotation( - fileCitationDeltaAnnotation: FileCitationDeltaAnnotation - ): T + fun visitFileCitation(fileCitation: FileCitationDeltaAnnotation): T /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool * to generate a file. */ - fun visitFilePathDeltaAnnotation(filePathDeltaAnnotation: FilePathDeltaAnnotation): T + fun visitFilePath(filePath: FilePathDeltaAnnotation): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown AnnotationDelta: $json") @@ -178,7 +162,7 @@ private constructor( it.validate() } ?.let { - return AnnotationDelta(fileCitationDeltaAnnotation = it, _json = json) + return AnnotationDelta(fileCitation = it, _json = json) } } "file_path" -> { @@ -186,7 +170,7 @@ private constructor( it.validate() } ?.let { - return AnnotationDelta(filePathDeltaAnnotation = it, _json = json) + return AnnotationDelta(filePath = it, _json = json) } } } @@ -203,10 +187,8 @@ private constructor( provider: SerializerProvider ) { when { - value.fileCitationDeltaAnnotation != null -> - generator.writeObject(value.fileCitationDeltaAnnotation) - value.filePathDeltaAnnotation != null -> - generator.writeObject(value.filePathDeltaAnnotation) + value.fileCitation != null -> generator.writeObject(value.fileCitation) + value.filePath != null -> generator.writeObject(value.filePath) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid AnnotationDelta") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt b/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt index 86e9b7bef..2107903cc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt @@ -407,22 +407,20 @@ private constructor( * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(AssistantTool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(AssistantTool.ofCodeInterpreter(codeInterpreter)) /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(fileSearchTool: FileSearchTool) = - addTool(AssistantTool.ofFileSearchTool(fileSearchTool)) + fun addTool(fileSearch: FileSearchTool) = addTool(AssistantTool.ofFileSearch(fileSearch)) /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(functionTool: FunctionTool) = - addTool(AssistantTool.ofFunctionTool(functionTool)) + fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function)) /** * Specifies the format that the model must output. Compatible with diff --git a/openai-java-core/src/main/kotlin/com/openai/models/AssistantTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/AssistantTool.kt index 0a9b6aa7b..ee54f771c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AssistantTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AssistantTool.kt @@ -22,39 +22,37 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = AssistantTool.Serializer::class) class AssistantTool private constructor( - private val codeInterpreterTool: CodeInterpreterTool? = null, - private val fileSearchTool: FileSearchTool? = null, - private val functionTool: FunctionTool? = null, + private val codeInterpreter: CodeInterpreterTool? = null, + private val fileSearch: FileSearchTool? = null, + private val function: FunctionTool? = null, private val _json: JsonValue? = null, ) { - fun codeInterpreterTool(): Optional = - Optional.ofNullable(codeInterpreterTool) + fun codeInterpreter(): Optional = Optional.ofNullable(codeInterpreter) - fun fileSearchTool(): Optional = Optional.ofNullable(fileSearchTool) + fun fileSearch(): Optional = Optional.ofNullable(fileSearch) - fun functionTool(): Optional = Optional.ofNullable(functionTool) + fun function(): Optional = Optional.ofNullable(function) - fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null + fun isCodeInterpreter(): Boolean = codeInterpreter != null - fun isFileSearchTool(): Boolean = fileSearchTool != null + fun isFileSearch(): Boolean = fileSearch != null - fun isFunctionTool(): Boolean = functionTool != null + fun isFunction(): Boolean = function != null - fun asCodeInterpreterTool(): CodeInterpreterTool = - codeInterpreterTool.getOrThrow("codeInterpreterTool") + fun asCodeInterpreter(): CodeInterpreterTool = codeInterpreter.getOrThrow("codeInterpreter") - fun asFileSearchTool(): FileSearchTool = fileSearchTool.getOrThrow("fileSearchTool") + fun asFileSearch(): FileSearchTool = fileSearch.getOrThrow("fileSearch") - fun asFunctionTool(): FunctionTool = functionTool.getOrThrow("functionTool") + fun asFunction(): FunctionTool = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - codeInterpreterTool != null -> visitor.visitCodeInterpreterTool(codeInterpreterTool) - fileSearchTool != null -> visitor.visitFileSearchTool(fileSearchTool) - functionTool != null -> visitor.visitFunctionTool(functionTool) + codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) + fileSearch != null -> visitor.visitFileSearch(fileSearch) + function != null -> visitor.visitFunction(function) else -> visitor.unknown(_json) } } @@ -68,16 +66,16 @@ private constructor( accept( object : Visitor { - override fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool) { - codeInterpreterTool.validate() + override fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool) { + codeInterpreter.validate() } - override fun visitFileSearchTool(fileSearchTool: FileSearchTool) { - fileSearchTool.validate() + override fun visitFileSearch(fileSearch: FileSearchTool) { + fileSearch.validate() } - override fun visitFunctionTool(functionTool: FunctionTool) { - functionTool.validate() + override fun visitFunction(function: FunctionTool) { + function.validate() } } ) @@ -89,16 +87,16 @@ private constructor( return true } - return /* spotless:off */ other is AssistantTool && codeInterpreterTool == other.codeInterpreterTool && fileSearchTool == other.fileSearchTool && functionTool == other.functionTool /* spotless:on */ + return /* spotless:off */ other is AssistantTool && codeInterpreter == other.codeInterpreter && fileSearch == other.fileSearch && function == other.function /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterTool, fileSearchTool, functionTool) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreter, fileSearch, function) /* spotless:on */ override fun toString(): String = when { - codeInterpreterTool != null -> "AssistantTool{codeInterpreterTool=$codeInterpreterTool}" - fileSearchTool != null -> "AssistantTool{fileSearchTool=$fileSearchTool}" - functionTool != null -> "AssistantTool{functionTool=$functionTool}" + codeInterpreter != null -> "AssistantTool{codeInterpreter=$codeInterpreter}" + fileSearch != null -> "AssistantTool{fileSearch=$fileSearch}" + function != null -> "AssistantTool{function=$function}" _json != null -> "AssistantTool{_unknown=$_json}" else -> throw IllegalStateException("Invalid AssistantTool") } @@ -106,24 +104,22 @@ private constructor( companion object { @JvmStatic - fun ofCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool) = - AssistantTool(codeInterpreterTool = codeInterpreterTool) + fun ofCodeInterpreter(codeInterpreter: CodeInterpreterTool) = + AssistantTool(codeInterpreter = codeInterpreter) @JvmStatic - fun ofFileSearchTool(fileSearchTool: FileSearchTool) = - AssistantTool(fileSearchTool = fileSearchTool) + fun ofFileSearch(fileSearch: FileSearchTool) = AssistantTool(fileSearch = fileSearch) - @JvmStatic - fun ofFunctionTool(functionTool: FunctionTool) = AssistantTool(functionTool = functionTool) + @JvmStatic fun ofFunction(function: FunctionTool) = AssistantTool(function = function) } interface Visitor { - fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T + fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool): T - fun visitFileSearchTool(fileSearchTool: FileSearchTool): T + fun visitFileSearch(fileSearch: FileSearchTool): T - fun visitFunctionTool(functionTool: FunctionTool): T + fun visitFunction(function: FunctionTool): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown AssistantTool: $json") @@ -140,19 +136,19 @@ private constructor( "code_interpreter" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return AssistantTool(codeInterpreterTool = it, _json = json) + return AssistantTool(codeInterpreter = it, _json = json) } } "file_search" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return AssistantTool(fileSearchTool = it, _json = json) + return AssistantTool(fileSearch = it, _json = json) } } "function" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return AssistantTool(functionTool = it, _json = json) + return AssistantTool(function = it, _json = json) } } } @@ -169,10 +165,9 @@ private constructor( provider: SerializerProvider ) { when { - value.codeInterpreterTool != null -> - generator.writeObject(value.codeInterpreterTool) - value.fileSearchTool != null -> generator.writeObject(value.fileSearchTool) - value.functionTool != null -> generator.writeObject(value.functionTool) + value.codeInterpreter != null -> generator.writeObject(value.codeInterpreter) + value.fileSearch != null -> generator.writeObject(value.fileSearch) + value.function != null -> generator.writeObject(value.function) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid AssistantTool") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt index 858eb36aa..e2a9f60e9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt @@ -768,22 +768,21 @@ constructor( * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(AssistantTool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(AssistantTool.ofCodeInterpreter(codeInterpreter)) /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(fileSearchTool: FileSearchTool) = - addTool(AssistantTool.ofFileSearchTool(fileSearchTool)) + fun addTool(fileSearch: FileSearchTool) = + addTool(AssistantTool.ofFileSearch(fileSearch)) /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(functionTool: FunctionTool) = - addTool(AssistantTool.ofFunctionTool(functionTool)) + fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function)) /** * An alternative to sampling with temperature, called nucleus sampling, where the model @@ -1189,21 +1188,19 @@ constructor( * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = apply { - body.addTool(codeInterpreterTool) - } + fun addTool(codeInterpreter: CodeInterpreterTool) = apply { body.addTool(codeInterpreter) } /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(fileSearchTool: FileSearchTool) = apply { body.addTool(fileSearchTool) } + fun addTool(fileSearch: FileSearchTool) = apply { body.addTool(fileSearch) } /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(functionTool: FunctionTool) = apply { body.addTool(functionTool) } + fun addTool(function: FunctionTool) = apply { body.addTool(function) } /** * An alternative to sampling with temperature, called nucleus sampling, where the model @@ -1927,27 +1924,15 @@ constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` * of `800` and `chunk_overlap_tokens` of `400`. */ - fun chunkingStrategy( - autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam - ) = - chunkingStrategy( - FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam( - autoFileChunkingStrategyParam - ) - ) + fun chunkingStrategy(auto: AutoFileChunkingStrategyParam) = + chunkingStrategy(FileChunkingStrategyParam.ofAuto(auto)) /** * The chunking strategy used to chunk the file(s). If not set, will use the * `auto` strategy. Only applicable if `file_ids` is non-empty. */ - fun chunkingStrategy( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) = - chunkingStrategy( - FileChunkingStrategyParam.ofStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam - ) - ) + fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) = + chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_)) /** * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantUpdateParams.kt index d2733429c..3b1f20426 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantUpdateParams.kt @@ -770,22 +770,21 @@ constructor( * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(AssistantTool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(AssistantTool.ofCodeInterpreter(codeInterpreter)) /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(fileSearchTool: FileSearchTool) = - addTool(AssistantTool.ofFileSearchTool(fileSearchTool)) + fun addTool(fileSearch: FileSearchTool) = + addTool(AssistantTool.ofFileSearch(fileSearch)) /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(functionTool: FunctionTool) = - addTool(AssistantTool.ofFunctionTool(functionTool)) + fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function)) /** * An alternative to sampling with temperature, called nucleus sampling, where the model @@ -1187,21 +1186,19 @@ constructor( * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = apply { - body.addTool(codeInterpreterTool) - } + fun addTool(codeInterpreter: CodeInterpreterTool) = apply { body.addTool(codeInterpreter) } /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(fileSearchTool: FileSearchTool) = apply { body.addTool(fileSearchTool) } + fun addTool(fileSearch: FileSearchTool) = apply { body.addTool(fileSearch) } /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per * assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. */ - fun addTool(functionTool: FunctionTool) = apply { body.addTool(functionTool) } + fun addTool(function: FunctionTool) = apply { body.addTool(function) } /** * An alternative to sampling with temperature, called nucleus sampling, where the model diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt index 7d93d8c94..3609b3691 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt @@ -1152,21 +1152,20 @@ constructor( * Override the tools the assistant can use for this run. This is useful for modifying * the behavior on a per-run basis. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(Tool.ofCodeInterpreter(codeInterpreter)) /** * Override the tools the assistant can use for this run. This is useful for modifying * the behavior on a per-run basis. */ - fun addTool(fileSearchTool: FileSearchTool) = - addTool(Tool.ofFileSearchTool(fileSearchTool)) + fun addTool(fileSearch: FileSearchTool) = addTool(Tool.ofFileSearch(fileSearch)) /** * Override the tools the assistant can use for this run. This is useful for modifying * the behavior on a per-run basis. */ - fun addTool(functionTool: FunctionTool) = addTool(Tool.ofFunctionTool(functionTool)) + fun addTool(function: FunctionTool) = addTool(Tool.ofFunction(function)) /** * An alternative to sampling with temperature, called nucleus sampling, where the model @@ -1753,21 +1752,19 @@ constructor( * Override the tools the assistant can use for this run. This is useful for modifying the * behavior on a per-run basis. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = apply { - body.addTool(codeInterpreterTool) - } + fun addTool(codeInterpreter: CodeInterpreterTool) = apply { body.addTool(codeInterpreter) } /** * Override the tools the assistant can use for this run. This is useful for modifying the * behavior on a per-run basis. */ - fun addTool(fileSearchTool: FileSearchTool) = apply { body.addTool(fileSearchTool) } + fun addTool(fileSearch: FileSearchTool) = apply { body.addTool(fileSearch) } /** * Override the tools the assistant can use for this run. This is useful for modifying the * behavior on a per-run basis. */ - fun addTool(functionTool: FunctionTool) = apply { body.addTool(functionTool) } + fun addTool(function: FunctionTool) = apply { body.addTool(function) } /** * An alternative to sampling with temperature, called nucleus sampling, where the model @@ -2253,7 +2250,7 @@ constructor( fun content(content: JsonField) = apply { this.content = content } /** The text contents of the message. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type, each can be of type `text` or @@ -2362,13 +2359,13 @@ constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { /** The text contents of the message. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type, each can be of type `text` or @@ -2378,12 +2375,12 @@ constructor( fun arrayOfContentParts(): Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null /** The text contents of the message. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type, each can be of type `text` or @@ -2397,7 +2394,7 @@ constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) @@ -2413,7 +2410,7 @@ constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -2430,14 +2427,14 @@ constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" @@ -2447,8 +2444,7 @@ constructor( companion object { /** The text contents of the message. */ - @JvmStatic - fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type, each can be of type `text` or @@ -2464,7 +2460,7 @@ constructor( interface Visitor { /** The text contents of the message. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type, each can be of type `text` or @@ -2487,7 +2483,7 @@ constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } @@ -2508,7 +2504,7 @@ constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) @@ -2673,8 +2669,8 @@ constructor( } /** The tools to add this file to. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(Tool.ofCodeInterpreter(codeInterpreter)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2710,22 +2706,22 @@ constructor( @JsonSerialize(using = Tool.Serializer::class) class Tool private constructor( - private val codeInterpreterTool: CodeInterpreterTool? = null, + private val codeInterpreter: CodeInterpreterTool? = null, private val fileSearch: JsonValue? = null, private val _json: JsonValue? = null, ) { - fun codeInterpreterTool(): Optional = - Optional.ofNullable(codeInterpreterTool) + fun codeInterpreter(): Optional = + Optional.ofNullable(codeInterpreter) fun fileSearch(): Optional = Optional.ofNullable(fileSearch) - fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null + fun isCodeInterpreter(): Boolean = codeInterpreter != null fun isFileSearch(): Boolean = fileSearch != null - fun asCodeInterpreterTool(): CodeInterpreterTool = - codeInterpreterTool.getOrThrow("codeInterpreterTool") + fun asCodeInterpreter(): CodeInterpreterTool = + codeInterpreter.getOrThrow("codeInterpreter") fun asFileSearch(): JsonValue = fileSearch.getOrThrow("fileSearch") @@ -2733,8 +2729,7 @@ constructor( fun accept(visitor: Visitor): T { return when { - codeInterpreterTool != null -> - visitor.visitCodeInterpreterTool(codeInterpreterTool) + codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) fileSearch != null -> visitor.visitFileSearch(fileSearch) else -> visitor.unknown(_json) } @@ -2749,10 +2744,10 @@ constructor( accept( object : Visitor { - override fun visitCodeInterpreterTool( - codeInterpreterTool: CodeInterpreterTool + override fun visitCodeInterpreter( + codeInterpreter: CodeInterpreterTool ) { - codeInterpreterTool.validate() + codeInterpreter.validate() } override fun visitFileSearch(fileSearch: JsonValue) { @@ -2774,15 +2769,14 @@ constructor( return true } - return /* spotless:off */ other is Tool && codeInterpreterTool == other.codeInterpreterTool && fileSearch == other.fileSearch /* spotless:on */ + return /* spotless:off */ other is Tool && codeInterpreter == other.codeInterpreter && fileSearch == other.fileSearch /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterTool, fileSearch) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreter, fileSearch) /* spotless:on */ override fun toString(): String = when { - codeInterpreterTool != null -> - "Tool{codeInterpreterTool=$codeInterpreterTool}" + codeInterpreter != null -> "Tool{codeInterpreter=$codeInterpreter}" fileSearch != null -> "Tool{fileSearch=$fileSearch}" _json != null -> "Tool{_unknown=$_json}" else -> throw IllegalStateException("Invalid Tool") @@ -2791,8 +2785,8 @@ constructor( companion object { @JvmStatic - fun ofCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool) = - Tool(codeInterpreterTool = codeInterpreterTool) + fun ofCodeInterpreter(codeInterpreter: CodeInterpreterTool) = + Tool(codeInterpreter = codeInterpreter) @JvmStatic fun ofFileSearch() = @@ -2801,7 +2795,7 @@ constructor( interface Visitor { - fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T + fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool): T fun visitFileSearch(fileSearch: JsonValue): T @@ -2823,7 +2817,7 @@ constructor( it.validate() } ?.let { - return Tool(codeInterpreterTool = it, _json = json) + return Tool(codeInterpreter = it, _json = json) } } "file_search" -> { @@ -2859,8 +2853,8 @@ constructor( provider: SerializerProvider ) { when { - value.codeInterpreterTool != null -> - generator.writeObject(value.codeInterpreterTool) + value.codeInterpreter != null -> + generator.writeObject(value.codeInterpreter) value.fileSearch != null -> generator.writeObject(value.fileSearch) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Tool") @@ -3471,28 +3465,15 @@ constructor( * The default strategy. This strategy currently uses a * `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. */ - fun chunkingStrategy( - autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam - ) = - chunkingStrategy( - FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam( - autoFileChunkingStrategyParam - ) - ) + fun chunkingStrategy(auto: AutoFileChunkingStrategyParam) = + chunkingStrategy(FileChunkingStrategyParam.ofAuto(auto)) /** * The chunking strategy used to chunk the file(s). If not set, will use the * `auto` strategy. Only applicable if `file_ids` is non-empty. */ - fun chunkingStrategy( - staticFileChunkingStrategyObjectParam: - StaticFileChunkingStrategyObjectParam - ) = - chunkingStrategy( - FileChunkingStrategyParam.ofStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam - ) - ) + fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) = + chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_)) /** * A list of [file](https://platform.openai.com/docs/api-reference/files) @@ -4060,39 +4041,37 @@ constructor( @JsonSerialize(using = Tool.Serializer::class) class Tool private constructor( - private val codeInterpreterTool: CodeInterpreterTool? = null, - private val fileSearchTool: FileSearchTool? = null, - private val functionTool: FunctionTool? = null, + private val codeInterpreter: CodeInterpreterTool? = null, + private val fileSearch: FileSearchTool? = null, + private val function: FunctionTool? = null, private val _json: JsonValue? = null, ) { - fun codeInterpreterTool(): Optional = - Optional.ofNullable(codeInterpreterTool) + fun codeInterpreter(): Optional = Optional.ofNullable(codeInterpreter) - fun fileSearchTool(): Optional = Optional.ofNullable(fileSearchTool) + fun fileSearch(): Optional = Optional.ofNullable(fileSearch) - fun functionTool(): Optional = Optional.ofNullable(functionTool) + fun function(): Optional = Optional.ofNullable(function) - fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null + fun isCodeInterpreter(): Boolean = codeInterpreter != null - fun isFileSearchTool(): Boolean = fileSearchTool != null + fun isFileSearch(): Boolean = fileSearch != null - fun isFunctionTool(): Boolean = functionTool != null + fun isFunction(): Boolean = function != null - fun asCodeInterpreterTool(): CodeInterpreterTool = - codeInterpreterTool.getOrThrow("codeInterpreterTool") + fun asCodeInterpreter(): CodeInterpreterTool = codeInterpreter.getOrThrow("codeInterpreter") - fun asFileSearchTool(): FileSearchTool = fileSearchTool.getOrThrow("fileSearchTool") + fun asFileSearch(): FileSearchTool = fileSearch.getOrThrow("fileSearch") - fun asFunctionTool(): FunctionTool = functionTool.getOrThrow("functionTool") + fun asFunction(): FunctionTool = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - codeInterpreterTool != null -> visitor.visitCodeInterpreterTool(codeInterpreterTool) - fileSearchTool != null -> visitor.visitFileSearchTool(fileSearchTool) - functionTool != null -> visitor.visitFunctionTool(functionTool) + codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) + fileSearch != null -> visitor.visitFileSearch(fileSearch) + function != null -> visitor.visitFunction(function) else -> visitor.unknown(_json) } } @@ -4106,18 +4085,16 @@ constructor( accept( object : Visitor { - override fun visitCodeInterpreterTool( - codeInterpreterTool: CodeInterpreterTool - ) { - codeInterpreterTool.validate() + override fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool) { + codeInterpreter.validate() } - override fun visitFileSearchTool(fileSearchTool: FileSearchTool) { - fileSearchTool.validate() + override fun visitFileSearch(fileSearch: FileSearchTool) { + fileSearch.validate() } - override fun visitFunctionTool(functionTool: FunctionTool) { - functionTool.validate() + override fun visitFunction(function: FunctionTool) { + function.validate() } } ) @@ -4129,16 +4106,16 @@ constructor( return true } - return /* spotless:off */ other is Tool && codeInterpreterTool == other.codeInterpreterTool && fileSearchTool == other.fileSearchTool && functionTool == other.functionTool /* spotless:on */ + return /* spotless:off */ other is Tool && codeInterpreter == other.codeInterpreter && fileSearch == other.fileSearch && function == other.function /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterTool, fileSearchTool, functionTool) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreter, fileSearch, function) /* spotless:on */ override fun toString(): String = when { - codeInterpreterTool != null -> "Tool{codeInterpreterTool=$codeInterpreterTool}" - fileSearchTool != null -> "Tool{fileSearchTool=$fileSearchTool}" - functionTool != null -> "Tool{functionTool=$functionTool}" + codeInterpreter != null -> "Tool{codeInterpreter=$codeInterpreter}" + fileSearch != null -> "Tool{fileSearch=$fileSearch}" + function != null -> "Tool{function=$function}" _json != null -> "Tool{_unknown=$_json}" else -> throw IllegalStateException("Invalid Tool") } @@ -4146,24 +4123,21 @@ constructor( companion object { @JvmStatic - fun ofCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool) = - Tool(codeInterpreterTool = codeInterpreterTool) + fun ofCodeInterpreter(codeInterpreter: CodeInterpreterTool) = + Tool(codeInterpreter = codeInterpreter) - @JvmStatic - fun ofFileSearchTool(fileSearchTool: FileSearchTool) = - Tool(fileSearchTool = fileSearchTool) + @JvmStatic fun ofFileSearch(fileSearch: FileSearchTool) = Tool(fileSearch = fileSearch) - @JvmStatic - fun ofFunctionTool(functionTool: FunctionTool) = Tool(functionTool = functionTool) + @JvmStatic fun ofFunction(function: FunctionTool) = Tool(function = function) } interface Visitor { - fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T + fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool): T - fun visitFileSearchTool(fileSearchTool: FileSearchTool): T + fun visitFileSearch(fileSearch: FileSearchTool): T - fun visitFunctionTool(functionTool: FunctionTool): T + fun visitFunction(function: FunctionTool): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown Tool: $json") @@ -4177,15 +4151,15 @@ constructor( tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Tool(codeInterpreterTool = it, _json = json) + return Tool(codeInterpreter = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Tool(fileSearchTool = it, _json = json) + return Tool(fileSearch = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Tool(functionTool = it, _json = json) + return Tool(function = it, _json = json) } return Tool(_json = json) @@ -4200,10 +4174,9 @@ constructor( provider: SerializerProvider ) { when { - value.codeInterpreterTool != null -> - generator.writeObject(value.codeInterpreterTool) - value.fileSearchTool != null -> generator.writeObject(value.fileSearchTool) - value.functionTool != null -> generator.writeObject(value.functionTool) + value.codeInterpreter != null -> generator.writeObject(value.codeInterpreter) + value.fileSearch != null -> generator.writeObject(value.fileSearch) + value.function != null -> generator.writeObject(value.function) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Tool") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt index b4e0172a6..8a3c47bb7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt @@ -599,7 +599,7 @@ constructor( fun content(content: JsonField) = apply { this.content = content } /** The text contents of the message. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type, each can be of type `text` or images @@ -695,13 +695,13 @@ constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { /** The text contents of the message. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type, each can be of type `text` or images @@ -711,12 +711,12 @@ constructor( fun arrayOfContentParts(): Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null /** The text contents of the message. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type, each can be of type `text` or images @@ -730,7 +730,7 @@ constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) @@ -746,7 +746,7 @@ constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -763,14 +763,14 @@ constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" @@ -780,8 +780,7 @@ constructor( companion object { /** The text contents of the message. */ - @JvmStatic - fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type, each can be of type `text` or @@ -796,7 +795,7 @@ constructor( interface Visitor { /** The text contents of the message. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type, each can be of type `text` or @@ -816,7 +815,7 @@ constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } @@ -837,7 +836,7 @@ constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) @@ -1002,8 +1001,8 @@ constructor( } /** The tools to add this file to. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(Tool.ofCodeInterpreter(codeInterpreter)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1039,22 +1038,22 @@ constructor( @JsonSerialize(using = Tool.Serializer::class) class Tool private constructor( - private val codeInterpreterTool: CodeInterpreterTool? = null, + private val codeInterpreter: CodeInterpreterTool? = null, private val fileSearch: JsonValue? = null, private val _json: JsonValue? = null, ) { - fun codeInterpreterTool(): Optional = - Optional.ofNullable(codeInterpreterTool) + fun codeInterpreter(): Optional = + Optional.ofNullable(codeInterpreter) fun fileSearch(): Optional = Optional.ofNullable(fileSearch) - fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null + fun isCodeInterpreter(): Boolean = codeInterpreter != null fun isFileSearch(): Boolean = fileSearch != null - fun asCodeInterpreterTool(): CodeInterpreterTool = - codeInterpreterTool.getOrThrow("codeInterpreterTool") + fun asCodeInterpreter(): CodeInterpreterTool = + codeInterpreter.getOrThrow("codeInterpreter") fun asFileSearch(): JsonValue = fileSearch.getOrThrow("fileSearch") @@ -1062,8 +1061,7 @@ constructor( fun accept(visitor: Visitor): T { return when { - codeInterpreterTool != null -> - visitor.visitCodeInterpreterTool(codeInterpreterTool) + codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) fileSearch != null -> visitor.visitFileSearch(fileSearch) else -> visitor.unknown(_json) } @@ -1078,10 +1076,10 @@ constructor( accept( object : Visitor { - override fun visitCodeInterpreterTool( - codeInterpreterTool: CodeInterpreterTool + override fun visitCodeInterpreter( + codeInterpreter: CodeInterpreterTool ) { - codeInterpreterTool.validate() + codeInterpreter.validate() } override fun visitFileSearch(fileSearch: JsonValue) { @@ -1103,15 +1101,14 @@ constructor( return true } - return /* spotless:off */ other is Tool && codeInterpreterTool == other.codeInterpreterTool && fileSearch == other.fileSearch /* spotless:on */ + return /* spotless:off */ other is Tool && codeInterpreter == other.codeInterpreter && fileSearch == other.fileSearch /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterTool, fileSearch) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreter, fileSearch) /* spotless:on */ override fun toString(): String = when { - codeInterpreterTool != null -> - "Tool{codeInterpreterTool=$codeInterpreterTool}" + codeInterpreter != null -> "Tool{codeInterpreter=$codeInterpreter}" fileSearch != null -> "Tool{fileSearch=$fileSearch}" _json != null -> "Tool{_unknown=$_json}" else -> throw IllegalStateException("Invalid Tool") @@ -1120,8 +1117,8 @@ constructor( companion object { @JvmStatic - fun ofCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool) = - Tool(codeInterpreterTool = codeInterpreterTool) + fun ofCodeInterpreter(codeInterpreter: CodeInterpreterTool) = + Tool(codeInterpreter = codeInterpreter) @JvmStatic fun ofFileSearch() = @@ -1130,7 +1127,7 @@ constructor( interface Visitor { - fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T + fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool): T fun visitFileSearch(fileSearch: JsonValue): T @@ -1151,7 +1148,7 @@ constructor( it.validate() } ?.let { - return Tool(codeInterpreterTool = it, _json = json) + return Tool(codeInterpreter = it, _json = json) } } "file_search" -> { @@ -1184,8 +1181,8 @@ constructor( provider: SerializerProvider ) { when { - value.codeInterpreterTool != null -> - generator.writeObject(value.codeInterpreterTool) + value.codeInterpreter != null -> + generator.writeObject(value.codeInterpreter) value.fileSearch != null -> generator.writeObject(value.fileSearch) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Tool") @@ -1790,27 +1787,15 @@ constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` * of `800` and `chunk_overlap_tokens` of `400`. */ - fun chunkingStrategy( - autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam - ) = - chunkingStrategy( - FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam( - autoFileChunkingStrategyParam - ) - ) + fun chunkingStrategy(auto: AutoFileChunkingStrategyParam) = + chunkingStrategy(FileChunkingStrategyParam.ofAuto(auto)) /** * The chunking strategy used to chunk the file(s). If not set, will use the * `auto` strategy. Only applicable if `file_ids` is non-empty. */ - fun chunkingStrategy( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) = - chunkingStrategy( - FileChunkingStrategyParam.ofStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam - ) - ) + fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) = + chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_)) /** * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt index 635e468c5..62625645f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt @@ -206,7 +206,7 @@ constructor( fun content(content: JsonField) = apply { this.content = content } /** The text contents of the message. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type, each can be of type `text` or images @@ -348,7 +348,7 @@ constructor( fun content(content: JsonField) = apply { body.content(content) } /** The text contents of the message. */ - fun content(textContent: String) = apply { body.content(textContent) } + fun content(text: String) = apply { body.content(text) } /** * An array of content parts with a defined type, each can be of type `text` or images can @@ -531,13 +531,13 @@ constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { /** The text contents of the message. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type, each can be of type `text` or images can @@ -547,12 +547,12 @@ constructor( fun arrayOfContentParts(): Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null /** The text contents of the message. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type, each can be of type `text` or images can @@ -566,7 +566,7 @@ constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } @@ -581,7 +581,7 @@ constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -598,14 +598,14 @@ constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") @@ -614,7 +614,7 @@ constructor( companion object { /** The text contents of the message. */ - @JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type, each can be of type `text` or images @@ -629,7 +629,7 @@ constructor( interface Visitor { /** The text contents of the message. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type, each can be of type `text` or images @@ -649,7 +649,7 @@ constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } @@ -670,7 +670,7 @@ constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) @@ -835,8 +835,8 @@ constructor( } /** The tools to add this file to. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(Tool.ofCodeInterpreter(codeInterpreter)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -869,22 +869,22 @@ constructor( @JsonSerialize(using = Tool.Serializer::class) class Tool private constructor( - private val codeInterpreterTool: CodeInterpreterTool? = null, + private val codeInterpreter: CodeInterpreterTool? = null, private val fileSearch: JsonValue? = null, private val _json: JsonValue? = null, ) { - fun codeInterpreterTool(): Optional = - Optional.ofNullable(codeInterpreterTool) + fun codeInterpreter(): Optional = + Optional.ofNullable(codeInterpreter) fun fileSearch(): Optional = Optional.ofNullable(fileSearch) - fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null + fun isCodeInterpreter(): Boolean = codeInterpreter != null fun isFileSearch(): Boolean = fileSearch != null - fun asCodeInterpreterTool(): CodeInterpreterTool = - codeInterpreterTool.getOrThrow("codeInterpreterTool") + fun asCodeInterpreter(): CodeInterpreterTool = + codeInterpreter.getOrThrow("codeInterpreter") fun asFileSearch(): JsonValue = fileSearch.getOrThrow("fileSearch") @@ -892,8 +892,7 @@ constructor( fun accept(visitor: Visitor): T { return when { - codeInterpreterTool != null -> - visitor.visitCodeInterpreterTool(codeInterpreterTool) + codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) fileSearch != null -> visitor.visitFileSearch(fileSearch) else -> visitor.unknown(_json) } @@ -908,10 +907,8 @@ constructor( accept( object : Visitor { - override fun visitCodeInterpreterTool( - codeInterpreterTool: CodeInterpreterTool - ) { - codeInterpreterTool.validate() + override fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool) { + codeInterpreter.validate() } override fun visitFileSearch(fileSearch: JsonValue) { @@ -933,14 +930,14 @@ constructor( return true } - return /* spotless:off */ other is Tool && codeInterpreterTool == other.codeInterpreterTool && fileSearch == other.fileSearch /* spotless:on */ + return /* spotless:off */ other is Tool && codeInterpreter == other.codeInterpreter && fileSearch == other.fileSearch /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterTool, fileSearch) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreter, fileSearch) /* spotless:on */ override fun toString(): String = when { - codeInterpreterTool != null -> "Tool{codeInterpreterTool=$codeInterpreterTool}" + codeInterpreter != null -> "Tool{codeInterpreter=$codeInterpreter}" fileSearch != null -> "Tool{fileSearch=$fileSearch}" _json != null -> "Tool{_unknown=$_json}" else -> throw IllegalStateException("Invalid Tool") @@ -949,8 +946,8 @@ constructor( companion object { @JvmStatic - fun ofCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool) = - Tool(codeInterpreterTool = codeInterpreterTool) + fun ofCodeInterpreter(codeInterpreter: CodeInterpreterTool) = + Tool(codeInterpreter = codeInterpreter) @JvmStatic fun ofFileSearch() = @@ -959,7 +956,7 @@ constructor( interface Visitor { - fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T + fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool): T fun visitFileSearch(fileSearch: JsonValue): T @@ -980,7 +977,7 @@ constructor( it.validate() } ?.let { - return Tool(codeInterpreterTool = it, _json = json) + return Tool(codeInterpreter = it, _json = json) } } "file_search" -> { @@ -1011,8 +1008,8 @@ constructor( provider: SerializerProvider ) { when { - value.codeInterpreterTool != null -> - generator.writeObject(value.codeInterpreterTool) + value.codeInterpreter != null -> + generator.writeObject(value.codeInterpreter) value.fileSearch != null -> generator.writeObject(value.fileSearch) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Tool") diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt index fd3d928df..c413ab9e0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt @@ -1209,22 +1209,21 @@ constructor( * Override the tools the assistant can use for this run. This is useful for modifying * the behavior on a per-run basis. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(AssistantTool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(AssistantTool.ofCodeInterpreter(codeInterpreter)) /** * Override the tools the assistant can use for this run. This is useful for modifying * the behavior on a per-run basis. */ - fun addTool(fileSearchTool: FileSearchTool) = - addTool(AssistantTool.ofFileSearchTool(fileSearchTool)) + fun addTool(fileSearch: FileSearchTool) = + addTool(AssistantTool.ofFileSearch(fileSearch)) /** * Override the tools the assistant can use for this run. This is useful for modifying * the behavior on a per-run basis. */ - fun addTool(functionTool: FunctionTool) = - addTool(AssistantTool.ofFunctionTool(functionTool)) + fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function)) /** * An alternative to sampling with temperature, called nucleus sampling, where the model @@ -1870,21 +1869,19 @@ constructor( * Override the tools the assistant can use for this run. This is useful for modifying the * behavior on a per-run basis. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = apply { - body.addTool(codeInterpreterTool) - } + fun addTool(codeInterpreter: CodeInterpreterTool) = apply { body.addTool(codeInterpreter) } /** * Override the tools the assistant can use for this run. This is useful for modifying the * behavior on a per-run basis. */ - fun addTool(fileSearchTool: FileSearchTool) = apply { body.addTool(fileSearchTool) } + fun addTool(fileSearch: FileSearchTool) = apply { body.addTool(fileSearch) } /** * Override the tools the assistant can use for this run. This is useful for modifying the * behavior on a per-run basis. */ - fun addTool(functionTool: FunctionTool) = apply { body.addTool(functionTool) } + fun addTool(function: FunctionTool) = apply { body.addTool(function) } /** * An alternative to sampling with temperature, called nucleus sampling, where the model @@ -2179,7 +2176,7 @@ constructor( fun content(content: JsonField) = apply { this.content = content } /** The text contents of the message. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type, each can be of type `text` or images @@ -2275,13 +2272,13 @@ constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { /** The text contents of the message. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type, each can be of type `text` or images @@ -2291,12 +2288,12 @@ constructor( fun arrayOfContentParts(): Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null /** The text contents of the message. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type, each can be of type `text` or images @@ -2310,7 +2307,7 @@ constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) @@ -2326,7 +2323,7 @@ constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -2343,14 +2340,14 @@ constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" @@ -2360,8 +2357,7 @@ constructor( companion object { /** The text contents of the message. */ - @JvmStatic - fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type, each can be of type `text` or @@ -2376,7 +2372,7 @@ constructor( interface Visitor { /** The text contents of the message. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type, each can be of type `text` or @@ -2396,7 +2392,7 @@ constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } @@ -2417,7 +2413,7 @@ constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) @@ -2582,8 +2578,8 @@ constructor( } /** The tools to add this file to. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(Tool.ofCodeInterpreter(codeInterpreter)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2619,22 +2615,22 @@ constructor( @JsonSerialize(using = Tool.Serializer::class) class Tool private constructor( - private val codeInterpreterTool: CodeInterpreterTool? = null, + private val codeInterpreter: CodeInterpreterTool? = null, private val fileSearch: JsonValue? = null, private val _json: JsonValue? = null, ) { - fun codeInterpreterTool(): Optional = - Optional.ofNullable(codeInterpreterTool) + fun codeInterpreter(): Optional = + Optional.ofNullable(codeInterpreter) fun fileSearch(): Optional = Optional.ofNullable(fileSearch) - fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null + fun isCodeInterpreter(): Boolean = codeInterpreter != null fun isFileSearch(): Boolean = fileSearch != null - fun asCodeInterpreterTool(): CodeInterpreterTool = - codeInterpreterTool.getOrThrow("codeInterpreterTool") + fun asCodeInterpreter(): CodeInterpreterTool = + codeInterpreter.getOrThrow("codeInterpreter") fun asFileSearch(): JsonValue = fileSearch.getOrThrow("fileSearch") @@ -2642,8 +2638,7 @@ constructor( fun accept(visitor: Visitor): T { return when { - codeInterpreterTool != null -> - visitor.visitCodeInterpreterTool(codeInterpreterTool) + codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) fileSearch != null -> visitor.visitFileSearch(fileSearch) else -> visitor.unknown(_json) } @@ -2658,10 +2653,10 @@ constructor( accept( object : Visitor { - override fun visitCodeInterpreterTool( - codeInterpreterTool: CodeInterpreterTool + override fun visitCodeInterpreter( + codeInterpreter: CodeInterpreterTool ) { - codeInterpreterTool.validate() + codeInterpreter.validate() } override fun visitFileSearch(fileSearch: JsonValue) { @@ -2683,15 +2678,14 @@ constructor( return true } - return /* spotless:off */ other is Tool && codeInterpreterTool == other.codeInterpreterTool && fileSearch == other.fileSearch /* spotless:on */ + return /* spotless:off */ other is Tool && codeInterpreter == other.codeInterpreter && fileSearch == other.fileSearch /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterTool, fileSearch) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreter, fileSearch) /* spotless:on */ override fun toString(): String = when { - codeInterpreterTool != null -> - "Tool{codeInterpreterTool=$codeInterpreterTool}" + codeInterpreter != null -> "Tool{codeInterpreter=$codeInterpreter}" fileSearch != null -> "Tool{fileSearch=$fileSearch}" _json != null -> "Tool{_unknown=$_json}" else -> throw IllegalStateException("Invalid Tool") @@ -2700,8 +2694,8 @@ constructor( companion object { @JvmStatic - fun ofCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool) = - Tool(codeInterpreterTool = codeInterpreterTool) + fun ofCodeInterpreter(codeInterpreter: CodeInterpreterTool) = + Tool(codeInterpreter = codeInterpreter) @JvmStatic fun ofFileSearch() = @@ -2710,7 +2704,7 @@ constructor( interface Visitor { - fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T + fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool): T fun visitFileSearch(fileSearch: JsonValue): T @@ -2731,7 +2725,7 @@ constructor( it.validate() } ?.let { - return Tool(codeInterpreterTool = it, _json = json) + return Tool(codeInterpreter = it, _json = json) } } "file_search" -> { @@ -2764,8 +2758,8 @@ constructor( provider: SerializerProvider ) { when { - value.codeInterpreterTool != null -> - generator.writeObject(value.codeInterpreterTool) + value.codeInterpreter != null -> + generator.writeObject(value.codeInterpreter) value.fileSearch != null -> generator.writeObject(value.fileSearch) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Tool") diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreCreateParams.kt index dea49f1b1..e4017acc2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreCreateParams.kt @@ -218,25 +218,15 @@ constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` * and `chunk_overlap_tokens` of `400`. */ - fun chunkingStrategy(autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam) = - chunkingStrategy( - FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam( - autoFileChunkingStrategyParam - ) - ) + fun chunkingStrategy(auto: AutoFileChunkingStrategyParam) = + chunkingStrategy(FileChunkingStrategyParam.ofAuto(auto)) /** * The chunking strategy used to chunk the file(s). If not set, will use the `auto` * strategy. Only applicable if `file_ids` is non-empty. */ - fun chunkingStrategy( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) = - chunkingStrategy( - FileChunkingStrategyParam.ofStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam - ) - ) + fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) = + chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_)) /** The expiration policy for a vector store. */ fun expiresAfter(expiresAfter: ExpiresAfter) = expiresAfter(JsonField.of(expiresAfter)) @@ -379,17 +369,17 @@ constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and * `chunk_overlap_tokens` of `400`. */ - fun chunkingStrategy(autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam) = apply { - body.chunkingStrategy(autoFileChunkingStrategyParam) + fun chunkingStrategy(auto: AutoFileChunkingStrategyParam) = apply { + body.chunkingStrategy(auto) } /** * The chunking strategy used to chunk the file(s). If not set, will use the `auto` * strategy. Only applicable if `file_ids` is non-empty. */ - fun chunkingStrategy( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) = apply { body.chunkingStrategy(staticFileChunkingStrategyObjectParam) } + fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) = apply { + body.chunkingStrategy(static_) + } /** The expiration policy for a vector store. */ fun expiresAfter(expiresAfter: ExpiresAfter) = apply { body.expiresAfter(expiresAfter) } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreFileBatchCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreFileBatchCreateParams.kt index 825805c46..6d17080d9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreFileBatchCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreFileBatchCreateParams.kt @@ -203,25 +203,15 @@ constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` * and `chunk_overlap_tokens` of `400`. */ - fun chunkingStrategy(autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam) = - chunkingStrategy( - FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam( - autoFileChunkingStrategyParam - ) - ) + fun chunkingStrategy(auto: AutoFileChunkingStrategyParam) = + chunkingStrategy(FileChunkingStrategyParam.ofAuto(auto)) /** * The chunking strategy used to chunk the file(s). If not set, will use the `auto` * strategy. Only applicable if `file_ids` is non-empty. */ - fun chunkingStrategy( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) = - chunkingStrategy( - FileChunkingStrategyParam.ofStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam - ) - ) + fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) = + chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -335,17 +325,17 @@ constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and * `chunk_overlap_tokens` of `400`. */ - fun chunkingStrategy(autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam) = apply { - body.chunkingStrategy(autoFileChunkingStrategyParam) + fun chunkingStrategy(auto: AutoFileChunkingStrategyParam) = apply { + body.chunkingStrategy(auto) } /** * The chunking strategy used to chunk the file(s). If not set, will use the `auto` * strategy. Only applicable if `file_ids` is non-empty. */ - fun chunkingStrategy( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) = apply { body.chunkingStrategy(staticFileChunkingStrategyObjectParam) } + fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) = apply { + body.chunkingStrategy(static_) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreFileCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreFileCreateParams.kt index 9aa650cdf..af6143a51 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreFileCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreFileCreateParams.kt @@ -187,25 +187,15 @@ constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` * and `chunk_overlap_tokens` of `400`. */ - fun chunkingStrategy(autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam) = - chunkingStrategy( - FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam( - autoFileChunkingStrategyParam - ) - ) + fun chunkingStrategy(auto: AutoFileChunkingStrategyParam) = + chunkingStrategy(FileChunkingStrategyParam.ofAuto(auto)) /** * The chunking strategy used to chunk the file(s). If not set, will use the `auto` * strategy. Only applicable if `file_ids` is non-empty. */ - fun chunkingStrategy( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) = - chunkingStrategy( - FileChunkingStrategyParam.ofStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam - ) - ) + fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) = + chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -312,17 +302,17 @@ constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and * `chunk_overlap_tokens` of `400`. */ - fun chunkingStrategy(autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam) = apply { - body.chunkingStrategy(autoFileChunkingStrategyParam) + fun chunkingStrategy(auto: AutoFileChunkingStrategyParam) = apply { + body.chunkingStrategy(auto) } /** * The chunking strategy used to chunk the file(s). If not set, will use the `auto` * strategy. Only applicable if `file_ids` is non-empty. */ - fun chunkingStrategy( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) = apply { body.chunkingStrategy(staticFileChunkingStrategyObjectParam) } + fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) = apply { + body.chunkingStrategy(static_) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionAssistantMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionAssistantMessageParam.kt index a826a5268..b97162a88 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionAssistantMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionAssistantMessageParam.kt @@ -221,7 +221,7 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** The contents of the assistant message. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type. Can be one or more of type `text`, or @@ -437,14 +437,14 @@ private constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { /** The contents of the assistant message. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type. Can be one or more of type `text`, or @@ -454,12 +454,12 @@ private constructor( Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null /** The contents of the assistant message. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type. Can be one or more of type `text`, or @@ -472,7 +472,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } @@ -487,7 +487,7 @@ private constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -504,14 +504,14 @@ private constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") @@ -520,7 +520,7 @@ private constructor( companion object { /** The contents of the assistant message. */ - @JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type. Can be one or more of type `text`, or @@ -535,7 +535,7 @@ private constructor( interface Visitor { /** The contents of the assistant message. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type. Can be one or more of type `text`, or @@ -556,7 +556,7 @@ private constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize( node, @@ -580,7 +580,7 @@ private constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) @@ -596,44 +596,35 @@ private constructor( @JsonSerialize(using = ChatCompletionRequestAssistantMessageContentPart.Serializer::class) class ChatCompletionRequestAssistantMessageContentPart private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, - private val chatCompletionContentPartRefusal: ChatCompletionContentPartRefusal? = null, + private val text: ChatCompletionContentPartText? = null, + private val refusal: ChatCompletionContentPartRefusal? = null, private val _json: JsonValue? = null, ) { /** * Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */ - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) + fun text(): Optional = Optional.ofNullable(text) - fun chatCompletionContentPartRefusal(): Optional = - Optional.ofNullable(chatCompletionContentPartRefusal) + fun refusal(): Optional = Optional.ofNullable(refusal) - fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null + fun isText(): Boolean = text != null - fun isChatCompletionContentPartRefusal(): Boolean = - chatCompletionContentPartRefusal != null + fun isRefusal(): Boolean = refusal != null /** * Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */ - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + fun asText(): ChatCompletionContentPartText = text.getOrThrow("text") - fun asChatCompletionContentPartRefusal(): ChatCompletionContentPartRefusal = - chatCompletionContentPartRefusal.getOrThrow("chatCompletionContentPartRefusal") + fun asRefusal(): ChatCompletionContentPartRefusal = refusal.getOrThrow("refusal") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) - chatCompletionContentPartRefusal != null -> - visitor.visitChatCompletionContentPartRefusal( - chatCompletionContentPartRefusal - ) + text != null -> visitor.visitText(text) + refusal != null -> visitor.visitRefusal(refusal) else -> visitor.unknown(_json) } } @@ -647,16 +638,12 @@ private constructor( accept( object : Visitor { - override fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) { - chatCompletionContentPartText.validate() + override fun visitText(text: ChatCompletionContentPartText) { + text.validate() } - override fun visitChatCompletionContentPartRefusal( - chatCompletionContentPartRefusal: ChatCompletionContentPartRefusal - ) { - chatCompletionContentPartRefusal.validate() + override fun visitRefusal(refusal: ChatCompletionContentPartRefusal) { + refusal.validate() } } ) @@ -668,17 +655,16 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionRequestAssistantMessageContentPart && chatCompletionContentPartText == other.chatCompletionContentPartText && chatCompletionContentPartRefusal == other.chatCompletionContentPartRefusal /* spotless:on */ + return /* spotless:off */ other is ChatCompletionRequestAssistantMessageContentPart && text == other.text && refusal == other.refusal /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartRefusal) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, refusal) /* spotless:on */ override fun toString(): String = when { - chatCompletionContentPartText != null -> - "ChatCompletionRequestAssistantMessageContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartRefusal != null -> - "ChatCompletionRequestAssistantMessageContentPart{chatCompletionContentPartRefusal=$chatCompletionContentPartRefusal}" + text != null -> "ChatCompletionRequestAssistantMessageContentPart{text=$text}" + refusal != null -> + "ChatCompletionRequestAssistantMessageContentPart{refusal=$refusal}" _json != null -> "ChatCompletionRequestAssistantMessageContentPart{_unknown=$_json}" else -> @@ -694,20 +680,12 @@ private constructor( * [text inputs](https://platform.openai.com/docs/guides/text-generation). */ @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionRequestAssistantMessageContentPart( - chatCompletionContentPartText = chatCompletionContentPartText - ) + fun ofText(text: ChatCompletionContentPartText) = + ChatCompletionRequestAssistantMessageContentPart(text = text) @JvmStatic - fun ofChatCompletionContentPartRefusal( - chatCompletionContentPartRefusal: ChatCompletionContentPartRefusal - ) = - ChatCompletionRequestAssistantMessageContentPart( - chatCompletionContentPartRefusal = chatCompletionContentPartRefusal - ) + fun ofRefusal(refusal: ChatCompletionContentPartRefusal) = + ChatCompletionRequestAssistantMessageContentPart(refusal = refusal) } interface Visitor { @@ -716,13 +694,9 @@ private constructor( * Learn about * [text inputs](https://platform.openai.com/docs/guides/text-generation). */ - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T + fun visitText(text: ChatCompletionContentPartText): T - fun visitChatCompletionContentPartRefusal( - chatCompletionContentPartRefusal: ChatCompletionContentPartRefusal - ): T + fun visitRefusal(refusal: ChatCompletionContentPartRefusal): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException( @@ -749,7 +723,7 @@ private constructor( } ?.let { return ChatCompletionRequestAssistantMessageContentPart( - chatCompletionContentPartText = it, + text = it, _json = json ) } @@ -763,7 +737,7 @@ private constructor( } ?.let { return ChatCompletionRequestAssistantMessageContentPart( - chatCompletionContentPartRefusal = it, + refusal = it, _json = json ) } @@ -785,10 +759,8 @@ private constructor( provider: SerializerProvider ) { when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartRefusal != null -> - generator.writeObject(value.chatCompletionContentPartRefusal) + value.text != null -> generator.writeObject(value.text) + value.refusal != null -> generator.writeObject(value.refusal) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionContentPart.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionContentPart.kt index 2bcc088a5..5c0e1c488 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionContentPart.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionContentPart.kt @@ -23,55 +23,44 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) class ChatCompletionContentPart private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, - private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = null, - private val chatCompletionContentPartInputAudio: ChatCompletionContentPartInputAudio? = null, + private val text: ChatCompletionContentPartText? = null, + private val imageUrl: ChatCompletionContentPartImage? = null, + private val inputAudio: ChatCompletionContentPartInputAudio? = null, private val _json: JsonValue? = null, ) { /** Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */ - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) + fun text(): Optional = Optional.ofNullable(text) /** Learn about [image inputs](https://platform.openai.com/docs/guides/vision). */ - fun chatCompletionContentPartImage(): Optional = - Optional.ofNullable(chatCompletionContentPartImage) + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) /** Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). */ - fun chatCompletionContentPartInputAudio(): Optional = - Optional.ofNullable(chatCompletionContentPartInputAudio) + fun inputAudio(): Optional = + Optional.ofNullable(inputAudio) - fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null + fun isText(): Boolean = text != null - fun isChatCompletionContentPartImage(): Boolean = chatCompletionContentPartImage != null + fun isImageUrl(): Boolean = imageUrl != null - fun isChatCompletionContentPartInputAudio(): Boolean = - chatCompletionContentPartInputAudio != null + fun isInputAudio(): Boolean = inputAudio != null /** Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */ - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + fun asText(): ChatCompletionContentPartText = text.getOrThrow("text") /** Learn about [image inputs](https://platform.openai.com/docs/guides/vision). */ - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") + fun asImageUrl(): ChatCompletionContentPartImage = imageUrl.getOrThrow("imageUrl") /** Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). */ - fun asChatCompletionContentPartInputAudio(): ChatCompletionContentPartInputAudio = - chatCompletionContentPartInputAudio.getOrThrow("chatCompletionContentPartInputAudio") + fun asInputAudio(): ChatCompletionContentPartInputAudio = inputAudio.getOrThrow("inputAudio") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage(chatCompletionContentPartImage) - chatCompletionContentPartInputAudio != null -> - visitor.visitChatCompletionContentPartInputAudio( - chatCompletionContentPartInputAudio - ) + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + inputAudio != null -> visitor.visitInputAudio(inputAudio) else -> visitor.unknown(_json) } } @@ -85,22 +74,16 @@ private constructor( accept( object : Visitor { - override fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) { - chatCompletionContentPartText.validate() + override fun visitText(text: ChatCompletionContentPartText) { + text.validate() } - override fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) { - chatCompletionContentPartImage.validate() + override fun visitImageUrl(imageUrl: ChatCompletionContentPartImage) { + imageUrl.validate() } - override fun visitChatCompletionContentPartInputAudio( - chatCompletionContentPartInputAudio: ChatCompletionContentPartInputAudio - ) { - chatCompletionContentPartInputAudio.validate() + override fun visitInputAudio(inputAudio: ChatCompletionContentPartInputAudio) { + inputAudio.validate() } } ) @@ -112,19 +95,16 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionContentPart && chatCompletionContentPartText == other.chatCompletionContentPartText && chatCompletionContentPartImage == other.chatCompletionContentPartImage && chatCompletionContentPartInputAudio == other.chatCompletionContentPartInputAudio /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && imageUrl == other.imageUrl && inputAudio == other.inputAudio /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage, chatCompletionContentPartInputAudio) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, imageUrl, inputAudio) /* spotless:on */ override fun toString(): String = when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - chatCompletionContentPartInputAudio != null -> - "ChatCompletionContentPart{chatCompletionContentPartInputAudio=$chatCompletionContentPartInputAudio}" + text != null -> "ChatCompletionContentPart{text=$text}" + imageUrl != null -> "ChatCompletionContentPart{imageUrl=$imageUrl}" + inputAudio != null -> "ChatCompletionContentPart{inputAudio=$inputAudio}" _json != null -> "ChatCompletionContentPart{_unknown=$_json}" else -> throw IllegalStateException("Invalid ChatCompletionContentPart") } @@ -133,45 +113,29 @@ private constructor( /** Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */ @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = ChatCompletionContentPart(chatCompletionContentPartText = chatCompletionContentPartText) + fun ofText(text: ChatCompletionContentPartText) = ChatCompletionContentPart(text = text) /** Learn about [image inputs](https://platform.openai.com/docs/guides/vision). */ @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = chatCompletionContentPartImage - ) + fun ofImageUrl(imageUrl: ChatCompletionContentPartImage) = + ChatCompletionContentPart(imageUrl = imageUrl) /** Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). */ @JvmStatic - fun ofChatCompletionContentPartInputAudio( - chatCompletionContentPartInputAudio: ChatCompletionContentPartInputAudio - ) = - ChatCompletionContentPart( - chatCompletionContentPartInputAudio = chatCompletionContentPartInputAudio - ) + fun ofInputAudio(inputAudio: ChatCompletionContentPartInputAudio) = + ChatCompletionContentPart(inputAudio = inputAudio) } interface Visitor { /** Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). */ - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T + fun visitText(text: ChatCompletionContentPartText): T /** Learn about [image inputs](https://platform.openai.com/docs/guides/vision). */ - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T + fun visitImageUrl(imageUrl: ChatCompletionContentPartImage): T /** Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). */ - fun visitChatCompletionContentPartInputAudio( - chatCompletionContentPartInputAudio: ChatCompletionContentPartInputAudio - ): T + fun visitInputAudio(inputAudio: ChatCompletionContentPartInputAudio): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown ChatCompletionContentPart: $json") @@ -191,10 +155,7 @@ private constructor( it.validate() } ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) + return ChatCompletionContentPart(text = it, _json = json) } } "image_url" -> { @@ -202,10 +163,7 @@ private constructor( it.validate() } ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) + return ChatCompletionContentPart(imageUrl = it, _json = json) } } "input_audio" -> { @@ -213,10 +171,7 @@ private constructor( it.validate() } ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartInputAudio = it, - _json = json - ) + return ChatCompletionContentPart(inputAudio = it, _json = json) } } } @@ -233,12 +188,9 @@ private constructor( provider: SerializerProvider ) { when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartImage != null -> - generator.writeObject(value.chatCompletionContentPartImage) - value.chatCompletionContentPartInputAudio != null -> - generator.writeObject(value.chatCompletionContentPartInputAudio) + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> generator.writeObject(value.imageUrl) + value.inputAudio != null -> generator.writeObject(value.inputAudio) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ChatCompletionContentPart") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt index d9c5cafb2..33439abf9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt @@ -1364,50 +1364,29 @@ constructor( * sent by the user. With o1 models and newer, `developer` messages replace the previous * `system` messages. */ - fun addMessage( - chatCompletionDeveloperMessageParam: ChatCompletionDeveloperMessageParam - ) = - addMessage( - ChatCompletionMessageParam.ofChatCompletionDeveloperMessageParam( - chatCompletionDeveloperMessageParam - ) - ) + fun addMessage(developer: ChatCompletionDeveloperMessageParam) = + addMessage(ChatCompletionMessageParam.ofDeveloper(developer)) /** * Developer-provided instructions that the model should follow, regardless of messages * sent by the user. With o1 models and newer, use `developer` messages for this purpose * instead. */ - fun addMessage(chatCompletionSystemMessageParam: ChatCompletionSystemMessageParam) = - addMessage( - ChatCompletionMessageParam.ofChatCompletionSystemMessageParam( - chatCompletionSystemMessageParam - ) - ) + fun addMessage(system: ChatCompletionSystemMessageParam) = + addMessage(ChatCompletionMessageParam.ofSystem(system)) /** * Messages sent by an end user, containing prompts or additional context information. */ - fun addMessage(chatCompletionUserMessageParam: ChatCompletionUserMessageParam) = - addMessage( - ChatCompletionMessageParam.ofChatCompletionUserMessageParam( - chatCompletionUserMessageParam - ) - ) + fun addMessage(user: ChatCompletionUserMessageParam) = + addMessage(ChatCompletionMessageParam.ofUser(user)) /** Messages sent by the model in response to user messages. */ - fun addMessage( - chatCompletionAssistantMessageParam: ChatCompletionAssistantMessageParam - ) = - addMessage( - ChatCompletionMessageParam.ofChatCompletionAssistantMessageParam( - chatCompletionAssistantMessageParam - ) - ) + fun addMessage(assistant: ChatCompletionAssistantMessageParam) = + addMessage(ChatCompletionMessageParam.ofAssistant(assistant)) /** Messages sent by the model in response to user messages. */ - fun addMessage(chatCompletionAssistantMessageParam: ChatCompletionMessage) = - addMessage(chatCompletionAssistantMessageParam.toParam()) + fun addMessage(assistant: ChatCompletionMessage) = addMessage(assistant.toParam()) /** * A list of messages comprising the conversation so far. Depending on the @@ -1417,12 +1396,8 @@ constructor( * [images](https://platform.openai.com/docs/guides/vision), and * [audio](https://platform.openai.com/docs/guides/audio). */ - fun addMessage(chatCompletionToolMessageParam: ChatCompletionToolMessageParam) = - addMessage( - ChatCompletionMessageParam.ofChatCompletionToolMessageParam( - chatCompletionToolMessageParam - ) - ) + fun addMessage(tool: ChatCompletionToolMessageParam) = + addMessage(ChatCompletionMessageParam.ofTool(tool)) /** * A list of messages comprising the conversation so far. Depending on the @@ -1433,12 +1408,8 @@ constructor( * [audio](https://platform.openai.com/docs/guides/audio). */ @Deprecated("deprecated") - fun addMessage(chatCompletionFunctionMessageParam: ChatCompletionFunctionMessageParam) = - addMessage( - ChatCompletionMessageParam.ofChatCompletionFunctionMessageParam( - chatCompletionFunctionMessageParam - ) - ) + fun addMessage(function: ChatCompletionFunctionMessageParam) = + addMessage(ChatCompletionMessageParam.ofFunction(function)) /** * ID of the model to use. See the @@ -2019,8 +1990,8 @@ constructor( * may be partially cut off if `finish_reason="length"`, which indicates the generation * exceeded `max_tokens` or the conversation exceeded the max context length. */ - fun responseFormat(responseFormatText: ResponseFormatText) = - responseFormat(ResponseFormat.ofResponseFormatText(responseFormatText)) + fun responseFormat(text: ResponseFormatText) = + responseFormat(ResponseFormat.ofText(text)) /** * An object specifying the format that the model must output. @@ -2040,8 +2011,8 @@ constructor( * may be partially cut off if `finish_reason="length"`, which indicates the generation * exceeded `max_tokens` or the conversation exceeded the max context length. */ - fun responseFormat(responseFormatJsonObject: ResponseFormatJsonObject) = - responseFormat(ResponseFormat.ofResponseFormatJsonObject(responseFormatJsonObject)) + fun responseFormat(jsonObject: ResponseFormatJsonObject) = + responseFormat(ResponseFormat.ofJsonObject(jsonObject)) /** * An object specifying the format that the model must output. @@ -2061,8 +2032,8 @@ constructor( * may be partially cut off if `finish_reason="length"`, which indicates the generation * exceeded `max_tokens` or the conversation exceeded the max context length. */ - fun responseFormat(responseFormatJsonSchema: ResponseFormatJsonSchema) = - responseFormat(ResponseFormat.ofResponseFormatJsonSchema(responseFormatJsonSchema)) + fun responseFormat(jsonSchema: ResponseFormatJsonSchema) = + responseFormat(ResponseFormat.ofJsonSchema(jsonSchema)) /** * This feature is in Beta. If specified, our system will make a best effort to sample @@ -2268,12 +2239,8 @@ constructor( * Specifies a tool the model should use. Use to force the model to call a specific * function. */ - fun toolChoice(chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice) = - toolChoice( - ChatCompletionToolChoiceOption.ofChatCompletionNamedToolChoice( - chatCompletionNamedToolChoice - ) - ) + fun toolChoice(namedToolChoice: ChatCompletionNamedToolChoice) = + toolChoice(ChatCompletionToolChoiceOption.ofNamedToolChoice(namedToolChoice)) /** * A list of tools the model may call. Currently, only functions are supported as a @@ -2520,34 +2487,26 @@ constructor( * by the user. With o1 models and newer, `developer` messages replace the previous `system` * messages. */ - fun addMessage(chatCompletionDeveloperMessageParam: ChatCompletionDeveloperMessageParam) = - apply { - body.addMessage(chatCompletionDeveloperMessageParam) - } + fun addMessage(developer: ChatCompletionDeveloperMessageParam) = apply { + body.addMessage(developer) + } /** * Developer-provided instructions that the model should follow, regardless of messages sent * by the user. With o1 models and newer, use `developer` messages for this purpose instead. */ - fun addMessage(chatCompletionSystemMessageParam: ChatCompletionSystemMessageParam) = apply { - body.addMessage(chatCompletionSystemMessageParam) - } + fun addMessage(system: ChatCompletionSystemMessageParam) = apply { body.addMessage(system) } /** Messages sent by an end user, containing prompts or additional context information. */ - fun addMessage(chatCompletionUserMessageParam: ChatCompletionUserMessageParam) = apply { - body.addMessage(chatCompletionUserMessageParam) - } + fun addMessage(user: ChatCompletionUserMessageParam) = apply { body.addMessage(user) } /** Messages sent by the model in response to user messages. */ - fun addMessage(chatCompletionAssistantMessageParam: ChatCompletionAssistantMessageParam) = - apply { - body.addMessage(chatCompletionAssistantMessageParam) - } + fun addMessage(assistant: ChatCompletionAssistantMessageParam) = apply { + body.addMessage(assistant) + } /** Messages sent by the model in response to user messages. */ - fun addMessage(chatCompletionAssistantMessageParam: ChatCompletionMessage) = apply { - body.addMessage(chatCompletionAssistantMessageParam) - } + fun addMessage(assistant: ChatCompletionMessage) = apply { body.addMessage(assistant) } /** * A list of messages comprising the conversation so far. Depending on the @@ -2557,9 +2516,7 @@ constructor( * [images](https://platform.openai.com/docs/guides/vision), and * [audio](https://platform.openai.com/docs/guides/audio). */ - fun addMessage(chatCompletionToolMessageParam: ChatCompletionToolMessageParam) = apply { - body.addMessage(chatCompletionToolMessageParam) - } + fun addMessage(tool: ChatCompletionToolMessageParam) = apply { body.addMessage(tool) } /** * A list of messages comprising the conversation so far. Depending on the @@ -2570,10 +2527,9 @@ constructor( * [audio](https://platform.openai.com/docs/guides/audio). */ @Deprecated("deprecated") - fun addMessage(chatCompletionFunctionMessageParam: ChatCompletionFunctionMessageParam) = - apply { - body.addMessage(chatCompletionFunctionMessageParam) - } + fun addMessage(function: ChatCompletionFunctionMessageParam) = apply { + body.addMessage(function) + } /** * ID of the model to use. See the @@ -3124,9 +3080,7 @@ constructor( * partially cut off if `finish_reason="length"`, which indicates the generation exceeded * `max_tokens` or the conversation exceeded the max context length. */ - fun responseFormat(responseFormatText: ResponseFormatText) = apply { - body.responseFormat(responseFormatText) - } + fun responseFormat(text: ResponseFormatText) = apply { body.responseFormat(text) } /** * An object specifying the format that the model must output. @@ -3145,8 +3099,8 @@ constructor( * partially cut off if `finish_reason="length"`, which indicates the generation exceeded * `max_tokens` or the conversation exceeded the max context length. */ - fun responseFormat(responseFormatJsonObject: ResponseFormatJsonObject) = apply { - body.responseFormat(responseFormatJsonObject) + fun responseFormat(jsonObject: ResponseFormatJsonObject) = apply { + body.responseFormat(jsonObject) } /** @@ -3166,8 +3120,8 @@ constructor( * partially cut off if `finish_reason="length"`, which indicates the generation exceeded * `max_tokens` or the conversation exceeded the max context length. */ - fun responseFormat(responseFormatJsonSchema: ResponseFormatJsonSchema) = apply { - body.responseFormat(responseFormatJsonSchema) + fun responseFormat(jsonSchema: ResponseFormatJsonSchema) = apply { + body.responseFormat(jsonSchema) } /** @@ -3371,8 +3325,8 @@ constructor( * Specifies a tool the model should use. Use to force the model to call a specific * function. */ - fun toolChoice(chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice) = apply { - body.toolChoice(chatCompletionNamedToolChoice) + fun toolChoice(namedToolChoice: ChatCompletionNamedToolChoice) = apply { + body.toolChoice(namedToolChoice) } /** @@ -4229,45 +4183,37 @@ constructor( @JsonSerialize(using = ResponseFormat.Serializer::class) class ResponseFormat private constructor( - private val responseFormatText: ResponseFormatText? = null, - private val responseFormatJsonObject: ResponseFormatJsonObject? = null, - private val responseFormatJsonSchema: ResponseFormatJsonSchema? = null, + private val text: ResponseFormatText? = null, + private val jsonObject: ResponseFormatJsonObject? = null, + private val jsonSchema: ResponseFormatJsonSchema? = null, private val _json: JsonValue? = null, ) { - fun responseFormatText(): Optional = - Optional.ofNullable(responseFormatText) + fun text(): Optional = Optional.ofNullable(text) - fun responseFormatJsonObject(): Optional = - Optional.ofNullable(responseFormatJsonObject) + fun jsonObject(): Optional = Optional.ofNullable(jsonObject) - fun responseFormatJsonSchema(): Optional = - Optional.ofNullable(responseFormatJsonSchema) + fun jsonSchema(): Optional = Optional.ofNullable(jsonSchema) - fun isResponseFormatText(): Boolean = responseFormatText != null + fun isText(): Boolean = text != null - fun isResponseFormatJsonObject(): Boolean = responseFormatJsonObject != null + fun isJsonObject(): Boolean = jsonObject != null - fun isResponseFormatJsonSchema(): Boolean = responseFormatJsonSchema != null + fun isJsonSchema(): Boolean = jsonSchema != null - fun asResponseFormatText(): ResponseFormatText = - responseFormatText.getOrThrow("responseFormatText") + fun asText(): ResponseFormatText = text.getOrThrow("text") - fun asResponseFormatJsonObject(): ResponseFormatJsonObject = - responseFormatJsonObject.getOrThrow("responseFormatJsonObject") + fun asJsonObject(): ResponseFormatJsonObject = jsonObject.getOrThrow("jsonObject") - fun asResponseFormatJsonSchema(): ResponseFormatJsonSchema = - responseFormatJsonSchema.getOrThrow("responseFormatJsonSchema") + fun asJsonSchema(): ResponseFormatJsonSchema = jsonSchema.getOrThrow("jsonSchema") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - responseFormatText != null -> visitor.visitResponseFormatText(responseFormatText) - responseFormatJsonObject != null -> - visitor.visitResponseFormatJsonObject(responseFormatJsonObject) - responseFormatJsonSchema != null -> - visitor.visitResponseFormatJsonSchema(responseFormatJsonSchema) + text != null -> visitor.visitText(text) + jsonObject != null -> visitor.visitJsonObject(jsonObject) + jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) else -> visitor.unknown(_json) } } @@ -4281,20 +4227,16 @@ constructor( accept( object : Visitor { - override fun visitResponseFormatText(responseFormatText: ResponseFormatText) { - responseFormatText.validate() + override fun visitText(text: ResponseFormatText) { + text.validate() } - override fun visitResponseFormatJsonObject( - responseFormatJsonObject: ResponseFormatJsonObject - ) { - responseFormatJsonObject.validate() + override fun visitJsonObject(jsonObject: ResponseFormatJsonObject) { + jsonObject.validate() } - override fun visitResponseFormatJsonSchema( - responseFormatJsonSchema: ResponseFormatJsonSchema - ) { - responseFormatJsonSchema.validate() + override fun visitJsonSchema(jsonSchema: ResponseFormatJsonSchema) { + jsonSchema.validate() } } ) @@ -4306,45 +4248,40 @@ constructor( return true } - return /* spotless:off */ other is ResponseFormat && responseFormatText == other.responseFormatText && responseFormatJsonObject == other.responseFormatJsonObject && responseFormatJsonSchema == other.responseFormatJsonSchema /* spotless:on */ + return /* spotless:off */ other is ResponseFormat && text == other.text && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responseFormatText, responseFormatJsonObject, responseFormatJsonSchema) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, jsonObject, jsonSchema) /* spotless:on */ override fun toString(): String = when { - responseFormatText != null -> - "ResponseFormat{responseFormatText=$responseFormatText}" - responseFormatJsonObject != null -> - "ResponseFormat{responseFormatJsonObject=$responseFormatJsonObject}" - responseFormatJsonSchema != null -> - "ResponseFormat{responseFormatJsonSchema=$responseFormatJsonSchema}" + text != null -> "ResponseFormat{text=$text}" + jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" + jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" _json != null -> "ResponseFormat{_unknown=$_json}" else -> throw IllegalStateException("Invalid ResponseFormat") } companion object { - @JvmStatic - fun ofResponseFormatText(responseFormatText: ResponseFormatText) = - ResponseFormat(responseFormatText = responseFormatText) + @JvmStatic fun ofText(text: ResponseFormatText) = ResponseFormat(text = text) @JvmStatic - fun ofResponseFormatJsonObject(responseFormatJsonObject: ResponseFormatJsonObject) = - ResponseFormat(responseFormatJsonObject = responseFormatJsonObject) + fun ofJsonObject(jsonObject: ResponseFormatJsonObject) = + ResponseFormat(jsonObject = jsonObject) @JvmStatic - fun ofResponseFormatJsonSchema(responseFormatJsonSchema: ResponseFormatJsonSchema) = - ResponseFormat(responseFormatJsonSchema = responseFormatJsonSchema) + fun ofJsonSchema(jsonSchema: ResponseFormatJsonSchema) = + ResponseFormat(jsonSchema = jsonSchema) } interface Visitor { - fun visitResponseFormatText(responseFormatText: ResponseFormatText): T + fun visitText(text: ResponseFormatText): T - fun visitResponseFormatJsonObject(responseFormatJsonObject: ResponseFormatJsonObject): T + fun visitJsonObject(jsonObject: ResponseFormatJsonObject): T - fun visitResponseFormatJsonSchema(responseFormatJsonSchema: ResponseFormatJsonSchema): T + fun visitJsonSchema(jsonSchema: ResponseFormatJsonSchema): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown ResponseFormat: $json") @@ -4358,15 +4295,15 @@ constructor( tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return ResponseFormat(responseFormatText = it, _json = json) + return ResponseFormat(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return ResponseFormat(responseFormatJsonObject = it, _json = json) + return ResponseFormat(jsonObject = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return ResponseFormat(responseFormatJsonSchema = it, _json = json) + return ResponseFormat(jsonSchema = it, _json = json) } return ResponseFormat(_json = json) @@ -4381,12 +4318,9 @@ constructor( provider: SerializerProvider ) { when { - value.responseFormatText != null -> - generator.writeObject(value.responseFormatText) - value.responseFormatJsonObject != null -> - generator.writeObject(value.responseFormatJsonObject) - value.responseFormatJsonSchema != null -> - generator.writeObject(value.responseFormatJsonSchema) + value.text != null -> generator.writeObject(value.text) + value.jsonObject != null -> generator.writeObject(value.jsonObject) + value.jsonSchema != null -> generator.writeObject(value.jsonSchema) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ResponseFormat") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionDeveloperMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionDeveloperMessageParam.kt index a0615d2a2..a6289520b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionDeveloperMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionDeveloperMessageParam.kt @@ -118,7 +118,7 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** The contents of the developer message. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type. For developer messages, only type `text` @@ -175,13 +175,13 @@ private constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { /** The contents of the developer message. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type. For developer messages, only type `text` @@ -190,12 +190,12 @@ private constructor( fun arrayOfContentParts(): Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null /** The contents of the developer message. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type. For developer messages, only type `text` @@ -208,7 +208,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } @@ -223,7 +223,7 @@ private constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -240,14 +240,14 @@ private constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") @@ -256,7 +256,7 @@ private constructor( companion object { /** The contents of the developer message. */ - @JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type. For developer messages, only type @@ -270,7 +270,7 @@ private constructor( interface Visitor { /** The contents of the developer message. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type. For developer messages, only type @@ -291,7 +291,7 @@ private constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } @@ -312,7 +312,7 @@ private constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionMessage.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionMessage.kt index 3216cf313..e02911691 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionMessage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionMessage.kt @@ -106,9 +106,7 @@ private constructor( ChatCompletionAssistantMessageParam.Audio.builder().id(it._id()).build() } ) - .content( - _content().map { ChatCompletionAssistantMessageParam.Content.ofTextContent(it) } - ) + .content(_content().map { ChatCompletionAssistantMessageParam.Content.ofText(it) }) .functionCall( _functionCall().map { ChatCompletionAssistantMessageParam.FunctionCall.builder() diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionMessageParam.kt index f737a7cd6..a4dfa45f5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionMessageParam.kt @@ -26,12 +26,12 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = ChatCompletionMessageParam.Serializer::class) class ChatCompletionMessageParam private constructor( - private val chatCompletionDeveloperMessageParam: ChatCompletionDeveloperMessageParam? = null, - private val chatCompletionSystemMessageParam: ChatCompletionSystemMessageParam? = null, - private val chatCompletionUserMessageParam: ChatCompletionUserMessageParam? = null, - private val chatCompletionAssistantMessageParam: ChatCompletionAssistantMessageParam? = null, - private val chatCompletionToolMessageParam: ChatCompletionToolMessageParam? = null, - private val chatCompletionFunctionMessageParam: ChatCompletionFunctionMessageParam? = null, + private val developer: ChatCompletionDeveloperMessageParam? = null, + private val system: ChatCompletionSystemMessageParam? = null, + private val user: ChatCompletionUserMessageParam? = null, + private val assistant: ChatCompletionAssistantMessageParam? = null, + private val tool: ChatCompletionToolMessageParam? = null, + private val function: ChatCompletionFunctionMessageParam? = null, private val _json: JsonValue? = null, ) { @@ -40,96 +40,71 @@ private constructor( * the user. With o1 models and newer, `developer` messages replace the previous `system` * messages. */ - fun chatCompletionDeveloperMessageParam(): Optional = - Optional.ofNullable(chatCompletionDeveloperMessageParam) + fun developer(): Optional = Optional.ofNullable(developer) /** * Developer-provided instructions that the model should follow, regardless of messages sent by * the user. With o1 models and newer, use `developer` messages for this purpose instead. */ - fun chatCompletionSystemMessageParam(): Optional = - Optional.ofNullable(chatCompletionSystemMessageParam) + fun system(): Optional = Optional.ofNullable(system) /** Messages sent by an end user, containing prompts or additional context information. */ - fun chatCompletionUserMessageParam(): Optional = - Optional.ofNullable(chatCompletionUserMessageParam) + fun user(): Optional = Optional.ofNullable(user) /** Messages sent by the model in response to user messages. */ - fun chatCompletionAssistantMessageParam(): Optional = - Optional.ofNullable(chatCompletionAssistantMessageParam) + fun assistant(): Optional = Optional.ofNullable(assistant) - fun chatCompletionToolMessageParam(): Optional = - Optional.ofNullable(chatCompletionToolMessageParam) + fun tool(): Optional = Optional.ofNullable(tool) @Deprecated("deprecated") - fun chatCompletionFunctionMessageParam(): Optional = - Optional.ofNullable(chatCompletionFunctionMessageParam) + fun function(): Optional = Optional.ofNullable(function) - fun isChatCompletionDeveloperMessageParam(): Boolean = - chatCompletionDeveloperMessageParam != null + fun isDeveloper(): Boolean = developer != null - fun isChatCompletionSystemMessageParam(): Boolean = chatCompletionSystemMessageParam != null + fun isSystem(): Boolean = system != null - fun isChatCompletionUserMessageParam(): Boolean = chatCompletionUserMessageParam != null + fun isUser(): Boolean = user != null - fun isChatCompletionAssistantMessageParam(): Boolean = - chatCompletionAssistantMessageParam != null + fun isAssistant(): Boolean = assistant != null - fun isChatCompletionToolMessageParam(): Boolean = chatCompletionToolMessageParam != null + fun isTool(): Boolean = tool != null - @Deprecated("deprecated") - fun isChatCompletionFunctionMessageParam(): Boolean = chatCompletionFunctionMessageParam != null + @Deprecated("deprecated") fun isFunction(): Boolean = function != null /** * Developer-provided instructions that the model should follow, regardless of messages sent by * the user. With o1 models and newer, `developer` messages replace the previous `system` * messages. */ - fun asChatCompletionDeveloperMessageParam(): ChatCompletionDeveloperMessageParam = - chatCompletionDeveloperMessageParam.getOrThrow("chatCompletionDeveloperMessageParam") + fun asDeveloper(): ChatCompletionDeveloperMessageParam = developer.getOrThrow("developer") /** * Developer-provided instructions that the model should follow, regardless of messages sent by * the user. With o1 models and newer, use `developer` messages for this purpose instead. */ - fun asChatCompletionSystemMessageParam(): ChatCompletionSystemMessageParam = - chatCompletionSystemMessageParam.getOrThrow("chatCompletionSystemMessageParam") + fun asSystem(): ChatCompletionSystemMessageParam = system.getOrThrow("system") /** Messages sent by an end user, containing prompts or additional context information. */ - fun asChatCompletionUserMessageParam(): ChatCompletionUserMessageParam = - chatCompletionUserMessageParam.getOrThrow("chatCompletionUserMessageParam") + fun asUser(): ChatCompletionUserMessageParam = user.getOrThrow("user") /** Messages sent by the model in response to user messages. */ - fun asChatCompletionAssistantMessageParam(): ChatCompletionAssistantMessageParam = - chatCompletionAssistantMessageParam.getOrThrow("chatCompletionAssistantMessageParam") + fun asAssistant(): ChatCompletionAssistantMessageParam = assistant.getOrThrow("assistant") - fun asChatCompletionToolMessageParam(): ChatCompletionToolMessageParam = - chatCompletionToolMessageParam.getOrThrow("chatCompletionToolMessageParam") + fun asTool(): ChatCompletionToolMessageParam = tool.getOrThrow("tool") @Deprecated("deprecated") - fun asChatCompletionFunctionMessageParam(): ChatCompletionFunctionMessageParam = - chatCompletionFunctionMessageParam.getOrThrow("chatCompletionFunctionMessageParam") + fun asFunction(): ChatCompletionFunctionMessageParam = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - chatCompletionDeveloperMessageParam != null -> - visitor.visitChatCompletionDeveloperMessageParam( - chatCompletionDeveloperMessageParam - ) - chatCompletionSystemMessageParam != null -> - visitor.visitChatCompletionSystemMessageParam(chatCompletionSystemMessageParam) - chatCompletionUserMessageParam != null -> - visitor.visitChatCompletionUserMessageParam(chatCompletionUserMessageParam) - chatCompletionAssistantMessageParam != null -> - visitor.visitChatCompletionAssistantMessageParam( - chatCompletionAssistantMessageParam - ) - chatCompletionToolMessageParam != null -> - visitor.visitChatCompletionToolMessageParam(chatCompletionToolMessageParam) - chatCompletionFunctionMessageParam != null -> - visitor.visitChatCompletionFunctionMessageParam(chatCompletionFunctionMessageParam) + developer != null -> visitor.visitDeveloper(developer) + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) else -> visitor.unknown(_json) } } @@ -143,40 +118,28 @@ private constructor( accept( object : Visitor { - override fun visitChatCompletionDeveloperMessageParam( - chatCompletionDeveloperMessageParam: ChatCompletionDeveloperMessageParam - ) { - chatCompletionDeveloperMessageParam.validate() + override fun visitDeveloper(developer: ChatCompletionDeveloperMessageParam) { + developer.validate() } - override fun visitChatCompletionSystemMessageParam( - chatCompletionSystemMessageParam: ChatCompletionSystemMessageParam - ) { - chatCompletionSystemMessageParam.validate() + override fun visitSystem(system: ChatCompletionSystemMessageParam) { + system.validate() } - override fun visitChatCompletionUserMessageParam( - chatCompletionUserMessageParam: ChatCompletionUserMessageParam - ) { - chatCompletionUserMessageParam.validate() + override fun visitUser(user: ChatCompletionUserMessageParam) { + user.validate() } - override fun visitChatCompletionAssistantMessageParam( - chatCompletionAssistantMessageParam: ChatCompletionAssistantMessageParam - ) { - chatCompletionAssistantMessageParam.validate() + override fun visitAssistant(assistant: ChatCompletionAssistantMessageParam) { + assistant.validate() } - override fun visitChatCompletionToolMessageParam( - chatCompletionToolMessageParam: ChatCompletionToolMessageParam - ) { - chatCompletionToolMessageParam.validate() + override fun visitTool(tool: ChatCompletionToolMessageParam) { + tool.validate() } - override fun visitChatCompletionFunctionMessageParam( - chatCompletionFunctionMessageParam: ChatCompletionFunctionMessageParam - ) { - chatCompletionFunctionMessageParam.validate() + override fun visitFunction(function: ChatCompletionFunctionMessageParam) { + function.validate() } } ) @@ -188,25 +151,19 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionMessageParam && chatCompletionDeveloperMessageParam == other.chatCompletionDeveloperMessageParam && chatCompletionSystemMessageParam == other.chatCompletionSystemMessageParam && chatCompletionUserMessageParam == other.chatCompletionUserMessageParam && chatCompletionAssistantMessageParam == other.chatCompletionAssistantMessageParam && chatCompletionToolMessageParam == other.chatCompletionToolMessageParam && chatCompletionFunctionMessageParam == other.chatCompletionFunctionMessageParam /* spotless:on */ + return /* spotless:off */ other is ChatCompletionMessageParam && developer == other.developer && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(chatCompletionDeveloperMessageParam, chatCompletionSystemMessageParam, chatCompletionUserMessageParam, chatCompletionAssistantMessageParam, chatCompletionToolMessageParam, chatCompletionFunctionMessageParam) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(developer, system, user, assistant, tool, function) /* spotless:on */ override fun toString(): String = when { - chatCompletionDeveloperMessageParam != null -> - "ChatCompletionMessageParam{chatCompletionDeveloperMessageParam=$chatCompletionDeveloperMessageParam}" - chatCompletionSystemMessageParam != null -> - "ChatCompletionMessageParam{chatCompletionSystemMessageParam=$chatCompletionSystemMessageParam}" - chatCompletionUserMessageParam != null -> - "ChatCompletionMessageParam{chatCompletionUserMessageParam=$chatCompletionUserMessageParam}" - chatCompletionAssistantMessageParam != null -> - "ChatCompletionMessageParam{chatCompletionAssistantMessageParam=$chatCompletionAssistantMessageParam}" - chatCompletionToolMessageParam != null -> - "ChatCompletionMessageParam{chatCompletionToolMessageParam=$chatCompletionToolMessageParam}" - chatCompletionFunctionMessageParam != null -> - "ChatCompletionMessageParam{chatCompletionFunctionMessageParam=$chatCompletionFunctionMessageParam}" + developer != null -> "ChatCompletionMessageParam{developer=$developer}" + system != null -> "ChatCompletionMessageParam{system=$system}" + user != null -> "ChatCompletionMessageParam{user=$user}" + assistant != null -> "ChatCompletionMessageParam{assistant=$assistant}" + tool != null -> "ChatCompletionMessageParam{tool=$tool}" + function != null -> "ChatCompletionMessageParam{function=$function}" _json != null -> "ChatCompletionMessageParam{_unknown=$_json}" else -> throw IllegalStateException("Invalid ChatCompletionMessageParam") } @@ -219,59 +176,33 @@ private constructor( * messages. */ @JvmStatic - fun ofChatCompletionDeveloperMessageParam( - chatCompletionDeveloperMessageParam: ChatCompletionDeveloperMessageParam - ) = - ChatCompletionMessageParam( - chatCompletionDeveloperMessageParam = chatCompletionDeveloperMessageParam - ) + fun ofDeveloper(developer: ChatCompletionDeveloperMessageParam) = + ChatCompletionMessageParam(developer = developer) /** * Developer-provided instructions that the model should follow, regardless of messages sent * by the user. With o1 models and newer, use `developer` messages for this purpose instead. */ @JvmStatic - fun ofChatCompletionSystemMessageParam( - chatCompletionSystemMessageParam: ChatCompletionSystemMessageParam - ) = - ChatCompletionMessageParam( - chatCompletionSystemMessageParam = chatCompletionSystemMessageParam - ) + fun ofSystem(system: ChatCompletionSystemMessageParam) = + ChatCompletionMessageParam(system = system) /** Messages sent by an end user, containing prompts or additional context information. */ @JvmStatic - fun ofChatCompletionUserMessageParam( - chatCompletionUserMessageParam: ChatCompletionUserMessageParam - ) = - ChatCompletionMessageParam( - chatCompletionUserMessageParam = chatCompletionUserMessageParam - ) + fun ofUser(user: ChatCompletionUserMessageParam) = ChatCompletionMessageParam(user = user) /** Messages sent by the model in response to user messages. */ @JvmStatic - fun ofChatCompletionAssistantMessageParam( - chatCompletionAssistantMessageParam: ChatCompletionAssistantMessageParam - ) = - ChatCompletionMessageParam( - chatCompletionAssistantMessageParam = chatCompletionAssistantMessageParam - ) + fun ofAssistant(assistant: ChatCompletionAssistantMessageParam) = + ChatCompletionMessageParam(assistant = assistant) @JvmStatic - fun ofChatCompletionToolMessageParam( - chatCompletionToolMessageParam: ChatCompletionToolMessageParam - ) = - ChatCompletionMessageParam( - chatCompletionToolMessageParam = chatCompletionToolMessageParam - ) + fun ofTool(tool: ChatCompletionToolMessageParam) = ChatCompletionMessageParam(tool = tool) @Deprecated("deprecated") @JvmStatic - fun ofChatCompletionFunctionMessageParam( - chatCompletionFunctionMessageParam: ChatCompletionFunctionMessageParam - ) = - ChatCompletionMessageParam( - chatCompletionFunctionMessageParam = chatCompletionFunctionMessageParam - ) + fun ofFunction(function: ChatCompletionFunctionMessageParam) = + ChatCompletionMessageParam(function = function) } interface Visitor { @@ -281,36 +212,23 @@ private constructor( * by the user. With o1 models and newer, `developer` messages replace the previous `system` * messages. */ - fun visitChatCompletionDeveloperMessageParam( - chatCompletionDeveloperMessageParam: ChatCompletionDeveloperMessageParam - ): T + fun visitDeveloper(developer: ChatCompletionDeveloperMessageParam): T /** * Developer-provided instructions that the model should follow, regardless of messages sent * by the user. With o1 models and newer, use `developer` messages for this purpose instead. */ - fun visitChatCompletionSystemMessageParam( - chatCompletionSystemMessageParam: ChatCompletionSystemMessageParam - ): T + fun visitSystem(system: ChatCompletionSystemMessageParam): T /** Messages sent by an end user, containing prompts or additional context information. */ - fun visitChatCompletionUserMessageParam( - chatCompletionUserMessageParam: ChatCompletionUserMessageParam - ): T + fun visitUser(user: ChatCompletionUserMessageParam): T /** Messages sent by the model in response to user messages. */ - fun visitChatCompletionAssistantMessageParam( - chatCompletionAssistantMessageParam: ChatCompletionAssistantMessageParam - ): T + fun visitAssistant(assistant: ChatCompletionAssistantMessageParam): T - fun visitChatCompletionToolMessageParam( - chatCompletionToolMessageParam: ChatCompletionToolMessageParam - ): T + fun visitTool(tool: ChatCompletionToolMessageParam): T - @Deprecated("deprecated") - fun visitChatCompletionFunctionMessageParam( - chatCompletionFunctionMessageParam: ChatCompletionFunctionMessageParam - ): T + @Deprecated("deprecated") fun visitFunction(function: ChatCompletionFunctionMessageParam): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown ChatCompletionMessageParam: $json") @@ -330,10 +248,7 @@ private constructor( it.validate() } ?.let { - return ChatCompletionMessageParam( - chatCompletionDeveloperMessageParam = it, - _json = json - ) + return ChatCompletionMessageParam(developer = it, _json = json) } } "system" -> { @@ -341,10 +256,7 @@ private constructor( it.validate() } ?.let { - return ChatCompletionMessageParam( - chatCompletionSystemMessageParam = it, - _json = json - ) + return ChatCompletionMessageParam(system = it, _json = json) } } "user" -> { @@ -352,10 +264,7 @@ private constructor( it.validate() } ?.let { - return ChatCompletionMessageParam( - chatCompletionUserMessageParam = it, - _json = json - ) + return ChatCompletionMessageParam(user = it, _json = json) } } "assistant" -> { @@ -363,10 +272,7 @@ private constructor( it.validate() } ?.let { - return ChatCompletionMessageParam( - chatCompletionAssistantMessageParam = it, - _json = json - ) + return ChatCompletionMessageParam(assistant = it, _json = json) } } "tool" -> { @@ -374,10 +280,7 @@ private constructor( it.validate() } ?.let { - return ChatCompletionMessageParam( - chatCompletionToolMessageParam = it, - _json = json - ) + return ChatCompletionMessageParam(tool = it, _json = json) } } "function" -> { @@ -385,10 +288,7 @@ private constructor( it.validate() } ?.let { - return ChatCompletionMessageParam( - chatCompletionFunctionMessageParam = it, - _json = json - ) + return ChatCompletionMessageParam(function = it, _json = json) } } } @@ -406,18 +306,12 @@ private constructor( provider: SerializerProvider ) { when { - value.chatCompletionDeveloperMessageParam != null -> - generator.writeObject(value.chatCompletionDeveloperMessageParam) - value.chatCompletionSystemMessageParam != null -> - generator.writeObject(value.chatCompletionSystemMessageParam) - value.chatCompletionUserMessageParam != null -> - generator.writeObject(value.chatCompletionUserMessageParam) - value.chatCompletionAssistantMessageParam != null -> - generator.writeObject(value.chatCompletionAssistantMessageParam) - value.chatCompletionToolMessageParam != null -> - generator.writeObject(value.chatCompletionToolMessageParam) - value.chatCompletionFunctionMessageParam != null -> - generator.writeObject(value.chatCompletionFunctionMessageParam) + value.developer != null -> generator.writeObject(value.developer) + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ChatCompletionMessageParam") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionPredictionContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionPredictionContent.kt index 0bce88696..b96e14ce1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionPredictionContent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionPredictionContent.kt @@ -118,7 +118,7 @@ private constructor( * The content used for a Predicted Output. This is often the text of a file you are * regenerating with minor changes. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type. Supported options differ based on the @@ -169,7 +169,7 @@ private constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { @@ -178,7 +178,7 @@ private constructor( * The content used for a Predicted Output. This is often the text of a file you are * regenerating with minor changes. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type. Supported options differ based on the @@ -188,7 +188,7 @@ private constructor( fun arrayOfContentParts(): Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null @@ -196,7 +196,7 @@ private constructor( * The content used for a Predicted Output. This is often the text of a file you are * regenerating with minor changes. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type. Supported options differ based on the @@ -210,7 +210,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } @@ -225,7 +225,7 @@ private constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -242,14 +242,14 @@ private constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") @@ -261,7 +261,7 @@ private constructor( * The content used for a Predicted Output. This is often the text of a file you are * regenerating with minor changes. */ - @JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type. Supported options differ based on the @@ -279,7 +279,7 @@ private constructor( * The content used for a Predicted Output. This is often the text of a file you are * regenerating with minor changes. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type. Supported options differ based on the @@ -301,7 +301,7 @@ private constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } @@ -322,7 +322,7 @@ private constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionSystemMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionSystemMessageParam.kt index 94b5cf3c8..cb7a96ced 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionSystemMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionSystemMessageParam.kt @@ -117,7 +117,7 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** The contents of the system message. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type. For system messages, only type `text` is @@ -174,13 +174,13 @@ private constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { /** The contents of the system message. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type. For system messages, only type `text` is @@ -189,12 +189,12 @@ private constructor( fun arrayOfContentParts(): Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null /** The contents of the system message. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type. For system messages, only type `text` is @@ -207,7 +207,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } @@ -222,7 +222,7 @@ private constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -239,14 +239,14 @@ private constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") @@ -255,7 +255,7 @@ private constructor( companion object { /** The contents of the system message. */ - @JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type. For system messages, only type `text` @@ -269,7 +269,7 @@ private constructor( interface Visitor { /** The contents of the system message. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type. For system messages, only type `text` @@ -290,7 +290,7 @@ private constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } @@ -311,7 +311,7 @@ private constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionToolChoiceOption.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionToolChoiceOption.kt index dde03bb6e..2a7b47d64 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionToolChoiceOption.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionToolChoiceOption.kt @@ -34,7 +34,7 @@ import java.util.Optional class ChatCompletionToolChoiceOption private constructor( private val auto: Auto? = null, - private val chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice? = null, + private val namedToolChoice: ChatCompletionNamedToolChoice? = null, private val _json: JsonValue? = null, ) { @@ -48,12 +48,12 @@ private constructor( /** * Specifies a tool the model should use. Use to force the model to call a specific function. */ - fun chatCompletionNamedToolChoice(): Optional = - Optional.ofNullable(chatCompletionNamedToolChoice) + fun namedToolChoice(): Optional = + Optional.ofNullable(namedToolChoice) fun isAuto(): Boolean = auto != null - fun isChatCompletionNamedToolChoice(): Boolean = chatCompletionNamedToolChoice != null + fun isNamedToolChoice(): Boolean = namedToolChoice != null /** * `none` means the model will not call any tool and instead generates a message. `auto` means @@ -65,16 +65,15 @@ private constructor( /** * Specifies a tool the model should use. Use to force the model to call a specific function. */ - fun asChatCompletionNamedToolChoice(): ChatCompletionNamedToolChoice = - chatCompletionNamedToolChoice.getOrThrow("chatCompletionNamedToolChoice") + fun asNamedToolChoice(): ChatCompletionNamedToolChoice = + namedToolChoice.getOrThrow("namedToolChoice") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { auto != null -> visitor.visitAuto(auto) - chatCompletionNamedToolChoice != null -> - visitor.visitChatCompletionNamedToolChoice(chatCompletionNamedToolChoice) + namedToolChoice != null -> visitor.visitNamedToolChoice(namedToolChoice) else -> visitor.unknown(_json) } } @@ -90,10 +89,8 @@ private constructor( object : Visitor { override fun visitAuto(auto: Auto) {} - override fun visitChatCompletionNamedToolChoice( - chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice - ) { - chatCompletionNamedToolChoice.validate() + override fun visitNamedToolChoice(namedToolChoice: ChatCompletionNamedToolChoice) { + namedToolChoice.validate() } } ) @@ -105,16 +102,16 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionToolChoiceOption && auto == other.auto && chatCompletionNamedToolChoice == other.chatCompletionNamedToolChoice /* spotless:on */ + return /* spotless:off */ other is ChatCompletionToolChoiceOption && auto == other.auto && namedToolChoice == other.namedToolChoice /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(auto, chatCompletionNamedToolChoice) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(auto, namedToolChoice) /* spotless:on */ override fun toString(): String = when { auto != null -> "ChatCompletionToolChoiceOption{auto=$auto}" - chatCompletionNamedToolChoice != null -> - "ChatCompletionToolChoiceOption{chatCompletionNamedToolChoice=$chatCompletionNamedToolChoice}" + namedToolChoice != null -> + "ChatCompletionToolChoiceOption{namedToolChoice=$namedToolChoice}" _json != null -> "ChatCompletionToolChoiceOption{_unknown=$_json}" else -> throw IllegalStateException("Invalid ChatCompletionToolChoiceOption") } @@ -133,12 +130,8 @@ private constructor( * function. */ @JvmStatic - fun ofChatCompletionNamedToolChoice( - chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice - ) = - ChatCompletionToolChoiceOption( - chatCompletionNamedToolChoice = chatCompletionNamedToolChoice - ) + fun ofNamedToolChoice(namedToolChoice: ChatCompletionNamedToolChoice) = + ChatCompletionToolChoiceOption(namedToolChoice = namedToolChoice) } interface Visitor { @@ -154,9 +147,7 @@ private constructor( * Specifies a tool the model should use. Use to force the model to call a specific * function. */ - fun visitChatCompletionNamedToolChoice( - chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice - ): T + fun visitNamedToolChoice(namedToolChoice: ChatCompletionNamedToolChoice): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown ChatCompletionToolChoiceOption: $json") @@ -174,10 +165,7 @@ private constructor( } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return ChatCompletionToolChoiceOption( - chatCompletionNamedToolChoice = it, - _json = json - ) + return ChatCompletionToolChoiceOption(namedToolChoice = it, _json = json) } return ChatCompletionToolChoiceOption(_json = json) @@ -194,8 +182,7 @@ private constructor( ) { when { value.auto != null -> generator.writeObject(value.auto) - value.chatCompletionNamedToolChoice != null -> - generator.writeObject(value.chatCompletionNamedToolChoice) + value.namedToolChoice != null -> generator.writeObject(value.namedToolChoice) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ChatCompletionToolChoiceOption") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionToolMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionToolMessageParam.kt index 0129fba8f..1c4ccffd4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionToolMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionToolMessageParam.kt @@ -108,7 +108,7 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** The contents of the tool message. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type. For tool messages, only type `text` is @@ -159,13 +159,13 @@ private constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { /** The contents of the tool message. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type. For tool messages, only type `text` is @@ -174,12 +174,12 @@ private constructor( fun arrayOfContentParts(): Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null /** The contents of the tool message. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type. For tool messages, only type `text` is @@ -192,7 +192,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } @@ -207,7 +207,7 @@ private constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -224,14 +224,14 @@ private constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") @@ -240,7 +240,7 @@ private constructor( companion object { /** The contents of the tool message. */ - @JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type. For tool messages, only type `text` is @@ -254,7 +254,7 @@ private constructor( interface Visitor { /** The contents of the tool message. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type. For tool messages, only type `text` is @@ -275,7 +275,7 @@ private constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } @@ -296,7 +296,7 @@ private constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionUserMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionUserMessageParam.kt index b93553cbb..afd0e9665 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionUserMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionUserMessageParam.kt @@ -113,7 +113,7 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** The text contents of the message. */ - fun content(textContent: String) = content(Content.ofTextContent(textContent)) + fun content(text: String) = content(Content.ofText(text)) /** * An array of content parts with a defined type. Supported options differ based on the @@ -171,13 +171,13 @@ private constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val textContent: String? = null, + private val text: String? = null, private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, ) { /** The text contents of the message. */ - fun textContent(): Optional = Optional.ofNullable(textContent) + fun text(): Optional = Optional.ofNullable(text) /** * An array of content parts with a defined type. Supported options differ based on the @@ -187,12 +187,12 @@ private constructor( fun arrayOfContentParts(): Optional> = Optional.ofNullable(arrayOfContentParts) - fun isTextContent(): Boolean = textContent != null + fun isText(): Boolean = text != null fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null /** The text contents of the message. */ - fun asTextContent(): String = textContent.getOrThrow("textContent") + fun asText(): String = text.getOrThrow("text") /** * An array of content parts with a defined type. Supported options differ based on the @@ -206,7 +206,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - textContent != null -> visitor.visitTextContent(textContent) + text != null -> visitor.visitText(text) arrayOfContentParts != null -> visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } @@ -221,7 +221,7 @@ private constructor( accept( object : Visitor { - override fun visitTextContent(textContent: String) {} + override fun visitText(text: String) {} override fun visitArrayOfContentParts( arrayOfContentParts: List @@ -238,14 +238,14 @@ private constructor( return true } - return /* spotless:off */ other is Content && textContent == other.textContent && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, arrayOfContentParts) /* spotless:on */ override fun toString(): String = when { - textContent != null -> "Content{textContent=$textContent}" + text != null -> "Content{text=$text}" arrayOfContentParts != null -> "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") @@ -254,7 +254,7 @@ private constructor( companion object { /** The text contents of the message. */ - @JvmStatic fun ofTextContent(textContent: String) = Content(textContent = textContent) + @JvmStatic fun ofText(text: String) = Content(text = text) /** * An array of content parts with a defined type. Supported options differ based on the @@ -269,7 +269,7 @@ private constructor( interface Visitor { /** The text contents of the message. */ - fun visitTextContent(textContent: String): T + fun visitText(text: String): T /** * An array of content parts with a defined type. Supported options differ based on the @@ -289,7 +289,7 @@ private constructor( val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(textContent = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } @@ -310,7 +310,7 @@ private constructor( provider: SerializerProvider ) { when { - value.textContent != null -> generator.writeObject(value.textContent) + value.text != null -> generator.writeObject(value.text) value.arrayOfContentParts != null -> generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/CodeInterpreterToolCallDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/CodeInterpreterToolCallDelta.kt index 4ec722ac4..c8e78ee12 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/CodeInterpreterToolCallDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/CodeInterpreterToolCallDelta.kt @@ -284,16 +284,14 @@ private constructor( } /** Text output from the Code Interpreter tool call as part of a run step. */ - fun addOutput(codeInterpreterLogs: CodeInterpreterLogs) = - addOutput(Output.ofCodeInterpreterLogs(codeInterpreterLogs)) + fun addOutput(logs: CodeInterpreterLogs) = addOutput(Output.ofLogs(logs)) /** * The outputs from the Code Interpreter tool call. Code Interpreter can output one or * more items, including text (`logs`) or images (`image`). Each of these are * represented by a different object type. */ - fun addOutput(codeInterpreterOutputImage: CodeInterpreterOutputImage) = - addOutput(Output.ofCodeInterpreterOutputImage(codeInterpreterOutputImage)) + fun addOutput(image: CodeInterpreterOutputImage) = addOutput(Output.ofImage(image)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -327,37 +325,31 @@ private constructor( @JsonSerialize(using = Output.Serializer::class) class Output private constructor( - private val codeInterpreterLogs: CodeInterpreterLogs? = null, - private val codeInterpreterOutputImage: CodeInterpreterOutputImage? = null, + private val logs: CodeInterpreterLogs? = null, + private val image: CodeInterpreterOutputImage? = null, private val _json: JsonValue? = null, ) { /** Text output from the Code Interpreter tool call as part of a run step. */ - fun codeInterpreterLogs(): Optional = - Optional.ofNullable(codeInterpreterLogs) + fun logs(): Optional = Optional.ofNullable(logs) - fun codeInterpreterOutputImage(): Optional = - Optional.ofNullable(codeInterpreterOutputImage) + fun image(): Optional = Optional.ofNullable(image) - fun isCodeInterpreterLogs(): Boolean = codeInterpreterLogs != null + fun isLogs(): Boolean = logs != null - fun isCodeInterpreterOutputImage(): Boolean = codeInterpreterOutputImage != null + fun isImage(): Boolean = image != null /** Text output from the Code Interpreter tool call as part of a run step. */ - fun asCodeInterpreterLogs(): CodeInterpreterLogs = - codeInterpreterLogs.getOrThrow("codeInterpreterLogs") + fun asLogs(): CodeInterpreterLogs = logs.getOrThrow("logs") - fun asCodeInterpreterOutputImage(): CodeInterpreterOutputImage = - codeInterpreterOutputImage.getOrThrow("codeInterpreterOutputImage") + fun asImage(): CodeInterpreterOutputImage = image.getOrThrow("image") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - codeInterpreterLogs != null -> - visitor.visitCodeInterpreterLogs(codeInterpreterLogs) - codeInterpreterOutputImage != null -> - visitor.visitCodeInterpreterOutputImage(codeInterpreterOutputImage) + logs != null -> visitor.visitLogs(logs) + image != null -> visitor.visitImage(image) else -> visitor.unknown(_json) } } @@ -371,16 +363,12 @@ private constructor( accept( object : Visitor { - override fun visitCodeInterpreterLogs( - codeInterpreterLogs: CodeInterpreterLogs - ) { - codeInterpreterLogs.validate() + override fun visitLogs(logs: CodeInterpreterLogs) { + logs.validate() } - override fun visitCodeInterpreterOutputImage( - codeInterpreterOutputImage: CodeInterpreterOutputImage - ) { - codeInterpreterOutputImage.validate() + override fun visitImage(image: CodeInterpreterOutputImage) { + image.validate() } } ) @@ -392,17 +380,15 @@ private constructor( return true } - return /* spotless:off */ other is Output && codeInterpreterLogs == other.codeInterpreterLogs && codeInterpreterOutputImage == other.codeInterpreterOutputImage /* spotless:on */ + return /* spotless:off */ other is Output && logs == other.logs && image == other.image /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterLogs, codeInterpreterOutputImage) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(logs, image) /* spotless:on */ override fun toString(): String = when { - codeInterpreterLogs != null -> - "Output{codeInterpreterLogs=$codeInterpreterLogs}" - codeInterpreterOutputImage != null -> - "Output{codeInterpreterOutputImage=$codeInterpreterOutputImage}" + logs != null -> "Output{logs=$logs}" + image != null -> "Output{image=$image}" _json != null -> "Output{_unknown=$_json}" else -> throw IllegalStateException("Invalid Output") } @@ -410,24 +396,17 @@ private constructor( companion object { /** Text output from the Code Interpreter tool call as part of a run step. */ - @JvmStatic - fun ofCodeInterpreterLogs(codeInterpreterLogs: CodeInterpreterLogs) = - Output(codeInterpreterLogs = codeInterpreterLogs) - - @JvmStatic - fun ofCodeInterpreterOutputImage( - codeInterpreterOutputImage: CodeInterpreterOutputImage - ) = Output(codeInterpreterOutputImage = codeInterpreterOutputImage) + @JvmStatic fun ofLogs(logs: CodeInterpreterLogs) = Output(logs = logs) + + @JvmStatic fun ofImage(image: CodeInterpreterOutputImage) = Output(image = image) } interface Visitor { /** Text output from the Code Interpreter tool call as part of a run step. */ - fun visitCodeInterpreterLogs(codeInterpreterLogs: CodeInterpreterLogs): T + fun visitLogs(logs: CodeInterpreterLogs): T - fun visitCodeInterpreterOutputImage( - codeInterpreterOutputImage: CodeInterpreterOutputImage - ): T + fun visitImage(image: CodeInterpreterOutputImage): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown Output: $json") @@ -446,7 +425,7 @@ private constructor( it.validate() } ?.let { - return Output(codeInterpreterLogs = it, _json = json) + return Output(logs = it, _json = json) } } "image" -> { @@ -454,7 +433,7 @@ private constructor( it.validate() } ?.let { - return Output(codeInterpreterOutputImage = it, _json = json) + return Output(image = it, _json = json) } } } @@ -471,10 +450,8 @@ private constructor( provider: SerializerProvider ) { when { - value.codeInterpreterLogs != null -> - generator.writeObject(value.codeInterpreterLogs) - value.codeInterpreterOutputImage != null -> - generator.writeObject(value.codeInterpreterOutputImage) + value.logs != null -> generator.writeObject(value.logs) + value.image != null -> generator.writeObject(value.image) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Output") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/FileChunkingStrategy.kt b/openai-java-core/src/main/kotlin/com/openai/models/FileChunkingStrategy.kt index eb3f3b97d..9c0e34b29 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/FileChunkingStrategy.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/FileChunkingStrategy.kt @@ -23,43 +23,37 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = FileChunkingStrategy.Serializer::class) class FileChunkingStrategy private constructor( - private val staticFileChunkingStrategyObject: StaticFileChunkingStrategyObject? = null, - private val otherFileChunkingStrategyObject: OtherFileChunkingStrategyObject? = null, + private val static_: StaticFileChunkingStrategyObject? = null, + private val other: OtherFileChunkingStrategyObject? = null, private val _json: JsonValue? = null, ) { - fun staticFileChunkingStrategyObject(): Optional = - Optional.ofNullable(staticFileChunkingStrategyObject) + fun static_(): Optional = Optional.ofNullable(static_) /** * This is returned when the chunking strategy is unknown. Typically, this is because the file * was indexed before the `chunking_strategy` concept was introduced in the API. */ - fun otherFileChunkingStrategyObject(): Optional = - Optional.ofNullable(otherFileChunkingStrategyObject) + fun other(): Optional = Optional.ofNullable(other) - fun isStaticFileChunkingStrategyObject(): Boolean = staticFileChunkingStrategyObject != null + fun isStatic(): Boolean = static_ != null - fun isOtherFileChunkingStrategyObject(): Boolean = otherFileChunkingStrategyObject != null + fun isOther(): Boolean = other != null - fun asStaticFileChunkingStrategyObject(): StaticFileChunkingStrategyObject = - staticFileChunkingStrategyObject.getOrThrow("staticFileChunkingStrategyObject") + fun asStatic(): StaticFileChunkingStrategyObject = static_.getOrThrow("static_") /** * This is returned when the chunking strategy is unknown. Typically, this is because the file * was indexed before the `chunking_strategy` concept was introduced in the API. */ - fun asOtherFileChunkingStrategyObject(): OtherFileChunkingStrategyObject = - otherFileChunkingStrategyObject.getOrThrow("otherFileChunkingStrategyObject") + fun asOther(): OtherFileChunkingStrategyObject = other.getOrThrow("other") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - staticFileChunkingStrategyObject != null -> - visitor.visitStaticFileChunkingStrategyObject(staticFileChunkingStrategyObject) - otherFileChunkingStrategyObject != null -> - visitor.visitOtherFileChunkingStrategyObject(otherFileChunkingStrategyObject) + static_ != null -> visitor.visitStatic(static_) + other != null -> visitor.visitOther(other) else -> visitor.unknown(_json) } } @@ -73,16 +67,12 @@ private constructor( accept( object : Visitor { - override fun visitStaticFileChunkingStrategyObject( - staticFileChunkingStrategyObject: StaticFileChunkingStrategyObject - ) { - staticFileChunkingStrategyObject.validate() + override fun visitStatic(static_: StaticFileChunkingStrategyObject) { + static_.validate() } - override fun visitOtherFileChunkingStrategyObject( - otherFileChunkingStrategyObject: OtherFileChunkingStrategyObject - ) { - otherFileChunkingStrategyObject.validate() + override fun visitOther(other: OtherFileChunkingStrategyObject) { + other.validate() } } ) @@ -94,17 +84,15 @@ private constructor( return true } - return /* spotless:off */ other is FileChunkingStrategy && staticFileChunkingStrategyObject == other.staticFileChunkingStrategyObject && otherFileChunkingStrategyObject == other.otherFileChunkingStrategyObject /* spotless:on */ + return /* spotless:off */ other is FileChunkingStrategy && static_ == other.static_ && this.other == other.other /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(staticFileChunkingStrategyObject, otherFileChunkingStrategyObject) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(static_, other) /* spotless:on */ override fun toString(): String = when { - staticFileChunkingStrategyObject != null -> - "FileChunkingStrategy{staticFileChunkingStrategyObject=$staticFileChunkingStrategyObject}" - otherFileChunkingStrategyObject != null -> - "FileChunkingStrategy{otherFileChunkingStrategyObject=$otherFileChunkingStrategyObject}" + static_ != null -> "FileChunkingStrategy{static_=$static_}" + other != null -> "FileChunkingStrategy{other=$other}" _json != null -> "FileChunkingStrategy{_unknown=$_json}" else -> throw IllegalStateException("Invalid FileChunkingStrategy") } @@ -112,36 +100,26 @@ private constructor( companion object { @JvmStatic - fun ofStaticFileChunkingStrategyObject( - staticFileChunkingStrategyObject: StaticFileChunkingStrategyObject - ) = - FileChunkingStrategy( - staticFileChunkingStrategyObject = staticFileChunkingStrategyObject - ) + fun ofStatic(static_: StaticFileChunkingStrategyObject) = + FileChunkingStrategy(static_ = static_) /** * This is returned when the chunking strategy is unknown. Typically, this is because the * file was indexed before the `chunking_strategy` concept was introduced in the API. */ @JvmStatic - fun ofOtherFileChunkingStrategyObject( - otherFileChunkingStrategyObject: OtherFileChunkingStrategyObject - ) = FileChunkingStrategy(otherFileChunkingStrategyObject = otherFileChunkingStrategyObject) + fun ofOther(other: OtherFileChunkingStrategyObject) = FileChunkingStrategy(other = other) } interface Visitor { - fun visitStaticFileChunkingStrategyObject( - staticFileChunkingStrategyObject: StaticFileChunkingStrategyObject - ): T + fun visitStatic(static_: StaticFileChunkingStrategyObject): T /** * This is returned when the chunking strategy is unknown. Typically, this is because the * file was indexed before the `chunking_strategy` concept was introduced in the API. */ - fun visitOtherFileChunkingStrategyObject( - otherFileChunkingStrategyObject: OtherFileChunkingStrategyObject - ): T + fun visitOther(other: OtherFileChunkingStrategyObject): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown FileChunkingStrategy: $json") @@ -160,10 +138,7 @@ private constructor( it.validate() } ?.let { - return FileChunkingStrategy( - staticFileChunkingStrategyObject = it, - _json = json - ) + return FileChunkingStrategy(static_ = it, _json = json) } } "other" -> { @@ -171,10 +146,7 @@ private constructor( it.validate() } ?.let { - return FileChunkingStrategy( - otherFileChunkingStrategyObject = it, - _json = json - ) + return FileChunkingStrategy(other = it, _json = json) } } } @@ -191,10 +163,8 @@ private constructor( provider: SerializerProvider ) { when { - value.staticFileChunkingStrategyObject != null -> - generator.writeObject(value.staticFileChunkingStrategyObject) - value.otherFileChunkingStrategyObject != null -> - generator.writeObject(value.otherFileChunkingStrategyObject) + value.static_ != null -> generator.writeObject(value.static_) + value.other != null -> generator.writeObject(value.other) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid FileChunkingStrategy") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/FileChunkingStrategyParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/FileChunkingStrategyParam.kt index 941f6f939..f92e25e51 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/FileChunkingStrategyParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/FileChunkingStrategyParam.kt @@ -26,9 +26,8 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = FileChunkingStrategyParam.Serializer::class) class FileChunkingStrategyParam private constructor( - private val autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam? = null, - private val staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam? = - null, + private val auto: AutoFileChunkingStrategyParam? = null, + private val static_: StaticFileChunkingStrategyObjectParam? = null, private val _json: JsonValue? = null, ) { @@ -36,37 +35,28 @@ private constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and * `chunk_overlap_tokens` of `400`. */ - fun autoFileChunkingStrategyParam(): Optional = - Optional.ofNullable(autoFileChunkingStrategyParam) + fun auto(): Optional = Optional.ofNullable(auto) - fun staticFileChunkingStrategyObjectParam(): Optional = - Optional.ofNullable(staticFileChunkingStrategyObjectParam) + fun static_(): Optional = Optional.ofNullable(static_) - fun isAutoFileChunkingStrategyParam(): Boolean = autoFileChunkingStrategyParam != null + fun isAuto(): Boolean = auto != null - fun isStaticFileChunkingStrategyObjectParam(): Boolean = - staticFileChunkingStrategyObjectParam != null + fun isStatic(): Boolean = static_ != null /** * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and * `chunk_overlap_tokens` of `400`. */ - fun asAutoFileChunkingStrategyParam(): AutoFileChunkingStrategyParam = - autoFileChunkingStrategyParam.getOrThrow("autoFileChunkingStrategyParam") + fun asAuto(): AutoFileChunkingStrategyParam = auto.getOrThrow("auto") - fun asStaticFileChunkingStrategyObjectParam(): StaticFileChunkingStrategyObjectParam = - staticFileChunkingStrategyObjectParam.getOrThrow("staticFileChunkingStrategyObjectParam") + fun asStatic(): StaticFileChunkingStrategyObjectParam = static_.getOrThrow("static_") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - autoFileChunkingStrategyParam != null -> - visitor.visitAutoFileChunkingStrategyParam(autoFileChunkingStrategyParam) - staticFileChunkingStrategyObjectParam != null -> - visitor.visitStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam - ) + auto != null -> visitor.visitAuto(auto) + static_ != null -> visitor.visitStatic(static_) else -> visitor.unknown(_json) } } @@ -80,16 +70,12 @@ private constructor( accept( object : Visitor { - override fun visitAutoFileChunkingStrategyParam( - autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam - ) { - autoFileChunkingStrategyParam.validate() + override fun visitAuto(auto: AutoFileChunkingStrategyParam) { + auto.validate() } - override fun visitStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) { - staticFileChunkingStrategyObjectParam.validate() + override fun visitStatic(static_: StaticFileChunkingStrategyObjectParam) { + static_.validate() } } ) @@ -101,17 +87,15 @@ private constructor( return true } - return /* spotless:off */ other is FileChunkingStrategyParam && autoFileChunkingStrategyParam == other.autoFileChunkingStrategyParam && staticFileChunkingStrategyObjectParam == other.staticFileChunkingStrategyObjectParam /* spotless:on */ + return /* spotless:off */ other is FileChunkingStrategyParam && auto == other.auto && static_ == other.static_ /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(autoFileChunkingStrategyParam, staticFileChunkingStrategyObjectParam) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(auto, static_) /* spotless:on */ override fun toString(): String = when { - autoFileChunkingStrategyParam != null -> - "FileChunkingStrategyParam{autoFileChunkingStrategyParam=$autoFileChunkingStrategyParam}" - staticFileChunkingStrategyObjectParam != null -> - "FileChunkingStrategyParam{staticFileChunkingStrategyObjectParam=$staticFileChunkingStrategyObjectParam}" + auto != null -> "FileChunkingStrategyParam{auto=$auto}" + static_ != null -> "FileChunkingStrategyParam{static_=$static_}" _json != null -> "FileChunkingStrategyParam{_unknown=$_json}" else -> throw IllegalStateException("Invalid FileChunkingStrategyParam") } @@ -123,17 +107,11 @@ private constructor( * `chunk_overlap_tokens` of `400`. */ @JvmStatic - fun ofAutoFileChunkingStrategyParam( - autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam - ) = FileChunkingStrategyParam(autoFileChunkingStrategyParam = autoFileChunkingStrategyParam) + fun ofAuto(auto: AutoFileChunkingStrategyParam) = FileChunkingStrategyParam(auto = auto) @JvmStatic - fun ofStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ) = - FileChunkingStrategyParam( - staticFileChunkingStrategyObjectParam = staticFileChunkingStrategyObjectParam - ) + fun ofStatic(static_: StaticFileChunkingStrategyObjectParam) = + FileChunkingStrategyParam(static_ = static_) } interface Visitor { @@ -142,13 +120,9 @@ private constructor( * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and * `chunk_overlap_tokens` of `400`. */ - fun visitAutoFileChunkingStrategyParam( - autoFileChunkingStrategyParam: AutoFileChunkingStrategyParam - ): T + fun visitAuto(auto: AutoFileChunkingStrategyParam): T - fun visitStaticFileChunkingStrategyObjectParam( - staticFileChunkingStrategyObjectParam: StaticFileChunkingStrategyObjectParam - ): T + fun visitStatic(static_: StaticFileChunkingStrategyObjectParam): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown FileChunkingStrategyParam: $json") @@ -168,10 +142,7 @@ private constructor( it.validate() } ?.let { - return FileChunkingStrategyParam( - autoFileChunkingStrategyParam = it, - _json = json - ) + return FileChunkingStrategyParam(auto = it, _json = json) } } "static" -> { @@ -179,10 +150,7 @@ private constructor( it.validate() } ?.let { - return FileChunkingStrategyParam( - staticFileChunkingStrategyObjectParam = it, - _json = json - ) + return FileChunkingStrategyParam(static_ = it, _json = json) } } } @@ -199,10 +167,8 @@ private constructor( provider: SerializerProvider ) { when { - value.autoFileChunkingStrategyParam != null -> - generator.writeObject(value.autoFileChunkingStrategyParam) - value.staticFileChunkingStrategyObjectParam != null -> - generator.writeObject(value.staticFileChunkingStrategyObjectParam) + value.auto != null -> generator.writeObject(value.auto) + value.static_ != null -> generator.writeObject(value.static_) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid FileChunkingStrategyParam") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Message.kt b/openai-java-core/src/main/kotlin/com/openai/models/Message.kt index e012c8dae..2e0ff32e0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Message.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Message.kt @@ -362,20 +362,18 @@ private constructor( * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun addContent(imageFileContentBlock: ImageFileContentBlock) = - addContent(MessageContent.ofImageFileContentBlock(imageFileContentBlock)) + fun addContent(imageFile: ImageFileContentBlock) = + addContent(MessageContent.ofImageFile(imageFile)) /** References an image URL in the content of a message. */ - fun addContent(imageUrlContentBlock: ImageUrlContentBlock) = - addContent(MessageContent.ofImageUrlContentBlock(imageUrlContentBlock)) + fun addContent(imageUrl: ImageUrlContentBlock) = + addContent(MessageContent.ofImageUrl(imageUrl)) /** The text content that is part of a message. */ - fun addContent(textContentBlock: TextContentBlock) = - addContent(MessageContent.ofTextContentBlock(textContentBlock)) + fun addContent(text: TextContentBlock) = addContent(MessageContent.ofText(text)) /** The refusal content generated by the assistant. */ - fun addContent(refusalContentBlock: RefusalContentBlock) = - addContent(MessageContent.ofRefusalContentBlock(refusalContentBlock)) + fun addContent(refusal: RefusalContentBlock) = addContent(MessageContent.ofRefusal(refusal)) /** The Unix timestamp (in seconds) for when the message was created. */ fun createdAt(createdAt: Long) = createdAt(JsonField.of(createdAt)) @@ -601,8 +599,8 @@ private constructor( } /** The tools to add this file to. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(Tool.ofCodeInterpreter(codeInterpreter)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -635,24 +633,24 @@ private constructor( @JsonSerialize(using = Tool.Serializer::class) class Tool private constructor( - private val codeInterpreterTool: CodeInterpreterTool? = null, + private val codeInterpreter: CodeInterpreterTool? = null, private val assistantToolsFileSearchTypeOnly: JsonValue? = null, private val _json: JsonValue? = null, ) { - fun codeInterpreterTool(): Optional = - Optional.ofNullable(codeInterpreterTool) + fun codeInterpreter(): Optional = + Optional.ofNullable(codeInterpreter) fun assistantToolsFileSearchTypeOnly(): Optional = Optional.ofNullable(assistantToolsFileSearchTypeOnly) - fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null + fun isCodeInterpreter(): Boolean = codeInterpreter != null fun isAssistantToolsFileSearchTypeOnly(): Boolean = assistantToolsFileSearchTypeOnly != null - fun asCodeInterpreterTool(): CodeInterpreterTool = - codeInterpreterTool.getOrThrow("codeInterpreterTool") + fun asCodeInterpreter(): CodeInterpreterTool = + codeInterpreter.getOrThrow("codeInterpreter") fun asAssistantToolsFileSearchTypeOnly(): JsonValue = assistantToolsFileSearchTypeOnly.getOrThrow("assistantToolsFileSearchTypeOnly") @@ -661,8 +659,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - codeInterpreterTool != null -> - visitor.visitCodeInterpreterTool(codeInterpreterTool) + codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) assistantToolsFileSearchTypeOnly != null -> visitor.visitAssistantToolsFileSearchTypeOnly( assistantToolsFileSearchTypeOnly @@ -680,10 +677,8 @@ private constructor( accept( object : Visitor { - override fun visitCodeInterpreterTool( - codeInterpreterTool: CodeInterpreterTool - ) { - codeInterpreterTool.validate() + override fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool) { + codeInterpreter.validate() } override fun visitAssistantToolsFileSearchTypeOnly( @@ -707,14 +702,14 @@ private constructor( return true } - return /* spotless:off */ other is Tool && codeInterpreterTool == other.codeInterpreterTool && assistantToolsFileSearchTypeOnly == other.assistantToolsFileSearchTypeOnly /* spotless:on */ + return /* spotless:off */ other is Tool && codeInterpreter == other.codeInterpreter && assistantToolsFileSearchTypeOnly == other.assistantToolsFileSearchTypeOnly /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterTool, assistantToolsFileSearchTypeOnly) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreter, assistantToolsFileSearchTypeOnly) /* spotless:on */ override fun toString(): String = when { - codeInterpreterTool != null -> "Tool{codeInterpreterTool=$codeInterpreterTool}" + codeInterpreter != null -> "Tool{codeInterpreter=$codeInterpreter}" assistantToolsFileSearchTypeOnly != null -> "Tool{assistantToolsFileSearchTypeOnly=$assistantToolsFileSearchTypeOnly}" _json != null -> "Tool{_unknown=$_json}" @@ -724,8 +719,8 @@ private constructor( companion object { @JvmStatic - fun ofCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool) = - Tool(codeInterpreterTool = codeInterpreterTool) + fun ofCodeInterpreter(codeInterpreter: CodeInterpreterTool) = + Tool(codeInterpreter = codeInterpreter) @JvmStatic fun ofAssistantToolsFileSearchTypeOnly() = @@ -737,7 +732,7 @@ private constructor( interface Visitor { - fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T + fun visitCodeInterpreter(codeInterpreter: CodeInterpreterTool): T fun visitAssistantToolsFileSearchTypeOnly( assistantToolsFileSearchTypeOnly: JsonValue @@ -755,7 +750,7 @@ private constructor( tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Tool(codeInterpreterTool = it, _json = json) + return Tool(codeInterpreter = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.let { @@ -782,8 +777,8 @@ private constructor( provider: SerializerProvider ) { when { - value.codeInterpreterTool != null -> - generator.writeObject(value.codeInterpreterTool) + value.codeInterpreter != null -> + generator.writeObject(value.codeInterpreter) value.assistantToolsFileSearchTypeOnly != null -> generator.writeObject(value.assistantToolsFileSearchTypeOnly) value._json != null -> generator.writeObject(value._json) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/MessageContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/MessageContent.kt index b4b900fed..63f8cc320 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/MessageContent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/MessageContent.kt @@ -26,10 +26,10 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = MessageContent.Serializer::class) class MessageContent private constructor( - private val imageFileContentBlock: ImageFileContentBlock? = null, - private val imageUrlContentBlock: ImageUrlContentBlock? = null, - private val textContentBlock: TextContentBlock? = null, - private val refusalContentBlock: RefusalContentBlock? = null, + private val imageFile: ImageFileContentBlock? = null, + private val imageUrl: ImageUrlContentBlock? = null, + private val text: TextContentBlock? = null, + private val refusal: RefusalContentBlock? = null, private val _json: JsonValue? = null, ) { @@ -37,55 +37,48 @@ private constructor( * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun imageFileContentBlock(): Optional = - Optional.ofNullable(imageFileContentBlock) + fun imageFile(): Optional = Optional.ofNullable(imageFile) /** References an image URL in the content of a message. */ - fun imageUrlContentBlock(): Optional = - Optional.ofNullable(imageUrlContentBlock) + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) /** The text content that is part of a message. */ - fun textContentBlock(): Optional = Optional.ofNullable(textContentBlock) + fun text(): Optional = Optional.ofNullable(text) /** The refusal content generated by the assistant. */ - fun refusalContentBlock(): Optional = - Optional.ofNullable(refusalContentBlock) + fun refusal(): Optional = Optional.ofNullable(refusal) - fun isImageFileContentBlock(): Boolean = imageFileContentBlock != null + fun isImageFile(): Boolean = imageFile != null - fun isImageUrlContentBlock(): Boolean = imageUrlContentBlock != null + fun isImageUrl(): Boolean = imageUrl != null - fun isTextContentBlock(): Boolean = textContentBlock != null + fun isText(): Boolean = text != null - fun isRefusalContentBlock(): Boolean = refusalContentBlock != null + fun isRefusal(): Boolean = refusal != null /** * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun asImageFileContentBlock(): ImageFileContentBlock = - imageFileContentBlock.getOrThrow("imageFileContentBlock") + fun asImageFile(): ImageFileContentBlock = imageFile.getOrThrow("imageFile") /** References an image URL in the content of a message. */ - fun asImageUrlContentBlock(): ImageUrlContentBlock = - imageUrlContentBlock.getOrThrow("imageUrlContentBlock") + fun asImageUrl(): ImageUrlContentBlock = imageUrl.getOrThrow("imageUrl") /** The text content that is part of a message. */ - fun asTextContentBlock(): TextContentBlock = textContentBlock.getOrThrow("textContentBlock") + fun asText(): TextContentBlock = text.getOrThrow("text") /** The refusal content generated by the assistant. */ - fun asRefusalContentBlock(): RefusalContentBlock = - refusalContentBlock.getOrThrow("refusalContentBlock") + fun asRefusal(): RefusalContentBlock = refusal.getOrThrow("refusal") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - imageFileContentBlock != null -> - visitor.visitImageFileContentBlock(imageFileContentBlock) - imageUrlContentBlock != null -> visitor.visitImageUrlContentBlock(imageUrlContentBlock) - textContentBlock != null -> visitor.visitTextContentBlock(textContentBlock) - refusalContentBlock != null -> visitor.visitRefusalContentBlock(refusalContentBlock) + imageFile != null -> visitor.visitImageFile(imageFile) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + text != null -> visitor.visitText(text) + refusal != null -> visitor.visitRefusal(refusal) else -> visitor.unknown(_json) } } @@ -99,22 +92,20 @@ private constructor( accept( object : Visitor { - override fun visitImageFileContentBlock( - imageFileContentBlock: ImageFileContentBlock - ) { - imageFileContentBlock.validate() + override fun visitImageFile(imageFile: ImageFileContentBlock) { + imageFile.validate() } - override fun visitImageUrlContentBlock(imageUrlContentBlock: ImageUrlContentBlock) { - imageUrlContentBlock.validate() + override fun visitImageUrl(imageUrl: ImageUrlContentBlock) { + imageUrl.validate() } - override fun visitTextContentBlock(textContentBlock: TextContentBlock) { - textContentBlock.validate() + override fun visitText(text: TextContentBlock) { + text.validate() } - override fun visitRefusalContentBlock(refusalContentBlock: RefusalContentBlock) { - refusalContentBlock.validate() + override fun visitRefusal(refusal: RefusalContentBlock) { + refusal.validate() } } ) @@ -126,20 +117,17 @@ private constructor( return true } - return /* spotless:off */ other is MessageContent && imageFileContentBlock == other.imageFileContentBlock && imageUrlContentBlock == other.imageUrlContentBlock && textContentBlock == other.textContentBlock && refusalContentBlock == other.refusalContentBlock /* spotless:on */ + return /* spotless:off */ other is MessageContent && imageFile == other.imageFile && imageUrl == other.imageUrl && text == other.text && refusal == other.refusal /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(imageFileContentBlock, imageUrlContentBlock, textContentBlock, refusalContentBlock) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(imageFile, imageUrl, text, refusal) /* spotless:on */ override fun toString(): String = when { - imageFileContentBlock != null -> - "MessageContent{imageFileContentBlock=$imageFileContentBlock}" - imageUrlContentBlock != null -> - "MessageContent{imageUrlContentBlock=$imageUrlContentBlock}" - textContentBlock != null -> "MessageContent{textContentBlock=$textContentBlock}" - refusalContentBlock != null -> - "MessageContent{refusalContentBlock=$refusalContentBlock}" + imageFile != null -> "MessageContent{imageFile=$imageFile}" + imageUrl != null -> "MessageContent{imageUrl=$imageUrl}" + text != null -> "MessageContent{text=$text}" + refusal != null -> "MessageContent{refusal=$refusal}" _json != null -> "MessageContent{_unknown=$_json}" else -> throw IllegalStateException("Invalid MessageContent") } @@ -151,23 +139,17 @@ private constructor( * content of a message. */ @JvmStatic - fun ofImageFileContentBlock(imageFileContentBlock: ImageFileContentBlock) = - MessageContent(imageFileContentBlock = imageFileContentBlock) + fun ofImageFile(imageFile: ImageFileContentBlock) = MessageContent(imageFile = imageFile) /** References an image URL in the content of a message. */ @JvmStatic - fun ofImageUrlContentBlock(imageUrlContentBlock: ImageUrlContentBlock) = - MessageContent(imageUrlContentBlock = imageUrlContentBlock) + fun ofImageUrl(imageUrl: ImageUrlContentBlock) = MessageContent(imageUrl = imageUrl) /** The text content that is part of a message. */ - @JvmStatic - fun ofTextContentBlock(textContentBlock: TextContentBlock) = - MessageContent(textContentBlock = textContentBlock) + @JvmStatic fun ofText(text: TextContentBlock) = MessageContent(text = text) /** The refusal content generated by the assistant. */ - @JvmStatic - fun ofRefusalContentBlock(refusalContentBlock: RefusalContentBlock) = - MessageContent(refusalContentBlock = refusalContentBlock) + @JvmStatic fun ofRefusal(refusal: RefusalContentBlock) = MessageContent(refusal = refusal) } interface Visitor { @@ -176,16 +158,16 @@ private constructor( * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun visitImageFileContentBlock(imageFileContentBlock: ImageFileContentBlock): T + fun visitImageFile(imageFile: ImageFileContentBlock): T /** References an image URL in the content of a message. */ - fun visitImageUrlContentBlock(imageUrlContentBlock: ImageUrlContentBlock): T + fun visitImageUrl(imageUrl: ImageUrlContentBlock): T /** The text content that is part of a message. */ - fun visitTextContentBlock(textContentBlock: TextContentBlock): T + fun visitText(text: TextContentBlock): T /** The refusal content generated by the assistant. */ - fun visitRefusalContentBlock(refusalContentBlock: RefusalContentBlock): T + fun visitRefusal(refusal: RefusalContentBlock): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown MessageContent: $json") @@ -202,25 +184,25 @@ private constructor( "image_file" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContent(imageFileContentBlock = it, _json = json) + return MessageContent(imageFile = it, _json = json) } } "image_url" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContent(imageUrlContentBlock = it, _json = json) + return MessageContent(imageUrl = it, _json = json) } } "text" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContent(textContentBlock = it, _json = json) + return MessageContent(text = it, _json = json) } } "refusal" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContent(refusalContentBlock = it, _json = json) + return MessageContent(refusal = it, _json = json) } } } @@ -237,13 +219,10 @@ private constructor( provider: SerializerProvider ) { when { - value.imageFileContentBlock != null -> - generator.writeObject(value.imageFileContentBlock) - value.imageUrlContentBlock != null -> - generator.writeObject(value.imageUrlContentBlock) - value.textContentBlock != null -> generator.writeObject(value.textContentBlock) - value.refusalContentBlock != null -> - generator.writeObject(value.refusalContentBlock) + value.imageFile != null -> generator.writeObject(value.imageFile) + value.imageUrl != null -> generator.writeObject(value.imageUrl) + value.text != null -> generator.writeObject(value.text) + value.refusal != null -> generator.writeObject(value.refusal) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid MessageContent") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/MessageContentDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/MessageContentDelta.kt index 54b94cbe5..1484286ef 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/MessageContentDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/MessageContentDelta.kt @@ -26,10 +26,10 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = MessageContentDelta.Serializer::class) class MessageContentDelta private constructor( - private val imageFileDeltaBlock: ImageFileDeltaBlock? = null, - private val textDeltaBlock: TextDeltaBlock? = null, - private val refusalDeltaBlock: RefusalDeltaBlock? = null, - private val imageUrlDeltaBlock: ImageUrlDeltaBlock? = null, + private val imageFile: ImageFileDeltaBlock? = null, + private val text: TextDeltaBlock? = null, + private val refusal: RefusalDeltaBlock? = null, + private val imageUrl: ImageUrlDeltaBlock? = null, private val _json: JsonValue? = null, ) { @@ -37,51 +37,48 @@ private constructor( * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun imageFileDeltaBlock(): Optional = - Optional.ofNullable(imageFileDeltaBlock) + fun imageFile(): Optional = Optional.ofNullable(imageFile) /** The text content that is part of a message. */ - fun textDeltaBlock(): Optional = Optional.ofNullable(textDeltaBlock) + fun text(): Optional = Optional.ofNullable(text) /** The refusal content that is part of a message. */ - fun refusalDeltaBlock(): Optional = Optional.ofNullable(refusalDeltaBlock) + fun refusal(): Optional = Optional.ofNullable(refusal) /** References an image URL in the content of a message. */ - fun imageUrlDeltaBlock(): Optional = Optional.ofNullable(imageUrlDeltaBlock) + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) - fun isImageFileDeltaBlock(): Boolean = imageFileDeltaBlock != null + fun isImageFile(): Boolean = imageFile != null - fun isTextDeltaBlock(): Boolean = textDeltaBlock != null + fun isText(): Boolean = text != null - fun isRefusalDeltaBlock(): Boolean = refusalDeltaBlock != null + fun isRefusal(): Boolean = refusal != null - fun isImageUrlDeltaBlock(): Boolean = imageUrlDeltaBlock != null + fun isImageUrl(): Boolean = imageUrl != null /** * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun asImageFileDeltaBlock(): ImageFileDeltaBlock = - imageFileDeltaBlock.getOrThrow("imageFileDeltaBlock") + fun asImageFile(): ImageFileDeltaBlock = imageFile.getOrThrow("imageFile") /** The text content that is part of a message. */ - fun asTextDeltaBlock(): TextDeltaBlock = textDeltaBlock.getOrThrow("textDeltaBlock") + fun asText(): TextDeltaBlock = text.getOrThrow("text") /** The refusal content that is part of a message. */ - fun asRefusalDeltaBlock(): RefusalDeltaBlock = refusalDeltaBlock.getOrThrow("refusalDeltaBlock") + fun asRefusal(): RefusalDeltaBlock = refusal.getOrThrow("refusal") /** References an image URL in the content of a message. */ - fun asImageUrlDeltaBlock(): ImageUrlDeltaBlock = - imageUrlDeltaBlock.getOrThrow("imageUrlDeltaBlock") + fun asImageUrl(): ImageUrlDeltaBlock = imageUrl.getOrThrow("imageUrl") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - imageFileDeltaBlock != null -> visitor.visitImageFileDeltaBlock(imageFileDeltaBlock) - textDeltaBlock != null -> visitor.visitTextDeltaBlock(textDeltaBlock) - refusalDeltaBlock != null -> visitor.visitRefusalDeltaBlock(refusalDeltaBlock) - imageUrlDeltaBlock != null -> visitor.visitImageUrlDeltaBlock(imageUrlDeltaBlock) + imageFile != null -> visitor.visitImageFile(imageFile) + text != null -> visitor.visitText(text) + refusal != null -> visitor.visitRefusal(refusal) + imageUrl != null -> visitor.visitImageUrl(imageUrl) else -> visitor.unknown(_json) } } @@ -95,20 +92,20 @@ private constructor( accept( object : Visitor { - override fun visitImageFileDeltaBlock(imageFileDeltaBlock: ImageFileDeltaBlock) { - imageFileDeltaBlock.validate() + override fun visitImageFile(imageFile: ImageFileDeltaBlock) { + imageFile.validate() } - override fun visitTextDeltaBlock(textDeltaBlock: TextDeltaBlock) { - textDeltaBlock.validate() + override fun visitText(text: TextDeltaBlock) { + text.validate() } - override fun visitRefusalDeltaBlock(refusalDeltaBlock: RefusalDeltaBlock) { - refusalDeltaBlock.validate() + override fun visitRefusal(refusal: RefusalDeltaBlock) { + refusal.validate() } - override fun visitImageUrlDeltaBlock(imageUrlDeltaBlock: ImageUrlDeltaBlock) { - imageUrlDeltaBlock.validate() + override fun visitImageUrl(imageUrl: ImageUrlDeltaBlock) { + imageUrl.validate() } } ) @@ -120,19 +117,17 @@ private constructor( return true } - return /* spotless:off */ other is MessageContentDelta && imageFileDeltaBlock == other.imageFileDeltaBlock && textDeltaBlock == other.textDeltaBlock && refusalDeltaBlock == other.refusalDeltaBlock && imageUrlDeltaBlock == other.imageUrlDeltaBlock /* spotless:on */ + return /* spotless:off */ other is MessageContentDelta && imageFile == other.imageFile && text == other.text && refusal == other.refusal && imageUrl == other.imageUrl /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(imageFileDeltaBlock, textDeltaBlock, refusalDeltaBlock, imageUrlDeltaBlock) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(imageFile, text, refusal, imageUrl) /* spotless:on */ override fun toString(): String = when { - imageFileDeltaBlock != null -> - "MessageContentDelta{imageFileDeltaBlock=$imageFileDeltaBlock}" - textDeltaBlock != null -> "MessageContentDelta{textDeltaBlock=$textDeltaBlock}" - refusalDeltaBlock != null -> "MessageContentDelta{refusalDeltaBlock=$refusalDeltaBlock}" - imageUrlDeltaBlock != null -> - "MessageContentDelta{imageUrlDeltaBlock=$imageUrlDeltaBlock}" + imageFile != null -> "MessageContentDelta{imageFile=$imageFile}" + text != null -> "MessageContentDelta{text=$text}" + refusal != null -> "MessageContentDelta{refusal=$refusal}" + imageUrl != null -> "MessageContentDelta{imageUrl=$imageUrl}" _json != null -> "MessageContentDelta{_unknown=$_json}" else -> throw IllegalStateException("Invalid MessageContentDelta") } @@ -144,23 +139,18 @@ private constructor( * content of a message. */ @JvmStatic - fun ofImageFileDeltaBlock(imageFileDeltaBlock: ImageFileDeltaBlock) = - MessageContentDelta(imageFileDeltaBlock = imageFileDeltaBlock) + fun ofImageFile(imageFile: ImageFileDeltaBlock) = MessageContentDelta(imageFile = imageFile) /** The text content that is part of a message. */ - @JvmStatic - fun ofTextDeltaBlock(textDeltaBlock: TextDeltaBlock) = - MessageContentDelta(textDeltaBlock = textDeltaBlock) + @JvmStatic fun ofText(text: TextDeltaBlock) = MessageContentDelta(text = text) /** The refusal content that is part of a message. */ @JvmStatic - fun ofRefusalDeltaBlock(refusalDeltaBlock: RefusalDeltaBlock) = - MessageContentDelta(refusalDeltaBlock = refusalDeltaBlock) + fun ofRefusal(refusal: RefusalDeltaBlock) = MessageContentDelta(refusal = refusal) /** References an image URL in the content of a message. */ @JvmStatic - fun ofImageUrlDeltaBlock(imageUrlDeltaBlock: ImageUrlDeltaBlock) = - MessageContentDelta(imageUrlDeltaBlock = imageUrlDeltaBlock) + fun ofImageUrl(imageUrl: ImageUrlDeltaBlock) = MessageContentDelta(imageUrl = imageUrl) } interface Visitor { @@ -169,16 +159,16 @@ private constructor( * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun visitImageFileDeltaBlock(imageFileDeltaBlock: ImageFileDeltaBlock): T + fun visitImageFile(imageFile: ImageFileDeltaBlock): T /** The text content that is part of a message. */ - fun visitTextDeltaBlock(textDeltaBlock: TextDeltaBlock): T + fun visitText(text: TextDeltaBlock): T /** The refusal content that is part of a message. */ - fun visitRefusalDeltaBlock(refusalDeltaBlock: RefusalDeltaBlock): T + fun visitRefusal(refusal: RefusalDeltaBlock): T /** References an image URL in the content of a message. */ - fun visitImageUrlDeltaBlock(imageUrlDeltaBlock: ImageUrlDeltaBlock): T + fun visitImageUrl(imageUrl: ImageUrlDeltaBlock): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown MessageContentDelta: $json") @@ -195,25 +185,25 @@ private constructor( "image_file" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContentDelta(imageFileDeltaBlock = it, _json = json) + return MessageContentDelta(imageFile = it, _json = json) } } "text" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContentDelta(textDeltaBlock = it, _json = json) + return MessageContentDelta(text = it, _json = json) } } "refusal" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContentDelta(refusalDeltaBlock = it, _json = json) + return MessageContentDelta(refusal = it, _json = json) } } "image_url" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContentDelta(imageUrlDeltaBlock = it, _json = json) + return MessageContentDelta(imageUrl = it, _json = json) } } } @@ -230,11 +220,10 @@ private constructor( provider: SerializerProvider ) { when { - value.imageFileDeltaBlock != null -> - generator.writeObject(value.imageFileDeltaBlock) - value.textDeltaBlock != null -> generator.writeObject(value.textDeltaBlock) - value.refusalDeltaBlock != null -> generator.writeObject(value.refusalDeltaBlock) - value.imageUrlDeltaBlock != null -> generator.writeObject(value.imageUrlDeltaBlock) + value.imageFile != null -> generator.writeObject(value.imageFile) + value.text != null -> generator.writeObject(value.text) + value.refusal != null -> generator.writeObject(value.refusal) + value.imageUrl != null -> generator.writeObject(value.imageUrl) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid MessageContentDelta") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/MessageContentPartParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/MessageContentPartParam.kt index fccef67ae..426811da0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/MessageContentPartParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/MessageContentPartParam.kt @@ -26,9 +26,9 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = MessageContentPartParam.Serializer::class) class MessageContentPartParam private constructor( - private val imageFileContentBlock: ImageFileContentBlock? = null, - private val imageUrlContentBlock: ImageUrlContentBlock? = null, - private val textContentBlockParam: TextContentBlockParam? = null, + private val imageFile: ImageFileContentBlock? = null, + private val imageUrl: ImageUrlContentBlock? = null, + private val text: TextContentBlockParam? = null, private val _json: JsonValue? = null, ) { @@ -36,47 +36,39 @@ private constructor( * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun imageFileContentBlock(): Optional = - Optional.ofNullable(imageFileContentBlock) + fun imageFile(): Optional = Optional.ofNullable(imageFile) /** References an image URL in the content of a message. */ - fun imageUrlContentBlock(): Optional = - Optional.ofNullable(imageUrlContentBlock) + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) /** The text content that is part of a message. */ - fun textContentBlockParam(): Optional = - Optional.ofNullable(textContentBlockParam) + fun text(): Optional = Optional.ofNullable(text) - fun isImageFileContentBlock(): Boolean = imageFileContentBlock != null + fun isImageFile(): Boolean = imageFile != null - fun isImageUrlContentBlock(): Boolean = imageUrlContentBlock != null + fun isImageUrl(): Boolean = imageUrl != null - fun isTextContentBlockParam(): Boolean = textContentBlockParam != null + fun isText(): Boolean = text != null /** * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun asImageFileContentBlock(): ImageFileContentBlock = - imageFileContentBlock.getOrThrow("imageFileContentBlock") + fun asImageFile(): ImageFileContentBlock = imageFile.getOrThrow("imageFile") /** References an image URL in the content of a message. */ - fun asImageUrlContentBlock(): ImageUrlContentBlock = - imageUrlContentBlock.getOrThrow("imageUrlContentBlock") + fun asImageUrl(): ImageUrlContentBlock = imageUrl.getOrThrow("imageUrl") /** The text content that is part of a message. */ - fun asTextContentBlockParam(): TextContentBlockParam = - textContentBlockParam.getOrThrow("textContentBlockParam") + fun asText(): TextContentBlockParam = text.getOrThrow("text") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - imageFileContentBlock != null -> - visitor.visitImageFileContentBlock(imageFileContentBlock) - imageUrlContentBlock != null -> visitor.visitImageUrlContentBlock(imageUrlContentBlock) - textContentBlockParam != null -> - visitor.visitTextContentBlockParam(textContentBlockParam) + imageFile != null -> visitor.visitImageFile(imageFile) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + text != null -> visitor.visitText(text) else -> visitor.unknown(_json) } } @@ -90,20 +82,16 @@ private constructor( accept( object : Visitor { - override fun visitImageFileContentBlock( - imageFileContentBlock: ImageFileContentBlock - ) { - imageFileContentBlock.validate() + override fun visitImageFile(imageFile: ImageFileContentBlock) { + imageFile.validate() } - override fun visitImageUrlContentBlock(imageUrlContentBlock: ImageUrlContentBlock) { - imageUrlContentBlock.validate() + override fun visitImageUrl(imageUrl: ImageUrlContentBlock) { + imageUrl.validate() } - override fun visitTextContentBlockParam( - textContentBlockParam: TextContentBlockParam - ) { - textContentBlockParam.validate() + override fun visitText(text: TextContentBlockParam) { + text.validate() } } ) @@ -115,19 +103,16 @@ private constructor( return true } - return /* spotless:off */ other is MessageContentPartParam && imageFileContentBlock == other.imageFileContentBlock && imageUrlContentBlock == other.imageUrlContentBlock && textContentBlockParam == other.textContentBlockParam /* spotless:on */ + return /* spotless:off */ other is MessageContentPartParam && imageFile == other.imageFile && imageUrl == other.imageUrl && text == other.text /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(imageFileContentBlock, imageUrlContentBlock, textContentBlockParam) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(imageFile, imageUrl, text) /* spotless:on */ override fun toString(): String = when { - imageFileContentBlock != null -> - "MessageContentPartParam{imageFileContentBlock=$imageFileContentBlock}" - imageUrlContentBlock != null -> - "MessageContentPartParam{imageUrlContentBlock=$imageUrlContentBlock}" - textContentBlockParam != null -> - "MessageContentPartParam{textContentBlockParam=$textContentBlockParam}" + imageFile != null -> "MessageContentPartParam{imageFile=$imageFile}" + imageUrl != null -> "MessageContentPartParam{imageUrl=$imageUrl}" + text != null -> "MessageContentPartParam{text=$text}" _json != null -> "MessageContentPartParam{_unknown=$_json}" else -> throw IllegalStateException("Invalid MessageContentPartParam") } @@ -139,18 +124,16 @@ private constructor( * content of a message. */ @JvmStatic - fun ofImageFileContentBlock(imageFileContentBlock: ImageFileContentBlock) = - MessageContentPartParam(imageFileContentBlock = imageFileContentBlock) + fun ofImageFile(imageFile: ImageFileContentBlock) = + MessageContentPartParam(imageFile = imageFile) /** References an image URL in the content of a message. */ @JvmStatic - fun ofImageUrlContentBlock(imageUrlContentBlock: ImageUrlContentBlock) = - MessageContentPartParam(imageUrlContentBlock = imageUrlContentBlock) + fun ofImageUrl(imageUrl: ImageUrlContentBlock) = + MessageContentPartParam(imageUrl = imageUrl) /** The text content that is part of a message. */ - @JvmStatic - fun ofTextContentBlockParam(textContentBlockParam: TextContentBlockParam) = - MessageContentPartParam(textContentBlockParam = textContentBlockParam) + @JvmStatic fun ofText(text: TextContentBlockParam) = MessageContentPartParam(text = text) } interface Visitor { @@ -159,13 +142,13 @@ private constructor( * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun visitImageFileContentBlock(imageFileContentBlock: ImageFileContentBlock): T + fun visitImageFile(imageFile: ImageFileContentBlock): T /** References an image URL in the content of a message. */ - fun visitImageUrlContentBlock(imageUrlContentBlock: ImageUrlContentBlock): T + fun visitImageUrl(imageUrl: ImageUrlContentBlock): T /** The text content that is part of a message. */ - fun visitTextContentBlockParam(textContentBlockParam: TextContentBlockParam): T + fun visitText(text: TextContentBlockParam): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown MessageContentPartParam: $json") @@ -182,19 +165,19 @@ private constructor( "image_file" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContentPartParam(imageFileContentBlock = it, _json = json) + return MessageContentPartParam(imageFile = it, _json = json) } } "image_url" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContentPartParam(imageUrlContentBlock = it, _json = json) + return MessageContentPartParam(imageUrl = it, _json = json) } } "text" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return MessageContentPartParam(textContentBlockParam = it, _json = json) + return MessageContentPartParam(text = it, _json = json) } } } @@ -211,12 +194,9 @@ private constructor( provider: SerializerProvider ) { when { - value.imageFileContentBlock != null -> - generator.writeObject(value.imageFileContentBlock) - value.imageUrlContentBlock != null -> - generator.writeObject(value.imageUrlContentBlock) - value.textContentBlockParam != null -> - generator.writeObject(value.textContentBlockParam) + value.imageFile != null -> generator.writeObject(value.imageFile) + value.imageUrl != null -> generator.writeObject(value.imageUrl) + value.text != null -> generator.writeObject(value.text) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid MessageContentPartParam") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/MessageDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/MessageDelta.kt index 5b6d3a5bc..c8b358bf6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/MessageDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/MessageDelta.kt @@ -107,20 +107,19 @@ private constructor( * References an image [File](https://platform.openai.com/docs/api-reference/files) in the * content of a message. */ - fun addContent(imageFileDeltaBlock: ImageFileDeltaBlock) = - addContent(MessageContentDelta.ofImageFileDeltaBlock(imageFileDeltaBlock)) + fun addContent(imageFile: ImageFileDeltaBlock) = + addContent(MessageContentDelta.ofImageFile(imageFile)) /** The text content that is part of a message. */ - fun addContent(textDeltaBlock: TextDeltaBlock) = - addContent(MessageContentDelta.ofTextDeltaBlock(textDeltaBlock)) + fun addContent(text: TextDeltaBlock) = addContent(MessageContentDelta.ofText(text)) /** The refusal content that is part of a message. */ - fun addContent(refusalDeltaBlock: RefusalDeltaBlock) = - addContent(MessageContentDelta.ofRefusalDeltaBlock(refusalDeltaBlock)) + fun addContent(refusal: RefusalDeltaBlock) = + addContent(MessageContentDelta.ofRefusal(refusal)) /** References an image URL in the content of a message. */ - fun addContent(imageUrlDeltaBlock: ImageUrlDeltaBlock) = - addContent(MessageContentDelta.ofImageUrlDeltaBlock(imageUrlDeltaBlock)) + fun addContent(imageUrl: ImageUrlDeltaBlock) = + addContent(MessageContentDelta.ofImageUrl(imageUrl)) /** The entity that produced the message. One of `user` or `assistant`. */ fun role(role: Role) = role(JsonField.of(role)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ModerationMultiModalInput.kt b/openai-java-core/src/main/kotlin/com/openai/models/ModerationMultiModalInput.kt index 1316bfb62..901c1ee09 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ModerationMultiModalInput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ModerationMultiModalInput.kt @@ -23,38 +23,33 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = ModerationMultiModalInput.Serializer::class) class ModerationMultiModalInput private constructor( - private val moderationImageUrlInput: ModerationImageUrlInput? = null, - private val moderationTextInput: ModerationTextInput? = null, + private val imageUrl: ModerationImageUrlInput? = null, + private val text: ModerationTextInput? = null, private val _json: JsonValue? = null, ) { /** An object describing an image to classify. */ - fun moderationImageUrlInput(): Optional = - Optional.ofNullable(moderationImageUrlInput) + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) /** An object describing text to classify. */ - fun moderationTextInput(): Optional = - Optional.ofNullable(moderationTextInput) + fun text(): Optional = Optional.ofNullable(text) - fun isModerationImageUrlInput(): Boolean = moderationImageUrlInput != null + fun isImageUrl(): Boolean = imageUrl != null - fun isModerationTextInput(): Boolean = moderationTextInput != null + fun isText(): Boolean = text != null /** An object describing an image to classify. */ - fun asModerationImageUrlInput(): ModerationImageUrlInput = - moderationImageUrlInput.getOrThrow("moderationImageUrlInput") + fun asImageUrl(): ModerationImageUrlInput = imageUrl.getOrThrow("imageUrl") /** An object describing text to classify. */ - fun asModerationTextInput(): ModerationTextInput = - moderationTextInput.getOrThrow("moderationTextInput") + fun asText(): ModerationTextInput = text.getOrThrow("text") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - moderationImageUrlInput != null -> - visitor.visitModerationImageUrlInput(moderationImageUrlInput) - moderationTextInput != null -> visitor.visitModerationTextInput(moderationTextInput) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + text != null -> visitor.visitText(text) else -> visitor.unknown(_json) } } @@ -68,14 +63,12 @@ private constructor( accept( object : Visitor { - override fun visitModerationImageUrlInput( - moderationImageUrlInput: ModerationImageUrlInput - ) { - moderationImageUrlInput.validate() + override fun visitImageUrl(imageUrl: ModerationImageUrlInput) { + imageUrl.validate() } - override fun visitModerationTextInput(moderationTextInput: ModerationTextInput) { - moderationTextInput.validate() + override fun visitText(text: ModerationTextInput) { + text.validate() } } ) @@ -87,17 +80,15 @@ private constructor( return true } - return /* spotless:off */ other is ModerationMultiModalInput && moderationImageUrlInput == other.moderationImageUrlInput && moderationTextInput == other.moderationTextInput /* spotless:on */ + return /* spotless:off */ other is ModerationMultiModalInput && imageUrl == other.imageUrl && text == other.text /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(moderationImageUrlInput, moderationTextInput) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(imageUrl, text) /* spotless:on */ override fun toString(): String = when { - moderationImageUrlInput != null -> - "ModerationMultiModalInput{moderationImageUrlInput=$moderationImageUrlInput}" - moderationTextInput != null -> - "ModerationMultiModalInput{moderationTextInput=$moderationTextInput}" + imageUrl != null -> "ModerationMultiModalInput{imageUrl=$imageUrl}" + text != null -> "ModerationMultiModalInput{text=$text}" _json != null -> "ModerationMultiModalInput{_unknown=$_json}" else -> throw IllegalStateException("Invalid ModerationMultiModalInput") } @@ -106,22 +97,20 @@ private constructor( /** An object describing an image to classify. */ @JvmStatic - fun ofModerationImageUrlInput(moderationImageUrlInput: ModerationImageUrlInput) = - ModerationMultiModalInput(moderationImageUrlInput = moderationImageUrlInput) + fun ofImageUrl(imageUrl: ModerationImageUrlInput) = + ModerationMultiModalInput(imageUrl = imageUrl) /** An object describing text to classify. */ - @JvmStatic - fun ofModerationTextInput(moderationTextInput: ModerationTextInput) = - ModerationMultiModalInput(moderationTextInput = moderationTextInput) + @JvmStatic fun ofText(text: ModerationTextInput) = ModerationMultiModalInput(text = text) } interface Visitor { /** An object describing an image to classify. */ - fun visitModerationImageUrlInput(moderationImageUrlInput: ModerationImageUrlInput): T + fun visitImageUrl(imageUrl: ModerationImageUrlInput): T /** An object describing text to classify. */ - fun visitModerationTextInput(moderationTextInput: ModerationTextInput): T + fun visitText(text: ModerationTextInput): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown ModerationMultiModalInput: $json") @@ -141,16 +130,13 @@ private constructor( it.validate() } ?.let { - return ModerationMultiModalInput( - moderationImageUrlInput = it, - _json = json - ) + return ModerationMultiModalInput(imageUrl = it, _json = json) } } "text" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return ModerationMultiModalInput(moderationTextInput = it, _json = json) + return ModerationMultiModalInput(text = it, _json = json) } } } @@ -167,10 +153,8 @@ private constructor( provider: SerializerProvider ) { when { - value.moderationImageUrlInput != null -> - generator.writeObject(value.moderationImageUrlInput) - value.moderationTextInput != null -> - generator.writeObject(value.moderationTextInput) + value.imageUrl != null -> generator.writeObject(value.imageUrl) + value.text != null -> generator.writeObject(value.text) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ModerationMultiModalInput") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Run.kt b/openai-java-core/src/main/kotlin/com/openai/models/Run.kt index 4ad6b6fa7..1bb757622 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Run.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Run.kt @@ -1023,22 +1023,20 @@ private constructor( * The list of tools that the * [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. */ - fun addTool(codeInterpreterTool: CodeInterpreterTool) = - addTool(AssistantTool.ofCodeInterpreterTool(codeInterpreterTool)) + fun addTool(codeInterpreter: CodeInterpreterTool) = + addTool(AssistantTool.ofCodeInterpreter(codeInterpreter)) /** * The list of tools that the * [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. */ - fun addTool(fileSearchTool: FileSearchTool) = - addTool(AssistantTool.ofFileSearchTool(fileSearchTool)) + fun addTool(fileSearch: FileSearchTool) = addTool(AssistantTool.ofFileSearch(fileSearch)) /** * The list of tools that the * [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. */ - fun addTool(functionTool: FunctionTool) = - addTool(AssistantTool.ofFunctionTool(functionTool)) + fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function)) /** * Controls for how a thread will be truncated prior to the run. Use this to control the diff --git a/openai-java-core/src/main/kotlin/com/openai/models/RunStep.kt b/openai-java-core/src/main/kotlin/com/openai/models/RunStep.kt index 989119fb5..ed89c5d80 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/RunStep.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/RunStep.kt @@ -429,12 +429,12 @@ private constructor( } /** Details of the message creation by the run step. */ - fun stepDetails(messageCreationStepDetails: MessageCreationStepDetails) = - stepDetails(StepDetails.ofMessageCreationStepDetails(messageCreationStepDetails)) + fun stepDetails(messageCreation: MessageCreationStepDetails) = + stepDetails(StepDetails.ofMessageCreation(messageCreation)) /** Details of the tool call. */ - fun stepDetails(toolCallsStepDetails: ToolCallsStepDetails) = - stepDetails(StepDetails.ofToolCallsStepDetails(toolCallsStepDetails)) + fun stepDetails(toolCalls: ToolCallsStepDetails) = + stepDetails(StepDetails.ofToolCalls(toolCalls)) /** * The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was @@ -773,39 +773,35 @@ private constructor( @JsonSerialize(using = StepDetails.Serializer::class) class StepDetails private constructor( - private val messageCreationStepDetails: MessageCreationStepDetails? = null, - private val toolCallsStepDetails: ToolCallsStepDetails? = null, + private val messageCreation: MessageCreationStepDetails? = null, + private val toolCalls: ToolCallsStepDetails? = null, private val _json: JsonValue? = null, ) { /** Details of the message creation by the run step. */ - fun messageCreationStepDetails(): Optional = - Optional.ofNullable(messageCreationStepDetails) + fun messageCreation(): Optional = + Optional.ofNullable(messageCreation) /** Details of the tool call. */ - fun toolCallsStepDetails(): Optional = - Optional.ofNullable(toolCallsStepDetails) + fun toolCalls(): Optional = Optional.ofNullable(toolCalls) - fun isMessageCreationStepDetails(): Boolean = messageCreationStepDetails != null + fun isMessageCreation(): Boolean = messageCreation != null - fun isToolCallsStepDetails(): Boolean = toolCallsStepDetails != null + fun isToolCalls(): Boolean = toolCalls != null /** Details of the message creation by the run step. */ - fun asMessageCreationStepDetails(): MessageCreationStepDetails = - messageCreationStepDetails.getOrThrow("messageCreationStepDetails") + fun asMessageCreation(): MessageCreationStepDetails = + messageCreation.getOrThrow("messageCreation") /** Details of the tool call. */ - fun asToolCallsStepDetails(): ToolCallsStepDetails = - toolCallsStepDetails.getOrThrow("toolCallsStepDetails") + fun asToolCalls(): ToolCallsStepDetails = toolCalls.getOrThrow("toolCalls") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - messageCreationStepDetails != null -> - visitor.visitMessageCreationStepDetails(messageCreationStepDetails) - toolCallsStepDetails != null -> - visitor.visitToolCallsStepDetails(toolCallsStepDetails) + messageCreation != null -> visitor.visitMessageCreation(messageCreation) + toolCalls != null -> visitor.visitToolCalls(toolCalls) else -> visitor.unknown(_json) } } @@ -819,16 +815,12 @@ private constructor( accept( object : Visitor { - override fun visitMessageCreationStepDetails( - messageCreationStepDetails: MessageCreationStepDetails - ) { - messageCreationStepDetails.validate() + override fun visitMessageCreation(messageCreation: MessageCreationStepDetails) { + messageCreation.validate() } - override fun visitToolCallsStepDetails( - toolCallsStepDetails: ToolCallsStepDetails - ) { - toolCallsStepDetails.validate() + override fun visitToolCalls(toolCalls: ToolCallsStepDetails) { + toolCalls.validate() } } ) @@ -840,17 +832,15 @@ private constructor( return true } - return /* spotless:off */ other is StepDetails && messageCreationStepDetails == other.messageCreationStepDetails && toolCallsStepDetails == other.toolCallsStepDetails /* spotless:on */ + return /* spotless:off */ other is StepDetails && messageCreation == other.messageCreation && toolCalls == other.toolCalls /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(messageCreationStepDetails, toolCallsStepDetails) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(messageCreation, toolCalls) /* spotless:on */ override fun toString(): String = when { - messageCreationStepDetails != null -> - "StepDetails{messageCreationStepDetails=$messageCreationStepDetails}" - toolCallsStepDetails != null -> - "StepDetails{toolCallsStepDetails=$toolCallsStepDetails}" + messageCreation != null -> "StepDetails{messageCreation=$messageCreation}" + toolCalls != null -> "StepDetails{toolCalls=$toolCalls}" _json != null -> "StepDetails{_unknown=$_json}" else -> throw IllegalStateException("Invalid StepDetails") } @@ -859,25 +849,21 @@ private constructor( /** Details of the message creation by the run step. */ @JvmStatic - fun ofMessageCreationStepDetails( - messageCreationStepDetails: MessageCreationStepDetails - ) = StepDetails(messageCreationStepDetails = messageCreationStepDetails) + fun ofMessageCreation(messageCreation: MessageCreationStepDetails) = + StepDetails(messageCreation = messageCreation) /** Details of the tool call. */ @JvmStatic - fun ofToolCallsStepDetails(toolCallsStepDetails: ToolCallsStepDetails) = - StepDetails(toolCallsStepDetails = toolCallsStepDetails) + fun ofToolCalls(toolCalls: ToolCallsStepDetails) = StepDetails(toolCalls = toolCalls) } interface Visitor { /** Details of the message creation by the run step. */ - fun visitMessageCreationStepDetails( - messageCreationStepDetails: MessageCreationStepDetails - ): T + fun visitMessageCreation(messageCreation: MessageCreationStepDetails): T /** Details of the tool call. */ - fun visitToolCallsStepDetails(toolCallsStepDetails: ToolCallsStepDetails): T + fun visitToolCalls(toolCalls: ToolCallsStepDetails): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown StepDetails: $json") @@ -896,7 +882,7 @@ private constructor( it.validate() } ?.let { - return StepDetails(messageCreationStepDetails = it, _json = json) + return StepDetails(messageCreation = it, _json = json) } } "tool_calls" -> { @@ -904,7 +890,7 @@ private constructor( it.validate() } ?.let { - return StepDetails(toolCallsStepDetails = it, _json = json) + return StepDetails(toolCalls = it, _json = json) } } } @@ -921,10 +907,8 @@ private constructor( provider: SerializerProvider ) { when { - value.messageCreationStepDetails != null -> - generator.writeObject(value.messageCreationStepDetails) - value.toolCallsStepDetails != null -> - generator.writeObject(value.toolCallsStepDetails) + value.messageCreation != null -> generator.writeObject(value.messageCreation) + value.toolCalls != null -> generator.writeObject(value.toolCalls) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid StepDetails") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/RunStepDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/RunStepDelta.kt index 52223425a..a3b717613 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/RunStepDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/RunStepDelta.kt @@ -90,12 +90,12 @@ private constructor( } /** Details of the message creation by the run step. */ - fun stepDetails(runStepDeltaMessageDelta: RunStepDeltaMessageDelta) = - stepDetails(StepDetails.ofRunStepDeltaMessageDelta(runStepDeltaMessageDelta)) + fun stepDetails(messageCreation: RunStepDeltaMessageDelta) = + stepDetails(StepDetails.ofMessageCreation(messageCreation)) /** Details of the tool call. */ - fun stepDetails(toolCallDeltaObject: ToolCallDeltaObject) = - stepDetails(StepDetails.ofToolCallDeltaObject(toolCallDeltaObject)) + fun stepDetails(toolCalls: ToolCallDeltaObject) = + stepDetails(StepDetails.ofToolCalls(toolCalls)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -124,38 +124,35 @@ private constructor( @JsonSerialize(using = StepDetails.Serializer::class) class StepDetails private constructor( - private val runStepDeltaMessageDelta: RunStepDeltaMessageDelta? = null, - private val toolCallDeltaObject: ToolCallDeltaObject? = null, + private val messageCreation: RunStepDeltaMessageDelta? = null, + private val toolCalls: ToolCallDeltaObject? = null, private val _json: JsonValue? = null, ) { /** Details of the message creation by the run step. */ - fun runStepDeltaMessageDelta(): Optional = - Optional.ofNullable(runStepDeltaMessageDelta) + fun messageCreation(): Optional = + Optional.ofNullable(messageCreation) /** Details of the tool call. */ - fun toolCallDeltaObject(): Optional = - Optional.ofNullable(toolCallDeltaObject) + fun toolCalls(): Optional = Optional.ofNullable(toolCalls) - fun isRunStepDeltaMessageDelta(): Boolean = runStepDeltaMessageDelta != null + fun isMessageCreation(): Boolean = messageCreation != null - fun isToolCallDeltaObject(): Boolean = toolCallDeltaObject != null + fun isToolCalls(): Boolean = toolCalls != null /** Details of the message creation by the run step. */ - fun asRunStepDeltaMessageDelta(): RunStepDeltaMessageDelta = - runStepDeltaMessageDelta.getOrThrow("runStepDeltaMessageDelta") + fun asMessageCreation(): RunStepDeltaMessageDelta = + messageCreation.getOrThrow("messageCreation") /** Details of the tool call. */ - fun asToolCallDeltaObject(): ToolCallDeltaObject = - toolCallDeltaObject.getOrThrow("toolCallDeltaObject") + fun asToolCalls(): ToolCallDeltaObject = toolCalls.getOrThrow("toolCalls") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - runStepDeltaMessageDelta != null -> - visitor.visitRunStepDeltaMessageDelta(runStepDeltaMessageDelta) - toolCallDeltaObject != null -> visitor.visitToolCallDeltaObject(toolCallDeltaObject) + messageCreation != null -> visitor.visitMessageCreation(messageCreation) + toolCalls != null -> visitor.visitToolCalls(toolCalls) else -> visitor.unknown(_json) } } @@ -169,16 +166,12 @@ private constructor( accept( object : Visitor { - override fun visitRunStepDeltaMessageDelta( - runStepDeltaMessageDelta: RunStepDeltaMessageDelta - ) { - runStepDeltaMessageDelta.validate() + override fun visitMessageCreation(messageCreation: RunStepDeltaMessageDelta) { + messageCreation.validate() } - override fun visitToolCallDeltaObject( - toolCallDeltaObject: ToolCallDeltaObject - ) { - toolCallDeltaObject.validate() + override fun visitToolCalls(toolCalls: ToolCallDeltaObject) { + toolCalls.validate() } } ) @@ -190,17 +183,15 @@ private constructor( return true } - return /* spotless:off */ other is StepDetails && runStepDeltaMessageDelta == other.runStepDeltaMessageDelta && toolCallDeltaObject == other.toolCallDeltaObject /* spotless:on */ + return /* spotless:off */ other is StepDetails && messageCreation == other.messageCreation && toolCalls == other.toolCalls /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(runStepDeltaMessageDelta, toolCallDeltaObject) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(messageCreation, toolCalls) /* spotless:on */ override fun toString(): String = when { - runStepDeltaMessageDelta != null -> - "StepDetails{runStepDeltaMessageDelta=$runStepDeltaMessageDelta}" - toolCallDeltaObject != null -> - "StepDetails{toolCallDeltaObject=$toolCallDeltaObject}" + messageCreation != null -> "StepDetails{messageCreation=$messageCreation}" + toolCalls != null -> "StepDetails{toolCalls=$toolCalls}" _json != null -> "StepDetails{_unknown=$_json}" else -> throw IllegalStateException("Invalid StepDetails") } @@ -209,22 +200,21 @@ private constructor( /** Details of the message creation by the run step. */ @JvmStatic - fun ofRunStepDeltaMessageDelta(runStepDeltaMessageDelta: RunStepDeltaMessageDelta) = - StepDetails(runStepDeltaMessageDelta = runStepDeltaMessageDelta) + fun ofMessageCreation(messageCreation: RunStepDeltaMessageDelta) = + StepDetails(messageCreation = messageCreation) /** Details of the tool call. */ @JvmStatic - fun ofToolCallDeltaObject(toolCallDeltaObject: ToolCallDeltaObject) = - StepDetails(toolCallDeltaObject = toolCallDeltaObject) + fun ofToolCalls(toolCalls: ToolCallDeltaObject) = StepDetails(toolCalls = toolCalls) } interface Visitor { /** Details of the message creation by the run step. */ - fun visitRunStepDeltaMessageDelta(runStepDeltaMessageDelta: RunStepDeltaMessageDelta): T + fun visitMessageCreation(messageCreation: RunStepDeltaMessageDelta): T /** Details of the tool call. */ - fun visitToolCallDeltaObject(toolCallDeltaObject: ToolCallDeltaObject): T + fun visitToolCalls(toolCalls: ToolCallDeltaObject): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown StepDetails: $json") @@ -243,7 +233,7 @@ private constructor( it.validate() } ?.let { - return StepDetails(runStepDeltaMessageDelta = it, _json = json) + return StepDetails(messageCreation = it, _json = json) } } "tool_calls" -> { @@ -251,7 +241,7 @@ private constructor( it.validate() } ?.let { - return StepDetails(toolCallDeltaObject = it, _json = json) + return StepDetails(toolCalls = it, _json = json) } } } @@ -268,10 +258,8 @@ private constructor( provider: SerializerProvider ) { when { - value.runStepDeltaMessageDelta != null -> - generator.writeObject(value.runStepDeltaMessageDelta) - value.toolCallDeltaObject != null -> - generator.writeObject(value.toolCallDeltaObject) + value.messageCreation != null -> generator.writeObject(value.messageCreation) + value.toolCalls != null -> generator.writeObject(value.toolCalls) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid StepDetails") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Text.kt b/openai-java-core/src/main/kotlin/com/openai/models/Text.kt index dc11629f3..127e1a5c4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Text.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Text.kt @@ -99,15 +99,15 @@ private constructor( * associated with the assistant or the message. Generated when the assistant uses the * "file_search" tool to search files. */ - fun addAnnotation(fileCitationAnnotation: FileCitationAnnotation) = - addAnnotation(Annotation.ofFileCitationAnnotation(fileCitationAnnotation)) + fun addAnnotation(fileCitation: FileCitationAnnotation) = + addAnnotation(Annotation.ofFileCitation(fileCitation)) /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool * to generate a file. */ - fun addAnnotation(filePathAnnotation: FilePathAnnotation) = - addAnnotation(Annotation.ofFilePathAnnotation(filePathAnnotation)) + fun addAnnotation(filePath: FilePathAnnotation) = + addAnnotation(Annotation.ofFilePath(filePath)) /** The data that makes up the text. */ fun value(value: String) = value(JsonField.of(value)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/TextDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/TextDelta.kt index fffd510b0..2f8c89ae6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/TextDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/TextDelta.kt @@ -100,17 +100,15 @@ private constructor( * associated with the assistant or the message. Generated when the assistant uses the * "file_search" tool to search files. */ - fun addAnnotation(fileCitationDeltaAnnotation: FileCitationDeltaAnnotation) = - addAnnotation( - AnnotationDelta.ofFileCitationDeltaAnnotation(fileCitationDeltaAnnotation) - ) + fun addAnnotation(fileCitation: FileCitationDeltaAnnotation) = + addAnnotation(AnnotationDelta.ofFileCitation(fileCitation)) /** * A URL for the file that's generated when the assistant used the `code_interpreter` tool * to generate a file. */ - fun addAnnotation(filePathDeltaAnnotation: FilePathDeltaAnnotation) = - addAnnotation(AnnotationDelta.ofFilePathDeltaAnnotation(filePathDeltaAnnotation)) + fun addAnnotation(filePath: FilePathDeltaAnnotation) = + addAnnotation(AnnotationDelta.ofFilePath(filePath)) /** The data that makes up the text. */ fun value(value: String) = value(JsonField.of(value)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/ToolCall.kt index 082d90189..a29721c4d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ToolCall.kt @@ -23,43 +23,39 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = ToolCall.Serializer::class) class ToolCall private constructor( - private val codeInterpreterToolCall: CodeInterpreterToolCall? = null, - private val fileSearchToolCall: FileSearchToolCall? = null, - private val functionToolCall: FunctionToolCall? = null, + private val codeInterpreter: CodeInterpreterToolCall? = null, + private val fileSearch: FileSearchToolCall? = null, + private val function: FunctionToolCall? = null, private val _json: JsonValue? = null, ) { /** Details of the Code Interpreter tool call the run step was involved in. */ - fun codeInterpreterToolCall(): Optional = - Optional.ofNullable(codeInterpreterToolCall) + fun codeInterpreter(): Optional = Optional.ofNullable(codeInterpreter) - fun fileSearchToolCall(): Optional = Optional.ofNullable(fileSearchToolCall) + fun fileSearch(): Optional = Optional.ofNullable(fileSearch) - fun functionToolCall(): Optional = Optional.ofNullable(functionToolCall) + fun function(): Optional = Optional.ofNullable(function) - fun isCodeInterpreterToolCall(): Boolean = codeInterpreterToolCall != null + fun isCodeInterpreter(): Boolean = codeInterpreter != null - fun isFileSearchToolCall(): Boolean = fileSearchToolCall != null + fun isFileSearch(): Boolean = fileSearch != null - fun isFunctionToolCall(): Boolean = functionToolCall != null + fun isFunction(): Boolean = function != null /** Details of the Code Interpreter tool call the run step was involved in. */ - fun asCodeInterpreterToolCall(): CodeInterpreterToolCall = - codeInterpreterToolCall.getOrThrow("codeInterpreterToolCall") + fun asCodeInterpreter(): CodeInterpreterToolCall = codeInterpreter.getOrThrow("codeInterpreter") - fun asFileSearchToolCall(): FileSearchToolCall = - fileSearchToolCall.getOrThrow("fileSearchToolCall") + fun asFileSearch(): FileSearchToolCall = fileSearch.getOrThrow("fileSearch") - fun asFunctionToolCall(): FunctionToolCall = functionToolCall.getOrThrow("functionToolCall") + fun asFunction(): FunctionToolCall = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - codeInterpreterToolCall != null -> - visitor.visitCodeInterpreterToolCall(codeInterpreterToolCall) - fileSearchToolCall != null -> visitor.visitFileSearchToolCall(fileSearchToolCall) - functionToolCall != null -> visitor.visitFunctionToolCall(functionToolCall) + codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) + fileSearch != null -> visitor.visitFileSearch(fileSearch) + function != null -> visitor.visitFunction(function) else -> visitor.unknown(_json) } } @@ -73,18 +69,16 @@ private constructor( accept( object : Visitor { - override fun visitCodeInterpreterToolCall( - codeInterpreterToolCall: CodeInterpreterToolCall - ) { - codeInterpreterToolCall.validate() + override fun visitCodeInterpreter(codeInterpreter: CodeInterpreterToolCall) { + codeInterpreter.validate() } - override fun visitFileSearchToolCall(fileSearchToolCall: FileSearchToolCall) { - fileSearchToolCall.validate() + override fun visitFileSearch(fileSearch: FileSearchToolCall) { + fileSearch.validate() } - override fun visitFunctionToolCall(functionToolCall: FunctionToolCall) { - functionToolCall.validate() + override fun visitFunction(function: FunctionToolCall) { + function.validate() } } ) @@ -96,17 +90,16 @@ private constructor( return true } - return /* spotless:off */ other is ToolCall && codeInterpreterToolCall == other.codeInterpreterToolCall && fileSearchToolCall == other.fileSearchToolCall && functionToolCall == other.functionToolCall /* spotless:on */ + return /* spotless:off */ other is ToolCall && codeInterpreter == other.codeInterpreter && fileSearch == other.fileSearch && function == other.function /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterToolCall, fileSearchToolCall, functionToolCall) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreter, fileSearch, function) /* spotless:on */ override fun toString(): String = when { - codeInterpreterToolCall != null -> - "ToolCall{codeInterpreterToolCall=$codeInterpreterToolCall}" - fileSearchToolCall != null -> "ToolCall{fileSearchToolCall=$fileSearchToolCall}" - functionToolCall != null -> "ToolCall{functionToolCall=$functionToolCall}" + codeInterpreter != null -> "ToolCall{codeInterpreter=$codeInterpreter}" + fileSearch != null -> "ToolCall{fileSearch=$fileSearch}" + function != null -> "ToolCall{function=$function}" _json != null -> "ToolCall{_unknown=$_json}" else -> throw IllegalStateException("Invalid ToolCall") } @@ -115,26 +108,23 @@ private constructor( /** Details of the Code Interpreter tool call the run step was involved in. */ @JvmStatic - fun ofCodeInterpreterToolCall(codeInterpreterToolCall: CodeInterpreterToolCall) = - ToolCall(codeInterpreterToolCall = codeInterpreterToolCall) + fun ofCodeInterpreter(codeInterpreter: CodeInterpreterToolCall) = + ToolCall(codeInterpreter = codeInterpreter) @JvmStatic - fun ofFileSearchToolCall(fileSearchToolCall: FileSearchToolCall) = - ToolCall(fileSearchToolCall = fileSearchToolCall) + fun ofFileSearch(fileSearch: FileSearchToolCall) = ToolCall(fileSearch = fileSearch) - @JvmStatic - fun ofFunctionToolCall(functionToolCall: FunctionToolCall) = - ToolCall(functionToolCall = functionToolCall) + @JvmStatic fun ofFunction(function: FunctionToolCall) = ToolCall(function = function) } interface Visitor { /** Details of the Code Interpreter tool call the run step was involved in. */ - fun visitCodeInterpreterToolCall(codeInterpreterToolCall: CodeInterpreterToolCall): T + fun visitCodeInterpreter(codeInterpreter: CodeInterpreterToolCall): T - fun visitFileSearchToolCall(fileSearchToolCall: FileSearchToolCall): T + fun visitFileSearch(fileSearch: FileSearchToolCall): T - fun visitFunctionToolCall(functionToolCall: FunctionToolCall): T + fun visitFunction(function: FunctionToolCall): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown ToolCall: $json") @@ -153,19 +143,19 @@ private constructor( it.validate() } ?.let { - return ToolCall(codeInterpreterToolCall = it, _json = json) + return ToolCall(codeInterpreter = it, _json = json) } } "file_search" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return ToolCall(fileSearchToolCall = it, _json = json) + return ToolCall(fileSearch = it, _json = json) } } "function" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return ToolCall(functionToolCall = it, _json = json) + return ToolCall(function = it, _json = json) } } } @@ -182,10 +172,9 @@ private constructor( provider: SerializerProvider ) { when { - value.codeInterpreterToolCall != null -> - generator.writeObject(value.codeInterpreterToolCall) - value.fileSearchToolCall != null -> generator.writeObject(value.fileSearchToolCall) - value.functionToolCall != null -> generator.writeObject(value.functionToolCall) + value.codeInterpreter != null -> generator.writeObject(value.codeInterpreter) + value.fileSearch != null -> generator.writeObject(value.fileSearch) + value.function != null -> generator.writeObject(value.function) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ToolCall") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ToolCallDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/ToolCallDelta.kt index 918c3977a..de3488b6b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ToolCallDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ToolCallDelta.kt @@ -23,48 +23,41 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = ToolCallDelta.Serializer::class) class ToolCallDelta private constructor( - private val codeInterpreterToolCallDelta: CodeInterpreterToolCallDelta? = null, - private val fileSearchToolCallDelta: FileSearchToolCallDelta? = null, - private val functionToolCallDelta: FunctionToolCallDelta? = null, + private val codeInterpreter: CodeInterpreterToolCallDelta? = null, + private val fileSearch: FileSearchToolCallDelta? = null, + private val function: FunctionToolCallDelta? = null, private val _json: JsonValue? = null, ) { /** Details of the Code Interpreter tool call the run step was involved in. */ - fun codeInterpreterToolCallDelta(): Optional = - Optional.ofNullable(codeInterpreterToolCallDelta) + fun codeInterpreter(): Optional = + Optional.ofNullable(codeInterpreter) - fun fileSearchToolCallDelta(): Optional = - Optional.ofNullable(fileSearchToolCallDelta) + fun fileSearch(): Optional = Optional.ofNullable(fileSearch) - fun functionToolCallDelta(): Optional = - Optional.ofNullable(functionToolCallDelta) + fun function(): Optional = Optional.ofNullable(function) - fun isCodeInterpreterToolCallDelta(): Boolean = codeInterpreterToolCallDelta != null + fun isCodeInterpreter(): Boolean = codeInterpreter != null - fun isFileSearchToolCallDelta(): Boolean = fileSearchToolCallDelta != null + fun isFileSearch(): Boolean = fileSearch != null - fun isFunctionToolCallDelta(): Boolean = functionToolCallDelta != null + fun isFunction(): Boolean = function != null /** Details of the Code Interpreter tool call the run step was involved in. */ - fun asCodeInterpreterToolCallDelta(): CodeInterpreterToolCallDelta = - codeInterpreterToolCallDelta.getOrThrow("codeInterpreterToolCallDelta") + fun asCodeInterpreter(): CodeInterpreterToolCallDelta = + codeInterpreter.getOrThrow("codeInterpreter") - fun asFileSearchToolCallDelta(): FileSearchToolCallDelta = - fileSearchToolCallDelta.getOrThrow("fileSearchToolCallDelta") + fun asFileSearch(): FileSearchToolCallDelta = fileSearch.getOrThrow("fileSearch") - fun asFunctionToolCallDelta(): FunctionToolCallDelta = - functionToolCallDelta.getOrThrow("functionToolCallDelta") + fun asFunction(): FunctionToolCallDelta = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - codeInterpreterToolCallDelta != null -> - visitor.visitCodeInterpreterToolCallDelta(codeInterpreterToolCallDelta) - fileSearchToolCallDelta != null -> - visitor.visitFileSearchToolCallDelta(fileSearchToolCallDelta) - functionToolCallDelta != null -> - visitor.visitFunctionToolCallDelta(functionToolCallDelta) + codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) + fileSearch != null -> visitor.visitFileSearch(fileSearch) + function != null -> visitor.visitFunction(function) else -> visitor.unknown(_json) } } @@ -78,22 +71,16 @@ private constructor( accept( object : Visitor { - override fun visitCodeInterpreterToolCallDelta( - codeInterpreterToolCallDelta: CodeInterpreterToolCallDelta - ) { - codeInterpreterToolCallDelta.validate() + override fun visitCodeInterpreter(codeInterpreter: CodeInterpreterToolCallDelta) { + codeInterpreter.validate() } - override fun visitFileSearchToolCallDelta( - fileSearchToolCallDelta: FileSearchToolCallDelta - ) { - fileSearchToolCallDelta.validate() + override fun visitFileSearch(fileSearch: FileSearchToolCallDelta) { + fileSearch.validate() } - override fun visitFunctionToolCallDelta( - functionToolCallDelta: FunctionToolCallDelta - ) { - functionToolCallDelta.validate() + override fun visitFunction(function: FunctionToolCallDelta) { + function.validate() } } ) @@ -105,19 +92,16 @@ private constructor( return true } - return /* spotless:off */ other is ToolCallDelta && codeInterpreterToolCallDelta == other.codeInterpreterToolCallDelta && fileSearchToolCallDelta == other.fileSearchToolCallDelta && functionToolCallDelta == other.functionToolCallDelta /* spotless:on */ + return /* spotless:off */ other is ToolCallDelta && codeInterpreter == other.codeInterpreter && fileSearch == other.fileSearch && function == other.function /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreterToolCallDelta, fileSearchToolCallDelta, functionToolCallDelta) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(codeInterpreter, fileSearch, function) /* spotless:on */ override fun toString(): String = when { - codeInterpreterToolCallDelta != null -> - "ToolCallDelta{codeInterpreterToolCallDelta=$codeInterpreterToolCallDelta}" - fileSearchToolCallDelta != null -> - "ToolCallDelta{fileSearchToolCallDelta=$fileSearchToolCallDelta}" - functionToolCallDelta != null -> - "ToolCallDelta{functionToolCallDelta=$functionToolCallDelta}" + codeInterpreter != null -> "ToolCallDelta{codeInterpreter=$codeInterpreter}" + fileSearch != null -> "ToolCallDelta{fileSearch=$fileSearch}" + function != null -> "ToolCallDelta{function=$function}" _json != null -> "ToolCallDelta{_unknown=$_json}" else -> throw IllegalStateException("Invalid ToolCallDelta") } @@ -126,29 +110,25 @@ private constructor( /** Details of the Code Interpreter tool call the run step was involved in. */ @JvmStatic - fun ofCodeInterpreterToolCallDelta( - codeInterpreterToolCallDelta: CodeInterpreterToolCallDelta - ) = ToolCallDelta(codeInterpreterToolCallDelta = codeInterpreterToolCallDelta) + fun ofCodeInterpreter(codeInterpreter: CodeInterpreterToolCallDelta) = + ToolCallDelta(codeInterpreter = codeInterpreter) @JvmStatic - fun ofFileSearchToolCallDelta(fileSearchToolCallDelta: FileSearchToolCallDelta) = - ToolCallDelta(fileSearchToolCallDelta = fileSearchToolCallDelta) + fun ofFileSearch(fileSearch: FileSearchToolCallDelta) = + ToolCallDelta(fileSearch = fileSearch) @JvmStatic - fun ofFunctionToolCallDelta(functionToolCallDelta: FunctionToolCallDelta) = - ToolCallDelta(functionToolCallDelta = functionToolCallDelta) + fun ofFunction(function: FunctionToolCallDelta) = ToolCallDelta(function = function) } interface Visitor { /** Details of the Code Interpreter tool call the run step was involved in. */ - fun visitCodeInterpreterToolCallDelta( - codeInterpreterToolCallDelta: CodeInterpreterToolCallDelta - ): T + fun visitCodeInterpreter(codeInterpreter: CodeInterpreterToolCallDelta): T - fun visitFileSearchToolCallDelta(fileSearchToolCallDelta: FileSearchToolCallDelta): T + fun visitFileSearch(fileSearch: FileSearchToolCallDelta): T - fun visitFunctionToolCallDelta(functionToolCallDelta: FunctionToolCallDelta): T + fun visitFunction(function: FunctionToolCallDelta): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown ToolCallDelta: $json") @@ -167,7 +147,7 @@ private constructor( it.validate() } ?.let { - return ToolCallDelta(codeInterpreterToolCallDelta = it, _json = json) + return ToolCallDelta(codeInterpreter = it, _json = json) } } "file_search" -> { @@ -175,13 +155,13 @@ private constructor( it.validate() } ?.let { - return ToolCallDelta(fileSearchToolCallDelta = it, _json = json) + return ToolCallDelta(fileSearch = it, _json = json) } } "function" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return ToolCallDelta(functionToolCallDelta = it, _json = json) + return ToolCallDelta(function = it, _json = json) } } } @@ -198,12 +178,9 @@ private constructor( provider: SerializerProvider ) { when { - value.codeInterpreterToolCallDelta != null -> - generator.writeObject(value.codeInterpreterToolCallDelta) - value.fileSearchToolCallDelta != null -> - generator.writeObject(value.fileSearchToolCallDelta) - value.functionToolCallDelta != null -> - generator.writeObject(value.functionToolCallDelta) + value.codeInterpreter != null -> generator.writeObject(value.codeInterpreter) + value.fileSearch != null -> generator.writeObject(value.fileSearch) + value.function != null -> generator.writeObject(value.function) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ToolCallDelta") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ToolCallDeltaObject.kt b/openai-java-core/src/main/kotlin/com/openai/models/ToolCallDeltaObject.kt index 2f0bf5f1c..649ea6f38 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ToolCallDeltaObject.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ToolCallDeltaObject.kt @@ -122,22 +122,22 @@ private constructor( } /** Details of the Code Interpreter tool call the run step was involved in. */ - fun addToolCall(codeInterpreterToolCallDelta: CodeInterpreterToolCallDelta) = - addToolCall(ToolCallDelta.ofCodeInterpreterToolCallDelta(codeInterpreterToolCallDelta)) + fun addToolCall(codeInterpreter: CodeInterpreterToolCallDelta) = + addToolCall(ToolCallDelta.ofCodeInterpreter(codeInterpreter)) /** * An array of tool calls the run step was involved in. These can be associated with one of * three types of tools: `code_interpreter`, `file_search`, or `function`. */ - fun addToolCall(fileSearchToolCallDelta: FileSearchToolCallDelta) = - addToolCall(ToolCallDelta.ofFileSearchToolCallDelta(fileSearchToolCallDelta)) + fun addToolCall(fileSearch: FileSearchToolCallDelta) = + addToolCall(ToolCallDelta.ofFileSearch(fileSearch)) /** * An array of tool calls the run step was involved in. These can be associated with one of * three types of tools: `code_interpreter`, `file_search`, or `function`. */ - fun addToolCall(functionToolCallDelta: FunctionToolCallDelta) = - addToolCall(ToolCallDelta.ofFunctionToolCallDelta(functionToolCallDelta)) + fun addToolCall(function: FunctionToolCallDelta) = + addToolCall(ToolCallDelta.ofFunction(function)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ToolCallsStepDetails.kt b/openai-java-core/src/main/kotlin/com/openai/models/ToolCallsStepDetails.kt index a80b66640..1649ddbd7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ToolCallsStepDetails.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ToolCallsStepDetails.kt @@ -118,22 +118,21 @@ private constructor( } /** Details of the Code Interpreter tool call the run step was involved in. */ - fun addToolCall(codeInterpreterToolCall: CodeInterpreterToolCall) = - addToolCall(ToolCall.ofCodeInterpreterToolCall(codeInterpreterToolCall)) + fun addToolCall(codeInterpreter: CodeInterpreterToolCall) = + addToolCall(ToolCall.ofCodeInterpreter(codeInterpreter)) /** * An array of tool calls the run step was involved in. These can be associated with one of * three types of tools: `code_interpreter`, `file_search`, or `function`. */ - fun addToolCall(fileSearchToolCall: FileSearchToolCall) = - addToolCall(ToolCall.ofFileSearchToolCall(fileSearchToolCall)) + fun addToolCall(fileSearch: FileSearchToolCall) = + addToolCall(ToolCall.ofFileSearch(fileSearch)) /** * An array of tool calls the run step was involved in. These can be associated with one of * three types of tools: `code_interpreter`, `file_search`, or `function`. */ - fun addToolCall(functionToolCall: FunctionToolCall) = - addToolCall(ToolCall.ofFunctionToolCall(functionToolCall)) + fun addToolCall(function: FunctionToolCall) = addToolCall(ToolCall.ofFunction(function)) /** Always `tool_calls`. */ fun type(type: JsonValue) = apply { this.type = type } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/VectorStoreFile.kt b/openai-java-core/src/main/kotlin/com/openai/models/VectorStoreFile.kt index 91d4884fc..c5d2d639e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/VectorStoreFile.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/VectorStoreFile.kt @@ -266,23 +266,15 @@ private constructor( } /** The strategy used to chunk the file. */ - fun chunkingStrategy(staticFileChunkingStrategyObject: StaticFileChunkingStrategyObject) = - chunkingStrategy( - FileChunkingStrategy.ofStaticFileChunkingStrategyObject( - staticFileChunkingStrategyObject - ) - ) + fun chunkingStrategy(static_: StaticFileChunkingStrategyObject) = + chunkingStrategy(FileChunkingStrategy.ofStatic(static_)) /** * This is returned when the chunking strategy is unknown. Typically, this is because the * file was indexed before the `chunking_strategy` concept was introduced in the API. */ - fun chunkingStrategy(otherFileChunkingStrategyObject: OtherFileChunkingStrategyObject) = - chunkingStrategy( - FileChunkingStrategy.ofOtherFileChunkingStrategyObject( - otherFileChunkingStrategyObject - ) - ) + fun chunkingStrategy(other: OtherFileChunkingStrategyObject) = + chunkingStrategy(FileChunkingStrategy.ofOther(other)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/AssistantTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/AssistantTest.kt index 109bf6e1a..5ef7a61f4 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/AssistantTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/AssistantTest.kt @@ -47,9 +47,7 @@ class AssistantTest { assertThat(assistant.model()).isEqualTo("model") assertThat(assistant.name()).contains("name") assertThat(assistant.tools()) - .containsExactly( - AssistantTool.ofCodeInterpreterTool(CodeInterpreterTool.builder().build()) - ) + .containsExactly(AssistantTool.ofCodeInterpreter(CodeInterpreterTool.builder().build())) assertThat(assistant.responseFormat()).contains(AssistantResponseFormatOption.ofAuto()) assertThat(assistant.temperature()).contains(1.0) assertThat(assistant.toolResources()) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantCreateParamsTest.kt index 4ad22b7b2..556d35051 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantCreateParamsTest.kt @@ -121,7 +121,7 @@ class BetaAssistantCreateParamsTest { ) assertThat(body.tools()) .contains( - listOf(AssistantTool.ofCodeInterpreterTool(CodeInterpreterTool.builder().build())) + listOf(AssistantTool.ofCodeInterpreter(CodeInterpreterTool.builder().build())) ) assertThat(body.topP()).contains(1.0) } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantUpdateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantUpdateParamsTest.kt index 244ed7f7e..a2620cbaa 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantUpdateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantUpdateParamsTest.kt @@ -93,7 +93,7 @@ class BetaAssistantUpdateParamsTest { ) assertThat(body.tools()) .contains( - listOf(AssistantTool.ofCodeInterpreterTool(CodeInterpreterTool.builder().build())) + listOf(AssistantTool.ofCodeInterpreter(CodeInterpreterTool.builder().build())) ) assertThat(body.topP()).contains(1.0) } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadCreateAndRunParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadCreateAndRunParamsTest.kt index ff3ac0561..4c83c3362 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadCreateAndRunParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadCreateAndRunParamsTest.kt @@ -252,7 +252,7 @@ class BetaThreadCreateAndRunParamsTest { assertThat(body.tools()) .contains( listOf( - BetaThreadCreateAndRunParams.Tool.ofCodeInterpreterTool( + BetaThreadCreateAndRunParams.Tool.ofCodeInterpreter( CodeInterpreterTool.builder().build() ) ) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadMessageCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadMessageCreateParamsTest.kt index ba03f883a..e226b151c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadMessageCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadMessageCreateParamsTest.kt @@ -41,8 +41,7 @@ class BetaThreadMessageCreateParamsTest { .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.content()) - .isEqualTo(BetaThreadMessageCreateParams.Content.ofTextContent("string")) + assertThat(body.content()).isEqualTo(BetaThreadMessageCreateParams.Content.ofText("string")) assertThat(body.role()).isEqualTo(BetaThreadMessageCreateParams.Role.USER) assertThat(body.attachments()) .contains( @@ -66,8 +65,7 @@ class BetaThreadMessageCreateParamsTest { .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.content()) - .isEqualTo(BetaThreadMessageCreateParams.Content.ofTextContent("string")) + assertThat(body.content()).isEqualTo(BetaThreadMessageCreateParams.Content.ofText("string")) assertThat(body.role()).isEqualTo(BetaThreadMessageCreateParams.Role.USER) } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunCreateParamsTest.kt index 9324dd83a..0addbde1d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunCreateParamsTest.kt @@ -178,7 +178,7 @@ class BetaThreadRunCreateParamsTest { .contains(AssistantToolChoiceOption.ofAuto(AssistantToolChoiceOption.Auto.NONE)) assertThat(body.tools()) .contains( - listOf(AssistantTool.ofCodeInterpreterTool(CodeInterpreterTool.builder().build())) + listOf(AssistantTool.ofCodeInterpreter(CodeInterpreterTool.builder().build())) ) assertThat(body.topP()).contains(1.0) assertThat(body.truncationStrategy()) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreCreateParamsTest.kt index d16d72754..50f9aad66 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreCreateParamsTest.kt @@ -33,9 +33,7 @@ class BetaVectorStoreCreateParamsTest { assertThat(body).isNotNull assertThat(body.chunkingStrategy()) .contains( - FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam( - AutoFileChunkingStrategyParam.builder().build() - ) + FileChunkingStrategyParam.ofAuto(AutoFileChunkingStrategyParam.builder().build()) ) assertThat(body.expiresAfter()) .contains(BetaVectorStoreCreateParams.ExpiresAfter.builder().days(1L).build()) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreFileBatchCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreFileBatchCreateParamsTest.kt index c3298dd26..4bf86d77d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreFileBatchCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreFileBatchCreateParamsTest.kt @@ -29,9 +29,7 @@ class BetaVectorStoreFileBatchCreateParamsTest { assertThat(body.fileIds()).isEqualTo(listOf("string")) assertThat(body.chunkingStrategy()) .contains( - FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam( - AutoFileChunkingStrategyParam.builder().build() - ) + FileChunkingStrategyParam.ofAuto(AutoFileChunkingStrategyParam.builder().build()) ) } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreFileCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreFileCreateParamsTest.kt index 3a60b3938..09ffd082e 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreFileCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaVectorStoreFileCreateParamsTest.kt @@ -29,9 +29,7 @@ class BetaVectorStoreFileCreateParamsTest { assertThat(body.fileId()).isEqualTo("file_id") assertThat(body.chunkingStrategy()) .contains( - FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam( - AutoFileChunkingStrategyParam.builder().build() - ) + FileChunkingStrategyParam.ofAuto(AutoFileChunkingStrategyParam.builder().build()) ) } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionAssistantMessageParamTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionAssistantMessageParamTest.kt index 0cee64174..3f47e21e3 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionAssistantMessageParamTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionAssistantMessageParamTest.kt @@ -37,7 +37,7 @@ class ChatCompletionAssistantMessageParamTest { assertThat(chatCompletionAssistantMessageParam.audio()) .contains(ChatCompletionAssistantMessageParam.Audio.builder().id("id").build()) assertThat(chatCompletionAssistantMessageParam.content()) - .contains(ChatCompletionAssistantMessageParam.Content.ofTextContent("string")) + .contains(ChatCompletionAssistantMessageParam.Content.ofText("string")) assertThat(chatCompletionAssistantMessageParam.functionCall()) .contains( ChatCompletionAssistantMessageParam.FunctionCall.builder() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionCreateParamsTest.kt index d9bf094dc..e5985c029 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionCreateParamsTest.kt @@ -165,7 +165,7 @@ class ChatCompletionCreateParamsTest { assertThat(body.messages()) .isEqualTo( listOf( - ChatCompletionMessageParam.ofChatCompletionDeveloperMessageParam( + ChatCompletionMessageParam.ofDeveloper( ChatCompletionDeveloperMessageParam.builder() .content("string") .name("name") @@ -226,7 +226,7 @@ class ChatCompletionCreateParamsTest { assertThat(body.reasoningEffort()).contains(ChatCompletionReasoningEffort.LOW) assertThat(body.responseFormat()) .contains( - ChatCompletionCreateParams.ResponseFormat.ofResponseFormatText( + ChatCompletionCreateParams.ResponseFormat.ofText( ResponseFormatText.builder().build() ) ) @@ -277,7 +277,7 @@ class ChatCompletionCreateParamsTest { assertThat(body.messages()) .isEqualTo( listOf( - ChatCompletionMessageParam.ofChatCompletionDeveloperMessageParam( + ChatCompletionMessageParam.ofDeveloper( ChatCompletionDeveloperMessageParam.builder().content("string").build() ) ) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionDeveloperMessageParamTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionDeveloperMessageParamTest.kt index 0559a7810..c047cc274 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionDeveloperMessageParamTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionDeveloperMessageParamTest.kt @@ -13,7 +13,7 @@ class ChatCompletionDeveloperMessageParamTest { ChatCompletionDeveloperMessageParam.builder().content("string").name("name").build() assertThat(chatCompletionDeveloperMessageParam).isNotNull assertThat(chatCompletionDeveloperMessageParam.content()) - .isEqualTo(ChatCompletionDeveloperMessageParam.Content.ofTextContent("string")) + .isEqualTo(ChatCompletionDeveloperMessageParam.Content.ofText("string")) assertThat(chatCompletionDeveloperMessageParam.name()).contains("name") } } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionPredictionContentTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionPredictionContentTest.kt index ff67d1809..b6da8783e 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionPredictionContentTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionPredictionContentTest.kt @@ -13,6 +13,6 @@ class ChatCompletionPredictionContentTest { ChatCompletionPredictionContent.builder().content("string").build() assertThat(chatCompletionPredictionContent).isNotNull assertThat(chatCompletionPredictionContent.content()) - .isEqualTo(ChatCompletionPredictionContent.Content.ofTextContent("string")) + .isEqualTo(ChatCompletionPredictionContent.Content.ofText("string")) } } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionSystemMessageParamTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionSystemMessageParamTest.kt index af2b498e1..dee3fd034 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionSystemMessageParamTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionSystemMessageParamTest.kt @@ -13,7 +13,7 @@ class ChatCompletionSystemMessageParamTest { ChatCompletionSystemMessageParam.builder().content("string").name("name").build() assertThat(chatCompletionSystemMessageParam).isNotNull assertThat(chatCompletionSystemMessageParam.content()) - .isEqualTo(ChatCompletionSystemMessageParam.Content.ofTextContent("string")) + .isEqualTo(ChatCompletionSystemMessageParam.Content.ofText("string")) assertThat(chatCompletionSystemMessageParam.name()).contains("name") } } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionToolMessageParamTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionToolMessageParamTest.kt index d4c404c74..49361e88e 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionToolMessageParamTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionToolMessageParamTest.kt @@ -16,7 +16,7 @@ class ChatCompletionToolMessageParamTest { .build() assertThat(chatCompletionToolMessageParam).isNotNull assertThat(chatCompletionToolMessageParam.content()) - .isEqualTo(ChatCompletionToolMessageParam.Content.ofTextContent("string")) + .isEqualTo(ChatCompletionToolMessageParam.Content.ofText("string")) assertThat(chatCompletionToolMessageParam.toolCallId()).isEqualTo("tool_call_id") } } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionUserMessageParamTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionUserMessageParamTest.kt index 913dd3057..215e163e7 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionUserMessageParamTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionUserMessageParamTest.kt @@ -13,7 +13,7 @@ class ChatCompletionUserMessageParamTest { ChatCompletionUserMessageParam.builder().content("string").name("name").build() assertThat(chatCompletionUserMessageParam).isNotNull assertThat(chatCompletionUserMessageParam.content()) - .isEqualTo(ChatCompletionUserMessageParam.Content.ofTextContent("string")) + .isEqualTo(ChatCompletionUserMessageParam.Content.ofText("string")) assertThat(chatCompletionUserMessageParam.name()).contains("name") } } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/MessageDeltaTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/MessageDeltaTest.kt index cdab95756..39b27defe 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/MessageDeltaTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/MessageDeltaTest.kt @@ -27,7 +27,7 @@ class MessageDeltaTest { assertThat(messageDelta).isNotNull assertThat(messageDelta.content().get()) .containsExactly( - MessageContentDelta.ofImageFileDeltaBlock( + MessageContentDelta.ofImageFile( ImageFileDeltaBlock.builder() .index(0L) .imageFile( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/MessageTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/MessageTest.kt index bef9522a9..fbbc80fb7 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/MessageTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/MessageTest.kt @@ -57,7 +57,7 @@ class MessageTest { assertThat(message.completedAt()).contains(0L) assertThat(message.content()) .containsExactly( - MessageContent.ofImageFileContentBlock( + MessageContent.ofImageFile( ImageFileContentBlock.builder() .imageFile( ImageFile.builder() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/RunStepDeltaTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/RunStepDeltaTest.kt index 724ec019d..9d95feaa4 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/RunStepDeltaTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/RunStepDeltaTest.kt @@ -24,7 +24,7 @@ class RunStepDeltaTest { assertThat(runStepDelta).isNotNull assertThat(runStepDelta.stepDetails()) .contains( - RunStepDelta.StepDetails.ofRunStepDeltaMessageDelta( + RunStepDelta.StepDetails.ofMessageCreation( RunStepDeltaMessageDelta.builder() .messageCreation( RunStepDeltaMessageDelta.MessageCreation.builder() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/RunStepTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/RunStepTest.kt index cfc7bf959..55b6ad1b7 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/RunStepTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/RunStepTest.kt @@ -67,7 +67,7 @@ class RunStepTest { assertThat(runStep.status()).isEqualTo(RunStep.Status.IN_PROGRESS) assertThat(runStep.stepDetails()) .isEqualTo( - RunStep.StepDetails.ofMessageCreationStepDetails( + RunStep.StepDetails.ofMessageCreation( MessageCreationStepDetails.builder() .messageCreation( MessageCreationStepDetails.MessageCreation.builder() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/RunTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/RunTest.kt index 136c107b5..06ab99eb4 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/RunTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/RunTest.kt @@ -131,9 +131,7 @@ class RunTest { assertThat(run.toolChoice()) .contains(AssistantToolChoiceOption.ofAuto(AssistantToolChoiceOption.Auto.NONE)) assertThat(run.tools()) - .containsExactly( - AssistantTool.ofCodeInterpreterTool(CodeInterpreterTool.builder().build()) - ) + .containsExactly(AssistantTool.ofCodeInterpreter(CodeInterpreterTool.builder().build())) assertThat(run.truncationStrategy()) .contains( Run.TruncationStrategy.builder() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/TextDeltaTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/TextDeltaTest.kt index 8582da3a0..b807c1236 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/TextDeltaTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/TextDeltaTest.kt @@ -30,7 +30,7 @@ class TextDeltaTest { assertThat(textDelta).isNotNull assertThat(textDelta.annotations().get()) .containsExactly( - AnnotationDelta.ofFileCitationDeltaAnnotation( + AnnotationDelta.ofFileCitation( FileCitationDeltaAnnotation.builder() .index(0L) .endIndex(0L) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/TextTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/TextTest.kt index 4f93eff7f..1ebf70ac8 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/TextTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/TextTest.kt @@ -26,7 +26,7 @@ class TextTest { assertThat(text).isNotNull assertThat(text.annotations()) .containsExactly( - Annotation.ofFileCitationAnnotation( + Annotation.ofFileCitation( FileCitationAnnotation.builder() .endIndex(0L) .fileCitation( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ToolCallDeltaObjectTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ToolCallDeltaObjectTest.kt index c8ef1aa96..763cb95fb 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ToolCallDeltaObjectTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ToolCallDeltaObjectTest.kt @@ -29,7 +29,7 @@ class ToolCallDeltaObjectTest { assertThat(toolCallDeltaObject).isNotNull assertThat(toolCallDeltaObject.toolCalls().get()) .containsExactly( - ToolCallDelta.ofCodeInterpreterToolCallDelta( + ToolCallDelta.ofCodeInterpreter( CodeInterpreterToolCallDelta.builder() .index(0L) .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ToolCallsStepDetailsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ToolCallsStepDetailsTest.kt index 59628855a..b6ad68ff5 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ToolCallsStepDetailsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ToolCallsStepDetailsTest.kt @@ -31,7 +31,7 @@ class ToolCallsStepDetailsTest { assertThat(toolCallsStepDetails).isNotNull assertThat(toolCallsStepDetails.toolCalls()) .containsExactly( - ToolCall.ofCodeInterpreterToolCall( + ToolCall.ofCodeInterpreter( CodeInterpreterToolCall.builder() .id("id") .codeInterpreter( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/VectorStoreFileTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/VectorStoreFileTest.kt index 75b65d682..2d9ba6d2d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/VectorStoreFileTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/VectorStoreFileTest.kt @@ -48,7 +48,7 @@ class VectorStoreFileTest { assertThat(vectorStoreFile.vectorStoreId()).isEqualTo("vector_store_id") assertThat(vectorStoreFile.chunkingStrategy()) .contains( - FileChunkingStrategy.ofStaticFileChunkingStrategyObject( + FileChunkingStrategy.ofStatic( StaticFileChunkingStrategyObject.builder() .static_( StaticFileChunkingStrategy.builder() diff --git a/openai-java-example/src/main/java/com/openai/example/Main.java b/openai-java-example/src/main/java/com/openai/example/Main.java index 3f09b0a6e..8daeb5598 100644 --- a/openai-java-example/src/main/java/com/openai/example/Main.java +++ b/openai-java-example/src/main/java/com/openai/example/Main.java @@ -12,12 +12,10 @@ public static void main(String[] args) { OpenAIClient client = OpenAIOkHttpClient.fromEnv(); ChatCompletionCreateParams completionCreateParams = ChatCompletionCreateParams.builder() .model(ChatModel.GPT_3_5_TURBO) - .maxTokens(1024) - .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( - ChatCompletionUserMessageParam.builder() - .content(ChatCompletionUserMessageParam.Content.ofTextContent( - "Tell me a story about building the best SDK!")) - .build())) + .maxCompletionTokens(1024) + .addMessage(ChatCompletionUserMessageParam.builder() + .content("Tell me a story about building the best SDK!") + .build()) .build(); // Non-streaming example