@@ -53,7 +53,7 @@ public function add(VectorDocument ...$documents): void
5353 }
5454
5555 /**
56- * @param array{where?: array<string, string>, whereDocument?: array<string, mixed>} $options
56+ * @param array{where?: array<string, string>, whereDocument?: array<string, mixed>, include?: array<string> } $options
5757 */
5858 public function query (Vector $ vector , array $ options = []): iterable
5959 {
@@ -63,13 +63,21 @@ public function query(Vector $vector, array $options = []): iterable
6363 nResults: 4 ,
6464 where: $ options ['where ' ] ?? null ,
6565 whereDocument: $ options ['whereDocument ' ] ?? null ,
66+ include : $ options ['include ' ] ?? null ,
6667 );
6768
68- for ($ i = 0 ; $ i < \count ($ queryResponse ->metadatas [0 ]); ++$ i ) {
69+ $ metaCount = \count ($ queryResponse ->metadatas [0 ]);
70+
71+ for ($ i = 0 ; $ i < $ metaCount ; ++$ i ) {
72+ $ metaData = new Metadata ($ queryResponse ->metadatas [0 ][$ i ]);
73+ if (isset ($ queryResponse ->documents [0 ][$ i ])) {
74+ $ metaData ->setText ($ queryResponse ->documents [0 ][$ i ]);
75+ }
76+
6977 yield new VectorDocument (
7078 id: Uuid::fromString ($ queryResponse ->ids [0 ][$ i ]),
7179 vector: new Vector ($ queryResponse ->embeddings [0 ][$ i ]),
72- metadata: new Metadata ( $ queryResponse -> metadatas [ 0 ][ $ i ]) ,
80+ metadata: $ metaData ,
7381 score: $ queryResponse ->distances [0 ][$ i ] ?? null ,
7482 );
7583 }
0 commit comments