Skip to content

Commit 8189888

Browse files
committed
always add default values and merge user inputs
1 parent f32bfa5 commit 8189888

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/store/src/Bridge/ChromaDb/Store.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,22 @@ public function add(VectorDocument ...$documents): void
5757
*/
5858
public function query(Vector $vector, array $options = []): iterable
5959
{
60+
$include ??= ['embeddings', 'metadatas', 'distances'];
61+
if ([] !== ($options['include'] ?? [])) {
62+
$include = array_values(
63+
array_unique(
64+
array_merge($include, $options['include'])
65+
)
66+
);
67+
}
68+
6069
$collection = $this->client->getOrCreateCollection($this->collectionName);
6170
$queryResponse = $collection->query(
6271
queryEmbeddings: [$vector->getData()],
6372
nResults: 4,
6473
where: $options['where'] ?? null,
6574
whereDocument: $options['whereDocument'] ?? null,
66-
include: $options['include'] ?? null,
75+
include: $include,
6776
);
6877

6978
$metaCount = \count($queryResponse->metadatas[0]);

0 commit comments

Comments
 (0)