Skip to content

Commit 1fec8d9

Browse files
apcha-oaistainless-app[bot]
authored andcommitted
fix delegation test
1 parent 49f0547 commit 1fec8d9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

openai-java-core/src/main/kotlin/com/openai/models/chat/completions/StructuredChatCompletionCreateParams.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.openai.core.http.QueryParams
99
import com.openai.core.responseFormatFromClass
1010
import com.openai.models.ChatModel
1111
import com.openai.models.ReasoningEffort
12+
import com.openai.models.ResponseFormatJsonSchema
1213
import java.util.Objects
1314
import java.util.Optional
1415

@@ -442,6 +443,11 @@ internal constructor(
442443
paramsBuilder.safetyIdentifier(safetyIdentifier)
443444
}
444445

446+
/** @see ChatCompletionCreateParams.Builder.jsonSchemaResponseFormat */
447+
fun jsonSchemaResponseFormat(jsonSchema: ResponseFormatJsonSchema.JsonSchema) = apply {
448+
paramsBuilder.jsonSchemaResponseFormat(jsonSchema)
449+
}
450+
445451
/**
446452
* Sets the response format to a JSON schema derived from the structure of the given class.
447453
*

openai-java-core/src/test/kotlin/com/openai/models/chat/completions/StructuredChatCompletionCreateParamsTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.openai.core.http.QueryParams
2727
import com.openai.core.responseFormatFromClass
2828
import com.openai.models.ChatModel
2929
import com.openai.models.FunctionDefinition
30+
import com.openai.models.ResponseFormatJsonSchema
3031
import org.junit.jupiter.api.Test
3132
import org.junit.jupiter.params.ParameterizedTest
3233
import org.junit.jupiter.params.provider.MethodSource
@@ -118,6 +119,8 @@ internal class StructuredChatCompletionCreateParamsTest {
118119
ChatCompletionCustomTool.Custom.builder().name(STRING).build()
119120
private val FUNCTION_TOOL =
120121
ChatCompletionFunctionTool.builder().function(FUNCTION_DEFINITION).build()
122+
private val RESPONSE_FORMAT_JSON_SCHEMA =
123+
ResponseFormatJsonSchema.JsonSchema.builder().name("json_schema").build()
121124
private val ALLOWED_TOOL_CHOICE =
122125
ChatCompletionAllowedToolChoice.builder()
123126
.allowedTools(
@@ -224,6 +227,7 @@ internal class StructuredChatCompletionCreateParamsTest {
224227
DelegationWriteTestCase("reasoningEffort", NULLABLE),
225228
DelegationWriteTestCase("reasoningEffort", OPTIONAL),
226229
DelegationWriteTestCase("reasoningEffort", JSON_FIELD),
230+
DelegationWriteTestCase("jsonSchemaResponseFormat", RESPONSE_FORMAT_JSON_SCHEMA),
227231
// `responseFormat()` is a special case and has its own unit test.
228232
DelegationWriteTestCase("safetyIdentifier", STRING),
229233
DelegationWriteTestCase("safetyIdentifier", JSON_FIELD),

0 commit comments

Comments
 (0)