12
12
namespace App \Blog \Command ;
13
13
14
14
use Codewithkyrian \ChromaDB \Client ;
15
- use Symfony \AI \Platform \Bridge \OpenAi \Embeddings ;
16
- use Symfony \AI \Platform \PlatformInterface ;
15
+ use Symfony \AI \Store \Document \VectorizerInterface ;
17
16
use Symfony \Component \Console \Attribute \AsCommand ;
18
17
use Symfony \Component \Console \Command \Command ;
19
18
use Symfony \Component \Console \Style \SymfonyStyle ;
19
+ use Symfony \Component \DependencyInjection \Attribute \Autowire ;
20
20
21
21
#[AsCommand('app:blog:query ' , description: 'Test command for querying the blog collection in Chroma DB. ' )]
22
- final class QueryCommand
22
+ final readonly class QueryCommand
23
23
{
24
24
public function __construct (
25
- private readonly Client $ chromaClient ,
26
- private readonly PlatformInterface $ platform ,
25
+ private Client $ chromaClient ,
26
+ #[Autowire(service: 'ai.vectorizer.openai ' )]
27
+ private VectorizerInterface $ vectorizer ,
27
28
) {
28
29
}
29
30
@@ -44,9 +45,9 @@ public function __invoke(SymfonyStyle $io): int
44
45
$ io ->comment (\sprintf ('Converting "%s" to vector & searching in Chroma DB ... ' , $ search ));
45
46
$ io ->comment ('Results are limited to 4 most similar documents. ' );
46
47
47
- $ platformResponse = $ this ->platform -> invoke ( new Embeddings (Embeddings:: TEXT_3_SMALL ), $ search );
48
+ $ vector = $ this ->vectorizer -> vectorize ( $ search );
48
49
$ queryResponse = $ collection ->query (
49
- queryEmbeddings: [$ platformResponse -> asVectors ()[ 0 ] ->getData ()],
50
+ queryEmbeddings: [$ vector ->getData ()],
50
51
nResults: 4 ,
51
52
);
52
53
0 commit comments