Skip to content

Commit f57a693

Browse files
committed
ref(chat): new component && API improvements
1 parent 8dfb617 commit f57a693

35 files changed

+486
-199
lines changed

examples/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"probots-io/pinecone-php": "^1.0",
1818
"psr/http-factory-implementation": "*",
1919
"symfony/ai-agent": "@dev",
20+
"symfony/ai-chat": "@dev",
2021
"symfony/ai-platform": "@dev",
2122
"symfony/ai-store": "@dev",
2223
"symfony/cache": "^7.3|^8.0",

examples/misc/persistent-chat-double-agent.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111

1212
use Symfony\AI\Agent\Agent;
13-
use Symfony\AI\Agent\Chat;
14-
use Symfony\AI\Agent\Chat\MessageStore\InMemoryStore;
13+
use Symfony\AI\Chat\Bridge\Local\InMemoryStore;
14+
use Symfony\AI\Chat\Chat;
1515
use Symfony\AI\Platform\Bridge\OpenAi\Gpt;
1616
use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory;
1717
use Symfony\AI\Platform\Message\Message;
@@ -26,21 +26,19 @@
2626

2727
$store = new InMemoryStore();
2828

29-
$firstChat = new Chat($agent, $store);
30-
$secondChat = new Chat($agent, $store);
29+
$chat = new Chat($agent, $store);
3130

32-
$firstChat->initiate(new MessageBag(
31+
$chat->initiate(new MessageBag(
3332
Message::forSystem('You are a helpful assistant. You only answer with short sentences.'),
34-
), '_first_chat');
35-
$secondChat->initiate(new MessageBag(
36-
Message::forSystem('You are a helpful assistant. You only answer with short sentences.'),
37-
), '_second_chat');
33+
));
34+
35+
$forkedChat = $chat->fork('fork');
3836

39-
$firstChat->submit(Message::ofUser('My name is Christopher.'));
40-
$firstChatMessage = $firstChat->submit(Message::ofUser('What is my name?'));
37+
$chat->submit(Message::ofUser('My name is Christopher.'));
38+
$firstChatMessage = $chat->submit(Message::ofUser('What is my name?'));
4139

42-
$secondChat->submit(Message::ofUser('My name is William.'));
43-
$secondChatMessage = $secondChat->submit(Message::ofUser('What is my name?'));
40+
$forkedChat->submit(Message::ofUser('My name is William.'));
41+
$secondChatMessage = $forkedChat->submit(Message::ofUser('What is my name?'));
4442

4543
$firstChatMessageContent = $firstChatMessage->content;
4644
$secondChatMessageContent = $secondChatMessage->content;

examples/misc/persistent-chat.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111

1212
use Symfony\AI\Agent\Agent;
13-
use Symfony\AI\Agent\Chat;
14-
use Symfony\AI\Agent\Chat\MessageStore\InMemoryStore;
13+
use Symfony\AI\Chat\Bridge\Local\InMemoryStore;
14+
use Symfony\AI\Chat\Chat;
1515
use Symfony\AI\Platform\Bridge\OpenAi\Gpt;
1616
use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory;
1717
use Symfony\AI\Platform\Message\Message;

src/agent/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"phpdocumentor/reflection-docblock": "^5.4",
2525
"phpstan/phpdoc-parser": "^2.1",
2626
"psr/log": "^3.0",
27+
"symfony/ai-chat": "@dev",
2728
"symfony/ai-platform": "@dev",
2829
"symfony/clock": "^7.3|^8.0",
2930
"symfony/http-client": "^7.3|^8.0",

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": "^7.3|^8.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\Memory\MemoryInputProcessor;
@@ -40,6 +34,12 @@
4034
use Symfony\AI\AiBundle\Profiler\TraceablePlatform;
4135
use Symfony\AI\AiBundle\Profiler\TraceableToolbox;
4236
use Symfony\AI\AiBundle\Security\Attribute\IsGrantedTool;
37+
use Symfony\AI\Chat\Bridge\Local\CacheStore as CacheMessageStore;
38+
use Symfony\AI\Chat\Bridge\Local\InMemoryStore as InMemoryMessageStore;
39+
use Symfony\AI\Chat\Bridge\Symfony\SessionStore as SessionMessageStore;
40+
use Symfony\AI\Chat\Chat;
41+
use Symfony\AI\Chat\ChatInterface;
42+
use Symfony\AI\Chat\MessageStoreInterface;
4343
use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory as AnthropicPlatformFactory;
4444
use Symfony\AI\Platform\Bridge\Azure\OpenAi\PlatformFactory as AzureOpenAiPlatformFactory;
4545
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
/**

0 commit comments

Comments
 (0)