Skip to content

Commit fdd3ea9

Browse files
release: 0.11.4 (#123)
* chore(internal): extract a `checkRequired` function (#113) * chore(types): rename vector store chunking strategy (#116) * chore(internal): add and tweak check functions (#117) chore(internal): tweak client options nullability handling * chore: simplify examples involving lists (#118) * chore: simplify examples involving unions (#119) * docs: don't mention a non-existent SDK (#120) * chore(internal): remove unused gradle task (#121) * chore(internal): fix tests * chore(internal): remove space (#125) * release: 0.11.4 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> Co-authored-by: Tomer Aberbach <[email protected]>
1 parent c5596ce commit fdd3ea9

File tree

249 files changed

+3123
-4820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+3123
-4820
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.11.3"
2+
".": "0.11.4"
33
}

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Changelog
22

3+
## 0.11.4 (2025-01-16)
4+
5+
Full Changelog: [v0.11.3...v0.11.4](https://github.com/openai/openai-java/compare/v0.11.3...v0.11.4)
6+
7+
### Chores
8+
9+
* **internal:** add and tweak check functions ([#117](https://github.com/openai/openai-java/issues/117)) ([627cb56](https://github.com/openai/openai-java/commit/627cb568af9ff28a570de4d9ebae04a2ba5c46d7))
10+
* **internal:** extract a `checkRequired` function ([#113](https://github.com/openai/openai-java/issues/113)) ([b63b2b1](https://github.com/openai/openai-java/commit/b63b2b159bd6c9d01d22a64980a13bfcc3f64863))
11+
* **internal:** fix tests ([61ada05](https://github.com/openai/openai-java/commit/61ada05fe8d4a3509fc59c6626611e5dbc308aff))
12+
* **internal:** remove space ([#125](https://github.com/openai/openai-java/issues/125)) ([27bfcec](https://github.com/openai/openai-java/commit/27bfcec6deccf7d000a305e630b4eda012154222))
13+
* **internal:** remove unused gradle task ([#121](https://github.com/openai/openai-java/issues/121)) ([0b4e59a](https://github.com/openai/openai-java/commit/0b4e59abac5343abe8cda697864fe8afa9fe1774))
14+
* **internal:** tweak client options nullability handling ([627cb56](https://github.com/openai/openai-java/commit/627cb568af9ff28a570de4d9ebae04a2ba5c46d7))
15+
* simplify examples involving lists ([#118](https://github.com/openai/openai-java/issues/118)) ([557c071](https://github.com/openai/openai-java/commit/557c0713590c7e0556dd68e77e4179fde8923c86))
16+
* simplify examples involving unions ([#119](https://github.com/openai/openai-java/issues/119)) ([7c7795c](https://github.com/openai/openai-java/commit/7c7795c852c09bca6ab23b22435fd7846730e95c))
17+
* **types:** rename vector store chunking strategy ([#116](https://github.com/openai/openai-java/issues/116)) ([387935f](https://github.com/openai/openai-java/commit/387935fa16873ae252522aa926d3ed701186a292))
18+
19+
20+
### Documentation
21+
22+
* don't mention a non-existent SDK ([#120](https://github.com/openai/openai-java/issues/120)) ([23eb658](https://github.com/openai/openai-java/commit/23eb6584b4ba7dfd8e5a9147d815ab01e364726e))
23+
324
## 0.11.3 (2025-01-14)
425

526
Full Changelog: [v0.11.2...v0.11.3](https://github.com/openai/openai-java/compare/v0.11.2...v0.11.3)

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
1010
<!-- x-release-please-start-version -->
1111

12-
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.11.3)
12+
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.11.4)
1313

1414
<!-- x-release-please-end -->
1515

1616
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.
1717

18-
The OpenAI Java SDK is similar to the OpenAI Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions.
19-
2018
## Documentation
2119

2220
The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs).
@@ -32,7 +30,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfo
3230
<!-- x-release-please-start-version -->
3331

3432
```kotlin
35-
implementation("com.openai:openai-java:0.11.3")
33+
implementation("com.openai:openai-java:0.11.4")
3634
```
3735

3836
#### Maven
@@ -41,7 +39,7 @@ implementation("com.openai:openai-java:0.11.3")
4139
<dependency>
4240
<groupId>com.openai</groupId>
4341
<artifactId>openai-java</artifactId>
44-
<version>0.11.3</version>
42+
<version>0.11.4</version>
4543
</dependency>
4644
```
4745

@@ -92,16 +90,14 @@ To create a new chat completion, first use the `ChatCompletionCreateParams` buil
9290
```java
9391
import com.openai.models.ChatCompletion;
9492
import com.openai.models.ChatCompletionCreateParams;
95-
import com.openai.models.ChatCompletionMessageParam;
9693
import com.openai.models.ChatCompletionUserMessageParam;
9794
import com.openai.models.ChatModel;
98-
import java.util.List;
9995

10096
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
101-
.messages(List.of(ChatCompletionMessageParam.ofChatCompletionUserMessageParam(ChatCompletionUserMessageParam.builder()
97+
.addMessage(ChatCompletionUserMessageParam.builder()
10298
.role(ChatCompletionUserMessageParam.Role.USER)
103-
.content(ChatCompletionUserMessageParam.Content.ofTextContent("Say this is a test"))
104-
.build())))
99+
.content("Say this is a test")
100+
.build())
105101
.model(ChatModel.O1)
106102
.build();
107103
ChatCompletion chatCompletion = client.chat().completions().create(params);

build.gradle.kts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@ plugins {
44

55
allprojects {
66
group = "com.openai"
7-
version = "0.11.3" // x-release-please-version
7+
version = "0.11.4" // x-release-please-version
88
}
99

1010
subprojects {
1111
apply(plugin = "org.jetbrains.dokka")
1212
}
13-
14-
tasks.register<Jar>("dokkaJavadocJar") {
15-
dependsOn(tasks.dokkaJavadoc)
16-
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
17-
archiveClassifier.set("javadoc")
18-
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@file:JvmName("Check")
2+
3+
package com.openai.core
4+
5+
@JvmSynthetic
6+
internal fun <T : Any> checkRequired(name: String, value: T?): T =
7+
checkNotNull(value) { "`$name` is required, but was not set" }
8+
9+
@JvmSynthetic
10+
internal fun checkLength(name: String, value: String, length: Int): String =
11+
value.also {
12+
check(it.length == length) { "`$name` must have length $length, but was ${it.length}" }
13+
}
14+
15+
@JvmSynthetic
16+
internal fun checkMinLength(name: String, value: String, minLength: Int): String =
17+
value.also {
18+
check(it.length >= minLength) {
19+
if (minLength == 1) "`$name` must be non-empty, but was empty"
20+
else "`$name` must have at least length $minLength, but was ${it.length}"
21+
}
22+
}
23+
24+
@JvmSynthetic
25+
internal fun checkMaxLength(name: String, value: String, maxLength: Int): String =
26+
value.also {
27+
check(it.length <= maxLength) {
28+
"`$name` must have at most length $maxLength, but was ${it.length}"
29+
}
30+
}

openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ private constructor(
230230
}
231231

232232
fun build(): ClientOptions {
233-
checkNotNull(httpClient) { "`httpClient` is required but was not set" }
234-
checkNotNull(credential) { "`credential` is required but was not set" }
233+
val httpClient = checkRequired("httpClient", httpClient)
234+
val credential = checkRequired("credential", credential)
235235

236236
val headers = Headers.builder()
237237
val queryParams = QueryParams.builder()
@@ -245,12 +245,12 @@ private constructor(
245245
organization?.let { headers.put("OpenAI-Organization", it) }
246246
project?.let { headers.put("OpenAI-Project", it) }
247247

248-
when (val currentCredential = credential) {
248+
when (credential) {
249249
is AzureApiKeyCredential -> {
250-
headers.put("api-key", currentCredential.apiKey())
250+
headers.put("api-key", credential.apiKey())
251251
}
252252
is BearerTokenCredential -> {
253-
headers.put("Authorization", "Bearer ${currentCredential.token()}")
253+
headers.put("Authorization", "Bearer ${credential.token()}")
254254
}
255255
else -> {
256256
throw IllegalArgumentException("Invalid credential type")
@@ -268,10 +268,10 @@ private constructor(
268268
queryParams.replaceAll(this.queryParams.build())
269269

270270
return ClientOptions(
271-
httpClient!!,
271+
httpClient,
272272
PhantomReachableClosingHttpClient(
273273
RetryingHttpClient.builder()
274-
.httpClient(httpClient!!)
274+
.httpClient(httpClient)
275275
.clock(clock)
276276
.maxRetries(maxRetries)
277277
.build()
@@ -298,7 +298,7 @@ private constructor(
298298
queryParams.build(),
299299
responseValidation,
300300
maxRetries,
301-
credential!!,
301+
credential,
302302
organization,
303303
project,
304304
)

openai-java-core/src/main/kotlin/com/openai/core/Values.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ sealed class JsonField<out T : Any> {
117117
is JsonValue -> this
118118
}
119119

120+
@JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume)
121+
120122
fun <R> accept(visitor: Visitor<T, R>): R =
121123
when (this) {
122124
is KnownValue -> visitor.visitKnown(value)

openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.openai.core.JsonField
1212
import com.openai.core.JsonMissing
1313
import com.openai.core.JsonValue
1414
import com.openai.core.NoAutoDetect
15+
import com.openai.core.checkRequired
1516
import com.openai.core.immutableEmptyMap
1617
import com.openai.core.toImmutable
1718
import com.openai.errors.OpenAIInvalidDataException
@@ -688,16 +689,15 @@ private constructor(
688689

689690
fun build(): Assistant =
690691
Assistant(
691-
checkNotNull(id) { "`id` is required but was not set" },
692-
checkNotNull(createdAt) { "`createdAt` is required but was not set" },
693-
checkNotNull(description) { "`description` is required but was not set" },
694-
checkNotNull(instructions) { "`instructions` is required but was not set" },
695-
checkNotNull(metadata) { "`metadata` is required but was not set" },
696-
checkNotNull(model) { "`model` is required but was not set" },
697-
checkNotNull(name) { "`name` is required but was not set" },
698-
checkNotNull(object_) { "`object_` is required but was not set" },
699-
checkNotNull(tools) { "`tools` is required but was not set" }
700-
.map { it.toImmutable() },
692+
checkRequired("id", id),
693+
checkRequired("createdAt", createdAt),
694+
checkRequired("description", description),
695+
checkRequired("instructions", instructions),
696+
checkRequired("metadata", metadata),
697+
checkRequired("model", model),
698+
checkRequired("name", name),
699+
checkRequired("object_", object_),
700+
checkRequired("tools", tools).map { it.toImmutable() },
701701
responseFormat,
702702
temperature,
703703
toolResources,

openai-java-core/src/main/kotlin/com/openai/models/AssistantDeleted.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.openai.core.JsonField
1212
import com.openai.core.JsonMissing
1313
import com.openai.core.JsonValue
1414
import com.openai.core.NoAutoDetect
15+
import com.openai.core.checkRequired
1516
import com.openai.core.immutableEmptyMap
1617
import com.openai.core.toImmutable
1718
import com.openai.errors.OpenAIInvalidDataException
@@ -115,9 +116,9 @@ private constructor(
115116

116117
fun build(): AssistantDeleted =
117118
AssistantDeleted(
118-
checkNotNull(id) { "`id` is required but was not set" },
119-
checkNotNull(deleted) { "`deleted` is required but was not set" },
120-
checkNotNull(object_) { "`object_` is required but was not set" },
119+
checkRequired("id", id),
120+
checkRequired("deleted", deleted),
121+
checkRequired("object_", object_),
121122
additionalProperties.toImmutable(),
122123
)
123124
}

0 commit comments

Comments
 (0)