6
6
7
7
use PhpLlm \LlmChain \Chain \Input ;
8
8
use PhpLlm \LlmChain \Chain \ToolBox \ChainProcessor ;
9
+ use PhpLlm \LlmChain \Chain \ToolBox \Metadata ;
9
10
use PhpLlm \LlmChain \Chain \ToolBox \ToolBoxInterface ;
10
11
use PhpLlm \LlmChain \Exception \MissingModelSupport ;
11
12
use PhpLlm \LlmChain \Model \LanguageModel ;
@@ -42,7 +43,9 @@ public function processInputWithoutRegisteredToolsWillResultInNoOptionChange():
42
43
public function processInputWithRegisteredToolsWillResultInOptionChange (): void
43
44
{
44
45
$ 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 ]);
46
49
47
50
$ llm = $ this ->createMock (LanguageModel::class);
48
51
$ llm ->method ('supportsToolCalling ' )->willReturn (true );
@@ -52,14 +55,16 @@ public function processInputWithRegisteredToolsWillResultInOptionChange(): void
52
55
53
56
$ chainProcessor ->processInput ($ input );
54
57
55
- self ::assertSame (['tools ' => [' tool1 ' => ' tool1 ' , ' tool2 ' => ' tool2 ' ]], $ input ->getOptions ());
58
+ self ::assertSame (['tools ' => [$ tool1, $ tool2 ]], $ input ->getOptions ());
56
59
}
57
60
58
61
#[Test]
59
62
public function processInputWithRegisteredToolsButToolOverride (): void
60
63
{
61
64
$ 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 ]);
63
68
64
69
$ llm = $ this ->createMock (LanguageModel::class);
65
70
$ llm ->method ('supportsToolCalling ' )->willReturn (true );
@@ -69,7 +74,7 @@ public function processInputWithRegisteredToolsButToolOverride(): void
69
74
70
75
$ chainProcessor ->processInput ($ input );
71
76
72
- self ::assertSame (['tools ' => [' tool2 ' => ' tool2-metadata ' ]], $ input ->getOptions ());
77
+ self ::assertSame (['tools ' => [$ tool2 ]], $ input ->getOptions ());
73
78
}
74
79
75
80
#[Test]
0 commit comments