Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/agent/src/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@
/**
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
final readonly class Agent implements AgentInterface
final class Agent implements AgentInterface
{
/**
* @var InputProcessorInterface[]
*/
private array $inputProcessors;
private readonly array $inputProcessors;

/**
* @var OutputProcessorInterface[]
*/
private array $outputProcessors;
private readonly array $outputProcessors;

/**
* @param InputProcessorInterface[] $inputProcessors
* @param OutputProcessorInterface[] $outputProcessors
* @param non-empty-string $model
*/
public function __construct(
private PlatformInterface $platform,
private string $model,
private readonly PlatformInterface $platform,
private readonly string $model,
iterable $inputProcessors = [],
iterable $outputProcessors = [],
private string $name = 'agent',
private readonly string $name = 'agent',
) {
$this->inputProcessors = $this->initializeProcessors($inputProcessors, InputProcessorInterface::class);
$this->outputProcessors = $this->initializeProcessors($outputProcessors, OutputProcessorInterface::class);
Expand Down
6 changes: 3 additions & 3 deletions src/agent/src/Attribute/AsInputProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* @author Vincent Langlet <vincentlanglet@github.com>
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
final readonly class AsInputProcessor
final class AsInputProcessor
{
/**
* @param string|null $agent the service id of the agent which will use this processor,
* null to register this processor for all existing agents
*/
public function __construct(
public ?string $agent = null,
public int $priority = 0,
public readonly ?string $agent = null,
public readonly int $priority = 0,
) {
}
}
6 changes: 3 additions & 3 deletions src/agent/src/Attribute/AsOutputProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* @author Vincent Langlet <vincentlanglet@github.com>
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
final readonly class AsOutputProcessor
final class AsOutputProcessor
{
/**
* @param string|null $agent the service id of the agent which will use this processor,
* null to register this processor for all existing agents
*/
public function __construct(
public ?string $agent = null,
public int $priority = 0,
public readonly ?string $agent = null,
public readonly int $priority = 0,
) {
}
}
10 changes: 5 additions & 5 deletions src/agent/src/InputProcessor/SystemPromptInputProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
/**
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
final readonly class SystemPromptInputProcessor implements InputProcessorInterface
final class SystemPromptInputProcessor implements InputProcessorInterface
{
/**
* @param \Stringable|TranslatableInterface|string|File $systemPrompt the system prompt to prepend to the input messages, or a File object to read from
* @param ToolboxInterface|null $toolbox the tool box to be used to append the tool definitions to the system prompt
*/
public function __construct(
private \Stringable|TranslatableInterface|string|File $systemPrompt,
private ?ToolboxInterface $toolbox = null,
private ?TranslatorInterface $translator = null,
private LoggerInterface $logger = new NullLogger(),
private readonly \Stringable|TranslatableInterface|string|File $systemPrompt,
private readonly ?ToolboxInterface $toolbox = null,
private readonly ?TranslatorInterface $translator = null,
private readonly LoggerInterface $logger = new NullLogger(),
) {
if ($this->systemPrompt instanceof TranslatableInterface && !$this->translator) {
throw new RuntimeException('Translatable system prompt is not supported when no translator is provided.');
Expand Down
8 changes: 4 additions & 4 deletions src/agent/src/Memory/EmbeddingProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
/**
* @author Denis Zunke <denis.zunke@gmail.com>
*/
final readonly class EmbeddingProvider implements MemoryProviderInterface
final class EmbeddingProvider implements MemoryProviderInterface
{
public function __construct(
private PlatformInterface $platform,
private Model $model,
private StoreInterface $vectorStore,
private readonly PlatformInterface $platform,
private readonly Model $model,
private readonly StoreInterface $vectorStore,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/agent/src/Memory/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
/**
* @author Denis Zunke <denis.zunke@gmail.com>
*/
final readonly class Memory
final class Memory
{
public function __construct(
private string $content,
private readonly string $content,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/agent/src/Memory/MemoryInputProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* @author Denis Zunke <denis.zunke@gmail.com>
*/
final readonly class MemoryInputProcessor implements InputProcessorInterface
final class MemoryInputProcessor implements InputProcessorInterface
{
private const MEMORY_PROMPT_MESSAGE = <<<MARKDOWN
# Conversation Memory
Expand All @@ -31,7 +31,7 @@
/**
* @var MemoryProviderInterface[]
*/
private array $memoryProviders;
private readonly array $memoryProviders;

public function __construct(
MemoryProviderInterface ...$memoryProviders,
Expand Down
4 changes: 2 additions & 2 deletions src/agent/src/Memory/StaticMemoryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
/**
* @author Denis Zunke <denis.zunke@gmail.com>
*/
final readonly class StaticMemoryProvider implements MemoryProviderInterface
final class StaticMemoryProvider implements MemoryProviderInterface
{
/**
* @var array<string>
*/
private array $memory;
private readonly array $memory;

public function __construct(string ...$memory)
{
Expand Down
6 changes: 3 additions & 3 deletions src/agent/src/MultiAgent/Handoff.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
*
* @author Oskar Stark <oskarstark@googlemail.com>
*/
final readonly class Handoff
final class Handoff
{
/**
* @param string[] $when Keywords or phrases that indicate this handoff
*/
public function __construct(
private AgentInterface $to,
private array $when,
private readonly AgentInterface $to,
private readonly array $when,
) {
if ([] === $when) {
throw new InvalidArgumentException('Handoff must have at least one "when" condition.');
Expand Down
6 changes: 3 additions & 3 deletions src/agent/src/MultiAgent/Handoff/Decision.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
*
* @author Oskar Stark <oskarstark@googlemail.com>
*/
final readonly class Decision
final class Decision
{
/**
* @param string $agentName The name of the selected agent, or empty string if no specific agent is selected
* @param string $reasoning The reasoning behind the selection
*/
public function __construct(
private string $agentName,
private string $reasoning = 'No reasoning provided',
private readonly string $agentName,
private readonly string $reasoning = 'No reasoning provided',
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/agent/src/Toolbox/Attribute/AsTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
final readonly class AsTool
final class AsTool
{
public function __construct(
public string $name,
public string $description,
public string $method = '__invoke',
public readonly string $name,
public readonly string $description,
public readonly string $method = '__invoke',
) {
}
}
8 changes: 4 additions & 4 deletions src/agent/src/Toolbox/Event/ToolCallArgumentsResolved.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*
* @author Valtteri R <valtzu@gmail.com>
*/
final readonly class ToolCallArgumentsResolved
final class ToolCallArgumentsResolved
{
/**
* @param array<string, mixed> $arguments
*/
public function __construct(
private object $tool,
private Tool $metadata,
private array $arguments,
private readonly object $tool,
private readonly Tool $metadata,
private readonly array $arguments,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions src/agent/src/Toolbox/Event/ToolCallFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
/**
* Dispatched after successfully invoking a tool.
*/
final readonly class ToolCallFailed
final class ToolCallFailed
{
/**
* @param array<string, mixed> $arguments
*/
public function __construct(
private object $tool,
private Tool $metadata,
private array $arguments,
private \Throwable $exception,
private readonly object $tool,
private readonly Tool $metadata,
private readonly array $arguments,
private readonly \Throwable $exception,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions src/agent/src/Toolbox/Event/ToolCallSucceeded.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
/**
* Dispatched after successfully invoking a tool.
*/
final readonly class ToolCallSucceeded
final class ToolCallSucceeded
{
/**
* @param array<string, mixed> $arguments
*/
public function __construct(
private object $tool,
private Tool $metadata,
private array $arguments,
private ToolResult $result,
private readonly object $tool,
private readonly Tool $metadata,
private readonly array $arguments,
private readonly ToolResult $result,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/agent/src/Toolbox/FaultTolerantToolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
final readonly class FaultTolerantToolbox implements ToolboxInterface
final class FaultTolerantToolbox implements ToolboxInterface
{
public function __construct(
private ToolboxInterface $innerToolbox,
private readonly ToolboxInterface $innerToolbox,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/agent/src/Toolbox/Source/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

namespace Symfony\AI\Agent\Toolbox\Source;

readonly class Source
class Source
{
public function __construct(
private string $name,
private string $reference,
private string $content,
private readonly string $name,
private readonly string $reference,
private readonly string $content,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/agent/src/Toolbox/Tool/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
/**
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
final readonly class Agent
final class Agent
{
public function __construct(
private AgentInterface $agent,
private readonly AgentInterface $agent,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/agent/src/Toolbox/Tool/Firecrawl.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
#[AsTool('firecrawl_scrape', description: 'Allow to scrape website using url', method: 'scrape')]
#[AsTool('firecrawl_crawl', description: 'Allow to crawl website using url', method: 'crawl')]
#[AsTool('firecrawl_map', description: 'Allow to retrieve all urls from a website using url', method: 'map')]
final readonly class Firecrawl
final class Firecrawl
{
public function __construct(
private HttpClientInterface $httpClient,
#[\SensitiveParameter] private string $apiKey,
private string $endpoint,
private readonly HttpClientInterface $httpClient,
#[\SensitiveParameter] private readonly string $apiKey,
private readonly string $endpoint,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/agent/src/Toolbox/Tool/Mapbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
*/
#[AsTool(name: 'geocode', description: 'Convert addresses to coordinates using Mapbox Geocoding API', method: 'geocode')]
#[AsTool(name: 'reverse_geocode', description: 'Convert coordinates to addresses using Mapbox Reverse Geocoding API', method: 'reverseGeocode')]
final readonly class Mapbox
final class Mapbox
{
public function __construct(
private HttpClientInterface $httpClient,
#[\SensitiveParameter] private string $accessToken,
private readonly HttpClientInterface $httpClient,
#[\SensitiveParameter] private readonly string $accessToken,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/agent/src/Toolbox/Tool/OpenMeteo.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
#[AsTool(name: 'weather_current', description: 'get current weather for a location', method: 'current')]
#[AsTool(name: 'weather_forecast', description: 'get weather forecast for a location', method: 'forecast')]
final readonly class OpenMeteo
final class OpenMeteo
{
private const WMO_CODES = [
0 => 'Clear',
Expand Down Expand Up @@ -54,7 +54,7 @@
];

public function __construct(
private HttpClientInterface $httpClient,
private readonly HttpClientInterface $httpClient,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/agent/src/Toolbox/Tool/YouTubeTranscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
#[AsTool('youtube_transcript', 'Fetches the transcript of a YouTube video')]
final readonly class YouTubeTranscriber
final class YouTubeTranscriber
{
public function __construct(
private HttpClientInterface $client,
private readonly HttpClientInterface $client,
) {
if (!class_exists(TranscriptListFetcher::class)) {
throw new LogicException('For using the YouTube transcription tool, the mrmysql/youtube-transcript package is required. Try running "composer require mrmysql/youtube-transcript".');
Expand Down
6 changes: 3 additions & 3 deletions src/agent/src/Toolbox/ToolCallArgumentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
/**
* @author Valtteri R <valtzu@gmail.com>
*/
final readonly class ToolCallArgumentResolver
final class ToolCallArgumentResolver
{
private TypeResolver $typeResolver;
private readonly TypeResolver $typeResolver;

public function __construct(
private DenormalizerInterface $denormalizer = new Serializer([new DateTimeNormalizer(), new ObjectNormalizer(), new ArrayDenormalizer()]),
private readonly DenormalizerInterface $denormalizer = new Serializer([new DateTimeNormalizer(), new ObjectNormalizer(), new ArrayDenormalizer()]),
?TypeResolver $typeResolver = null,
) {
$this->typeResolver = $typeResolver ?? TypeResolver::create();
Expand Down
Loading