File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
src/platform/tests/Bridge/Gemini/Gemini Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1515use Symfony \AI \Platform \Bridge \Gemini \Gemini \ResultConverter ;
1616use Symfony \AI \Platform \Exception \RuntimeException ;
1717use Symfony \AI \Platform \Result \RawHttpResult ;
18+ use Symfony \AI \Platform \Result \ToolCall ;
19+ use Symfony \AI \Platform \Result \ToolCallResult ;
1820use Symfony \Contracts \HttpClient \ResponseInterface ;
1921
2022/**
@@ -40,4 +42,38 @@ public function testConvertThrowsExceptionWithDetailedErrorInformation()
4042
4143 $ converter ->convert (new RawHttpResult ($ httpResponse ));
4244 }
45+
46+ public function testReturnsToolCallEvenIfMultipleContentPartsAreGiven ()
47+ {
48+ $ converter = new ResultConverter ();
49+ $ httpResponse = self ::createMock (ResponseInterface::class);
50+ $ httpResponse ->method ('getStatusCode ' )->willReturn (200 );
51+ $ httpResponse ->method ('toArray ' )->willReturn ([
52+ 'candidates ' => [
53+ [
54+ 'content ' => [
55+ 'parts ' => [
56+ [
57+ 'text ' => 'foo ' ,
58+ ],
59+ [
60+ 'functionCall ' => [
61+ 'id ' => '1234 ' ,
62+ 'name ' => 'some_tool ' ,
63+ 'args ' => [],
64+ ],
65+ ],
66+ ],
67+ ],
68+ ],
69+ ],
70+ ]);
71+
72+ $ result = $ converter ->convert (new RawHttpResult ($ httpResponse ));
73+ $ this ->assertInstanceOf (ToolCallResult::class, $ result );
74+ $ this ->assertCount (1 , $ result ->getContent ());
75+ $ toolCall = $ result ->getContent ()[0 ];
76+ $ this ->assertInstanceOf (ToolCall::class, $ toolCall );
77+ $ this ->assertEquals ('1234 ' , $ toolCall ->id );
78+ }
4379}
You can’t perform that action at this time.
0 commit comments