mirror of
https://github.com/symfony/ai.git
synced 2026-03-23 23:42:18 +01:00
33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
use Symfony\AI\Agent\Agent;
|
|
use Symfony\AI\Agent\Bridge\Wikipedia\Wikipedia;
|
|
use Symfony\AI\Agent\Toolbox\AgentProcessor;
|
|
use Symfony\AI\Agent\Toolbox\Toolbox;
|
|
use Symfony\AI\Platform\Bridge\DockerModelRunner\PlatformFactory;
|
|
use Symfony\AI\Platform\Message\Message;
|
|
use Symfony\AI\Platform\Message\MessageBag;
|
|
|
|
require_once dirname(__DIR__).'/bootstrap.php';
|
|
|
|
$platform = PlatformFactory::create(env('DOCKER_MODEL_RUNNER_HOST_URL'), http_client());
|
|
|
|
$wikipedia = new Wikipedia(http_client());
|
|
$toolbox = new Toolbox([$wikipedia]);
|
|
$processor = new AgentProcessor($toolbox);
|
|
$agent = new Agent($platform, 'ai/gemma3n', [$processor], [$processor]);
|
|
|
|
$messages = new MessageBag(Message::ofUser('Who is the actual Prime Minister of France?'));
|
|
$result = $agent->call($messages);
|
|
|
|
echo $result->getContent().\PHP_EOL;
|