Skip to content

Commit

Permalink
[ENH] Metadata segment GRPC reader
Browse files Browse the repository at this point in the history
  • Loading branch information
beggers committed Apr 22, 2024
1 parent ce5c6b3 commit a0f5429
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 9 deletions.
1 change: 1 addition & 0 deletions chromadb/server/fastapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ async def heartbeat(self) -> Dict[str, int]:

async def version(self) -> str:
return self._api.get_version()

def auth_and_get_tenant_and_database_for_request(
self,
headers: Headers,
Expand Down
73 changes: 64 additions & 9 deletions idl/chromadb/proto/chroma.proto
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,59 @@ message OperationRecord {
Operation operation = 4;
}

message VectorEmbeddingRecord {
string id = 1;
Vector vector = 3; // TODO: we need to rethink source of truth for vector dimensionality and encoding
/* Metadata Reader Interface */

service MetadataReader {
rpc GetMetadata(GetMetadataRequest) returns (GetMetadataResponse) {}
}

message VectorQueryResult {
string id = 1;
float distance = 3;
optional Vector vector = 4;
message GetMetadataRequest {
Where where = 1;
WhereDocument where_document = 2;
repeated string ids = 3;
optional int32 limit = 4;
optional int32 offset = 5;
}

message VectorQueryResults {
repeated VectorQueryResult results = 1;
enum WhereListType {
IN = 0;
NIN = 1;
}

enum WhereChildrenType {
AND = 0;
OR = 1;
}

// A `Where` clause for filtering metadata. A `Where` clause is a tree of
// `Where` clauses, where each node is exactly one of:
// - A leaf node with a key, a list of values, and a list type (IN or NIN)
// - An branch node with a list of children and a children type (AND or OR)
message Where {
// Metadata key
string key = 1;
// Allowed or disallowed metadata values
repeated string values = 2;
// Whether we're filtering IN or NIN `values`
WhereListType list_type = 3;
// Children of this `Where` clause
repeated Where children = 4;
// Whether children should be ANDed or ORed
WhereChildrenType children_type = 5;
}

message WhereDocument {
repeated string contains = 1;
repeated string not_contains = 2;
}

message GetMetadataResponse {
repeated MetadataEmbeddingRecord records = 1;
}

message MetadataEmbeddingRecord {
string id = 1;
UpdateMetadata metadata = 2;
}

/* Vector Reader Interface */
Expand All @@ -118,6 +158,11 @@ message GetVectorsResponse {
repeated VectorEmbeddingRecord records = 1;
}

message VectorEmbeddingRecord {
string id = 1;
Vector vector = 3; // TODO: we need to rethink source of truth for vector dimensionality and encoding
}

message QueryVectorsRequest {
repeated Vector vectors = 1;
int32 k = 2;
Expand All @@ -130,3 +175,13 @@ message QueryVectorsRequest {
message QueryVectorsResponse {
repeated VectorQueryResults results = 1;
}

message VectorQueryResults {
repeated VectorQueryResult results = 1;
}

message VectorQueryResult {
string id = 1;
float distance = 3;
optional Vector vector = 4;
}

0 comments on commit a0f5429

Please sign in to comment.