|
| 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\Agent\Toolbox\AgentProcessor; |
| 14 | +use Symfony\AI\Agent\Toolbox\Tool\Clock; |
| 15 | +use Symfony\AI\Agent\Toolbox\Toolbox; |
| 16 | +use Symfony\AI\Platform\Bridge\VertexAi\Gemini\Model; |
| 17 | +use Symfony\AI\Platform\Bridge\VertexAi\PlatformFactory; |
| 18 | +use Symfony\AI\Platform\Message\Message; |
| 19 | +use Symfony\AI\Platform\Message\MessageBag; |
| 20 | + |
| 21 | +require_once __DIR__.'/bootstrap.php'; |
| 22 | + |
| 23 | +$platform = PlatformFactory::create(env('GOOGLE_CLOUD_LOCATION'), env('GOOGLE_CLOUD_PROJECT'), adc_aware_http_client()); |
| 24 | + |
| 25 | +$model = new Model(Model::GEMINI_2_5_PRO); |
| 26 | + |
| 27 | +$toolbox = new Toolbox([new Clock()], logger: logger()); |
| 28 | +$processor = new AgentProcessor($toolbox); |
| 29 | +$agent = new Agent($platform, $model, [$processor], [$processor], logger()); |
| 30 | + |
| 31 | +$content = file_get_contents('https://www.euribor-rates.eu/en/current-euribor-rates/4/euribor-rate-12-months/'); |
| 32 | +$messages = new MessageBag( |
| 33 | + Message::ofUser("Based on the following page content, what was the 12-month Euribor rate a week ago?\n\n".$content) |
| 34 | +); |
| 35 | + |
| 36 | +$result = $agent->call($messages); |
| 37 | + |
| 38 | +echo $result->getContent().\PHP_EOL; |
0 commit comments