Skip to content

Commit

Permalink
chore: update mvi control plane for create and list indexes protos (#518
Browse files Browse the repository at this point in the history
)

Updates MVI list and create indexes backend for latest changes. Updates protos but developer-facing API remains otherwise the same.
  • Loading branch information
malandis authored Nov 15, 2023
1 parent f1c5f3f commit 34940fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/Momento.Sdk/Internal/VectorIndexControlClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ public async Task<CreateIndexResponse> CreateIndexAsync(string indexName, long n
_logger.LogTraceVectorIndexRequest("createVectorIndex", indexName);
CheckValidIndexName(indexName);
var validatedNumDimensions = ValidateNumDimensions(numDimensions);
var request = new _CreateIndexRequest { IndexName = indexName, NumDimensions = validatedNumDimensions };
var request = new _CreateIndexRequest { IndexName = indexName, NumDimensions = validatedNumDimensions, SimilarityMetric = new _SimilarityMetric() };
switch (similarityMetric)
{
case SimilarityMetric.CosineSimilarity:
request.CosineSimilarity = new _CreateIndexRequest.Types._CosineSimilarity();
request.SimilarityMetric.CosineSimilarity = new _SimilarityMetric.Types._CosineSimilarity();
break;
case SimilarityMetric.InnerProduct:
request.InnerProduct = new _CreateIndexRequest.Types._InnerProduct();
request.SimilarityMetric.InnerProduct = new _SimilarityMetric.Types._InnerProduct();
break;
case SimilarityMetric.EuclideanSimilarity:
request.EuclideanSimilarity = new _CreateIndexRequest.Types._EuclideanSimilarity();
request.SimilarityMetric.EuclideanSimilarity = new _SimilarityMetric.Types._EuclideanSimilarity();
break;
default:
throw new InvalidArgumentException($"Unknown similarity metric {similarityMetric}");
}

await grpcManager.Client.CreateIndexAsync(request, new CallOptions(deadline: CalculateDeadline()));
return _logger.LogTraceVectorIndexRequestSuccess("createVectorIndex", indexName, new CreateIndexResponse.Success());
}
Expand All @@ -71,7 +71,7 @@ public async Task<ListIndexesResponse> ListIndexesAsync()
var response = await grpcManager.Client.ListIndexesAsync(request, new CallOptions(deadline: CalculateDeadline()));
return _logger.LogTraceGenericRequestSuccess("listVectorIndexes",
new ListIndexesResponse.Success(
new List<IndexInfo>(response.IndexNames.Select(n => new IndexInfo(n)))));
new List<IndexInfo>(response.Indexes.Select(n => new IndexInfo(n.IndexName)))));
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Momento.Sdk/Momento.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.49.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageReference Include="Momento.Protos" Version="0.94.1" />
<PackageReference Include="Momento.Protos" Version="0.96.0" />
<PackageReference Include="JWT" Version="9.0.3" />
<PackageReference Include="System.Threading.Channels" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
Expand Down

0 comments on commit 34940fb

Please sign in to comment.