@@ -230,3 +230,104 @@ def test_ollama_skip_tls_verify() -> None:
230
230
)
231
231
232
232
assert model ._client ._client ._transport ._pool ._ssl_context .verify_mode == CERT_NONE # type: ignore
233
+
234
+
235
+ def test_opus_4_1_temperature_top_p () -> None :
236
+ """Test the temperature and top_p."""
237
+ raw_config : dict = {
238
+ "modelProvider" : "anthropic" ,
239
+ "model" : "claude-opus-4-1" ,
240
+ }
241
+
242
+ # test opus 4.1
243
+ simple_1 = raw_config .copy ()
244
+ llm_config = LLMConfig .model_validate (simple_1 )
245
+
246
+ # with temperature and top_p
247
+ simple_2 = raw_config .copy ()
248
+ simple_2 ["configuration" ] = {"temperature" : 0.5 , "top_p" : 0.5 }
249
+ llm_config = LLMConfig .model_validate (simple_2 )
250
+ # should be subset of llm_config.to_load_model_kwargs()
251
+ kwargs = llm_config .to_load_model_kwargs ()
252
+ assert "top_p" not in kwargs
253
+ assert "temperature" in kwargs
254
+ assert kwargs ["temperature" ] == 0.5
255
+
256
+ # test only temperature
257
+ simple_3 = raw_config .copy ()
258
+ simple_3 ["configuration" ] = {"temperature" : 0.5 }
259
+ llm_config = LLMConfig .model_validate (simple_3 )
260
+ kwargs = llm_config .to_load_model_kwargs ()
261
+ assert "top_p" not in kwargs
262
+ assert "temperature" in kwargs
263
+ assert kwargs ["temperature" ] == 0.5
264
+
265
+ # test only top_p
266
+ simple_4 = raw_config .copy ()
267
+ simple_4 ["configuration" ] = {"top_p" : 0.5 }
268
+ llm_config = LLMConfig .model_validate (simple_4 )
269
+ kwargs = llm_config .to_load_model_kwargs ()
270
+ assert "top_p" in kwargs
271
+ assert "temperature" not in kwargs
272
+ assert kwargs ["top_p" ] == 0.5
273
+
274
+ # oap provider
275
+ simple_5 = simple_2 .copy ()
276
+ simple_5 ["modelProvider" ] = "oap"
277
+ llm_config = LLMConfig .model_validate (simple_5 )
278
+ kwargs = llm_config .to_load_model_kwargs ()
279
+ assert "top_p" not in kwargs
280
+ assert "temperature" in kwargs
281
+ assert kwargs ["temperature" ] == 0.5
282
+
283
+ # test general llm config
284
+ simple_6 = simple_2 .copy ()
285
+ simple_6 ["model" ] = "gpt-4o"
286
+ llm_config = LLMConfig .model_validate (simple_6 )
287
+ kwargs = llm_config .to_load_model_kwargs ()
288
+ assert "top_p" in kwargs
289
+ assert "temperature" in kwargs
290
+ assert kwargs ["temperature" ] == 0.5
291
+ assert kwargs ["top_p" ] == 0.5
292
+
293
+
294
+ def test_gpt_5_temperature () -> None :
295
+ """Test the GPT-5 temperature."""
296
+ raw_config : dict = {
297
+ "modelProvider" : "openai" ,
298
+ "model" : "gpt-5" ,
299
+ }
300
+
301
+ simple_1 = raw_config .copy ()
302
+ llm_config = LLMConfig .model_validate (simple_1 )
303
+ kwargs = llm_config .to_load_model_kwargs ()
304
+ assert "temperature" not in kwargs
305
+
306
+ simple_2 = raw_config .copy ()
307
+ simple_2 ["configuration" ] = {"temperature" : 0.5 }
308
+ llm_config = LLMConfig .model_validate (simple_2 )
309
+ kwargs = llm_config .to_load_model_kwargs ()
310
+ assert "temperature" in kwargs
311
+ assert kwargs ["temperature" ] == 1
312
+
313
+ simple_3 = raw_config .copy ()
314
+ simple_3 ["configuration" ] = {"temperature" : 0 }
315
+ llm_config = LLMConfig .model_validate (simple_3 )
316
+ kwargs = llm_config .to_load_model_kwargs ()
317
+ assert "temperature" not in kwargs
318
+
319
+ # test oap provider
320
+ simple_4 = simple_2 .copy ()
321
+ simple_4 ["modelProvider" ] = "oap"
322
+ llm_config = LLMConfig .model_validate (simple_4 )
323
+ kwargs = llm_config .to_load_model_kwargs ()
324
+ assert "temperature" in kwargs
325
+ assert kwargs ["temperature" ] == 1
326
+
327
+ # test general llm config
328
+ simple_5 = simple_2 .copy ()
329
+ simple_5 ["model" ] = "gpt-4o"
330
+ llm_config = LLMConfig .model_validate (simple_5 )
331
+ kwargs = llm_config .to_load_model_kwargs ()
332
+ assert "temperature" in kwargs
333
+ assert kwargs ["temperature" ] == 0.5
0 commit comments