@@ -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 = []): array
5959 {
@@ -63,14 +63,22 @@ public function query(Vector $vector, array $options = []): array
6363 nResults: 4 ,
6464 where: $ options ['where ' ] ?? null ,
6565 whereDocument: $ options ['whereDocument ' ] ?? null ,
66+ include : $ options ['include ' ] ?? null ,
6667 );
6768
6869 $ documents = [];
69- for ($ i = 0 ; $ i < \count ($ queryResponse ->metadatas [0 ]); ++$ i ) {
70+ $ metaCount = \count ($ queryResponse ->metadatas [0 ]);
71+
72+ for ($ i = 0 ; $ i < $ metaCount ; ++$ i ) {
73+ $ metaData = new Metadata ($ queryResponse ->metadatas [0 ][$ i ]);
74+ if (isset ($ queryResponse ->documents [0 ][$ i ])) {
75+ $ metaData ->setText ($ queryResponse ->documents [0 ][$ i ]);
76+ }
77+
7078 $ documents [] = new VectorDocument (
7179 id: Uuid::fromString ($ queryResponse ->ids [0 ][$ i ]),
7280 vector: new Vector ($ queryResponse ->embeddings [0 ][$ i ]),
73- metadata: new Metadata ( $ queryResponse -> metadatas [ 0 ][ $ i ]) ,
81+ metadata: $ metaData ,
7482 );
7583 }
7684
0 commit comments