You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-66Lines changed: 40 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Perfect for building chatbots, AI agents, CLI wizards, or any system that guides
8
8
9
9
Agent Rules provides a logical processing unit for handling **unstructured input in a structured and interactive way**. It enables you to define validation rules that can request missing information, enforce business logic, and provide intelligent feedback to users or AI agents.
10
10
11
-
Built on top of[Symfony AI Agent](https://github.com/symfony/ai-agent), this library integrates seamlessly with AI-powered tools and conversational interfaces.
11
+
Built to be compatible with[Symfony AI Agent](https://github.com/symfony/ai-agent), this library integrates seamlessly with AI-powered tools and conversational interfaces.
12
12
13
13
## Key Features
14
14
@@ -17,7 +17,7 @@ Built on top of [Symfony AI Agent](https://github.com/symfony/ai-agent), this li
17
17
-**Interactive Feedback**: Rules can request missing data with structured result types
18
18
-**Composable Logic**: Combine rules with `Sequence` (AND), `Any` (OR), and `Either` patterns
19
19
-**Type-Safe**: Full PHP 8.4+ type safety with readonly classes and generic support
20
-
-**AI Agent Integration**: Built-in support for Symfony AI Agent's source tracking and tool system
20
+
-**Framework Agnostic**: Works independently with optional Symfony AI integration
21
21
22
22
## Installation
23
23
@@ -247,66 +247,36 @@ The engine automatically:
247
247
- Detects cyclic dependencies
248
248
- Validates that all dependencies exist
249
249
250
-
## Integration with Symfony AI Agent
250
+
## Adding Context with Sources
251
251
252
-
### Creating an AI Tool
252
+
You can attach contextual information to results that helps users or AI agents understand where to find more information:
253
253
254
254
```php
255
-
use Symfony\AI\Agent\Toolbox\Attribute\AsTool;
256
-
use Symfony\AI\Agent\Toolbox\Source\HasSourcesInterface;
257
-
use Symfony\AI\Agent\Toolbox\Source\HasSourcesTrait;
255
+
use Phpro\AgentRules\Source\Source;
258
256
259
-
#[AsTool(
260
-
name: 'validate_order',
261
-
description: 'Validates customer order information and guides through missing data.'
262
-
)]
263
-
final class OrderValidationTool implements HasSourcesInterface
264
-
{
265
-
use HasSourcesTrait;
266
-
267
-
public function __construct(
268
-
private RuleEngine $ruleEngine,
269
-
) {}
270
-
271
-
public function __invoke(
272
-
string $email,
273
-
?string $productId = null,
274
-
?int $quantity = null,
275
-
): ResultInterface {
276
-
$request = new OrderRequest($email, $productId, $quantity);
0 commit comments