Skip to content

Commit

Permalink
feat: add vectorindex proto (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
virratanasangpunth authored Aug 8, 2023
1 parent dd54989 commit 43ec538
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 4 deletions.
1 change: 1 addition & 0 deletions csharp/Momento.Protos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Protobuf Include="../proto/cacheclient.proto" GrpcServices="Client" />
<Protobuf Include="../proto/controlclient.proto" GrpcServices="Client" />
<Protobuf Include="../proto/cacheping.proto" GrpcServices="Client" />
<Protobuf Include="../proto/vectorindex.proto" GrpcServices="Client" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion javascript-web/generate_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mkdir $out
# So we do a terrible hack to comment out the package declaration before generating the JS types,
# but add them back before generating the GRPC web bindings

proto_file_list=" extensions.proto cacheclient.proto controlclient.proto auth.proto cacheping.proto cachepubsub.proto "
proto_file_list=" extensions.proto cacheclient.proto controlclient.proto auth.proto cacheping.proto cachepubsub.proto vectorindex.proto "

echo "Backing up protos dir"
cp -r ../proto ../proto.bak
Expand Down
2 changes: 1 addition & 1 deletion javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
```bash
npm install
mkdir dist
PATH=node_modules/protoc-gen-ts/bin/:$PATH protoc -I=../proto --ts_out=dist cacheclient.proto controlclient.proto cachepubsub.proto
PATH=node_modules/protoc-gen-ts/bin/:$PATH protoc -I=../proto --ts_out=dist cacheclient.proto controlclient.proto cachepubsub.proto vectorindex.proto
```
2 changes: 1 addition & 1 deletion javascript/generate_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -e
set -x

PATH=node_modules/protoc-gen-ts/bin/:$PATH protoc -I=../proto -I=/usr/local/include --ts_out=src cacheclient.proto controlclient.proto cachepubsub.proto auth.proto cacheping.proto
PATH=node_modules/protoc-gen-ts/bin/:$PATH protoc -I=../proto -I=/usr/local/include --ts_out=src cacheclient.proto controlclient.proto cachepubsub.proto auth.proto cacheping.proto vectorindex.proto
63 changes: 63 additions & 0 deletions proto/vectorindex.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
syntax = "proto3";

package vectorindex;

service VectorIndex {
rpc UpsertItemBatch(UpsertItemBatchRequest) returns (UpsertItemBatchResponse) {}
rpc Search(SearchRequest) returns (SearchResponse) {}
}

message Item {
string id = 1;
Vector vector = 2;
repeated Metadata metadata = 3;
}

message UpsertItemBatchRequest {
string index_name = 1;
repeated Item items = 2;
}

message UpsertItemBatchResponse {
repeated uint32 error_indices = 1;
}

message Vector {
repeated float elements = 1;
}

message Metadata {
string field = 1;
oneof value {
// Eventually can support ints, dates, etc
string string_value = 2;
}
}

message MetadataRequest {
message Some {
repeated string fields = 1;
}
message All {}

oneof kind {
Some some = 2;
}
}

message SearchRequest {
string index_name = 1;
uint32 top_k = 2;
Vector query_vector = 3;
MetadataRequest metadata_fields = 4;
}

message SearchHit {
string id = 1;
float distance = 2;
repeated Metadata metadata = 3;
}

message SearchResponse {
repeated SearchHit hits = 1;
}
2 changes: 1 addition & 1 deletion python/run-protoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ do
if [[ $python_protobuf_version == "protobuf>4" ]]; then
pyi_out="--pyi_out=$src_path"
fi
poetry run python -m grpc_tools.protoc -I../proto --python_out=$src_path $pyi_out --grpc_python_out=$src_path extensions.proto cacheclient.proto controlclient.proto auth.proto cachepubsub.proto
poetry run python -m grpc_tools.protoc -I../proto --python_out=$src_path $pyi_out --grpc_python_out=$src_path extensions.proto cacheclient.proto controlclient.proto auth.proto cachepubsub.proto vectorindex.proto

# A shortcoming of the generated code is in the grpc generated code,
# the protobuf imports are absolute instead of relative.
Expand Down
1 change: 1 addition & 0 deletions rust/proto_generator/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fn main() {
format!("{proto_dir}/cacheclient.proto"),
format!("{proto_dir}/cachepubsub.proto"),
format!("{proto_dir}/controlclient.proto"),
format!("{proto_dir}/vectorindex.proto"),
],
&[proto_dir],
)
Expand Down

0 comments on commit 43ec538

Please sign in to comment.