Skip to content

Commit 8b6eaa8

Browse files
committed
-
1 parent 9768e25 commit 8b6eaa8

File tree

4 files changed

+49
-48
lines changed

4 files changed

+49
-48
lines changed

docs/bundles/ai-bundle.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ Usage
699699
Agent Service
700700
~~~~~~~~~~~~~
701701

702-
Use the `Agent` service to leverage models and tools::
702+
Use the :class:`Symfony\\AI\\Agent\\Agent` service to leverage models and tools::
703703

704704
use Symfony\AI\Agent\AgentInterface;
705705
use Symfony\AI\Platform\Message\Message;
@@ -726,11 +726,11 @@ Use the `Agent` service to leverage models and tools::
726726
Register Processors
727727
~~~~~~~~~~~~~~~~~~~
728728

729-
By default, all services implementing the ``InputProcessorInterface`` or the
730-
``OutputProcessorInterface`` interfaces are automatically applied to every ``Agent``.
729+
By default, all services implementing the :class:`Symfony\\AI\\Agent\\InputProcessorInterface` or the
730+
:class:`Symfony\\AI\\Agent\\OutputProcessorInterface` interfaces are automatically applied to every :class:`Symfony\\AI\\Agent\\Agent`.
731731

732-
This behavior can be overridden/configured with the ``#[AsInputProcessor]`` and
733-
the ``#[AsOutputProcessor]`` attributes::
732+
This behavior can be overridden/configured with the :class:`Symfony\\AI\\AiBundle\\Attribute\\AsInputProcessor` and
733+
the :class:`Symfony\\AI\\AiBundle\\Attribute\\AsOutputProcessor` attributes::
734734

735735
use Symfony\AI\Agent\Input;
736736
use Symfony\AI\Agent\InputProcessorInterface;
@@ -779,7 +779,7 @@ To use existing tools, you can register them as a service:
779779
Symfony\AI\Agent\Toolbox\Tool\Brave:
780780
$apiKey: '%env(BRAVE_API_KEY)%'
781781
782-
Custom tools can be registered by using the ``#[AsTool]`` attribute::
782+
Custom tools can be registered by using the :class:`Symfony\\AI\\Agent\\Toolbox\\Attribute\\AsTool` attribute::
783783

784784
use Symfony\AI\Agent\Toolbox\Attribute\AsTool;
785785

@@ -813,8 +813,8 @@ To inject only specific tools, list them in the configuration:
813813
tools:
814814
- 'Symfony\AI\Agent\Toolbox\Tool\SimilaritySearch'
815815
816-
To restrict the access to a tool, you can use the ``IsGrantedTool`` attribute, which
817-
works similar to ``IsGranted`` attribute in `symfony/security-http`. For this to work,
816+
To restrict the access to a tool, you can use the :class:`Symfony\\AI\\Agent\\Attribute\\IsGrantedTool` attribute, which
817+
works similar to :class:`Symfony\\Component\\Security\\Http\\Attribute\\IsGranted` attribute in `symfony/security-http`. For this to work,
818818
make sure you have `symfony/security-core` installed in your project.
819819

820820
::
@@ -831,7 +831,7 @@ make sure you have `symfony/security-core` installed in your project.
831831
}
832832
}
833833

834-
The attribute ``IsGrantedTool`` can be added on class- or method-level - even multiple
834+
The attribute :class:`Symfony\\AI\\Agent\\Attribute\\IsGrantedTool` can be added on class- or method-level - even multiple
835835
times. If multiple attributes apply to one tool call, a logical AND is used and all access
836836
decisions have to grant access.
837837

docs/components/agent.rst

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Symfony AI - Agent Component
22
============================
33

4-
The Agent component provides a framework for building AI agents that, sits on top of the Platform and Store components,
5-
allowing you to create agents that can interact with users, perform tasks, and manage workflows.
4+
The Agent component provides a framework for building AI agents that,
5+
sits on top of the Platform and Store components, allowing you to create
6+
agents that can interact with users, perform tasks, and manage workflows.
67

78
Installation
89
------------
@@ -14,8 +15,8 @@ Installation
1415
Basic Usage
1516
-----------
1617

17-
To instantiate an agent, you need to pass a ``Symfony\AI\Platform\PlatformInterface`` and a
18-
``Symfony\AI\Platform\Model`` instance to the ``Symfony\AI\Agent\Agent`` class::
18+
To instantiate an agent, you need to pass a :class:`Symfony\\AI\\Platform\\PlatformInterface` and a
19+
:class:`Symfony\\AI\\Platform\\Model` instance to the :class:`Symfony\\AI\\Agent\\Agent` class::
1920

2021
use Symfony\AI\Agent\Agent;
2122
use Symfony\AI\Platform\Bridge\OpenAi\Gpt;
@@ -26,7 +27,7 @@ To instantiate an agent, you need to pass a ``Symfony\AI\Platform\PlatformInterf
2627

2728
$agent = new Agent($platform, $model);
2829

29-
You can then run the agent with a ``Symfony\AI\Platform\Message\MessageBagInterface`` instance as input and an optional
30+
You can then run the agent with a :class:`Symfony\\AI\\Platform\\Message\\MessageBagInterface` instance as input and an optional
3031
array of options::
3132

3233
use Symfony\AI\Agent\Agent;
@@ -74,7 +75,7 @@ Tool calling can be enabled by registering the processors in the agent::
7475

7576
$agent = new Agent($platform, $model, inputProcessors: [$toolProcessor], outputProcessors: [$toolProcessor]);
7677

77-
Custom tools can basically be any class, but must configure by the ``#[AsTool]`` attribute::
78+
Custom tools can basically be any class, but must configure by the :class:`Symfony\\AI\\Agent\\Toolbox\\Attribute\\AsTool` attribute::
7879

7980
use Symfony\AI\Toolbox\Attribute\AsTool;
8081

@@ -96,7 +97,7 @@ JsonSerializable interface, to JSON strings for you. So you can return arrays or
9697
Tool Methods
9798
~~~~~~~~~~~~
9899

99-
You can configure the method to be called by the LLM with the ``#[AsTool]`` attribute and have multiple tools per class::
100+
You can configure the method to be called by the LLM with the :class:`Symfony\\AI\\Agent\\Toolbox\\Attribute\\AsTool` attribute and have multiple tools per class::
100101

101102
use Symfony\AI\Toolbox\Attribute\AsTool;
102103

@@ -126,14 +127,14 @@ You can configure the method to be called by the LLM with the ``#[AsTool]`` attr
126127
Tool Parameters
127128
~~~~~~~~~~~~~~~
128129

129-
Symfony AI generates a JSON Schema representation for all tools in the Toolbox based on the ``#[AsTool]`` attribute and
130+
Symfony AI generates a JSON Schema representation for all tools in the :class:`Symfony\\AI\\Agent\\Toolbox\\Toolbox` based on the :class:`Symfony\\AI\\Agent\\Toolbox\\Attribute\\AsTool` attribute and
130131
method arguments and param comments in the doc block. Additionally, JSON Schema support validation rules, which are
131132
partially supported by LLMs like GPT.
132133

133134
Parameter Validation with ``#[With]`` Attribute
134135
...............................................
135136

136-
To leverage JSON Schema validation rules, configure the ``#[With]`` attribute on the method arguments of your tool::
137+
To leverage JSON Schema validation rules, configure the :class:`Symfony\\AI\\Platform\\Contract\\JsonSchema\\Attribute\\With` attribute on the method arguments of your tool::
137138

138139
use Symfony\AI\Agent\Toolbox\Attribute\AsTool;
139140
use Symfony\AI\Platform\Contract\JsonSchema\Attribute\With;
@@ -158,12 +159,12 @@ To leverage JSON Schema validation rules, configure the ``#[With]`` attribute on
158159
}
159160
}
160161

161-
See attribute class ``Symfony\AI\Platform\Contract\JsonSchema\Attribute\With`` for all available options.
162+
See attribute class :class:`Symfony\\AI\\Platform\\Contract\\JsonSchema\\Attribute\\With` for all available options.
162163

163164
Automatic Enum Validation
164165
.........................
165166

166-
For PHP backed enums, automatic validation without requiring any ``#[With]`` attribute is supported::
167+
For PHP backed enums, automatic validation without requiring any :class:`Symfony\\AI\\Platform\\Contract\\JsonSchema\\Attribute\\With` attribute is supported::
167168

168169
enum Priority: int
169170
{
@@ -208,8 +209,8 @@ This eliminates the need for manual ``#[With(enum: [...])]`` attributes when usi
208209
Third-Party Tools
209210
~~~~~~~~~~~~~~~~~
210211

211-
In some cases you might want to use third-party tools, which are not part of your application. Adding the ``#[AsTool]``
212-
attribute to the class is not possible in those cases, but you can explicitly register the tool in the MemoryFactory::
212+
In some cases you might want to use third-party tools, which are not part of your application. Adding the :class:`Symfony\\AI\\Agent\\Toolbox\\Attribute\\AsTool`
213+
attribute to the class is not possible in those cases, but you can explicitly register the tool in the :class:`Symfony\\AI\\Agent\\Toolbox\\ToolFactory\\MemoryToolFactory`::
213214

214215
use Symfony\AI\Agent\Toolbox\Toolbox;
215216
use Symfony\AI\Agent\Toolbox\ToolFactory\MemoryToolFactory;
@@ -223,7 +224,7 @@ attribute to the class is not possible in those cases, but you can explicitly re
223224

224225
Please be aware that not all return types are supported by the toolbox, so a decorator might still be needed.
225226

226-
This can be combined with the ``ChainFactory`` which enables you to use explicitly registered tools and ``#[AsTool]`` tagged
227+
This can be combined with the :class:`Symfony\\AI\\Agent\\Toolbox\\ToolFactory\\ChainFactory` which enables you to use explicitly registered tools and :class:`Symfony\\AI\\Agent\\Toolbox\\Attribute\\AsTool` tagged
227228
tools in the same chain - which even enables you to overwrite the pre-existing configuration of a tool::
228229

229230
use Symfony\AI\Agent\Toolbox\Toolbox;
@@ -261,7 +262,7 @@ Fault Tolerance
261262
~~~~~~~~~~~~~~~
262263

263264
To gracefully handle errors that occur during tool calling, e.g. wrong tool names or runtime errors, you can use the
264-
``FaultTolerantToolbox`` as a decorator for the Toolbox. It will catch the exceptions and return readable error messages
265+
:class:`Symfony\\AI\\Agent\\Toolbox\\FaultTolerantToolbox` as a decorator for the :class:`Symfony\\AI\\Agent\\Toolbox\\Toolbox`. It will catch the exceptions and return readable error messages
265266
to the LLM::
266267

267268
use Symfony\AI\Agent\Agent;
@@ -275,7 +276,7 @@ to the LLM::
275276

276277
$agent = new Agent($platform, $model, inputProcessor: [$toolProcessor], outputProcessor: [$toolProcessor]);
277278

278-
If you want to expose the underlying error to the LLM, you can throw a custom exception that implements `ToolExecutionExceptionInterface`::
279+
If you want to expose the underlying error to the LLM, you can throw a custom exception that implements :class:`Symfony\\AI\\Agent\\Toolbox\\Exception\\ToolExecutionExceptionInterface`::
279280

280281
use Symfony\AI\Agent\Toolbox\Exception\ToolExecutionExceptionInterface;
281282

@@ -325,7 +326,7 @@ Tool Result Interception
325326
~~~~~~~~~~~~~~~~~~~~~~~~
326327

327328
To react to the result of a tool, you can implement an EventListener, that listens to the
328-
``ToolCallsExecuted`` event. This event is dispatched after the Toolbox executed all current
329+
:class:`Symfony\\AI\\Agent\\Toolbox\\Event\\ToolCallsExecuted` event. This event is dispatched after the :class:`Symfony\\AI\\Agent\\Toolbox\\Toolbox` executed all current
329330
tool calls and enables you to skip the next LLM call by setting a result yourself::
330331

331332
$eventDispatcher->addListener(ToolCallsExecuted::class, function (ToolCallsExecuted $event): void {
@@ -525,8 +526,8 @@ They are provided while instantiating the agent instance::
525526
InputProcessor
526527
~~~~~~~~~~~~~~
527528

528-
InputProcessor instances are called in the agent before handing over the MessageBag and the $options array to the LLM
529-
and are able to mutate both on top of the Input instance provided::
529+
:class:`Symfony\\AI\\Agent\\InputProcessorInterface` instances are called in the agent before handing over the :class:`Symfony\\AI\\Platform\\Message\\MessageBag` and the $options array to the LLM
530+
and are able to mutate both on top of the :class:`Symfony\\AI\\Agent\\Input` instance provided::
530531

531532
use Symfony\AI\Agent\Input;
532533
use Symfony\AI\Agent\InputProcessorInterface;
@@ -549,7 +550,7 @@ and are able to mutate both on top of the Input instance provided::
549550
OutputProcessor
550551
~~~~~~~~~~~~~~~
551552

552-
OutputProcessor instances are called after the model provided a result and can - on top of options and messages - mutate
553+
:class:`Symfony\\AI\\Agent\\OutputProcessorInterface` instances are called after the model provided a result and can - on top of options and messages - mutate
553554
or replace the given result::
554555

555556
use Symfony\AI\Agent\Output;
@@ -569,9 +570,9 @@ or replace the given result::
569570
Agent Awareness
570571
~~~~~~~~~~~~~~~
571572

572-
Both, Input and Output instances, provide access to the LLM used by the agent, but the agent itself is only provided,
573-
in case the processor implemented the AgentAwareInterface interface, which can be combined with using the
574-
AgentAwareTrait::
573+
Both, :class:`Symfony\\AI\\Agent\\Input` and :class:`Symfony\\AI\\Agent\\Output` instances, provide access to the LLM used by the agent, but the agent itself is only provided,
574+
in case the processor implemented the :class:`Symfony\\AI\\Agent\\AgentAwareInterface` interface, which can be combined with using the
575+
:class:`Symfony\\AI\\Agent\\AgentAwareTrait`::
575576

576577
use Symfony\AI\Agent\AgentAwareInterface;
577578
use Symfony\AI\Agent\AgentAwareTrait;
@@ -599,7 +600,7 @@ model with context without changing your application logic.
599600
Using Memory
600601
^^^^^^^^^^^^
601602

602-
Memory integration is handled through the ``MemoryInputProcessor`` and one or more ``MemoryProviderInterface`` implementations::
603+
Memory integration is handled through the :class:`Symfony\\AI\\Agent\\Memory\\MemoryInputProcessor` and one or more :class:`Symfony\\AI\\Agent\\Memory\\MemoryProviderInterface` implementations::
603604

604605
use Symfony\AI\Agent\Agent;
605606
use Symfony\AI\Agent\Memory\MemoryInputProcessor;
@@ -669,7 +670,7 @@ Testing
669670
MockAgent
670671
^^^^^^^^^
671672

672-
For testing purposes, the Agent component provides a ``MockAgent`` class that behaves like Symfony's ``MockHttpClient``.
673+
For testing purposes, the Agent component provides a :class:`Symfony\\AI\\Agent\\MockAgent` class that behaves like Symfony's :class:`Symfony\\Component\\HttpClient\\MockHttpClient`.
673674
It provides predictable responses without making external API calls and includes assertion methods for verifying interactions::
674675

675676
use Symfony\AI\Agent\MockAgent;
@@ -702,7 +703,7 @@ Call Tracking and Assertions::
702703
MockResponse Objects
703704
^^^^^^^^^^^^^^^^^^^^
704705

705-
Similar to ``MockHttpClient``, you can use ``MockResponse`` objects for more complex scenarios::
706+
Similar to :class:`Symfony\\Component\\HttpClient\\MockHttpClient`, you can use :class:`Symfony\\AI\\Agent\\MockResponse` objects for more complex scenarios::
706707

707708
use Symfony\AI\Agent\MockResponse;
708709

@@ -715,7 +716,7 @@ Similar to ``MockHttpClient``, you can use ``MockResponse`` objects for more com
715716
Callable Responses
716717
^^^^^^^^^^^^^^^^^^
717718

718-
Like ``MockHttpClient``, ``MockAgent`` supports callable responses for dynamic behavior::
719+
Like :class:`Symfony\\Component\\HttpClient\\MockHttpClient`, :class:`Symfony\\AI\\Agent\\MockAgent` supports callable responses for dynamic behavior::
719720

720721
$agent = new MockAgent();
721722

docs/components/platform.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ One central feature of the Platform component is the support for language
126126
models and easing the interaction with them. This is supported by providing
127127
an extensive set of data classes around the concept of messages and their content.
128128

129-
Messages can be of different types, most importantly ``UserMessage``, ``SystemMessage``, or ``AssistantMessage``, can
130-
have different content types, like ``Text``, ``Image`` or ``Audio``, and can be grouped into a ``MessageBag``::
129+
Messages can be of different types, most importantly :class:`Symfony\\AI\\Platform\\Message\\UserMessage`, :class:`Symfony\\AI\\Platform\\Message\\SystemMessage`, or :class:`Symfony\\AI\\Platform\\Message\\AssistantMessage`, can
130+
have different content types, like :class:`Symfony\\AI\\Platform\\Message\\Content\\Text`, :class:`Symfony\\AI\\Platform\\Message\\Content\\Image` or :class:`Symfony\\AI\\Platform\\Message\\Content\\Audio`, and can be grouped into a :class:`Symfony\\AI\\Platform\\Message\\MessageBag`::
131131

132132
use Symfony\AI\Platform\Message\Content\Image;
133133
use Symfony\AI\Platform\Message\Message;
@@ -170,7 +170,7 @@ Result Streaming
170170
----------------
171171

172172
Since LLMs usually generate a result word by word, most of them also support streaming the result using Server Side
173-
Events. Symfony AI supports that by abstracting the conversion and returning a ``Generator`` as content of the result::
173+
Events. Symfony AI supports that by abstracting the conversion and returning a :class:`Generator` as content of the result::
174174

175175
use Symfony\AI\Agent\Agent;
176176
use Symfony\AI\Message\Message;
@@ -206,7 +206,7 @@ Code Examples
206206
Image Processing
207207
----------------
208208

209-
Some LLMs also support images as input, which Symfony AI supports as content type within the ``UserMessage``::
209+
Some LLMs also support images as input, which Symfony AI supports as content type within the :class:`Symfony\\AI\\Platform\\Message\\UserMessage`::
210210

211211
use Symfony\AI\Platform\Message\Content\Image;
212212
use Symfony\AI\Platform\Message\Message;
@@ -235,7 +235,7 @@ Audio Processing
235235
----------------
236236

237237
Similar to images, some LLMs also support audio as input, which is just another content type within the
238-
``UserMessage``::
238+
:class:`Symfony\\AI\\Platform\\Message\\UserMessage`::
239239

240240
use Symfony\AI\Platform\Message\Content\Audio;
241241
use Symfony\AI\Platform\Message\Message;
@@ -261,7 +261,7 @@ Embeddings
261261

262262
Creating embeddings of word, sentences, or paragraphs is a typical use case around the interaction with LLMs.
263263

264-
The standalone usage results in an ``Vector`` instance::
264+
The standalone usage results in a :class:`Symfony\\AI\\Store\\Vector` instance::
265265

266266
use Symfony\AI\Platform\Bridge\OpenAi\Embeddings;
267267

@@ -307,13 +307,13 @@ which can be useful to speed up the processing::
307307
Testing Tools
308308
-------------
309309

310-
For unit or integration testing, you can use the `InMemoryPlatform`,
311-
which implements `PlatformInterface` without calling external APIs.
310+
For unit or integration testing, you can use the :class:`Symfony\\AI\\Platform\\InMemoryPlatform`,
311+
which implements :class:`Symfony\\AI\\Platform\\PlatformInterface` without calling external APIs.
312312

313313
It supports returning either:
314314

315315
- A fixed string result
316-
- A callable that dynamically returns a simple string or any ``ResultInterface`` based on the model, input, and options::
316+
- A callable that dynamically returns a simple string or any :class:`Symfony\\AI\\Platform\\Result\\ResultInterface` based on the model, input, and options::
317317

318318
use Symfony\AI\Platform\InMemoryPlatform;
319319
use Symfony\AI\Platform\Model;

docs/components/store.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ for documents.
2222
Indexing
2323
--------
2424

25-
One higher level feature is the ``Symfony\AI\Store\Indexer``. The purpose of this service is to populate a store with documents.
26-
Therefore it accepts one or multiple ``Symfony\AI\Store\Document\TextDocument`` objects, converts them into embeddings and stores them in the
25+
One higher level feature is the :class:`Symfony\\AI\\Store\\Indexer`. The purpose of this service is to populate a store with documents.
26+
Therefore it accepts one or multiple :class:`Symfony\\AI\\Store\\Document\\TextDocument` objects, converts them into embeddings and stores them in the
2727
used vector store::
2828

2929
use Symfony\AI\Store\Document\TextDocument;
@@ -101,7 +101,7 @@ you can use the ``bin/console ai:store:setup`` command to initialize the store a
101101
Implementing a Bridge
102102
---------------------
103103

104-
The main extension points of the Store component is the ``Symfony\AI\Store\StoreInterface``, that defines the methods
104+
The main extension points of the Store component is the :class:`Symfony\\AI\\Store\\StoreInterface`, that defines the methods
105105
for adding vectorized documents to the store, and querying the store for documents with a vector.
106106

107107
This leads to a store implementing two methods::

0 commit comments

Comments
 (0)