Skip to content

Commit a233206

Browse files
committed
[Agent] Extract tools to dedicated bridges
1 parent 879602b commit a233206

File tree

117 files changed

+876
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+876
-101
lines changed

demo/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"php-http/discovery": "^1.20",
1515
"runtime/frankenphp-symfony": "^0.2.0",
1616
"symfony/ai-bundle": "@dev",
17+
"symfony/ai-clock-tool": "@dev",
18+
"symfony/ai-similarity-search-tool": "@dev",
19+
"symfony/ai-wikipedia-tool": "@dev",
1720
"symfony/asset": "~7.3.0",
1821
"symfony/asset-mapper": "~7.3.0",
1922
"symfony/clock": "~7.3.0",

demo/config/packages/ai.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ai:
99
platform: 'ai.platform.openai'
1010
model: 'gpt-4o-mini'
1111
tools:
12-
- 'Symfony\AI\Agent\Toolbox\Tool\SimilaritySearch'
12+
- 'Symfony\AI\Agent\Bridge\SimilaritySearch\SimilaritySearch'
1313
- service: 'clock'
1414
name: 'clock'
1515
description: 'Provides the current date and time.'
@@ -40,7 +40,7 @@ ai:
4040
text: 'Please answer the users question based on Wikipedia, only use information provided in the messages.'
4141
include_tools: true
4242
tools:
43-
- 'Symfony\AI\Agent\Toolbox\Tool\Wikipedia'
43+
- 'Symfony\AI\Agent\Bridge\Wikipedia\Wikipedia'
4444
include_sources: true
4545
speech:
4646
platform: 'ai.platform.openai'
@@ -52,7 +52,7 @@ ai:
5252
If you don't know the answer, say so. Keep in mind that you are in a spoken conversation, so keep your
5353
answers concise and to the point. They will be read out loud to the user.
5454
tools:
55-
- 'Symfony\AI\Agent\Toolbox\Tool\Clock'
55+
- 'Symfony\AI\Agent\Bridge\Clock\Clock'
5656
# Agent in agent 🤯
5757
- agent: 'blog'
5858
name: 'symfony_blog'
@@ -106,9 +106,11 @@ services:
106106
autowire: true
107107
autoconfigure: true
108108

109-
Symfony\AI\Agent\Toolbox\Tool\Clock: ~
110-
Symfony\AI\Agent\Toolbox\Tool\Wikipedia: ~
111-
Symfony\AI\Agent\Toolbox\Tool\SimilaritySearch:
109+
# TODO: Remove once flex recipe works correctly
110+
Symfony\AI\Agent\Bridge\Clock\Clock: ~
111+
Symfony\AI\Agent\Bridge\Wikipedia\Wikipedia: ~
112+
113+
Symfony\AI\Agent\Bridge\SimilaritySearch\SimilaritySearch:
112114
$vectorizer: '@ai.vectorizer.openai'
113115
$store: '@ai.store.chroma_db.symfonycon'
114116

docs/bundles/ai-bundle.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Advanced Example with Multiple Agents
7575
include_tools: true # Include tool definitions at the end of the system prompt
7676
tools:
7777
# Referencing a service with #[AsTool] attribute
78-
- 'Symfony\AI\Agent\Toolbox\Tool\SimilaritySearch'
78+
- 'Symfony\AI\Agent\Bridge\SimilaritySearch\SimilaritySearch'
7979
8080
# Referencing a service without #[AsTool] attribute
8181
- service: 'App\Agent\Tool\CompanyName'
@@ -91,7 +91,7 @@ Advanced Example with Multiple Agents
9191
platform: 'ai.platform.anthropic'
9292
model: 'claude-3-7-sonnet'
9393
tools: # If undefined, all tools are injected into the agent, use "tools: false" to disable tools.
94-
- 'Symfony\AI\Agent\Toolbox\Tool\Wikipedia'
94+
- 'Symfony\AI\Agent\Bridge\Wikipedia\Wikipedia'
9595
fault_tolerant_toolbox: false # Disables fault tolerant toolbox, default is true
9696
search_agent:
9797
platform: 'ai.platform.perplexity'
@@ -776,13 +776,18 @@ The following tools can be installed as dedicated packages, no configuration is
776776
.. code-block:: terminal
777777
778778
$ composer require symfony/ai-brave-tool
779+
$ composer require symfony/ai-clock-tool
779780
$ composer require symfony/ai-firecrawl-tool
780781
$ composer require symfony/ai-mapbox-tool
781782
$ composer require symfony/ai-open-meteo-tool
783+
$ composer require symfony/ai-scraper-tool
782784
$ composer require symfony/ai-serp-api-tool
785+
$ composer require symfony/ai-similarity-search-tool
783786
$ composer require symfony/ai-tavily-tool
787+
$ composer require symfony/ai-wikipedia-tool
788+
$ composer require symfony/ai-youtube-tool
784789
785-
For tools not available as dedicated packages (those in the ``Toolbox\Tool`` namespace), register them manually as services:
790+
Some tools may require additional configuration even when installed as dedicated packages. For example, the SimilaritySearch tool requires a vectorizer and store:
786791

787792
.. code-block:: yaml
788793
@@ -791,10 +796,9 @@ For tools not available as dedicated packages (those in the ``Toolbox\Tool`` nam
791796
autowire: true
792797
autoconfigure: true
793798
794-
Symfony\AI\Agent\Toolbox\Tool\Clock: ~
795-
Symfony\AI\Agent\Toolbox\Tool\SimilaritySearch: ~
796-
Symfony\AI\Agent\Toolbox\Tool\Wikipedia: ~
797-
Symfony\AI\Agent\Toolbox\Tool\YouTubeTranscriber: ~
799+
Symfony\AI\Agent\Bridge\SimilaritySearch\SimilaritySearch:
800+
$vectorizer: '@ai.vectorizer.openai'
801+
$store: '@ai.store.main'
798802
799803
Creating Custom Tools
800804
---------------------

examples/aimlapi/toolcall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111

1212
use Symfony\AI\Agent\Agent;
13+
use Symfony\AI\Agent\Bridge\Wikipedia\Wikipedia;
1314
use Symfony\AI\Agent\Toolbox\AgentProcessor;
14-
use Symfony\AI\Agent\Toolbox\Tool\Wikipedia;
1515
use Symfony\AI\Agent\Toolbox\Toolbox;
1616
use Symfony\AI\Platform\Bridge\AiMlApi\PlatformFactory;
1717
use Symfony\AI\Platform\Message\Message;

examples/anthropic/structured-output-clock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111

1212
use Symfony\AI\Agent\Agent;
13+
use Symfony\AI\Agent\Bridge\Clock\Clock;
1314
use Symfony\AI\Agent\Toolbox\AgentProcessor;
14-
use Symfony\AI\Agent\Toolbox\Tool\Clock;
1515
use Symfony\AI\Agent\Toolbox\Toolbox;
1616
use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory;
1717
use Symfony\AI\Platform\Message\Message;

examples/anthropic/toolcall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
*/
1111

1212
use Symfony\AI\Agent\Agent;
13+
use Symfony\AI\Agent\Bridge\Wikipedia\Wikipedia;
1314
use Symfony\AI\Agent\Toolbox\AgentProcessor;
1415
use Symfony\AI\Agent\Toolbox\Source\Source;
15-
use Symfony\AI\Agent\Toolbox\Tool\Wikipedia;
1616
use Symfony\AI\Agent\Toolbox\Toolbox;
1717
use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory;
1818
use Symfony\AI\Platform\Message\Message;

examples/bedrock/toolcall-claude.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111

1212
use Symfony\AI\Agent\Agent;
13+
use Symfony\AI\Agent\Bridge\Wikipedia\Wikipedia;
1314
use Symfony\AI\Agent\Toolbox\AgentProcessor;
14-
use Symfony\AI\Agent\Toolbox\Tool\Wikipedia;
1515
use Symfony\AI\Agent\Toolbox\Toolbox;
1616
use Symfony\AI\Platform\Bridge\Bedrock\PlatformFactory;
1717
use Symfony\AI\Platform\Message\Message;

examples/bedrock/toolcall-nova.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111

1212
use Symfony\AI\Agent\Agent;
13+
use Symfony\AI\Agent\Bridge\Wikipedia\Wikipedia;
1314
use Symfony\AI\Agent\Toolbox\AgentProcessor;
14-
use Symfony\AI\Agent\Toolbox\Tool\Wikipedia;
1515
use Symfony\AI\Agent\Toolbox\Toolbox;
1616
use Symfony\AI\Platform\Bridge\Bedrock\PlatformFactory;
1717
use Symfony\AI\Platform\Message\Message;

examples/composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020
"symfony/ai-agent": "@dev",
2121
"symfony/ai-brave-tool": "@dev",
2222
"symfony/ai-chat": "@dev",
23+
"symfony/ai-clock-tool": "@dev",
2324
"symfony/ai-open-meteo-tool": "@dev",
25+
"symfony/ai-scraper-tool": "@dev",
2426
"symfony/ai-serp-api-tool": "@dev",
27+
"symfony/ai-similarity-search-tool": "@dev",
2528
"symfony/ai-platform": "@dev",
2629
"symfony/ai-store": "@dev",
2730
"symfony/ai-tavily-tool": "@dev",
31+
"symfony/ai-wikipedia-tool": "@dev",
32+
"symfony/ai-youtube-tool": "@dev",
2833
"symfony/cache": "^7.3|^8.0",
2934
"symfony/clock": "^7.3|^8.0",
3035
"symfony/console": "^7.3|^8.0",

examples/deepseek/structured-output-clock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111

1212
use Symfony\AI\Agent\Agent;
13+
use Symfony\AI\Agent\Bridge\Clock\Clock;
1314
use Symfony\AI\Agent\Toolbox\AgentProcessor;
14-
use Symfony\AI\Agent\Toolbox\Tool\Clock;
1515
use Symfony\AI\Agent\Toolbox\Toolbox;
1616
use Symfony\AI\Platform\Bridge\DeepSeek\PlatformFactory;
1717
use Symfony\AI\Platform\Message\Message;

0 commit comments

Comments
 (0)