|
9 | 9 | * file that was distributed with this source code. |
10 | 10 | */ |
11 | 11 |
|
12 | | -use Symfony\AI\Agent\Agent; |
13 | 12 | use Symfony\AI\Platform\Bridge\Perplexity\PlatformFactory; |
14 | | -use Symfony\AI\Platform\Bridge\Perplexity\SearchResultProcessor; |
15 | 13 | use Symfony\AI\Platform\Message\Message; |
16 | 14 | use Symfony\AI\Platform\Message\MessageBag; |
17 | 15 |
|
18 | 16 | require_once dirname(__DIR__).'/bootstrap.php'; |
19 | 17 |
|
20 | 18 | $platform = PlatformFactory::create(env('PERPLEXITY_API_KEY'), http_client()); |
21 | | -$agent = new Agent($platform, 'sonar', outputProcessors: [new SearchResultProcessor()]); |
22 | 19 |
|
23 | 20 | $messages = new MessageBag(Message::ofUser('What is the best French cheese of the first quarter-century of 21st century?')); |
24 | | -$response = $agent->call($messages, [ |
| 21 | +$result = $platform->invoke('sonar', $messages, [ |
25 | 22 | 'search_mode' => 'academic', |
26 | 23 | 'search_after_date_filter' => '01/01/2000', |
27 | 24 | 'search_before_date_filter' => '01/01/2025', |
28 | 25 | ]); |
29 | 26 |
|
30 | | -echo $response->getContent().\PHP_EOL; |
| 27 | +echo $result->asText().\PHP_EOL; |
31 | 28 | echo \PHP_EOL; |
32 | 29 |
|
33 | | -perplexity_print_search_results($response->getMetadata()); |
34 | | -perplexity_print_citations($response->getMetadata()); |
| 30 | +perplexity_print_search_results($result->getMetadata()); |
| 31 | +perplexity_print_citations($result->getMetadata()); |
0 commit comments