@@ -14,7 +14,7 @@ def test_get_optional_params(self):
14
14
supported_params = config .get_supported_openai_params (model = "doubao-seed-1.6" )
15
15
assert "thinking" in supported_params
16
16
17
- # Test thinking disabled - should NOT appear in extra_body
17
+ # Test thinking disabled - should appear in extra_body
18
18
mapped_params = config .map_openai_params (
19
19
non_default_params = {
20
20
"thinking" : {"type" : "disabled" },
@@ -24,8 +24,10 @@ def test_get_optional_params(self):
24
24
drop_params = False ,
25
25
)
26
26
27
- # Fixed: thinking disabled should be omitted from extra_body
28
- assert mapped_params == {}
27
+ # Fixed: thinking disabled should appear in extra_body
28
+ assert mapped_params == {
29
+ "extra_body" : {"thinking" : {"type" : "disabled" }}
30
+ }
29
31
30
32
e2e_mapped_params = get_optional_params (
31
33
model = "doubao-seed-1.6" ,
@@ -43,7 +45,7 @@ def test_get_optional_params(self):
43
45
def test_thinking_parameter_handling (self ):
44
46
"""Test comprehensive thinking parameter handling scenarios"""
45
47
config = VolcEngineConfig ()
46
-
48
+
47
49
# Test 1: thinking enabled - should appear in extra_body
48
50
result_enabled = config .map_openai_params (
49
51
non_default_params = {"thinking" : {"type" : "enabled" }},
@@ -54,38 +56,36 @@ def test_thinking_parameter_handling(self):
54
56
assert result_enabled == {
55
57
"extra_body" : {"thinking" : {"type" : "enabled" }}
56
58
}
57
-
58
- # Test 2: thinking None - should appear in extra_body as None
59
+
60
+ # Test 2: thinking None - should NOT appear in extra_body
59
61
result_none = config .map_openai_params (
60
62
non_default_params = {"thinking" : None },
61
63
optional_params = {},
62
- model = "doubao-seed-1.6" ,
64
+ model = "doubao-seed-1.6" ,
63
65
drop_params = False ,
64
66
)
65
- assert result_none == {
66
- "extra_body" : {"thinking" : None }
67
- }
68
-
69
- # Test 3: thinking with custom value - should appear in extra_body
67
+ assert result_none == {}
68
+
69
+ # Test 3: thinking with custom value - should NOT appear in extra_body (invalid value)
70
70
result_custom = config .map_openai_params (
71
71
non_default_params = {"thinking" : "custom_mode" },
72
72
optional_params = {},
73
73
model = "doubao-seed-1.6" ,
74
74
drop_params = False ,
75
75
)
76
- assert result_custom == {
77
- "extra_body" : {"thinking" : "custom_mode" }
78
- }
79
-
80
- # Test 4: thinking disabled - should NOT appear in extra_body
76
+ assert result_custom == {}
77
+
78
+ # Test 4: thinking disabled - should appear in extra_body with original structure
81
79
result_disabled = config .map_openai_params (
82
80
non_default_params = {"thinking" : {"type" : "disabled" }},
83
81
optional_params = {},
84
82
model = "doubao-seed-1.6" ,
85
83
drop_params = False ,
86
84
)
87
- assert result_disabled == {}
88
-
85
+ assert result_disabled == {
86
+ "extra_body" : {"thinking" : {"type" : "disabled" }}
87
+ }
88
+
89
89
# Test 5: No thinking parameter - should return empty dict
90
90
result_no_thinking = config .map_openai_params (
91
91
non_default_params = {},
@@ -95,6 +95,24 @@ def test_thinking_parameter_handling(self):
95
95
)
96
96
assert result_no_thinking == {}
97
97
98
+ # Test 6: invalid thinking type - should NOT appear in extra_body (invalid type)
99
+ result_no_thinking = config .map_openai_params (
100
+ non_default_params = {"thinking" : {"type" : "invalid_type" }},
101
+ optional_params = {},
102
+ model = "doubao-seed-1.6" ,
103
+ drop_params = False ,
104
+ )
105
+ assert result_no_thinking == {}
106
+
107
+ # Test 7: invalid thinking type - should NOT appear in extra_body (value is None)
108
+ result_no_thinking = config .map_openai_params (
109
+ non_default_params = {"thinking" : {"type" : None }},
110
+ optional_params = {},
111
+ model = "doubao-seed-1.6" ,
112
+ drop_params = False ,
113
+ )
114
+ assert result_no_thinking == {}
115
+
98
116
def test_e2e_completion (self ):
99
117
from openai import OpenAI
100
118
@@ -131,5 +149,5 @@ def test_e2e_completion(self):
131
149
132
150
mock_create .assert_called_once ()
133
151
print (mock_create .call_args .kwargs )
134
- # Fixed: thinking disabled should NOT appear in extra_body
135
- assert "extra_body" not in mock_create .call_args .kwargs or "thinking" not in mock_create .call_args .kwargs .get ("extra_body" , {})
152
+ # Fixed: thinking disabled should appear in extra_body with original structure
153
+ assert "extra_body" in mock_create .call_args .kwargs and "thinking" in mock_create .call_args .kwargs .get ("extra_body" , {}) and mock_create . call_args . kwargs . get ( "extra_body" , {})[ "thinking" ] == { "type" : "disabled" }
0 commit comments