@@ -138,24 +138,25 @@ To integrate LLMs with your application, LLM Chain supports [tool calling](https
138138Tools are services that can be called by the LLM to provide additional features or process data.
139139
140140Tool calling can be enabled by registering the processors in the chain:
141+
141142``` php
142- use PhpLlm\LlmChain\Chain\ToolBox \ChainProcessor;
143- use PhpLlm\LlmChain\Chain\ToolBox\ToolBox ;
143+ use PhpLlm\LlmChain\Chain\Toolbox \ChainProcessor;
144+ use PhpLlm\LlmChain\Chain\Toolbox\Toolbox ;
144145
145146// Platform & LLM instantiation
146147
147148$yourTool = new YourTool();
148149
149- $toolBox = ToolBox ::create($yourTool);
150- $toolProcessor = new ChainProcessor($toolBox );
150+ $toolbox = Toolbox ::create($yourTool);
151+ $toolProcessor = new ChainProcessor($toolbox );
151152
152153$chain = new Chain($platform, $llm, inputProcessor: [$toolProcessor], outputProcessor: [$toolProcessor]);
153154```
154155
155156Custom tools can basically be any class, but must configure by the ` #[AsTool] ` attribute.
156157
157158``` php
158- use PhpLlm\LlmChain\ToolBox \Attribute\AsTool;
159+ use PhpLlm\LlmChain\Toolbox \Attribute\AsTool;
159160
160161#[AsTool('company_name', 'Provides the name of your company')]
161162final class CompanyName
@@ -177,7 +178,7 @@ In the end, the tool's response needs to be a string, but LLM Chain converts arr
177178You can configure the method to be called by the LLM with the ` #[AsTool] ` attribute and have multiple tools per class:
178179
179180``` php
180- use PhpLlm\LlmChain\ToolBox \Attribute\AsTool;
181+ use PhpLlm\LlmChain\Toolbox \Attribute\AsTool;
181182
182183#[AsTool(
183184 name: 'weather_current',
@@ -205,14 +206,15 @@ final readonly class OpenMeteo
205206
206207#### Tool Parameters
207208
208- LLM Chain generates a JSON Schema representation for all tools in the ` ToolBox ` based on the ` #[AsTool] ` attribute and
209+ LLM Chain generates a JSON Schema representation for all tools in the ` Toolbox ` based on the ` #[AsTool] ` attribute and
209210method arguments and param comments in the doc block. Additionally, JSON Schema support validation rules, which are
210211partially support by LLMs like GPT.
211212
212213To leverage this, configure the ` #[With] ` attribute on the method arguments of your tool:
214+
213215``` php
214216use PhpLlm\LlmChain\Chain\JsonSchema\Attribute\With;
215- use PhpLlm\LlmChain\Chain\ToolBox \Attribute\AsTool;
217+ use PhpLlm\LlmChain\Chain\Toolbox \Attribute\AsTool;
216218
217219#[AsTool('my_tool', 'Example tool with parameters requirements.')]
218220final class MyTool
@@ -240,17 +242,17 @@ See attribute class [With](src/Chain/JsonSchema/Attribute/With.php) for all avai
240242#### Fault Tolerance
241243
242244To gracefully handle errors that occur during tool calling, e.g. wrong tool names or runtime errors, you can use the
243- ` FaultTolerantToolBox ` as a decorator for the ` ToolBox ` . It will catch the exceptions and return readable error messages
245+ ` FaultTolerantToolbox ` as a decorator for the ` Toolbox ` . It will catch the exceptions and return readable error messages
244246to the LLM.
245247
246248``` php
247- use PhpLlm\LlmChain\Chain\ToolBox \ChainProcessor;
248- use PhpLlm\LlmChain\Chain\ToolBox\FaultTolerantToolBox ;
249+ use PhpLlm\LlmChain\Chain\Toolbox \ChainProcessor;
250+ use PhpLlm\LlmChain\Chain\Toolbox\FaultTolerantToolbox ;
249251
250- // Platform, LLM & ToolBox instantiation
252+ // Platform, LLM & Toolbox instantiation
251253
252- $toolBox = new FaultTolerantToolBox($innerToolBox );
253- $toolProcessor = new ChainProcessor($toolBox );
254+ $toolbox = new FaultTolerantToolbox($innerToolbox );
255+ $toolProcessor = new ChainProcessor($toolbox );
254256
255257$chain = new Chain($platform, $llm, inputProcessor: [$toolProcessor], outputProcessor: [$toolProcessor]);
256258```
@@ -267,7 +269,7 @@ $this->chain->call($messages, ['tools' => ['tavily_search']]);
267269#### Tool Result Interception
268270
269271To react to the result of a tool, you can implement an EventListener or EventSubscriber, that listens to the
270- ` ToolCallsExecuted ` event. This event is dispatched after the ` ToolBox ` executed all current tool calls and enables
272+ ` ToolCallsExecuted ` event. This event is dispatched after the ` Toolbox ` executed all current tool calls and enables
271273you to skip the next LLM call by setting a response yourself:
272274
273275``` php
@@ -338,15 +340,15 @@ In the end the chain is used in combination with a retrieval tool on top of the
338340use PhpLlm\LlmChain\Chain;
339341use PhpLlm\LlmChain\Model\Message\Message;
340342use PhpLlm\LlmChain\Model\Message\MessageBag;
341- use PhpLlm\LlmChain\Chain\ToolBox \ChainProcessor;
342- use PhpLlm\LlmChain\Chain\ToolBox \Tool\SimilaritySearch;
343- use PhpLlm\LlmChain\Chain\ToolBox\ToolBox ;
343+ use PhpLlm\LlmChain\Chain\Toolbox \ChainProcessor;
344+ use PhpLlm\LlmChain\Chain\Toolbox \Tool\SimilaritySearch;
345+ use PhpLlm\LlmChain\Chain\Toolbox\Toolbox ;
344346
345347// Initialize Platform & Models
346348
347349$similaritySearch = new SimilaritySearch($embeddings, $store);
348- $toolBox = ToolBox ::create($similaritySearch);
349- $processor = new ChainProcessor($toolBox );
350+ $toolbox = Toolbox ::create($similaritySearch);
351+ $processor = new ChainProcessor($toolbox );
350352$chain = new Chain($platform, $llm, [$processor], [$processor]);
351353
352354$messages = new MessageBag(
0 commit comments