Skip to content

Commit

Permalink
New+Optional memorydb interface to support batch memories upset (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
dluc authored Apr 27, 2024
1 parent ccbc801 commit b31638e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nuget-package.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<!-- Central version prefix - applies to all nuget packages. -->
<Version>0.38.0</Version>
<Version>0.39.0</Version>

<!-- These are set at the project level-->
<IsPackable>false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion service/Abstractions/MemoryStorage/IMemoryDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Task DeleteIndexAsync(
CancellationToken cancellationToken = default);

/// <summary>
/// Insert/Update a vector + payload, creates the given index if it does not exist.
/// Insert/Update a vector + payload.
/// </summary>
/// <param name="index">Index/Collection name</param>
/// <param name="record">Vector + payload to save</param>
Expand Down
27 changes: 27 additions & 0 deletions service/Abstractions/MemoryStorage/IMemoryDbBatchUpsert.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Collections.Generic;
using System.Threading;

namespace Microsoft.KernelMemory.MemoryStorage;

/// <summary>
/// Interface for memory DB adapters supporting batch upsert.
/// The interface is not mandatory and not implemented by all connectors.
/// Handlers/Clients should check if the interface is available and leverage it to optimize throughput.
/// </summary>
public interface IMemoryDbBatchUpsert
{
/// <summary>
/// Insert/Update a list of vectors + payload.
/// </summary>
/// <param name="index">Index/Collection name</param>
/// <param name="records">Vectors + payload to save</param>
/// <param name="cancellationToken">Task cancellation token</param>
/// <returns>Record IDs</returns>
/// <exception cref="IndexNotFound">Error returned if the index where to write doesn't exist</exception>
IAsyncEnumerable<string> BatchUpsertAsync(
string index,
IEnumerable<MemoryRecord> records,
CancellationToken cancellationToken = default);
}

0 comments on commit b31638e

Please sign in to comment.