Skip to content

Commit 2c4d20d

Browse files
committed
minor #751 [Docs] Improve the overall documentation (OskarStark)
This PR was squashed before being merged into the main branch. Discussion ---------- [Docs] Improve the overall documentation | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | yes | Issues | -- | License | MIT Commits ------- 69a69ae [Docs] Improve the overall documentation
2 parents 176cec3 + 69a69ae commit 2c4d20d

File tree

8 files changed

+178
-230
lines changed

8 files changed

+178
-230
lines changed

docs/bundles/ai-bundle.rst

Lines changed: 21 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Symfony integration bundle for Symfony AI components.
66
Integrating:
77

88
* `Symfony AI Agent`_
9+
* `Symfony AI Chat`_
910
* `Symfony AI Platform`_
1011
* `Symfony AI Store`_
1112

@@ -33,7 +34,7 @@ Basic Example with OpenAI
3334
default:
3435
model: 'gpt-4o-mini'
3536
36-
Advanced Example with multiple agents
37+
Advanced Example with Multiple Agents
3738
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3839

3940
.. code-block:: yaml
@@ -365,7 +366,8 @@ Then configure the prompt with translation enabled:
365366
enable_translation: true
366367
translation_domain: 'ai_prompts' # Optional: specify translation domain
367368
368-
The system prompt text will be automatically translated using the configured translator service. If no translation domain is specified, the default domain will be used.
369+
The system prompt text will be automatically translated using the configured translator service.
370+
If no translation domain is specified, the default domain will be used.
369371

370372
Memory Provider Configuration
371373
-----------------------------
@@ -434,7 +436,8 @@ Memory can work independently or alongside the system prompt:
434436
Custom Memory Provider Requirements
435437
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
436438

437-
When using a service reference, the memory service must implement the ``Symfony\AI\Agent\Memory\MemoryProviderInterface``::
439+
When using a service reference, the memory service must implement the
440+
:class:`Symfony\\AI\\Agent\\Memory\\MemoryProviderInterface`::
438441

439442
use Symfony\AI\Agent\Input;
440443
use Symfony\AI\Agent\Memory\Memory;
@@ -446,36 +449,13 @@ When using a service reference, the memory service must implement the ``Symfony\
446449
{
447450
// Return an array of Memory objects containing relevant conversation history
448451
return [
449-
new Memory('Previous conversation context...'),
452+
new Memory('Username: OskarStark'),
453+
new Memory('Age: 40'),
450454
new Memory('User preferences: prefers concise answers'),
451455
];
452456
}
453457
}
454458

455-
How Memory Works
456-
~~~~~~~~~~~~~~~~
457-
458-
The system uses explicit configuration to determine memory behavior:
459-
460-
Static Memory Processing
461-
........................
462-
463-
464-
1. When you provide a string value (e.g., ``memory: 'some text'``)
465-
2. The system creates a ``StaticMemoryProvider`` automatically
466-
3. Content is formatted as "## Static Memory" with the provided text
467-
4. This memory is consistently available across all conversations
468-
469-
Dynamic Memory Processing
470-
.........................
471-
472-
1. When you provide an array with a service key (e.g., ``memory: {service: 'my_service'}``)
473-
2. The ``MemoryInputProcessor`` uses the specified service directly
474-
3. The service's ``loadMemory()`` method is called before processing user input
475-
4. Dynamic memory content is injected based on the current context
476-
477-
In both cases, memory content is prepended to the system message, allowing the agent to utilize the context effectively.
478-
479459
Multi-Agent Orchestration
480460
-------------------------
481461

@@ -581,11 +561,6 @@ Example of creating a Handoff in PHP::
581561
when: ['code', 'debug', 'implementation', 'refactor', 'programming']
582562
);
583563

584-
$documentationHandoff = new Handoff(
585-
to: $documentationAgent,
586-
when: ['document', 'readme', 'explain', 'tutorial']
587-
);
588-
589564
The ``fallback`` parameter (required) specifies an agent to handle requests that don't match any handoff rules. This ensures all requests have a proper handler.
590565

591566
How It Works
@@ -636,7 +611,7 @@ This is useful for testing platform configurations and quick interactions with A
636611
``ai:agent:call``
637612
~~~~~~~~~~~~~~~~~
638613

639-
The ``ai:agent:call`` command (alias: ``ai:chat``) provides an interactive chat interface to communicate with configured agents.
614+
The ``ai:agent:call`` command provides an interactive chat interface to communicate with configured agents.
640615
This is useful for testing agent configurations, tools, and conversational flows.
641616

642617
.. code-block:: terminal
@@ -724,7 +699,7 @@ Usage
724699
Agent Service
725700
~~~~~~~~~~~~~
726701

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

729704
use Symfony\AI\Agent\AgentInterface;
730705
use Symfony\AI\Platform\Message\Message;
@@ -751,11 +726,11 @@ Use the `Agent` service to leverage models and tools::
751726
Register Processors
752727
~~~~~~~~~~~~~~~~~~~
753728

754-
By default, all services implementing the ``InputProcessorInterface`` or the
755-
``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`.
756731

757-
This behavior can be overridden/configured with the ``#[AsInputProcessor]`` and
758-
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::
759734

760735
use Symfony\AI\Agent\Input;
761736
use Symfony\AI\Agent\InputProcessorInterface;
@@ -804,7 +779,7 @@ To use existing tools, you can register them as a service:
804779
Symfony\AI\Agent\Toolbox\Tool\Brave:
805780
$apiKey: '%env(BRAVE_API_KEY)%'
806781
807-
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::
808783

809784
use Symfony\AI\Agent\Toolbox\Attribute\AsTool;
810785

@@ -838,8 +813,8 @@ To inject only specific tools, list them in the configuration:
838813
tools:
839814
- 'Symfony\AI\Agent\Toolbox\Tool\SimilaritySearch'
840815
841-
To restrict the access to a tool, you can use the ``IsGrantedTool`` attribute, which
842-
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,
843818
make sure you have `symfony/security-core` installed in your project.
844819

845820
::
@@ -855,7 +830,8 @@ make sure you have `symfony/security-core` installed in your project.
855830
return 'ACME Corp.';
856831
}
857832
}
858-
The attribute ``IsGrantedTool`` can be added on class- or method-level - even multiple
833+
834+
The attribute :class:`Symfony\\AI\\Agent\\Attribute\\IsGrantedTool` can be added on class- or method-level - even multiple
859835
times. If multiple attributes apply to one tool call, a logical AND is used and all access
860836
decisions have to grant access.
861837

@@ -898,14 +874,6 @@ The token usage information can be accessed from the result metadata::
898874
}
899875
}
900876

901-
Supported Platforms
902-
~~~~~~~~~~~~~~~~~~~
903-
904-
Token usage tracking is currently supported, and by default enabled, for the following platforms:
905-
906-
* **OpenAI**: Tracks all token types including cached and thinking tokens
907-
* **Mistral**: Tracks basic token usage and rate limit information
908-
909877
Disable Tracking
910878
~~~~~~~~~~~~~~~~
911879

@@ -916,8 +884,8 @@ To disable token usage tracking for an agent, set the ``track_token_usage`` opti
916884
ai:
917885
agent:
918886
my_agent:
919-
track_token_usage: false
920887
model: 'gpt-4o-mini'
888+
track_token_usage: false
921889
922890
Vectorizers
923891
-----------
@@ -990,5 +958,6 @@ The profiler panel provides insights into the agent's execution:
990958

991959

992960
.. _`Symfony AI Agent`: https://github.com/symfony/ai-agent
961+
.. _`Symfony AI Chat`: https://github.com/symfony/ai-chat
993962
.. _`Symfony AI Platform`: https://github.com/symfony/ai-platform
994963
.. _`Symfony AI Store`: https://github.com/symfony/ai-store

0 commit comments

Comments
 (0)