@@ -49,6 +49,21 @@ public function testGetModelWithIntegerQueryParameter()
4949 $ this ->assertSame (500 , $ options ['max_tokens ' ]);
5050 }
5151
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+
5267 public function testGetModelWithMultipleQueryParameters ()
5368 {
5469 $ catalog = $ this ->createTestCatalog ();
@@ -66,7 +81,8 @@ public function testGetModelWithMultipleQueryParameters()
6681 $ this ->assertSame (0.7 , $ options ['temperature ' ]);
6782
6883 $ this ->assertArrayHasKey ('stream ' , $ options );
69- $ this ->assertSame ('true ' , $ options ['stream ' ]);
84+ $ this ->assertIsBool ($ options ['stream ' ]);
85+ $ this ->assertTrue ($ options ['stream ' ]);
7086 }
7187
7288 public function testGetModelWithNestedArrayQueryParameters ()
@@ -125,6 +141,23 @@ public function testNumericStringsAreConvertedRecursively()
125141 $ this ->assertIsInt ($ options ['a ' ]['e ' ]);
126142 }
127143
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+
128161 private function createTestCatalog (): AbstractModelCatalog
129162 {
130163 return new class extends AbstractModelCatalog {
0 commit comments