|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +use Symfony\AI\Agent\Agent; |
| 13 | +use Symfony\AI\Platform\Bridge\Albert\PlatformFactory; |
| 14 | +use Symfony\AI\Platform\Bridge\OpenAI\GPT; |
| 15 | +use Symfony\AI\Platform\Message\Message; |
| 16 | +use Symfony\AI\Platform\Message\MessageBag; |
| 17 | + |
| 18 | +require_once dirname(__DIR__).'/../vendor/autoload.php'; |
| 19 | + |
| 20 | +if (!isset($_SERVER['ALBERT_API_KEY'], $_SERVER['ALBERT_API_URL'])) { |
| 21 | + echo 'Please set the ALBERT_API_KEY and ALBERT_API_URL environment variable (e.g., https://your-albert-instance.com/v1).'.\PHP_EOL; |
| 22 | + exit(1); |
| 23 | +} |
| 24 | + |
| 25 | +$platform = PlatformFactory::create($_SERVER['ALBERT_API_KEY'], $_SERVER['ALBERT_API_URL']); |
| 26 | + |
| 27 | +$model = new GPT('gpt-4o'); |
| 28 | +$agent = new Agent($platform, $model); |
| 29 | + |
| 30 | +$documentContext = <<<'CONTEXT' |
| 31 | + Document: AI Strategy of France |
| 32 | +
|
| 33 | + France has launched a comprehensive national AI strategy with the following key objectives: |
| 34 | + 1. Strengthening the AI ecosystem and attracting talent |
| 35 | + 2. Developing sovereign AI capabilities |
| 36 | + 3. Ensuring ethical and responsible AI development |
| 37 | + 4. Supporting AI adoption in public services |
| 38 | + 5. Investing €1.5 billion in AI research and development |
| 39 | +
|
| 40 | + The Albert project is part of this strategy, providing a sovereign AI solution for French public administration. |
| 41 | + CONTEXT; |
| 42 | + |
| 43 | +$messages = new MessageBag( |
| 44 | + Message::forSystem( |
| 45 | + 'You are an AI assistant with access to documents about French AI initiatives. '. |
| 46 | + 'Use the provided context to answer questions accurately.' |
| 47 | + ), |
| 48 | + Message::ofUser($documentContext), |
| 49 | + Message::ofUser('What are the main objectives of France\'s AI strategy?'), |
| 50 | +); |
| 51 | + |
| 52 | +$response = $agent->call($messages); |
| 53 | + |
| 54 | +echo $response->getContent().\PHP_EOL; |
0 commit comments