mirror of
https://github.com/symfony/ai.git
synced 2026-03-23 23:42:18 +01:00
39 lines
1.2 KiB
PHP
39 lines
1.2 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\Platform\Bridge\LMStudio\Completions;
|
|
use Symfony\AI\Platform\Bridge\LMStudio\PlatformFactory;
|
|
use Symfony\AI\Platform\Capability;
|
|
use Symfony\AI\Platform\Message\Content\Image;
|
|
use Symfony\AI\Platform\Message\Message;
|
|
use Symfony\AI\Platform\Message\MessageBag;
|
|
|
|
require_once dirname(__DIR__).'/bootstrap.php';
|
|
|
|
$platform = PlatformFactory::create(env('LMSTUDIO_HOST_URL'), http_client());
|
|
$model = new Completions(
|
|
name: 'gemma-3-4b-it-qat',
|
|
capabilities: [...Completions::DEFAULT_CAPABILITIES, Capability::INPUT_IMAGE]
|
|
);
|
|
|
|
$agent = new Agent($platform, $model, logger: logger());
|
|
$messages = new MessageBag(
|
|
Message::forSystem('You are an image analyzer bot that helps identify the content of images.'),
|
|
Message::ofUser(
|
|
'Describe the image as a comedian would do it.',
|
|
Image::fromFile(dirname(__DIR__, 2).'/fixtures/image.jpg'),
|
|
),
|
|
);
|
|
$response = $agent->call($messages);
|
|
|
|
echo $response->getContent().\PHP_EOL;
|