Skip to content

Commit 1c37e87

Browse files
committed
feature #675 [Chat] Introduce a new component (Guikingone)
This PR was merged into the main branch. Discussion ---------- [Chat] Introduce a new component | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | yes | Issues | Related to #254 | License | MIT Hi 👋🏻 Ok, time to tackle the big work on the #254 issue, the current structure doesn't allows to introduce new stores neither handling the storage of messages, mainly due to the fact that we can't intervene in the agent component without breaking the SRP of it. This PR aims to split the `Chat` into a new component and ease the work on storing messages (with a new component, we can easily add storages here rather than in the `agent` component), plus, it helps splitting the responsibilities inside the initiative as we should be allowed to start new agents without relying on any chats. This PR is a draft, feel free to open debates about it 😄 Commits ------- 3f1dd48 refactor(core): chat sub-component started
2 parents 65fb739 + 3f1dd48 commit 1c37e87

24 files changed

+347
-17
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Symfony AI consists of several lower and higher level **components** and the res
1515
* **Components**
1616
* **[Platform](src/platform/README.md)**: A unified interface to various AI platforms like OpenAI, Anthropic, Azure, Gemini, VertexAI, and more.
1717
* **[Agent](src/agent/README.md)**: Framework for building AI agents that can interact with users and perform tasks.
18+
* **[Chat](src/chat/README.md)**: An unified interface to send messages to agents and store long-term context.
1819
* **[Store](src/store/README.md)**: Data storage abstraction with indexing and retrieval for AI applications.
1920
* **Bundles**
2021
* **[AI Bundle](src/ai-bundle/README.md)**: Symfony integration for AI Platform, Store and Agent components.

examples/misc/persistent-chat.php renamed to examples/chat/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\PlatformFactory;
1616
use Symfony\AI\Platform\Message\Message;
1717
use Symfony\AI\Platform\Message\MessageBag;

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",

src/agent/AGENTS.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Framework for building AI agents with user interaction and task execution. Built
1111
### Core Classes
1212
- **Agent** (`src/Agent.php`): Main orchestration class
1313
- **AgentInterface**: Contract for implementations
14-
- **Chat** (`src/Chat.php`): High-level conversation interface
1514
- **Input/Output** (`src/Input.php`, `src/Output.php`): Pipeline data containers
1615

1716
### Processing Pipeline
@@ -79,4 +78,4 @@ cd ../../.. && vendor/bin/php-cs-fixer fix src/agent/
7978
- Component is experimental (BC breaks possible)
8079
- Add `@author` tags to new classes
8180
- Use component-specific exceptions from `src/Exception/`
82-
- Follow `@Symfony` PHP CS Fixer rules
81+
- Follow `@Symfony` PHP CS Fixer rules

src/chat/.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.github export-ignore
2+
/tests export-ignore
3+
.gitattributes export-ignore
4+
.gitignore export-ignore
5+
phpstan.dist.neon export-ignore
6+
phpunit.xml.dist export-ignore
7+
CLAUDE.md export-ignore
8+
AGENTS.md export-ignore
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Please do not submit any Pull Requests here. They will be closed.
2+
---
3+
4+
Please submit your PR here instead:
5+
https://github.com/symfony/ai
6+
7+
This repository is what we call a "subtree split": a read-only subset of that main repository.
8+
We're looking forward to your PR there!
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Close Pull Request
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: superbrothers/close-pull-request@v3
12+
with:
13+
comment: |
14+
Thanks for your Pull Request! We love contributions.
15+
16+
However, you should instead open your PR on the main repository:
17+
https://github.com/symfony/ai
18+
19+
This repository is what we call a "subtree split": a read-only subset of that main repository.
20+
We're looking forward to your PR there!

src/chat/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.lock
2+
vendor
3+
.phpunit.cache

src/chat/AGENTS.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# AGENTS.md
2+
3+
AI agent guidance for the Chat component.
4+
5+
## Component Overview
6+
7+
Library for building chats with agents using messages. Built on Platform and Agent components.
8+
9+
## Architecture
10+
11+
### Core Classes
12+
- **Chat** (`src/Chat.php`): Main orchestration class
13+
- **ChatInterface**: Contract for implementations
14+
- **MessageStoreInterface** High-level conversation storage interface
15+
16+
### Key Features
17+
- **Bridge** (`src/Bridge/`): Storage capacity for messages and conversations
18+
19+
## Essential Commands
20+
21+
### Testing
22+
```bash
23+
vendor/bin/phpunit
24+
vendor/bin/phpunit tests/ChatTest.php
25+
vendor/bin/phpunit --coverage-html coverage/
26+
```
27+
28+
### Code Quality
29+
```bash
30+
vendor/bin/phpstan analyse
31+
cd ../../.. && vendor/bin/php-cs-fixer fix src/chat/
32+
```
33+
34+
## Processing Architecture
35+
36+
### Built-in bridges
37+
- **CacheStore**: PSR-16 compliant storage
38+
- **InMemoryStore**: In-memory storage
39+
- **SessionStore**: Symfony HttpFoundation session storage
40+
41+
## Dependencies
42+
43+
- **Platform component**: Required for AI communication
44+
- **Agent component**: Required for agent interaction
45+
- **Symfony**: HttpFoundation
46+
47+
## Testing Patterns
48+
49+
- Use `MockHttpClient` over response mocking
50+
- Test bridges independently
51+
- Prefer `self::assert*` in tests
52+
53+
## Development Notes
54+
55+
- Component is experimental (BC breaks possible)
56+
- Add `@author` tags to new classes
57+
- Use component-specific exceptions from `src/Exception/`
58+
- Follow `@Symfony` PHP CS Fixer rules

src/chat/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHANGELOG
2+
=========
3+
4+
0.1
5+
---
6+
7+
* Introduce the component

0 commit comments

Comments
 (0)