66
77use PhpLlm \LlmChain \Chain \Input ;
88use PhpLlm \LlmChain \Chain \ToolBox \ChainProcessor ;
9+ use PhpLlm \LlmChain \Chain \ToolBox \Metadata ;
910use PhpLlm \LlmChain \Chain \ToolBox \ToolBoxInterface ;
1011use PhpLlm \LlmChain \Exception \MissingModelSupport ;
1112use PhpLlm \LlmChain \Model \LanguageModel ;
@@ -42,7 +43,9 @@ public function processInputWithoutRegisteredToolsWillResultInNoOptionChange():
4243 public function processInputWithRegisteredToolsWillResultInOptionChange (): void
4344 {
4445 $ toolBox = $ this ->createStub (ToolBoxInterface::class);
45- $ toolBox ->method ('getMap ' )->willReturn (['tool1 ' => 'tool1 ' , 'tool2 ' => 'tool2 ' ]);
46+ $ tool1 = new Metadata ('ClassTool1 ' , 'tool1 ' , 'description1 ' , 'method1 ' , null );
47+ $ tool2 = new Metadata ('ClassTool2 ' , 'tool2 ' , 'description2 ' , 'method2 ' , null );
48+ $ toolBox ->method ('getMap ' )->willReturn ([$ tool1 , $ tool2 ]);
4649
4750 $ llm = $ this ->createMock (LanguageModel::class);
4851 $ llm ->method ('supportsToolCalling ' )->willReturn (true );
@@ -52,14 +55,16 @@ public function processInputWithRegisteredToolsWillResultInOptionChange(): void
5255
5356 $ chainProcessor ->processInput ($ input );
5457
55- self ::assertSame (['tools ' => [' tool1 ' => ' tool1 ' , ' tool2 ' => ' tool2 ' ]], $ input ->getOptions ());
58+ self ::assertSame (['tools ' => [$ tool1, $ tool2 ]], $ input ->getOptions ());
5659 }
5760
5861 #[Test]
5962 public function processInputWithRegisteredToolsButToolOverride (): void
6063 {
6164 $ toolBox = $ this ->createStub (ToolBoxInterface::class);
62- $ toolBox ->method ('getMap ' )->willReturn (['tool1 ' => 'tool1-metadata ' , 'tool2 ' => 'tool2-metadata ' ]);
65+ $ tool1 = new Metadata ('ClassTool1 ' , 'tool1 ' , 'description1 ' , 'method1 ' , null );
66+ $ tool2 = new Metadata ('ClassTool2 ' , 'tool2 ' , 'description2 ' , 'method2 ' , null );
67+ $ toolBox ->method ('getMap ' )->willReturn ([$ tool1 , $ tool2 ]);
6368
6469 $ llm = $ this ->createMock (LanguageModel::class);
6570 $ llm ->method ('supportsToolCalling ' )->willReturn (true );
@@ -69,7 +74,7 @@ public function processInputWithRegisteredToolsButToolOverride(): void
6974
7075 $ chainProcessor ->processInput ($ input );
7176
72- self ::assertSame (['tools ' => [' tool2 ' => ' tool2-metadata ' ]], $ input ->getOptions ());
77+ self ::assertSame (['tools ' => [$ tool2 ]], $ input ->getOptions ());
7378 }
7479
7580 #[Test]
0 commit comments