mirror of
https://github.com/symfony/ai.git
synced 2026-03-23 23:42:18 +01:00
33 lines
962 B
PHP
33 lines
962 B
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\Platform\Bridge\Perplexity\PlatformFactory;
|
|
use Symfony\AI\Platform\Message\Content\DocumentUrl;
|
|
use Symfony\AI\Platform\Message\Message;
|
|
use Symfony\AI\Platform\Message\MessageBag;
|
|
|
|
require_once __DIR__.'/bootstrap.php';
|
|
|
|
$platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client());
|
|
|
|
$messages = new MessageBag(
|
|
Message::ofUser(
|
|
new DocumentUrl('https://upload.wikimedia.org/wikipedia/commons/2/20/Re_example.pdf'),
|
|
'What is this document about?',
|
|
),
|
|
);
|
|
$result = $platform->invoke('sonar', $messages);
|
|
|
|
echo $result->asText().\PHP_EOL;
|
|
|
|
print_search_results($result->getMetadata()->get('search_results'));
|
|
print_citations($result->getMetadata()->get('citations'));
|