|
11 | 11 |
|
12 | 12 | use Doctrine\DBAL\DriverManager; |
13 | 13 | use Doctrine\DBAL\Tools\DsnParser; |
14 | | -use PhpLlm\LlmChain\Chain\Chain; |
15 | | -use PhpLlm\LlmChain\Chain\Toolbox\ChainProcessor; |
16 | | -use PhpLlm\LlmChain\Chain\Toolbox\Tool\SimilaritySearch; |
17 | | -use PhpLlm\LlmChain\Chain\Toolbox\Toolbox; |
18 | | -use PhpLlm\LlmChain\Platform\Bridge\Google\Embeddings; |
19 | | -use PhpLlm\LlmChain\Platform\Bridge\Google\Embeddings\TaskType; |
20 | | -use PhpLlm\LlmChain\Platform\Bridge\Google\Gemini; |
21 | | -use PhpLlm\LlmChain\Platform\Bridge\Google\PlatformFactory; |
22 | | -use PhpLlm\LlmChain\Platform\Message\Message; |
23 | | -use PhpLlm\LlmChain\Platform\Message\MessageBag; |
24 | | -use PhpLlm\LlmChain\Store\Bridge\MariaDB\Store; |
25 | | -use PhpLlm\LlmChain\Store\Document\Metadata; |
26 | | -use PhpLlm\LlmChain\Store\Document\TextDocument; |
27 | | -use PhpLlm\LlmChain\Store\Indexer; |
| 14 | +use Symfony\AI\Agent\Agent; |
| 15 | +use Symfony\AI\Agent\Toolbox\AgentProcessor; |
| 16 | +use Symfony\AI\Agent\Toolbox\Tool\SimilaritySearch; |
| 17 | +use Symfony\AI\Agent\Toolbox\Toolbox; |
| 18 | +use Symfony\AI\Platform\Bridge\Google\Embeddings; |
| 19 | +use Symfony\AI\Platform\Bridge\Google\Embeddings\TaskType; |
| 20 | +use Symfony\AI\Platform\Bridge\Google\Gemini; |
| 21 | +use Symfony\AI\Platform\Bridge\Google\PlatformFactory; |
| 22 | +use Symfony\AI\Platform\Message\Message; |
| 23 | +use Symfony\AI\Platform\Message\MessageBag; |
| 24 | +use Symfony\AI\Store\Bridge\MariaDB\Store; |
| 25 | +use Symfony\AI\Store\Document\Metadata; |
| 26 | +use Symfony\AI\Store\Document\TextDocument; |
| 27 | +use Symfony\AI\Store\Document\Vectorizer; |
| 28 | +use Symfony\AI\Store\Indexer; |
28 | 29 | use Symfony\Component\Dotenv\Dotenv; |
29 | 30 | use Symfony\Component\Uid\Uuid; |
30 | 31 |
|
|
66 | 67 | // create embeddings for documents |
67 | 68 | $platform = PlatformFactory::create($_ENV['GOOGLE_API_KEY']); |
68 | 69 | $embeddings = new Embeddings(options: ['dimensions' => 768, 'task_type' => TaskType::SemanticSimilarity]); |
69 | | -$indexer = new Indexer($platform, $embeddings, $store); |
| 70 | +$vectorizer = new Vectorizer($platform, $embeddings); |
| 71 | +$indexer = new Indexer($vectorizer, $store); |
70 | 72 | $indexer->index($documents); |
71 | 73 |
|
72 | 74 | $model = new Gemini(Gemini::GEMINI_2_FLASH_LITE); |
73 | 75 |
|
74 | 76 | $similaritySearch = new SimilaritySearch($platform, $embeddings, $store); |
75 | 77 | $toolbox = Toolbox::create($similaritySearch); |
76 | | -$processor = new ChainProcessor($toolbox); |
77 | | -$chain = new Chain($platform, $model, [$processor], [$processor]); |
| 78 | +$processor = new AgentProcessor($toolbox); |
| 79 | +$agent = new Agent($platform, $model, [$processor], [$processor]); |
78 | 80 |
|
79 | 81 | $messages = new MessageBag( |
80 | 82 | Message::forSystem('Please answer all user questions only using SimilaritySearch function.'), |
81 | 83 | Message::ofUser('Which movie fits the theme of the mafia?') |
82 | 84 | ); |
83 | | -$response = $chain->call($messages); |
| 85 | +$response = $agent->call($messages); |
84 | 86 |
|
85 | 87 | echo $response->getContent().\PHP_EOL; |
0 commit comments