Skip to content

Commit c191646

Browse files
committed
ref(chat): new component && API improvements
1 parent cc44f81 commit c191646

32 files changed

+473
-184
lines changed

src/agent/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"phpstan/phpdoc-parser": "^2.1",
2626
"psr/log": "^3.0",
2727
"symfony/ai-platform": "@dev",
28+
"symfony/ai-chat": "@dev",
2829
"symfony/clock": "^6.4 || ^7.1",
2930
"symfony/http-client": "^6.4 || ^7.1",
3031
"symfony/property-access": "^6.4 || ^7.1",

src/agent/src/Chat.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/agent/tests/AgentTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public function testGetNameReturnsProvidedName()
433433
$this->assertSame($name, $agent->getName());
434434
}
435435

436-
public function testDoubleAgentCanUseSameMessageStore()
436+
public function testMultipleAgentCanUseSameChat()
437437
{
438438
$platform = $this->createMock(PlatformInterface::class);
439439
$platform->method('invoke')
@@ -451,10 +451,10 @@ public function testDoubleAgentCanUseSameMessageStore()
451451

452452
$firstChat->initiate(new MessageBag(
453453
Message::forSystem('You are a helpful assistant. You only answer with short sentences.'),
454-
), 'foo');
454+
));
455455
$secondChat->initiate(new MessageBag(
456456
Message::forSystem('You are a helpful assistant. You only answer with short sentences.'),
457-
), 'bar');
457+
));
458458

459459
$firstChat->submit(new UserMessage(new Text('Hello')));
460460
$secondChat->submit(new UserMessage(new Text('Hello')));

src/ai-bundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"require": {
1717
"php": ">=8.2",
1818
"symfony/ai-agent": "@dev",
19+
"symfony/ai-chat": "@dev",
1920
"symfony/ai-platform": "@dev",
2021
"symfony/ai-store": "@dev",
2122
"symfony/config": "^6.4 || ^7.0",

src/ai-bundle/src/AiBundle.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
use Symfony\AI\Agent\AgentInterface;
1818
use Symfony\AI\Agent\Attribute\AsInputProcessor;
1919
use Symfony\AI\Agent\Attribute\AsOutputProcessor;
20-
use Symfony\AI\Agent\Chat;
21-
use Symfony\AI\Agent\Chat\MessageStore\CacheStore as CacheMessageStore;
22-
use Symfony\AI\Agent\Chat\MessageStore\InMemoryStore as InMemoryMessageStore;
23-
use Symfony\AI\Agent\Chat\MessageStore\SessionStore as SessionMessageStore;
24-
use Symfony\AI\Agent\Chat\MessageStoreInterface;
25-
use Symfony\AI\Agent\ChatInterface;
2620
use Symfony\AI\Agent\InputProcessor\SystemPromptInputProcessor;
2721
use Symfony\AI\Agent\InputProcessorInterface;
2822
use Symfony\AI\Agent\OutputProcessorInterface;
@@ -38,6 +32,12 @@
3832
use Symfony\AI\AiBundle\Profiler\TraceablePlatform;
3933
use Symfony\AI\AiBundle\Profiler\TraceableToolbox;
4034
use Symfony\AI\AiBundle\Security\Attribute\IsGrantedTool;
35+
use Symfony\AI\Chat\Bridge\Local\CacheStore as CacheMessageStore;
36+
use Symfony\AI\Chat\Bridge\Local\InMemoryStore as InMemoryMessageStore;
37+
use Symfony\AI\Chat\Bridge\Symfony\SessionStore as SessionMessageStore;
38+
use Symfony\AI\Chat\Chat;
39+
use Symfony\AI\Chat\ChatInterface;
40+
use Symfony\AI\Chat\MessageStoreInterface;
4141
use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory as AnthropicPlatformFactory;
4242
use Symfony\AI\Platform\Bridge\Azure\OpenAi\PlatformFactory as AzureOpenAiPlatformFactory;
4343
use Symfony\AI\Platform\Bridge\Cerebras\PlatformFactory as CerebrasPlatformFactory;

src/ai-bundle/src/Profiler/TraceableChat.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\AI\AiBundle\Profiler;
1313

14-
use Symfony\AI\Agent\ChatInterface;
14+
use Symfony\AI\Chat\ChatInterface;
1515
use Symfony\AI\Platform\Message\AssistantMessage;
1616
use Symfony\AI\Platform\Message\MessageBag;
1717
use Symfony\AI\Platform\Message\UserMessage;
@@ -35,19 +35,4 @@ public function submit(UserMessage $message, ?string $id = null): AssistantMessa
3535
{
3636
return $this->chat->submit($message, $id);
3737
}
38-
39-
public function getCurrentMessageBag(): MessageBag
40-
{
41-
return $this->chat->getCurrentMessageBag();
42-
}
43-
44-
public function getMessageBag(string $id): MessageBag
45-
{
46-
return $this->chat->getMessageBag($id);
47-
}
48-
49-
public function getId(): string
50-
{
51-
return $this->chat->getId();
52-
}
5338
}

src/ai-bundle/src/Profiler/TraceableMessageStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\AI\AiBundle\Profiler;
1313

14-
use Symfony\AI\Agent\Chat\MessageStoreInterface;
14+
use Symfony\AI\Chat\MessageStoreInterface;
1515
use Symfony\AI\Platform\Message\MessageBag;
1616

1717
/**

src/ai-bundle/tests/DependencyInjection/AiBundleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,10 @@ public function testAgentsWithChatCanBeDefined()
12121212
'agent' => 'another_agent',
12131213
'message_store' => 'cache',
12141214
],
1215+
'second' => [
1216+
'agent' => 'another_agent',
1217+
'message_store' => 'cache',
1218+
],
12151219
],
12161220
],
12171221
]);

src/ai-bundle/tests/Profiler/TraceableChatTest.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
use PHPUnit\Framework\TestCase;
1717
use Symfony\AI\Agent\AgentInterface;
1818
use Symfony\AI\Agent\Chat;
19-
use Symfony\AI\Agent\Chat\MessageStore\InMemoryStore;
2019
use Symfony\AI\AiBundle\Profiler\TraceableChat;
20+
use Symfony\AI\Chat\Bridge\Local\InMemoryStore;
2121
use Symfony\AI\Platform\Message\Message;
2222
use Symfony\AI\Platform\Result\TextResult;
2323

@@ -28,18 +28,6 @@
2828
#[UsesClass(TextResult::class)]
2929
final class TraceableChatTest extends TestCase
3030
{
31-
public function testIdCanBeRetrieved()
32-
{
33-
$agent = $this->createMock(AgentInterface::class);
34-
35-
$store = new InMemoryStore('foo');
36-
$chat = new Chat($agent, $store);
37-
38-
$traceableChat = new TraceableChat($chat);
39-
40-
$this->assertSame('foo', $traceableChat->getId());
41-
}
42-
4331
public function testCurrentMessageBagCanBeRetrieved()
4432
{
4533
$agent = $this->createMock(AgentInterface::class);

src/ai-bundle/tests/Profiler/TraceableMessageStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use PHPUnit\Framework\Attributes\CoversClass;
1515
use PHPUnit\Framework\Attributes\UsesClass;
1616
use PHPUnit\Framework\TestCase;
17-
use Symfony\AI\Agent\Chat\MessageStore\InMemoryStore;
1817
use Symfony\AI\AiBundle\Profiler\TraceableMessageStore;
18+
use Symfony\AI\Chat\Bridge\Local\InMemoryStore;
1919
use Symfony\AI\Platform\Message\Message;
2020
use Symfony\AI\Platform\Message\MessageBag;
2121

0 commit comments

Comments
 (0)