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
6 changes: 0 additions & 6 deletions src/ai-bundle/src/Command/ChatCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
{
$agentArg = $input->getArgument('agent');

// If agent is already provided and valid, nothing to do
if ($agentArg) {
return;
}
Expand All @@ -106,7 +105,6 @@ protected function interact(InputInterface $input, OutputInterface $output): voi

protected function execute(InputInterface $input, OutputInterface $output): int
{
// Initialize agent (moved from initialize() to execute() so it runs after interact())
$availableAgents = array_keys($this->agents->getProvidedServices());

if (0 === \count($availableAgents)) {
Expand All @@ -116,19 +114,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$agentArg = $input->getArgument('agent');
$agentName = \is_string($agentArg) ? $agentArg : '';

// Validate that the agent exists if one was provided
if ($agentName && !$this->agents->has($agentName)) {
throw new InvalidArgumentException(\sprintf('Agent "%s" not found. Available agents: "%s"', $agentName, implode(', ', $availableAgents)));
}

// If we still don't have an agent name at this point, something went wrong
if (!$agentName) {
throw new InvalidArgumentException(\sprintf('Agent name is required. Available agents: "%s"', implode(', ', $availableAgents)));
}

$agent = $this->agents->get($agentName);

// Now start the chat
$io = new SymfonyStyle($input, $output);

$io->title(\sprintf('Chat with %s Agent', $agentName));
Expand All @@ -155,7 +150,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$result = $agent->call($messages);

// Display system prompt after first successful call
if (!$systemPromptDisplayed && null !== ($systemMessage = $messages->getSystemMessage())) {
$io->section('System Prompt');
$io->block($systemMessage->content, null, 'fg=gray', ' ', true);
Expand Down
3 changes: 0 additions & 3 deletions src/mcp-bundle/tests/DependencyInjection/McpBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,8 @@ public function testDefaultPageSizeConfiguration()
{
$container = $this->buildContainer([]);

// Test that the default page_size parameter is set to 20
$this->assertSame(20, $container->getParameter('mcp.page_size'));

// Test that ToolListHandler is registered
$this->assertTrue($container->hasDefinition('mcp.server.request_handler.tool_list'));

$definition = $container->getDefinition('mcp.server.request_handler.tool_list');
Expand All @@ -166,7 +164,6 @@ public function testCustomPageSizeConfiguration()
],
]);

// Test that the custom page_size parameter is set
$this->assertSame(50, $container->getParameter('mcp.page_size'));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ public function testNormalize(MessageBag $bag, array $expected)
{
$normalizer = new MessageBagNormalizer();

// Set up the inner normalizers
$userMessageNormalizer = new UserMessageNormalizer();
$assistantMessageNormalizer = new AssistantMessageNormalizer();

// Mock a normalizer that delegates to the appropriate concrete normalizer
$mockNormalizer = $this->createMock(NormalizerInterface::class);
$mockNormalizer->method('normalize')
->willReturnCallback(function ($message) use ($userMessageNormalizer, $assistantMessageNormalizer): ?array {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ public function testNormalize(MessageBag $bag, array $expected)
{
$normalizer = new MessageBagNormalizer();

// Set up the concrete user message normalizer
$userMessageNormalizer = new UserMessageNormalizer();

// Mock a normalizer that delegates to the concrete normalizer
$mockNormalizer = $this->createMock(NormalizerInterface::class);
$mockNormalizer->method('normalize')
->willReturnCallback(function ($messages) use ($userMessageNormalizer): array {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public function testFromArrayWithVariousFormats()

$this->assertCount(3, $result->fills);

// Test edge cases are properly handled
$this->assertSame(0, $result->fills[0]->token);
$this->assertSame('', $result->fills[0]->tokenStr);
$this->assertSame('', $result->fills[0]->sequence);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ public function testNormalize(MessageBag $bag, array $expected)
{
$normalizer = new MessageBagNormalizer();

// Set up the inner normalizers
$userMessageNormalizer = new UserMessageNormalizer();
$assistantMessageNormalizer = new AssistantMessageNormalizer();

// Mock a normalizer that delegates to the appropriate concrete normalizer
$mockNormalizer = $this->createMock(NormalizerInterface::class);
$mockNormalizer->method('normalize')
->willReturnCallback(function ($message) use ($userMessageNormalizer, $assistantMessageNormalizer): ?array {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ final class ModelClientTest extends TestCase
{
public function testItGeneratesTheEmbeddingSuccessfully()
{
// Assert
$expectedResponse = [
'predictions' => [
['embeddings' => ['values' => [0.3, 0.4, 0.4]]],
Expand All @@ -44,10 +43,8 @@ public function testItGeneratesTheEmbeddingSuccessfully()

$model = new Model(Model::GEMINI_EMBEDDING_001, ['outputDimensionality' => 1536, 'task_type' => TaskType::CLASSIFICATION]);

// Act
$result = $client->request($model, 'test payload');

// Assert
$this->assertSame($expectedResponse, $result->getData());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ final class ResultConverterTest extends TestCase
{
public function testItConvertsAResponseToAVectorResult()
{
// Assert
$expectedResponse = [
'predictions' => [
['embeddings' => ['values' => [0.3, 0.4, 0.4]]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ final class ModelClientTest extends TestCase
{
public function testItInvokesTheTextModelsSuccessfully()
{
// Arrange
$payload = [
'content' => [
['parts' => ['text' => 'Hello, world!']],
Expand All @@ -42,12 +41,10 @@ public function testItInvokesTheTextModelsSuccessfully()

$client = new ModelClient($httpClient, 'global', 'test');

// Act
$result = $client->request(new Model(Model::GEMINI_2_0_FLASH), $payload);
$data = $result->getData();
$info = $result->getObject()->getInfo();

// Assert
$this->assertNotEmpty($data);
$this->assertNotEmpty($info);
$this->assertSame('POST', $info['http_method']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ final class ResultConverterTest extends TestCase
{
public function testItConvertsAResponseToAVectorResult()
{
// Arrange
$payload = [
'content' => ['parts' => [['text' => 'Hello, world!']]],
];
Expand All @@ -42,10 +41,8 @@ public function testItConvertsAResponseToAVectorResult()

$resultConverter = new ResultConverter();

// Act
$result = $resultConverter->convert(new RawHttpResult($response));

// Assert
$this->assertInstanceOf(TextResult::class, $result);
$this->assertSame('Hello, world!', $result->getContent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function testItDoesNothingWithoutRawResponse()

public function testItAddsUsageTokensToMetadata()
{
// Arrange
$textResult = new TextResult('test');

$rawResponse = $this->createRawResponse([
Expand All @@ -64,10 +63,8 @@ public function testItAddsUsageTokensToMetadata()
$processor = new TokenOutputProcessor();
$output = $this->createOutput($textResult);

// Act
$processor->processOutput($output);

// Assert
$metadata = $output->result->getMetadata();
$tokenUsage = $metadata->get('token_usage');

Expand All @@ -81,7 +78,6 @@ public function testItAddsUsageTokensToMetadata()

public function testItHandlesMissingUsageFields()
{
// Arrange
$textResult = new TextResult('test');

$rawResponse = $this->createRawResponse([
Expand All @@ -94,10 +90,8 @@ public function testItHandlesMissingUsageFields()
$processor = new TokenOutputProcessor();
$output = $this->createOutput($textResult);

// Act
$processor->processOutput($output);

// Assert
$metadata = $output->result->getMetadata();
$tokenUsage = $metadata->get('token_usage');

Expand All @@ -111,17 +105,14 @@ public function testItHandlesMissingUsageFields()

public function testItAddsEmptyTokenUsageWhenUsageMetadataNotPresent()
{
// Arrange
$textResult = new TextResult('test');
$rawResponse = $this->createRawResponse(['other' => 'data']);
$textResult->setRawResult($rawResponse);
$processor = new TokenOutputProcessor();
$output = $this->createOutput($textResult);

// Act
$processor->processOutput($output);

// Assert
$metadata = $output->result->getMetadata();
$tokenUsage = $metadata->get('token_usage');

Expand Down
2 changes: 0 additions & 2 deletions src/store/src/Command/IndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$indexer = $input->getArgument('indexer');
$sources = $input->getOption('source');
// Convert array of sources to single source or null
$source = match (true) {
[] === $sources => null,
1 === \count($sources) => $sources[0],
Expand All @@ -89,7 +88,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$indexerService = $this->indexers->get($indexer);

// If source override is provided, use withSource to create a new indexer instance
if (null !== $source) {
$indexerService = $indexerService->withSource($source);
}
Expand Down
5 changes: 0 additions & 5 deletions src/store/src/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function index(array $options = []): void

$documents = [];
if ([] === $this->sources) {
// No specific source provided, load with null
$documents = $this->loadSource(null);
} else {
foreach ($this->sources as $singleSource) {
Expand All @@ -72,17 +71,14 @@ public function index(array $options = []): void
return;
}

// Filter documents through all filters
foreach ($this->filters as $filter) {
$documents = $filter->filter($documents);
}

// Transform documents through all transformers
foreach ($this->transformers as $transformer) {
$documents = $transformer->transform($documents);
}

// Vectorize and store documents in chunks
$chunkSize = $options['chunk_size'] ?? 50;
$counter = 0;
$chunk = [];
Expand All @@ -96,7 +92,6 @@ public function index(array $options = []): void
}
}

// Handle remaining documents
if ([] !== $chunk) {
$this->store->add(...$this->vectorizer->vectorizeTextDocuments($chunk));
}
Expand Down
1 change: 0 additions & 1 deletion src/store/tests/Document/Loader/RssFeedLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function testLoadWithValidRssFeed()
$documents = iterator_to_array($loader->load('https://feeds.feedburner.com/symfony/blog'));
$this->assertCount(10, $documents);

// Test first document
$firstDocument = $documents[0];
$this->assertInstanceOf(TextDocument::class, $firstDocument);
$this->assertStringStartsWith('Title: Save the date, SymfonyDay Montreal 2026!', $firstDocument->content);
Expand Down
16 changes: 0 additions & 16 deletions src/store/tests/Document/MetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ public function testParentIdMethods(int|string|null $parentId)
{
$metadata = new Metadata();

// Initially should not have parent ID
$this->assertFalse($metadata->hasParentId());
$this->assertNull($metadata->getParentId());

// Set parent ID
$metadata->setParentId($parentId);

$this->assertTrue($metadata->hasParentId());
Expand All @@ -78,11 +76,9 @@ public function testTextMethods(?string $text)
{
$metadata = new Metadata();

// Initially should not have text
$this->assertFalse($metadata->hasText());
$this->assertNull($metadata->getText());

// Set text
$metadata->setText($text);

$this->assertTrue($metadata->hasText());
Expand All @@ -108,11 +104,9 @@ public function testSourceMethods(?string $source)
{
$metadata = new Metadata();

// Initially should not have source
$this->assertFalse($metadata->hasSource());
$this->assertNull($metadata->getSource());

// Set source
$metadata->setSource($source);

$this->assertTrue($metadata->hasSource());
Expand Down Expand Up @@ -144,42 +138,34 @@ public function testMetadataInitializedWithSpecialKeys()

$metadata = new Metadata($data);

// Test parent ID
$this->assertTrue($metadata->hasParentId());
$this->assertSame('parent-123', $metadata->getParentId());

// Test text
$this->assertTrue($metadata->hasText());
$this->assertSame('This is the text content', $metadata->getText());

// Test source
$this->assertTrue($metadata->hasSource());
$this->assertSame('document.pdf', $metadata->getSource());

// Test regular metadata
$this->assertSame('Test Document', $metadata['title']);
}

public function testArrayObjectBehavior()
{
$metadata = new Metadata();

// Test setting and getting values
$metadata['title'] = 'Test Document';
$metadata['category'] = 'test';

$this->assertSame('Test Document', $metadata['title']);
$this->assertSame('test', $metadata['category']);

// Test isset
$this->assertTrue(isset($metadata['title']));
$this->assertFalse(isset($metadata['nonexistent']));

// Test unset
unset($metadata['category']);
$this->assertFalse(isset($metadata['category']));

// Test count
$this->assertCount(1, $metadata);
}

Expand Down Expand Up @@ -218,12 +204,10 @@ public function testOverwritingSpecialKeys()
{
$metadata = new Metadata();

// Set initial values
$metadata->setParentId('parent-1');
$metadata->setText('initial text');
$metadata->setSource('initial.pdf');

// Overwrite values
$metadata->setParentId('parent-2');
$metadata->setText('updated text');
$metadata->setSource('updated.pdf');
Expand Down
1 change: 0 additions & 1 deletion src/store/tests/Document/TextDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public function testReadonlyProperties()

$document = new TextDocument($id, $content, $metadata);

// Test that properties are publicly accessible
$this->assertSame($id, $document->id);
$this->assertSame($content, $document->content);
$this->assertSame($metadata, $document->metadata);
Expand Down
Loading