@@ -78,6 +78,14 @@ internal class StructuredResponseCreateParamsTest {
78
78
.environment(ComputerTool .Environment .LINUX )
79
79
.build()
80
80
private val TOOL = Tool .ofFunction(FUNCTION_TOOL )
81
+ private val MCP_TOOL = Tool .Mcp .builder().serverLabel(STRING ).serverUrl(STRING ).build()
82
+ private val CODE_INTERPRETER_TOOL_AUTO =
83
+ Tool .CodeInterpreter .Container .CodeInterpreterToolAuto .builder().build()
84
+ private val CODE_INTERPRETER_CONTAINER =
85
+ Tool .CodeInterpreter .Container .ofCodeInterpreterToolAuto(CODE_INTERPRETER_TOOL_AUTO )
86
+ private val CODE_INTERPRETER_TOOL =
87
+ Tool .CodeInterpreter .builder().container(CODE_INTERPRETER_CONTAINER ).build()
88
+ private val IMAGE_GENERATION_TOOL = Tool .ImageGeneration .builder().build()
81
89
82
90
private val HEADERS = Headers .builder().build()
83
91
private val QUERY_PARAMS = QueryParams .builder().build()
@@ -99,6 +107,10 @@ internal class StructuredResponseCreateParamsTest {
99
107
DelegationWriteTestCase (" model" , STRING ),
100
108
DelegationWriteTestCase (" model" , CHAT_MODEL ),
101
109
DelegationWriteTestCase (" model" , RESPONSES_ONLY_MODEL ),
110
+ DelegationWriteTestCase (" background" , NULLABLE_BOOLEAN ),
111
+ DelegationWriteTestCase (" background" , BOOLEAN ),
112
+ DelegationWriteTestCase (" background" , OPTIONAL ),
113
+ DelegationWriteTestCase (" background" , JSON_FIELD ),
102
114
DelegationWriteTestCase (" include" , LIST ),
103
115
DelegationWriteTestCase (" include" , OPTIONAL ),
104
116
DelegationWriteTestCase (" include" , JSON_FIELD ),
@@ -143,12 +155,19 @@ internal class StructuredResponseCreateParamsTest {
143
155
DelegationWriteTestCase (" tools" , LIST ),
144
156
DelegationWriteTestCase (" tools" , JSON_FIELD ),
145
157
DelegationWriteTestCase (" addTool" , TOOL ),
158
+ DelegationWriteTestCase (" addTool" , FUNCTION_TOOL ),
159
+ DelegationWriteTestCase (" addTool" , CLASS , VALIDATION ),
146
160
DelegationWriteTestCase (" addTool" , FILE_SEARCH_TOOL ),
147
161
DelegationWriteTestCase (" addFileSearchTool" , LIST ),
148
- DelegationWriteTestCase (" addTool" , FUNCTION_TOOL ),
149
162
DelegationWriteTestCase (" addTool" , WEB_SEARCH_TOOL ),
150
163
DelegationWriteTestCase (" addTool" , COMPUTER_TOOL ),
151
- DelegationWriteTestCase (" addTool" , CLASS , VALIDATION ),
164
+ DelegationWriteTestCase (" addTool" , MCP_TOOL ),
165
+ DelegationWriteTestCase (" addTool" , CODE_INTERPRETER_TOOL ),
166
+ DelegationWriteTestCase (" addCodeInterpreterTool" , CODE_INTERPRETER_CONTAINER ),
167
+ DelegationWriteTestCase (" addCodeInterpreterTool" , STRING ),
168
+ DelegationWriteTestCase (" addCodeInterpreterTool" , CODE_INTERPRETER_TOOL_AUTO ),
169
+ DelegationWriteTestCase (" addTool" , IMAGE_GENERATION_TOOL ),
170
+ DelegationWriteTestCase (" addToolLocalShell" ),
152
171
DelegationWriteTestCase (" topP" , NULLABLE_DOUBLE ),
153
172
DelegationWriteTestCase (" topP" , DOUBLE ),
154
173
DelegationWriteTestCase (" topP" , OPTIONAL ),
@@ -199,20 +218,30 @@ internal class StructuredResponseCreateParamsTest {
199
218
200
219
@Test
201
220
fun allBuilderDelegateFunctionsExistInDelegator () {
202
- // The delegator class does not implement various functions from the delegate class:
203
- // - text functions and body function
204
- // - addCodeInterpreterTool methods
205
- // - various tool-related methods (addTool variations, addToolLocalShell)
206
- // - background-related methods
207
221
checkAllDelegation(
208
222
mockBuilderDelegate::class ,
209
223
builderDelegator::class ,
224
+ // ************************************************************************************
225
+ // NOTE: THIS TEST EXISTS TO ENSURE THAT WHEN NEW FUNCTIONS ARE ADDED MANUALLY OR VIA
226
+ // CODE GEN TO `ResponseCreateParams.Builder`, THAT THOSE FUNCTIONS ARE _ALSO_ ADDED
227
+ // _MANUALLY_ TO `StructuredResponseCreateParams.Builder`. FAILURE TO ADD THOSE
228
+ // FUNCTIONS RESULTS IN _MISSING_ FUNCTIONALITY WHEN USING STRUCTURED OUTPUTS.
229
+ // EXCEPTIONS ADDED TO THIS LIST ARE PRESENT BY DESIGN, NOT BECAUSE THE FUNCTIONS ARE
230
+ // SIMPLY NOT YET IMPLEMENTED IN THE DELEGATOR CLASS.
231
+ //
232
+ // DO NOT ADD EXCEPTIONS TO THIS LIST SIMPLY BECAUSE TESTS ARE FAILING. THE TESTS ARE
233
+ // SUPPOSED TO FAIL. ADD THE NEW FUNCTIONS TO `StructuredResponseCreateParams.Builder`
234
+ // AND ADD A PARAMETERIZED TEST TO `builderDelegationTestCases` (above) TO ENSURE
235
+ // CORRECT DELEGATION BEHAVIOR.
236
+ // ************************************************************************************
237
+
238
+ // For Structured Outputs, setting `body` would overwrite the previously set `text`
239
+ // property, which would break the Structured Outputs behavior.
210
240
" body" ,
241
+ // For Structured Outputs, a new type-safe generic`text` function replaces all existing
242
+ // text functions, as they are mutually incompatible. This function has its own
243
+ // dedicated unit tests.
211
244
" text" ,
212
- " addCodeInterpreterTool" ,
213
- " addTool" ,
214
- " addToolLocalShell" ,
215
- " background" ,
216
245
)
217
246
}
218
247
0 commit comments