Skip to content

Commit cb5c638

Browse files
committed
chore(client): sync structured outputs features
1 parent 5698e53 commit cb5c638

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ class StructuredResponse<T : Any>(
6767
/** @see Response.topP */
6868
fun topP(): Optional<Double> = rawResponse.topP()
6969

70+
/** @see Response.maxToolCalls */
71+
fun maxToolCalls(): Optional<Long> = rawResponse.maxToolCalls()
72+
73+
/** @see Response.topLogprobs */
74+
fun topLogprobs(): Optional<Long> = rawResponse.topLogprobs()
75+
7076
/** @see Response.maxOutputTokens */
7177
fun maxOutputTokens(): Optional<Long> = rawResponse.maxOutputTokens()
7278

@@ -140,6 +146,12 @@ class StructuredResponse<T : Any>(
140146
/** @see Response._topP */
141147
fun _topP(): JsonField<Double> = rawResponse._topP()
142148

149+
/** @see Response._maxToolCalls */
150+
fun _maxToolCalls(): JsonField<Long> = rawResponse._maxToolCalls()
151+
152+
/** @see Response._topLogprobs */
153+
fun _topLogprobs(): JsonField<Long> = rawResponse._topLogprobs()
154+
143155
/** @see Response._maxOutputTokens */
144156
fun _maxOutputTokens(): JsonField<Long> = rawResponse._maxOutputTokens()
145157

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,22 @@ class StructuredResponseCreateParams<T : Any>(
155155
paramsBuilder.maxOutputTokens(maxOutputTokens)
156156
}
157157

158+
/** @see ResponseCreateParams.Builder.maxToolCalls */
159+
fun maxToolCalls(maxToolCalls: Long?) = apply { paramsBuilder.maxToolCalls(maxToolCalls) }
160+
161+
/** @see ResponseCreateParams.Builder.maxToolCalls */
162+
fun maxToolCalls(maxToolCalls: Long) = apply { paramsBuilder.maxToolCalls(maxToolCalls) }
163+
164+
/** @see ResponseCreateParams.Builder.maxToolCalls */
165+
fun maxToolCalls(maxToolCalls: Optional<Long>) = apply {
166+
paramsBuilder.maxToolCalls(maxToolCalls)
167+
}
168+
169+
/** @see ResponseCreateParams.Builder.maxToolCalls */
170+
fun maxToolCalls(maxToolCalls: JsonField<Long>) = apply {
171+
paramsBuilder.maxToolCalls(maxToolCalls)
172+
}
173+
158174
/** @see ResponseCreateParams.Builder.metadata */
159175
fun metadata(metadata: ResponseCreateParams.Metadata?) = apply {
160176
paramsBuilder.metadata(metadata)
@@ -302,6 +318,9 @@ class StructuredResponseCreateParams<T : Any>(
302318
/** @see ResponseCreateParams.Builder.toolChoice */
303319
fun toolChoice(function: ToolChoiceFunction) = apply { paramsBuilder.toolChoice(function) }
304320

321+
/** @see ResponseCreateParams.Builder.toolChoice */
322+
fun toolChoice(mcp: ToolChoiceMcp) = apply { paramsBuilder.toolChoice(mcp) }
323+
305324
/** @see ResponseCreateParams.Builder.tools */
306325
fun tools(tools: List<Tool>) = apply { paramsBuilder.tools(tools) }
307326

@@ -380,6 +399,22 @@ class StructuredResponseCreateParams<T : Any>(
380399
/** @see ResponseCreateParams.Builder.topP */
381400
fun topP(topP: JsonField<Double>) = apply { paramsBuilder.topP(topP) }
382401

402+
/** @see ResponseCreateParams.Builder.topLogprobs */
403+
fun topLogprobs(topLogprobs: Long?) = apply { paramsBuilder.topLogprobs(topLogprobs) }
404+
405+
/** @see ResponseCreateParams.Builder.topLogprobs */
406+
fun topLogprobs(topLogprobs: Long) = apply { paramsBuilder.topLogprobs(topLogprobs) }
407+
408+
/** @see ResponseCreateParams.Builder.topLogprobs */
409+
fun topLogprobs(topLogprobs: Optional<Long>) = apply {
410+
paramsBuilder.topLogprobs(topLogprobs)
411+
}
412+
413+
/** @see ResponseCreateParams.Builder.topLogprobs */
414+
fun topLogprobs(topLogprobs: JsonField<Long>) = apply {
415+
paramsBuilder.topLogprobs(topLogprobs)
416+
}
417+
383418
/** @see ResponseCreateParams.Builder.truncation */
384419
fun truncation(truncation: ResponseCreateParams.Truncation?) = apply {
385420
paramsBuilder.truncation(truncation)

openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseCreateParamsTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ internal class StructuredResponseCreateParamsTest {
6666
private val TOOL_CHOICE = ResponseCreateParams.ToolChoice.ofTypes(TOOL_CHOICE_TYPES)
6767
private val TOOL_CHOICE_OPTIONS = ToolChoiceOptions.AUTO
6868
private val TOOL_CHOICE_FUNCTION = ToolChoiceFunction.builder().name(STRING).build()
69+
private val TOOL_CHOICE_MCP =
70+
ToolChoiceMcp.builder().name(STRING).serverLabel(STRING).build()
6971

7072
private val FUNCTION_TOOL =
7173
FunctionTool.builder().name(STRING).parameters(NULLABLE).strict(BOOLEAN).build()
@@ -123,6 +125,10 @@ internal class StructuredResponseCreateParamsTest {
123125
DelegationWriteTestCase("maxOutputTokens", LONG),
124126
DelegationWriteTestCase("maxOutputTokens", OPTIONAL),
125127
DelegationWriteTestCase("maxOutputTokens", JSON_FIELD),
128+
DelegationWriteTestCase("maxToolCalls", NULLABLE_LONG),
129+
DelegationWriteTestCase("maxToolCalls", LONG),
130+
DelegationWriteTestCase("maxToolCalls", OPTIONAL),
131+
DelegationWriteTestCase("maxToolCalls", JSON_FIELD),
126132
DelegationWriteTestCase("metadata", METADATA),
127133
DelegationWriteTestCase("metadata", OPTIONAL),
128134
DelegationWriteTestCase("metadata", JSON_FIELD),
@@ -156,6 +162,7 @@ internal class StructuredResponseCreateParamsTest {
156162
DelegationWriteTestCase("toolChoice", TOOL_CHOICE_OPTIONS),
157163
DelegationWriteTestCase("toolChoice", TOOL_CHOICE_TYPES),
158164
DelegationWriteTestCase("toolChoice", TOOL_CHOICE_FUNCTION),
165+
DelegationWriteTestCase("toolChoice", TOOL_CHOICE_MCP),
159166
DelegationWriteTestCase("tools", LIST),
160167
DelegationWriteTestCase("tools", JSON_FIELD),
161168
DelegationWriteTestCase("addTool", TOOL),
@@ -176,6 +183,10 @@ internal class StructuredResponseCreateParamsTest {
176183
DelegationWriteTestCase("topP", DOUBLE),
177184
DelegationWriteTestCase("topP", OPTIONAL),
178185
DelegationWriteTestCase("topP", JSON_FIELD),
186+
DelegationWriteTestCase("topLogprobs", NULLABLE_LONG),
187+
DelegationWriteTestCase("topLogprobs", LONG),
188+
DelegationWriteTestCase("topLogprobs", OPTIONAL),
189+
DelegationWriteTestCase("topLogprobs", JSON_FIELD),
179190
DelegationWriteTestCase("truncation", NULLABLE),
180191
DelegationWriteTestCase("truncation", OPTIONAL),
181192
DelegationWriteTestCase("truncation", JSON_FIELD),

openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseOutputItemTest.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ internal class StructuredResponseOutputItemTest {
4444
ResponseFunctionWebSearch.builder()
4545
.id(STRING)
4646
.status(ResponseFunctionWebSearch.Status.COMPLETED)
47+
.action(
48+
ResponseFunctionWebSearch.Action.ofSearch(
49+
ResponseFunctionWebSearch.Action.Search.builder()
50+
.query("query")
51+
.addDomain("string")
52+
.build()
53+
)
54+
)
4755
.build()
4856
private val COMPUTER_TOOL_CALL =
4957
ResponseComputerToolCall.builder()

openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ internal class StructuredResponseTest {
6969
DelegationReadTestCase("toolChoice", TOOL_CHOICE),
7070
DelegationReadTestCase("tools", LIST),
7171
DelegationReadTestCase("topP", OPTIONAL),
72+
DelegationReadTestCase("maxToolCalls", OPTIONAL),
73+
DelegationReadTestCase("topLogprobs", OPTIONAL),
7274
DelegationReadTestCase("maxOutputTokens", OPTIONAL),
7375
DelegationReadTestCase("previousResponseId", OPTIONAL),
7476
DelegationReadTestCase("prompt", OPTIONAL),
@@ -92,6 +94,8 @@ internal class StructuredResponseTest {
9294
DelegationReadTestCase("_toolChoice", JSON_FIELD),
9395
DelegationReadTestCase("_tools", JSON_FIELD),
9496
DelegationReadTestCase("_topP", JSON_FIELD),
97+
DelegationReadTestCase("_maxToolCalls", JSON_FIELD),
98+
DelegationReadTestCase("_topLogprobs", JSON_FIELD),
9599
DelegationReadTestCase("_maxOutputTokens", JSON_FIELD),
96100
DelegationReadTestCase("_previousResponseId", JSON_FIELD),
97101
DelegationReadTestCase("_prompt", JSON_FIELD),

0 commit comments

Comments
 (0)