@@ -49,6 +49,21 @@ public function testGetModelWithIntegerQueryParameter()
49
49
$ this ->assertSame (500 , $ options ['max_tokens ' ]);
50
50
}
51
51
52
+ public function testGetModelWithBooleanQueryParameters ()
53
+ {
54
+ $ catalog = $ this ->createTestCatalog ();
55
+ $ model = $ catalog ->getModel ('test-model?think=true&stream=false ' );
56
+
57
+ $ this ->assertSame ('test-model ' , $ model ->getName ());
58
+ $ options = $ model ->getOptions ();
59
+ $ this ->assertArrayHasKey ('think ' , $ options );
60
+ $ this ->assertIsBool ($ options ['think ' ]);
61
+ $ this ->assertTrue ($ options ['think ' ]);
62
+ $ this ->assertArrayHasKey ('stream ' , $ options );
63
+ $ this ->assertIsBool ($ options ['stream ' ]);
64
+ $ this ->assertFalse ($ options ['stream ' ]);
65
+ }
66
+
52
67
public function testGetModelWithMultipleQueryParameters ()
53
68
{
54
69
$ catalog = $ this ->createTestCatalog ();
@@ -66,7 +81,8 @@ public function testGetModelWithMultipleQueryParameters()
66
81
$ this ->assertSame (0.7 , $ options ['temperature ' ]);
67
82
68
83
$ this ->assertArrayHasKey ('stream ' , $ options );
69
- $ this ->assertSame ('true ' , $ options ['stream ' ]);
84
+ $ this ->assertIsBool ($ options ['stream ' ]);
85
+ $ this ->assertTrue ($ options ['stream ' ]);
70
86
}
71
87
72
88
public function testGetModelWithNestedArrayQueryParameters ()
@@ -125,6 +141,23 @@ public function testNumericStringsAreConvertedRecursively()
125
141
$ this ->assertIsInt ($ options ['a ' ]['e ' ]);
126
142
}
127
143
144
+ public function testBooleanStringsAreConvertedRecursively ()
145
+ {
146
+ $ catalog = $ this ->createTestCatalog ();
147
+ $ model = $ catalog ->getModel ('test-model?a[b][c]=true&a[b][d]=text&a[e]=false ' );
148
+
149
+ $ options = $ model ->getOptions ();
150
+
151
+ $ this ->assertIsArray ($ options ['a ' ]);
152
+ $ this ->assertIsArray ($ options ['a ' ]['b ' ]);
153
+ $ this ->assertIsBool ($ options ['a ' ]['b ' ]['c ' ]);
154
+ $ this ->assertTrue ($ options ['a ' ]['b ' ]['c ' ]);
155
+ $ this ->assertIsString ($ options ['a ' ]['b ' ]['d ' ]);
156
+ $ this ->assertSame ('text ' , $ options ['a ' ]['b ' ]['d ' ]);
157
+ $ this ->assertIsBool ($ options ['a ' ]['e ' ]);
158
+ $ this ->assertFalse ($ options ['a ' ]['e ' ]);
159
+ }
160
+
128
161
private function createTestCatalog (): AbstractModelCatalog
129
162
{
130
163
return new class extends AbstractModelCatalog {
0 commit comments