Skip to content

Commit 53823ec

Browse files
committed
bug #596 [Agent][Documentation] Invalid call of Toolbox::create (lochmueller)
This PR was merged into the main branch. Discussion ---------- [Agent][Documentation] Invalid call of `Toolbox::create` | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | yes | Issues | | License | MIT Fix wrong calling of the Toolbox. `Toolbox::create()` vs. `new Toolbox([..])` Commits ------- 241dcf7 Fix documentation - Invalid call of Toolbox::create
2 parents 82d89af + 241dcf7 commit 53823ec

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/agent/doc/index.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Tool calling can be enabled by registering the processors in the agent::
7070

7171
$yourTool = new YourTool();
7272

73-
$toolbox = Toolbox::create($yourTool);
73+
$toolbox = new Toolbox([$yourTool]);
7474
$toolProcessor = new AgentProcessor($toolbox);
7575

7676
$agent = new Agent($platform, $model, inputProcessors: [$toolProcessor], outputProcessors: [$toolProcessor]);
@@ -157,7 +157,7 @@ To leverage JSON Schema validation rules, configure the ``#[With]`` attribute on
157157

158158
See attribute class ``Symfony\AI\Platform\Contract\JsonSchema\Attribute\With`` for all available options.
159159

160-
**Automatic Enum Validation**
160+
**Automatic Enum Validation**
161161

162162
For PHP backed enums, Symfony AI provides automatic validation without requiring any ``#[With]`` attributes::
163163

@@ -340,7 +340,7 @@ messages will be added to your MessageBag::
340340

341341
$yourTool = new YourTool();
342342

343-
$toolbox = Toolbox::create($yourTool);
343+
$toolbox = new Toolbox([$yourTool]);
344344
$toolProcessor = new AgentProcessor($toolbox, keepToolMessages: true);
345345

346346
$agent = new Agent($platform, $model, inputProcessor: [$toolProcessor], outputProcessor: [$toolProcessor]);
@@ -378,7 +378,7 @@ more accurate and context-aware results. Therefore, the component provides a bui
378378
// Initialize Platform & Models
379379

380380
$similaritySearch = new SimilaritySearch($model, $store);
381-
$toolbox = Toolbox::create($similaritySearch);
381+
$toolbox = new Toolbox([$similaritySearch]);
382382
$processor = new Agent($toolbox);
383383
$agent = new Agent($platform, $model, [$processor], [$processor]);
384384

@@ -635,19 +635,19 @@ It provides predictable responses without making external API calls and includes
635635

636636
$messages = new MessageBag(Message::ofUser('What is Symfony?'));
637637
$result = $agent->call($messages);
638-
638+
639639
echo $result->getContent(); // "Symfony is a PHP web framework"
640640

641641
Call Tracking and Assertions::
642642

643643
// Verify agent interactions
644644
$agent->assertCallCount(1);
645645
$agent->assertCalledWith('What is Symfony?');
646-
646+
647647
// Get detailed call information
648648
$calls = $agent->getCalls();
649649
$lastCall = $agent->getLastCall();
650-
650+
651651
// Reset call tracking
652652
$agent->reset();
653653

@@ -670,35 +670,35 @@ Callable Responses
670670
Like ``MockHttpClient``, ``MockAgent`` supports callable responses for dynamic behavior::
671671

672672
$agent = new MockAgent();
673-
673+
674674
// Dynamic response based on input and context
675675
$agent->addResponse('weather', function ($messages, $options, $input) {
676676
$messageCount = count($messages->getMessages());
677677
return "Weather info (context: {$messageCount} messages)";
678678
});
679-
679+
680680
// Callable can return string or MockResponse
681681
$agent->addResponse('complex', function ($messages, $options, $input) {
682682
return new MockResponse("Complex response for: {$input}");
683683
});
684-
684+
685685

686686
Service Testing Example
687687
~~~~~~~~~~~~~~~~~~~~~~~
688688

689689
Testing a service that uses an agent::
690690

691-
class ChatServiceTest extends TestCase
691+
class ChatServiceTest extends TestCase
692692
{
693693
public function testChatResponse(): void
694694
{
695695
$agent = new MockAgent([
696696
'Hello' => 'Hi there! How can I help?',
697697
]);
698-
698+
699699
$chatService = new ChatService($agent);
700700
$response = $chatService->processMessage('Hello');
701-
701+
702702
$this->assertSame('Hi there! How can I help?', $response);
703703
$agent->assertCallCount(1);
704704
$agent->assertCalledWith('Hello');

0 commit comments

Comments
 (0)