diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 6db19b9..4ad3fef 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.17.0"
+ ".": "0.18.0"
}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 08b74dd..b9e0bbb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog
+## 0.18.0 (2025-01-29)
+
+Full Changelog: [v0.17.0...v0.18.0](https://github.com/openai/openai-java/compare/v0.17.0...v0.18.0)
+
+### Features
+
+* **client:** helpers for discriminated union variants with one required prop ([#182](https://github.com/openai/openai-java/issues/182)) ([ec756b9](https://github.com/openai/openai-java/commit/ec756b9788629dfc36bb56d59d9f17f4d0d8cc35))
+
+
+### Chores
+
+* **internal:** improve `RetryingHttpClientTest` ([#180](https://github.com/openai/openai-java/issues/180)) ([b7ebe5d](https://github.com/openai/openai-java/commit/b7ebe5d44b2797618905614b51a27b73906e4271))
+* **internal:** simplify object construction ([#183](https://github.com/openai/openai-java/issues/183)) ([3d5a59d](https://github.com/openai/openai-java/commit/3d5a59dccc425e351a365f9dbdf2ae52244086ae))
+
+
+### Documentation
+
+* simpliy param construction ([2c2ccbc](https://github.com/openai/openai-java/commit/2c2ccbc83a053e525ad0d8df1506de5be4fda46c))
+
## 0.17.0 (2025-01-29)
Full Changelog: [v0.16.0...v0.17.0](https://github.com/openai/openai-java/compare/v0.16.0...v0.17.0)
diff --git a/README.md b/README.md
index 3d8e153..f2446b5 100644
--- a/README.md
+++ b/README.md
@@ -9,8 +9,8 @@
-[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.17.0)
-[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.17.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.17.0)
+[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.18.0)
+[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.18.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.18.0)
@@ -25,7 +25,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
### Gradle
```kotlin
-implementation("com.openai:openai-java:0.17.0")
+implementation("com.openai:openai-java:0.18.0")
```
### Maven
@@ -34,7 +34,7 @@ implementation("com.openai:openai-java:0.17.0")
com.openai
openai-java
- 0.17.0
+ 0.18.0
```
@@ -93,13 +93,10 @@ To create a new chat completion, first use the `ChatCompletionCreateParams` buil
```java
import com.openai.models.ChatCompletion;
import com.openai.models.ChatCompletionCreateParams;
-import com.openai.models.ChatCompletionUserMessageParam;
import com.openai.models.ChatModel;
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Say this is a test")
- .build())
+ .addUserMessage("Say this is a test")
.model(ChatModel.O1)
.build();
ChatCompletion chatCompletion = client.chat().completions().create(params);
diff --git a/build.gradle.kts b/build.gradle.kts
index b2f9776..e734683 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.openai"
- version = "0.17.0" // x-release-please-version
+ version = "0.18.0" // x-release-please-version
}
subprojects {
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 3b62306..5f4573c 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
@@ -423,6 +423,13 @@ private constructor(
*/
fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function))
+ /**
+ * 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 addFunctionTool(function: FunctionDefinition) =
+ addTool(FunctionTool.builder().function(function).build())
+
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4
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 c51c7b9..da55307 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
@@ -786,6 +786,13 @@ private constructor(
*/
fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function))
+ /**
+ * 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 addFunctionTool(function: FunctionDefinition) =
+ addTool(FunctionTool.builder().function(function).build())
+
/**
* An alternative to sampling with temperature, called nucleus sampling, where the model
* considers the results of the tokens with top_p probability mass. So 0.1 means only
@@ -1205,6 +1212,12 @@ private constructor(
*/
fun addTool(function: FunctionTool) = apply { body.addTool(function) }
+ /**
+ * 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 addFunctionTool(function: FunctionDefinition) = apply { body.addFunctionTool(function) }
+
/**
* An alternative to sampling with temperature, called nucleus sampling, where the model
* considers the results of the tokens with top_p probability mass. So 0.1 means only the
@@ -1941,6 +1954,15 @@ private constructor(
fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) =
chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_))
+ /**
+ * 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 staticChunkingStrategy(static_: StaticFileChunkingStrategy) =
+ chunkingStrategy(
+ StaticFileChunkingStrategyObjectParam.builder().static_(static_).build()
+ )
+
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. There can be a maximum of 10000 files in a vector
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 cd4e741..ec5b548 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
@@ -788,6 +788,13 @@ private constructor(
*/
fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function))
+ /**
+ * 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 addFunctionTool(function: FunctionDefinition) =
+ addTool(FunctionTool.builder().function(function).build())
+
/**
* An alternative to sampling with temperature, called nucleus sampling, where the model
* considers the results of the tokens with top_p probability mass. So 0.1 means only
@@ -1203,6 +1210,12 @@ private constructor(
*/
fun addTool(function: FunctionTool) = apply { body.addTool(function) }
+ /**
+ * 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 addFunctionTool(function: FunctionDefinition) = apply { body.addFunctionTool(function) }
+
/**
* An alternative to sampling with temperature, called nucleus sampling, where the model
* considers the results of the tokens with top_p probability mass. So 0.1 means only the
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 b1880ba..7bc26fc 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
@@ -3553,6 +3553,17 @@ private constructor(
fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) =
chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_))
+ /**
+ * 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 staticChunkingStrategy(static_: StaticFileChunkingStrategy) =
+ chunkingStrategy(
+ StaticFileChunkingStrategyObjectParam.builder()
+ .static_(static_)
+ .build()
+ )
+
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files)
* IDs to add to the vector store. There can be a maximum of 10000 files in
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 0fe6aa9..cd28452 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
@@ -1872,6 +1872,15 @@ private constructor(
fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) =
chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_))
+ /**
+ * 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 staticChunkingStrategy(static_: StaticFileChunkingStrategy) =
+ chunkingStrategy(
+ StaticFileChunkingStrategyObjectParam.builder().static_(static_).build()
+ )
+
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. There can be a maximum of 10000 files in a vector
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 b32bb0b..65060a9 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
@@ -1226,6 +1226,13 @@ private constructor(
*/
fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function))
+ /**
+ * Override the tools the assistant can use for this run. This is useful for modifying
+ * the behavior on a per-run basis.
+ */
+ fun addFunctionTool(function: FunctionDefinition) =
+ addTool(FunctionTool.builder().function(function).build())
+
/**
* An alternative to sampling with temperature, called nucleus sampling, where the model
* considers the results of the tokens with top_p probability mass. So 0.1 means only
@@ -1885,6 +1892,12 @@ private constructor(
*/
fun addTool(function: FunctionTool) = apply { body.addTool(function) }
+ /**
+ * Override the tools the assistant can use for this run. This is useful for modifying the
+ * behavior on a per-run basis.
+ */
+ fun addFunctionTool(function: FunctionDefinition) = apply { body.addFunctionTool(function) }
+
/**
* An alternative to sampling with temperature, called nucleus sampling, where the model
* considers the results of the tokens with top_p probability mass. So 0.1 means only the
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 0cb5b24..77e4a34 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
@@ -230,6 +230,15 @@ private constructor(
fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) =
chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_))
+ /**
+ * 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 staticChunkingStrategy(static_: StaticFileChunkingStrategy) =
+ chunkingStrategy(
+ StaticFileChunkingStrategyObjectParam.builder().static_(static_).build()
+ )
+
/** The expiration policy for a vector store. */
fun expiresAfter(expiresAfter: ExpiresAfter) = expiresAfter(JsonField.of(expiresAfter))
@@ -384,6 +393,14 @@ private constructor(
body.chunkingStrategy(static_)
}
+ /**
+ * 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 staticChunkingStrategy(static_: StaticFileChunkingStrategy) = apply {
+ body.staticChunkingStrategy(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 735f7f9..dc9c583 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
@@ -215,6 +215,15 @@ private constructor(
fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) =
chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_))
+ /**
+ * 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 staticChunkingStrategy(static_: StaticFileChunkingStrategy) =
+ chunkingStrategy(
+ StaticFileChunkingStrategyObjectParam.builder().static_(static_).build()
+ )
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -340,6 +349,14 @@ private constructor(
body.chunkingStrategy(static_)
}
+ /**
+ * 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 staticChunkingStrategy(static_: StaticFileChunkingStrategy) = apply {
+ body.staticChunkingStrategy(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 344b310..ddf5f2a 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
@@ -199,6 +199,15 @@ private constructor(
fun chunkingStrategy(static_: StaticFileChunkingStrategyObjectParam) =
chunkingStrategy(FileChunkingStrategyParam.ofStatic(static_))
+ /**
+ * 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 staticChunkingStrategy(static_: StaticFileChunkingStrategy) =
+ chunkingStrategy(
+ StaticFileChunkingStrategyObjectParam.builder().static_(static_).build()
+ )
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -317,6 +326,14 @@ private constructor(
body.chunkingStrategy(static_)
}
+ /**
+ * 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 staticChunkingStrategy(static_: StaticFileChunkingStrategy) = apply {
+ body.staticChunkingStrategy(static_)
+ }
+
fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
body.additionalProperties(additionalBodyProperties)
}
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 2c4a03f..7f8b522 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
@@ -1369,6 +1369,31 @@ private constructor(
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, `developer` messages replace the previous
+ * `system` messages.
+ */
+ fun addDeveloperMessage(content: ChatCompletionDeveloperMessageParam.Content) =
+ addMessage(ChatCompletionDeveloperMessageParam.builder().content(content).build())
+
+ /** The contents of the developer message. */
+ fun addDeveloperMessage(text: String) =
+ addDeveloperMessage(ChatCompletionDeveloperMessageParam.Content.ofText(text))
+
+ /**
+ * An array of content parts with a defined type. For developer messages, only type
+ * `text` is supported.
+ */
+ fun addDeveloperMessageOfArrayOfContentParts(
+ arrayOfContentParts: List
+ ) =
+ addDeveloperMessage(
+ ChatCompletionDeveloperMessageParam.Content.ofArrayOfContentParts(
+ arrayOfContentParts
+ )
+ )
+
/**
* 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
@@ -1377,12 +1402,61 @@ private constructor(
fun addMessage(system: ChatCompletionSystemMessageParam) =
addMessage(ChatCompletionMessageParam.ofSystem(system))
+ /**
+ * 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 addSystemMessage(content: ChatCompletionSystemMessageParam.Content) =
+ addMessage(ChatCompletionSystemMessageParam.builder().content(content).build())
+
+ /** The contents of the system message. */
+ fun addSystemMessage(text: String) =
+ addSystemMessage(ChatCompletionSystemMessageParam.Content.ofText(text))
+
+ /**
+ * An array of content parts with a defined type. For system messages, only type `text`
+ * is supported.
+ */
+ fun addSystemMessageOfArrayOfContentParts(
+ arrayOfContentParts: List
+ ) =
+ addSystemMessage(
+ ChatCompletionSystemMessageParam.Content.ofArrayOfContentParts(
+ arrayOfContentParts
+ )
+ )
+
/**
* Messages sent by an end user, containing prompts or additional context information.
*/
fun addMessage(user: ChatCompletionUserMessageParam) =
addMessage(ChatCompletionMessageParam.ofUser(user))
+ /**
+ * Messages sent by an end user, containing prompts or additional context information.
+ */
+ fun addUserMessage(content: ChatCompletionUserMessageParam.Content) =
+ addMessage(ChatCompletionUserMessageParam.builder().content(content).build())
+
+ /** The text contents of the message. */
+ fun addUserMessage(text: String) =
+ addUserMessage(ChatCompletionUserMessageParam.Content.ofText(text))
+
+ /**
+ * An array of content parts with a defined type. Supported options differ based on the
+ * [model](https://platform.openai.com/docs/models) being used to generate the response.
+ * Can contain text, image, or audio inputs.
+ */
+ fun addUserMessageOfArrayOfContentParts(
+ arrayOfContentParts: List
+ ) =
+ addUserMessage(
+ ChatCompletionUserMessageParam.Content.ofArrayOfContentParts(
+ arrayOfContentParts
+ )
+ )
+
/** Messages sent by the model in response to user messages. */
fun addMessage(assistant: ChatCompletionAssistantMessageParam) =
addMessage(ChatCompletionMessageParam.ofAssistant(assistant))
@@ -2496,15 +2570,71 @@ private constructor(
body.addMessage(developer)
}
+ /**
+ * 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 addDeveloperMessage(content: ChatCompletionDeveloperMessageParam.Content) = apply {
+ body.addDeveloperMessage(content)
+ }
+
+ /** The contents of the developer message. */
+ fun addDeveloperMessage(text: String) = apply { body.addDeveloperMessage(text) }
+
+ /**
+ * An array of content parts with a defined type. For developer messages, only type `text`
+ * is supported.
+ */
+ fun addDeveloperMessageOfArrayOfContentParts(
+ arrayOfContentParts: List
+ ) = apply { body.addDeveloperMessageOfArrayOfContentParts(arrayOfContentParts) }
+
/**
* 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(system: ChatCompletionSystemMessageParam) = apply { body.addMessage(system) }
+ /**
+ * 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 addSystemMessage(content: ChatCompletionSystemMessageParam.Content) = apply {
+ body.addSystemMessage(content)
+ }
+
+ /** The contents of the system message. */
+ fun addSystemMessage(text: String) = apply { body.addSystemMessage(text) }
+
+ /**
+ * An array of content parts with a defined type. For system messages, only type `text` is
+ * supported.
+ */
+ fun addSystemMessageOfArrayOfContentParts(
+ arrayOfContentParts: List
+ ) = apply { body.addSystemMessageOfArrayOfContentParts(arrayOfContentParts) }
+
/** Messages sent by an end user, containing prompts or additional context information. */
fun addMessage(user: ChatCompletionUserMessageParam) = apply { body.addMessage(user) }
+ /** Messages sent by an end user, containing prompts or additional context information. */
+ fun addUserMessage(content: ChatCompletionUserMessageParam.Content) = apply {
+ body.addUserMessage(content)
+ }
+
+ /** The text contents of the message. */
+ fun addUserMessage(text: String) = apply { body.addUserMessage(text) }
+
+ /**
+ * An array of content parts with a defined type. Supported options differ based on the
+ * [model](https://platform.openai.com/docs/models) being used to generate the response. Can
+ * contain text, image, or audio inputs.
+ */
+ fun addUserMessageOfArrayOfContentParts(
+ arrayOfContentParts: List
+ ) = apply { body.addUserMessageOfArrayOfContentParts(arrayOfContentParts) }
+
/** Messages sent by the model in response to user messages. */
fun addMessage(assistant: ChatCompletionAssistantMessageParam) = apply {
body.addMessage(assistant)
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/CodeInterpreterToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/CodeInterpreterToolCall.kt
index f0a1d30..bf90a15 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/CodeInterpreterToolCall.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/CodeInterpreterToolCall.kt
@@ -270,6 +270,10 @@ private constructor(
/** Text output from the Code Interpreter tool call as part of a run step. */
fun addOutput(logs: Output.LogsOutput) = addOutput(Output.ofLogs(logs))
+ /** Text output from the Code Interpreter tool call as part of a run step. */
+ fun addLogsOutput(logs: String) =
+ addOutput(Output.LogsOutput.builder().logs(logs).build())
+
/**
* 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
@@ -277,6 +281,14 @@ private constructor(
*/
fun addOutput(image: Output.ImageOutput) = addOutput(Output.ofImage(image))
+ /**
+ * 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 addImageOutput(image: Output.ImageOutput.Image) =
+ addOutput(Output.ImageOutput.builder().image(image).build())
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
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 01d874a..5fa395f 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
@@ -288,6 +288,10 @@ private constructor(
/** Text output from the Code Interpreter tool call as part of a run step. */
fun addOutput(logs: CodeInterpreterLogs) = addOutput(Output.ofLogs(logs))
+ /** Text output from the Code Interpreter tool call as part of a run step. */
+ fun addLogsOutput(index: Long) =
+ addOutput(CodeInterpreterLogs.builder().index(index).build())
+
/**
* 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
@@ -295,6 +299,14 @@ private constructor(
*/
fun addOutput(image: CodeInterpreterOutputImage) = addOutput(Output.ofImage(image))
+ /**
+ * 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 addImageOutput(index: Long) =
+ addOutput(CodeInterpreterOutputImage.builder().index(index).build())
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
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 0af5d70..8fdc99f 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
@@ -366,16 +366,34 @@ private constructor(
fun addContent(imageFile: ImageFileContentBlock) =
addContent(MessageContent.ofImageFile(imageFile))
+ /**
+ * References an image [File](https://platform.openai.com/docs/api-reference/files) in the
+ * content of a message.
+ */
+ fun addImageFileContent(imageFile: ImageFile) =
+ addContent(ImageFileContentBlock.builder().imageFile(imageFile).build())
+
/** References an image URL in the content of a message. */
fun addContent(imageUrl: ImageUrlContentBlock) =
addContent(MessageContent.ofImageUrl(imageUrl))
+ /** References an image URL in the content of a message. */
+ fun addImageUrlContent(imageUrl: ImageUrl) =
+ addContent(ImageUrlContentBlock.builder().imageUrl(imageUrl).build())
+
/** The text content that is part of a message. */
fun addContent(text: TextContentBlock) = addContent(MessageContent.ofText(text))
+ /** The text content that is part of a message. */
+ fun addTextContent(text: Text) = addContent(TextContentBlock.builder().text(text).build())
+
/** The refusal content generated by the assistant. */
fun addContent(refusal: RefusalContentBlock) = addContent(MessageContent.ofRefusal(refusal))
+ /** The refusal content generated by the assistant. */
+ fun addRefusalContent(refusal: String) =
+ addContent(RefusalContentBlock.builder().refusal(refusal).build())
+
/** The Unix timestamp (in seconds) for when the message was created. */
fun createdAt(createdAt: Long) = createdAt(JsonField.of(createdAt))
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 54b0bd7..df8ce5e 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
@@ -111,17 +111,35 @@ private constructor(
fun addContent(imageFile: ImageFileDeltaBlock) =
addContent(MessageContentDelta.ofImageFile(imageFile))
+ /**
+ * References an image [File](https://platform.openai.com/docs/api-reference/files) in the
+ * content of a message.
+ */
+ fun addImageFileContent(index: Long) =
+ addContent(ImageFileDeltaBlock.builder().index(index).build())
+
/** The text content that is part of a message. */
fun addContent(text: TextDeltaBlock) = addContent(MessageContentDelta.ofText(text))
+ /** The text content that is part of a message. */
+ fun addTextContent(index: Long) = addContent(TextDeltaBlock.builder().index(index).build())
+
/** The refusal content that is part of a message. */
fun addContent(refusal: RefusalDeltaBlock) =
addContent(MessageContentDelta.ofRefusal(refusal))
+ /** The refusal content that is part of a message. */
+ fun addRefusalContent(index: Long) =
+ addContent(RefusalDeltaBlock.builder().index(index).build())
+
/** References an image URL in the content of a message. */
fun addContent(imageUrl: ImageUrlDeltaBlock) =
addContent(MessageContentDelta.ofImageUrl(imageUrl))
+ /** References an image URL in the content of a message. */
+ fun addImageUrlContent(index: Long) =
+ addContent(ImageUrlDeltaBlock.builder().index(index).build())
+
/** 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/Run.kt b/openai-java-core/src/main/kotlin/com/openai/models/Run.kt
index e5298a3..06ea160 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
@@ -1039,6 +1039,13 @@ private constructor(
*/
fun addTool(function: FunctionTool) = addTool(AssistantTool.ofFunction(function))
+ /**
+ * The list of tools that the
+ * [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run.
+ */
+ fun addFunctionTool(function: FunctionDefinition) =
+ addTool(FunctionTool.builder().function(function).build())
+
/**
* Controls for how a thread will be truncated prior to the run. Use this to control the
* intial context window of the run.
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 3838152..e57b81e 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
@@ -433,10 +433,22 @@ private constructor(
fun stepDetails(messageCreation: MessageCreationStepDetails) =
stepDetails(StepDetails.ofMessageCreation(messageCreation))
+ /** Details of the message creation by the run step. */
+ fun messageCreationStepDetails(
+ messageCreation: MessageCreationStepDetails.MessageCreation
+ ) =
+ stepDetails(
+ MessageCreationStepDetails.builder().messageCreation(messageCreation).build()
+ )
+
/** Details of the tool call. */
fun stepDetails(toolCalls: ToolCallsStepDetails) =
stepDetails(StepDetails.ofToolCalls(toolCalls))
+ /** Details of the tool call. */
+ fun toolCallsStepDetails(toolCalls: List) =
+ stepDetails(ToolCallsStepDetails.builder().toolCalls(toolCalls).build())
+
/**
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was
* run.
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 ecb0152..071207d 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
@@ -104,6 +104,14 @@ private constructor(
fun addAnnotation(fileCitation: FileCitationDeltaAnnotation) =
addAnnotation(AnnotationDelta.ofFileCitation(fileCitation))
+ /**
+ * 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 addFileCitationAnnotation(index: Long) =
+ addAnnotation(FileCitationDeltaAnnotation.builder().index(index).build())
+
/**
* A URL for the file that's generated when the assistant used the `code_interpreter` tool
* to generate a file.
@@ -111,6 +119,13 @@ private constructor(
fun addAnnotation(filePath: FilePathDeltaAnnotation) =
addAnnotation(AnnotationDelta.ofFilePath(filePath))
+ /**
+ * A URL for the file that's generated when the assistant used the `code_interpreter` tool
+ * to generate a file.
+ */
+ fun addFilePathAnnotation(index: Long) =
+ addAnnotation(FilePathDeltaAnnotation.builder().index(index).build())
+
/** 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/ToolCallDeltaObject.kt b/openai-java-core/src/main/kotlin/com/openai/models/ToolCallDeltaObject.kt
index 59582d7..6d00d3f 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
@@ -126,6 +126,10 @@ private constructor(
fun addToolCall(codeInterpreter: CodeInterpreterToolCallDelta) =
addToolCall(ToolCallDelta.ofCodeInterpreter(codeInterpreter))
+ /** Details of the Code Interpreter tool call the run step was involved in. */
+ fun addCodeInterpreterToolCall(index: Long) =
+ addToolCall(CodeInterpreterToolCallDelta.builder().index(index).build())
+
/**
* 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`.
@@ -140,6 +144,13 @@ private constructor(
fun addToolCall(function: FunctionToolCallDelta) =
addToolCall(ToolCallDelta.ofFunction(function))
+ /**
+ * 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 addFunctionToolCall(index: Long) =
+ addToolCall(FunctionToolCallDelta.builder().index(index).build())
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
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 0047090..6bbaf69 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
@@ -270,6 +270,10 @@ private constructor(
fun chunkingStrategy(static_: StaticFileChunkingStrategyObject) =
chunkingStrategy(FileChunkingStrategy.ofStatic(static_))
+ /** The strategy used to chunk the file. */
+ fun staticChunkingStrategy(static_: StaticFileChunkingStrategy) =
+ chunkingStrategy(StaticFileChunkingStrategyObject.builder().static_(static_).build())
+
/**
* 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.
diff --git a/openai-java-core/src/test/kotlin/com/openai/core/http/RetryingHttpClientTest.kt b/openai-java-core/src/test/kotlin/com/openai/core/http/RetryingHttpClientTest.kt
index e59282b..36c5cc9 100644
--- a/openai-java-core/src/test/kotlin/com/openai/core/http/RetryingHttpClientTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/core/http/RetryingHttpClientTest.kt
@@ -7,7 +7,6 @@ import com.github.tomakehurst.wiremock.stubbing.Scenario
import com.openai.client.okhttp.OkHttpClient
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
-import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
@@ -22,21 +21,25 @@ internal class RetryingHttpClientTest {
resetAllScenarios()
}
- @Test
- fun byDefaultShouldNotAddIdempotencyHeaderToRequest() {
- val request =
- HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build()
+ @ParameterizedTest
+ @ValueSource(booleans = [false, true])
+ fun execute(async: Boolean) {
stubFor(post(urlPathEqualTo("/something")).willReturn(ok()))
val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build()
- val response = retryingClient.execute(request)
+
+ val response =
+ retryingClient.execute(
+ HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(),
+ async
+ )
+
assertThat(response.statusCode()).isEqualTo(200)
verify(1, postRequestedFor(urlPathEqualTo("/something")))
}
- @Test
- fun whenProvidedShouldAddIdempotencyHeaderToRequest() {
- val request =
- HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build()
+ @ParameterizedTest
+ @ValueSource(booleans = [false, true])
+ fun execute_withIdempotencyHeader(async: Boolean) {
stubFor(
post(urlPathEqualTo("/something"))
.withHeader("X-Some-Header", matching("stainless-java-retry-.+"))
@@ -48,19 +51,24 @@ internal class RetryingHttpClientTest {
.maxRetries(2)
.idempotencyHeader("X-Some-Header")
.build()
- val response = retryingClient.execute(request)
+
+ val response =
+ retryingClient.execute(
+ HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(),
+ async
+ )
+
assertThat(response.statusCode()).isEqualTo(200)
verify(1, postRequestedFor(urlPathEqualTo("/something")))
}
@ParameterizedTest
@ValueSource(booleans = [false, true])
- fun retryAfterHeader(async: Boolean) {
- val request =
- HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build()
+ fun execute_withRetryAfterHeader(async: Boolean) {
stubFor(
post(urlPathEqualTo("/something"))
- .inScenario("foo") // first we fail with a retry after header given as a date
+ // First we fail with a retry after header given as a date
+ .inScenario("foo")
.whenScenarioStateIs(Scenario.STARTED)
.willReturn(
serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT")
@@ -69,14 +77,16 @@ internal class RetryingHttpClientTest {
)
stubFor(
post(urlPathEqualTo("/something"))
- .inScenario("foo") // then we fail with a retry after header given as a delay
+ // Then we fail with a retry after header given as a delay
+ .inScenario("foo")
.whenScenarioStateIs("RETRY_AFTER_DATE")
.willReturn(serviceUnavailable().withHeader("Retry-After", "1.234"))
.willSetStateTo("RETRY_AFTER_DELAY")
)
stubFor(
post(urlPathEqualTo("/something"))
- .inScenario("foo") // then we return a success
+ // Then we return a success
+ .inScenario("foo")
.whenScenarioStateIs("RETRY_AFTER_DELAY")
.willReturn(ok())
.willSetStateTo("COMPLETED")
@@ -85,8 +95,10 @@ internal class RetryingHttpClientTest {
RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build()
val response =
- if (async) retryingClient.executeAsync(request).get()
- else retryingClient.execute(request)
+ retryingClient.execute(
+ HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(),
+ async
+ )
assertThat(response.statusCode()).isEqualTo(200)
verify(
@@ -108,13 +120,7 @@ internal class RetryingHttpClientTest {
@ParameterizedTest
@ValueSource(booleans = [false, true])
- fun overwriteRetryCountHeader(async: Boolean) {
- val request =
- HttpRequest.builder()
- .method(HttpMethod.POST)
- .addPathSegment("something")
- .putHeader("x-stainless-retry-count", "42")
- .build()
+ fun execute_withOverwrittenRetryCountHeader(async: Boolean) {
stubFor(
post(urlPathEqualTo("/something"))
.inScenario("foo") // first we fail with a retry after header given as a date
@@ -135,8 +141,14 @@ internal class RetryingHttpClientTest {
RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build()
val response =
- if (async) retryingClient.executeAsync(request).get()
- else retryingClient.execute(request)
+ retryingClient.execute(
+ HttpRequest.builder()
+ .method(HttpMethod.POST)
+ .addPathSegment("something")
+ .putHeader("x-stainless-retry-count", "42")
+ .build(),
+ async
+ )
assertThat(response.statusCode()).isEqualTo(200)
verify(
@@ -146,10 +158,9 @@ internal class RetryingHttpClientTest {
)
}
- @Test
- fun retryAfterMsHeader() {
- val request =
- HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build()
+ @ParameterizedTest
+ @ValueSource(booleans = [false, true])
+ fun execute_withRetryAfterMsHeader(async: Boolean) {
stubFor(
post(urlPathEqualTo("/something"))
.inScenario("foo")
@@ -166,8 +177,17 @@ internal class RetryingHttpClientTest {
)
val retryingClient =
RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build()
- val response = retryingClient.execute(request)
+
+ val response =
+ retryingClient.execute(
+ HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(),
+ async
+ )
+
assertThat(response.statusCode()).isEqualTo(200)
verify(2, postRequestedFor(urlPathEqualTo("/something")))
}
+
+ private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse =
+ if (async) executeAsync(request).get() else execute(request)
}
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 7060069..6c1cd81 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
@@ -269,7 +269,7 @@ class ChatCompletionCreateParamsTest {
fun bodyWithoutOptionalFields() {
val params =
ChatCompletionCreateParams.builder()
- .addMessage(ChatCompletionDeveloperMessageParam.builder().content("string").build())
+ .addDeveloperMessage("string")
.model(ChatModel.O1)
.build()
val body = params._body()
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/CodeInterpreterToolCallTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/CodeInterpreterToolCallTest.kt
index 74d57cc..2e74fe3 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/CodeInterpreterToolCallTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/CodeInterpreterToolCallTest.kt
@@ -15,11 +15,7 @@ class CodeInterpreterToolCallTest {
.codeInterpreter(
CodeInterpreterToolCall.CodeInterpreter.builder()
.input("input")
- .addOutput(
- CodeInterpreterToolCall.CodeInterpreter.Output.LogsOutput.builder()
- .logs("logs")
- .build()
- )
+ .addLogsOutput("logs")
.build()
)
.build()
@@ -29,11 +25,7 @@ class CodeInterpreterToolCallTest {
.isEqualTo(
CodeInterpreterToolCall.CodeInterpreter.builder()
.input("input")
- .addOutput(
- CodeInterpreterToolCall.CodeInterpreter.Output.LogsOutput.builder()
- .logs("logs")
- .build()
- )
+ .addLogsOutput("logs")
.build()
)
}
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 fbbc80f..f57c9e5 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
@@ -21,15 +21,8 @@ class MessageTest {
.build()
)
.completedAt(0L)
- .addContent(
- ImageFileContentBlock.builder()
- .imageFile(
- ImageFile.builder()
- .fileId("file_id")
- .detail(ImageFile.Detail.AUTO)
- .build()
- )
- .build()
+ .addImageFileContent(
+ ImageFile.builder().fileId("file_id").detail(ImageFile.Detail.AUTO).build()
)
.createdAt(0L)
.incompleteAt(0L)
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 55b6ad1..0ec490b 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
@@ -28,13 +28,9 @@ class RunStepTest {
.metadata(JsonValue.from(mapOf()))
.runId("run_id")
.status(RunStep.Status.IN_PROGRESS)
- .stepDetails(
- MessageCreationStepDetails.builder()
- .messageCreation(
- MessageCreationStepDetails.MessageCreation.builder()
- .messageId("message_id")
- .build()
- )
+ .messageCreationStepDetails(
+ MessageCreationStepDetails.MessageCreation.builder()
+ .messageId("message_id")
.build()
)
.threadId("thread_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 b6ad68f..0a87876 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
@@ -17,12 +17,7 @@ class ToolCallsStepDetailsTest {
.codeInterpreter(
CodeInterpreterToolCall.CodeInterpreter.builder()
.input("input")
- .addOutput(
- CodeInterpreterToolCall.CodeInterpreter.Output.LogsOutput
- .builder()
- .logs("logs")
- .build()
- )
+ .addLogsOutput("logs")
.build()
)
.build()
@@ -37,12 +32,7 @@ class ToolCallsStepDetailsTest {
.codeInterpreter(
CodeInterpreterToolCall.CodeInterpreter.builder()
.input("input")
- .addOutput(
- CodeInterpreterToolCall.CodeInterpreter.Output.LogsOutput
- .builder()
- .logs("logs")
- .build()
- )
+ .addLogsOutput("logs")
.build()
)
.build()
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 2d9ba6d..0a7b6fb 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
@@ -22,14 +22,10 @@ class VectorStoreFileTest {
.status(VectorStoreFile.Status.IN_PROGRESS)
.usageBytes(0L)
.vectorStoreId("vector_store_id")
- .chunkingStrategy(
- StaticFileChunkingStrategyObject.builder()
- .static_(
- StaticFileChunkingStrategy.builder()
- .chunkOverlapTokens(0L)
- .maxChunkSizeTokens(100L)
- .build()
- )
+ .staticChunkingStrategy(
+ StaticFileChunkingStrategy.builder()
+ .chunkOverlapTokens(0L)
+ .maxChunkSizeTokens(100L)
.build()
)
.build()
diff --git a/openai-java-example/src/main/java/com/openai/example/AzureEntraIdExample.java b/openai-java-example/src/main/java/com/openai/example/AzureEntraIdExample.java
index ccae081..a964e1e 100644
--- a/openai-java-example/src/main/java/com/openai/example/AzureEntraIdExample.java
+++ b/openai-java-example/src/main/java/com/openai/example/AzureEntraIdExample.java
@@ -6,8 +6,6 @@
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.credential.BearerTokenCredential;
import com.openai.models.ChatCompletionCreateParams;
-import com.openai.models.ChatCompletionDeveloperMessageParam;
-import com.openai.models.ChatCompletionUserMessageParam;
import com.openai.models.ChatModel;
public final class AzureEntraIdExample {
@@ -25,12 +23,8 @@ public static void main(String[] args) {
ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
.model(ChatModel.GPT_3_5_TURBO)
.maxCompletionTokens(2048)
- .addMessage(ChatCompletionDeveloperMessageParam.builder()
- .content("Make sure you mention Stainless!")
- .build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Tell me a story about building the best SDK!")
- .build())
+ .addDeveloperMessage("Make sure you mention Stainless!")
+ .addUserMessage("Tell me a story about building the best SDK!")
.build();
client.chat().completions().create(createParams).choices().stream()
diff --git a/openai-java-example/src/main/java/com/openai/example/CompletionsAsyncExample.java b/openai-java-example/src/main/java/com/openai/example/CompletionsAsyncExample.java
index 3913ae9..586f9f3 100644
--- a/openai-java-example/src/main/java/com/openai/example/CompletionsAsyncExample.java
+++ b/openai-java-example/src/main/java/com/openai/example/CompletionsAsyncExample.java
@@ -16,12 +16,8 @@ public static void main(String[] args) {
ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
.model(ChatModel.GPT_3_5_TURBO)
.maxCompletionTokens(2048)
- .addMessage(ChatCompletionDeveloperMessageParam.builder()
- .content("Make sure you mention Stainless!")
- .build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Tell me a story about building the best SDK!")
- .build())
+ .addDeveloperMessage("Make sure you mention Stainless!")
+ .addUserMessage("Tell me a story about building the best SDK!")
.build();
client.chat()
diff --git a/openai-java-example/src/main/java/com/openai/example/CompletionsConversationAsyncExample.java b/openai-java-example/src/main/java/com/openai/example/CompletionsConversationAsyncExample.java
index 2512ca4..47acea2 100644
--- a/openai-java-example/src/main/java/com/openai/example/CompletionsConversationAsyncExample.java
+++ b/openai-java-example/src/main/java/com/openai/example/CompletionsConversationAsyncExample.java
@@ -22,12 +22,8 @@ public static void main(String[] args) {
ChatCompletionCreateParams.Builder createParamsBuilder = ChatCompletionCreateParams.builder()
.model(ChatModel.GPT_3_5_TURBO)
.maxCompletionTokens(2048)
- .addMessage(ChatCompletionDeveloperMessageParam.builder()
- .content("Make sure you mention Stainless!")
- .build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Tell me a story about building the best SDK!")
- .build());
+ .addDeveloperMessage("Make sure you mention Stainless!")
+ .addUserMessage("Tell me a story about building the best SDK!");
CompletableFuture future = CompletableFuture.completedFuture(null);
for (int i = 0; i < 4; i++) {
@@ -47,12 +43,8 @@ public static void main(String[] args) {
messages.forEach(createParamsBuilder::addMessage);
createParamsBuilder
- .addMessage(ChatCompletionDeveloperMessageParam.builder()
- .content("Be as snarky as possible when replying!" + "!".repeat(index))
- .build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("But why?" + "?".repeat(index))
- .build());
+ .addDeveloperMessage("Be as snarky as possible when replying!" + "!".repeat(index))
+ .addUserMessage("But why?" + "?".repeat(index));
});
}
diff --git a/openai-java-example/src/main/java/com/openai/example/CompletionsConversationExample.java b/openai-java-example/src/main/java/com/openai/example/CompletionsConversationExample.java
index c337d9c..46564cf 100644
--- a/openai-java-example/src/main/java/com/openai/example/CompletionsConversationExample.java
+++ b/openai-java-example/src/main/java/com/openai/example/CompletionsConversationExample.java
@@ -21,12 +21,8 @@ public static void main(String[] args) {
ChatCompletionCreateParams.Builder createParamsBuilder = ChatCompletionCreateParams.builder()
.model(ChatModel.GPT_3_5_TURBO)
.maxCompletionTokens(2048)
- .addMessage(ChatCompletionDeveloperMessageParam.builder()
- .content("Make sure you mention Stainless!")
- .build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Tell me a story about building the best SDK!")
- .build());
+ .addDeveloperMessage("Make sure you mention Stainless!")
+ .addUserMessage("Tell me a story about building the best SDK!");
for (int i = 0; i < 4; i++) {
List messages =
@@ -40,12 +36,8 @@ public static void main(String[] args) {
messages.forEach(createParamsBuilder::addMessage);
createParamsBuilder
- .addMessage(ChatCompletionDeveloperMessageParam.builder()
- .content("Be as snarky as possible when replying!" + "!".repeat(i))
- .build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("But why?" + "?".repeat(i))
- .build());
+ .addDeveloperMessage("Be as snarky as possible when replying!" + "!".repeat(i))
+ .addUserMessage("But why?" + "?".repeat(i));
}
}
}
diff --git a/openai-java-example/src/main/java/com/openai/example/CompletionsExample.java b/openai-java-example/src/main/java/com/openai/example/CompletionsExample.java
index c6bdd27..9ffcd16 100644
--- a/openai-java-example/src/main/java/com/openai/example/CompletionsExample.java
+++ b/openai-java-example/src/main/java/com/openai/example/CompletionsExample.java
@@ -3,8 +3,6 @@
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.ChatCompletionCreateParams;
-import com.openai.models.ChatCompletionDeveloperMessageParam;
-import com.openai.models.ChatCompletionUserMessageParam;
import com.openai.models.ChatModel;
public final class CompletionsExample {
@@ -19,12 +17,8 @@ public static void main(String[] args) {
ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
.model(ChatModel.GPT_3_5_TURBO)
.maxCompletionTokens(2048)
- .addMessage(ChatCompletionDeveloperMessageParam.builder()
- .content("Make sure you mention Stainless!")
- .build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Tell me a story about building the best SDK!")
- .build())
+ .addDeveloperMessage("Make sure you mention Stainless!")
+ .addUserMessage("Tell me a story about building the best SDK!")
.build();
client.chat().completions().create(createParams).choices().stream()
diff --git a/openai-java-example/src/main/java/com/openai/example/CompletionsStreamingAsyncExample.java b/openai-java-example/src/main/java/com/openai/example/CompletionsStreamingAsyncExample.java
index c426350..408c3a9 100644
--- a/openai-java-example/src/main/java/com/openai/example/CompletionsStreamingAsyncExample.java
+++ b/openai-java-example/src/main/java/com/openai/example/CompletionsStreamingAsyncExample.java
@@ -19,12 +19,8 @@ public static void main(String[] args) throws Exception {
ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
.model(ChatModel.GPT_3_5_TURBO)
.maxCompletionTokens(2048)
- .addMessage(ChatCompletionDeveloperMessageParam.builder()
- .content("Make sure you mention Stainless!")
- .build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Tell me a story about building the best SDK!")
- .build())
+ .addDeveloperMessage("Make sure you mention Stainless!")
+ .addUserMessage("Tell me a story about building the best SDK!")
.build();
CompletableFuture onCompleteFuture = new CompletableFuture<>();
diff --git a/openai-java-example/src/main/java/com/openai/example/CompletionsStreamingExample.java b/openai-java-example/src/main/java/com/openai/example/CompletionsStreamingExample.java
index bd54654..e44c471 100644
--- a/openai-java-example/src/main/java/com/openai/example/CompletionsStreamingExample.java
+++ b/openai-java-example/src/main/java/com/openai/example/CompletionsStreamingExample.java
@@ -17,12 +17,8 @@ public static void main(String[] args) throws Exception {
ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
.model(ChatModel.GPT_3_5_TURBO)
.maxCompletionTokens(2048)
- .addMessage(ChatCompletionDeveloperMessageParam.builder()
- .content("Make sure you mention Stainless!")
- .build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Tell me a story about building the best SDK!")
- .build())
+ .addDeveloperMessage("Make sure you mention Stainless!")
+ .addUserMessage("Tell me a story about building the best SDK!")
.build();
try (StreamResponse streamResponse =
diff --git a/openai-java-example/src/main/java/com/openai/example/StructuredOutputsAsyncExample.java b/openai-java-example/src/main/java/com/openai/example/StructuredOutputsAsyncExample.java
index 37ba2dd..88e553e 100644
--- a/openai-java-example/src/main/java/com/openai/example/StructuredOutputsAsyncExample.java
+++ b/openai-java-example/src/main/java/com/openai/example/StructuredOutputsAsyncExample.java
@@ -4,7 +4,6 @@
import com.openai.client.okhttp.OpenAIOkHttpClientAsync;
import com.openai.core.JsonValue;
import com.openai.models.ChatCompletionCreateParams;
-import com.openai.models.ChatCompletionUserMessageParam;
import com.openai.models.ChatModel;
import com.openai.models.ResponseFormatJsonSchema;
import com.openai.models.ResponseFormatJsonSchema.JsonSchema;
@@ -34,9 +33,7 @@ public static void main(String[] args) {
.schema(schema)
.build())
.build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Who works at OpenAI?")
- .build())
+ .addUserMessage("Who works at OpenAI?")
.build();
client.chat()
diff --git a/openai-java-example/src/main/java/com/openai/example/StructuredOutputsExample.java b/openai-java-example/src/main/java/com/openai/example/StructuredOutputsExample.java
index e3faf84..cdbf430 100644
--- a/openai-java-example/src/main/java/com/openai/example/StructuredOutputsExample.java
+++ b/openai-java-example/src/main/java/com/openai/example/StructuredOutputsExample.java
@@ -31,9 +31,7 @@ public static void main(String[] args) {
.schema(schema)
.build())
.build())
- .addMessage(ChatCompletionUserMessageParam.builder()
- .content("Who works at OpenAI?")
- .build())
+ .addUserMessage("Who works at OpenAI?")
.build();
client.chat().completions().create(createParams).choices().stream()