Skip to content

Commit

Permalink
custom Postgres filtering logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dluc committed Nov 24, 2023
1 parent e57c3ae commit 711dcc1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
26 changes: 26 additions & 0 deletions PostgresMemoryStorage/PostgresMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ public Task<string> UpsertAsync(
bool withEmbeddings = false,
CancellationToken cancellationToken = default)
{
if (filters != null)
{
foreach (MemoryFilter filter in filters)
{
if (filter is PostgresMemoryFilter extendedFilter)
{
// use PostgresMemoryFilter filtering logic
}

// use MemoryFilter filtering logic
}
}

throw new NotImplementedException();
}

Expand All @@ -83,6 +96,19 @@ public IAsyncEnumerable<MemoryRecord> GetListAsync(
bool withEmbeddings = false,
CancellationToken cancellationToken = default)
{
if (filters != null)
{
foreach (MemoryFilter filter in filters)
{
if (filter is PostgresMemoryFilter extendedFilter)
{
// use PostgresMemoryFilter filtering logic
}

// use MemoryFilter filtering logic
}
}

throw new NotImplementedException();
}

Expand Down
11 changes: 11 additions & 0 deletions PostgresMemoryStorage/PostgresMemoryFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.

namespace Microsoft.KernelMemory.Postgres;

/// <summary>
/// Extended filtering options available when using Postgres
/// </summary>
public class PostgresMemoryFilter : MemoryFilter
{
// ...
}

0 comments on commit 711dcc1

Please sign in to comment.