Skip to content

[Store] Bridge ChromaDB - The query method should return more than 4 results #812

@YannickDurden

Description

@YannickDurden

Hi,

I'm using ChromaDB bridge and the query method return only 4 results. Why this value has been hardcoded ?

Here the expected code:

/**
 * @param array{where?: array<string, string>, whereDocument?: array<string, mixed>, nResults?: int} $options
 */
public function query(Vector $vector, array $options = []): array
{
    $collection = $this->client->getOrCreateCollection($this->collectionName);
    $queryResponse = $collection->query(
        queryEmbeddings: [$vector->getData()],
        nResults: $options['nResults'] ?? 4, // if no limit (aka nResults) passed, use the hardcoded value
        where: $options['where'] ?? null,
        whereDocument: $options['whereDocument'] ?? null,
    );

    $documents = [];
    for ($i = 0; $i < \count($queryResponse->metadatas[0]); ++$i) {
        $documents[] = new VectorDocument(
            id: Uuid::fromString($queryResponse->ids[0][$i]),
            vector: new Vector($queryResponse->embeddings[0][$i]),
            metadata: new Metadata($queryResponse->metadatas[0][$i]),
        );
    }

    return $documents;
}

What do you think about that? I'm able to create the PR. Just tell me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)StoreIssues & PRs about the AI Store component

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions