Skip to content

Commit

Permalink
Adding filtering to memory (#1)
Browse files Browse the repository at this point in the history
* Adding draft filtering changes

* Adding new qdrant filter class and general MemoryFilter

* Changing approach to QdrantFilter as a generic argument for IMemoryStore

* Adding generic memory storage available in the context.

* Adding json attributes to qdrant filter object

* Adding filterable memory getter to kernel plus missing comments.

* Styling changes; Tests fixed

* Missing IValidatable in RangeCondition

* Making System.Text.Json serialize properties of Condition-derived classes in QdrantFilter

* Creating filterable SemanticTextMemory

* Creating ISemanticTextMemory moved to a separate method

* Using JsonDerivedTypeAttribute for QdrantFilter conditions

* Test added + styling changes

* Allowing empty Conditions in QdrantFilter

* Update IMemoryStore.cs
  • Loading branch information
piotrek-appstream authored Jul 7, 2023
1 parent 5cae285 commit 6397f26
Show file tree
Hide file tree
Showing 137 changed files with 5,032 additions and 6,856 deletions.
33 changes: 31 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,57 @@

version: 2
updates:
# Maintain dependencies for nuget
- package-ecosystem: "nuget"
directory: "samples/apps/copilot-chat-app/webapi"
schedule:
interval: "weekly"
day: "monday"
labels:
- "copilot chat"
- "dependencies"

# Maintain dependencies for nuget
- package-ecosystem: "nuget"
directory: "dotnet/"
schedule:
interval: "weekly"
day: "monday"
ignore:
# For all System.* and Microsoft.Extensions/Bcl.* packages, ignore all major version updates
- dependency-name: "System.*"
update-types: ["version-update:semver-major"]
- dependency-name: "Microsoft.Extensions.*"
update-types: ["version-update:semver-major"]
- dependency-name: "Microsoft.Bcl.*"
update-types: ["version-update:semver-major"]
labels:
- ".NET"
- "dependencies"

# Maintain dependencies for nuget
- package-ecosystem: "nuget"
directory: "samples/"
directory: "samples/dotnet"
schedule:
interval: "weekly"

day: "monday"

# Maintain dependencies for npm
- package-ecosystem: "npm"
directory: "samples/apps"
schedule:
interval: "weekly"
day: "monday"

# Maintain dependencies for pip
- package-ecosystem: "pip"
directory: "python/"
schedule:
interval: "weekly"
day: "monday"
labels:
- "python"
- "dependencies"

# Maintain dependencies for github-actions
- package-ecosystem: "github-actions"
Expand All @@ -36,3 +64,4 @@ updates:
directory: "/"
schedule:
interval: "weekly"
day: "monday"
31 changes: 24 additions & 7 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Add 'kernel' label to any change within Connectors, Extensions, Skills, and tests directories
kernel:
- "dotnet/src/Connectors/**/*"
- "dotnet/src/Extensions/**/*"
- "dotnet/src/Skills/**/*"
- "dotnet/src/IntegrationTests/**/*"
- "dotnet/src/SemanticKernel.UnitTests/**/*"
- dotnet/src/Connectors/**/*
- dotnet/src/Extensions/**/*
- dotnet/src/Skills/**/*
- dotnet/src/IntegrationTests/**/*
- dotnet/src/SemanticKernel.UnitTests/**/*

# Add 'kernel.core' label to any change within the 'SemanticKernel', 'SemanticKernel.Abstractions', or 'SemanticKernel.MetaPackage' directories
kernel.core:
Expand All @@ -16,11 +16,28 @@ kernel.core:
python:
- python/**/*

# Add 'java' label to any change within the 'java' directory
java:
- java/**/*

# Add 'samples' label to any change within the 'samples' directory
samples:
- samples/**/*

# Add '.NET' label to any change within samples or kernel 'dotnet' directories.
.NET:
- dotnet/src/**/*
- samples/**/dotnet/**/*
- dotnet/**/*

# Add 'copilot chat' label to any change within the 'samples/apps/copilot-chat-app' directory
copilot chat:
- samples/apps/copilot-chat-app/**/*

# Add 'documentation' label to any change within the 'docs' directory, or any '.md' files
documentation:
- docs/**/*
- '**/*.md'

# Add 'memory' label to any memory connectors in dotnet/ or python/
memory:
- dotnet/src/Connectors/Connectors.Memory.*/**/*
- python/semantic_kernel/connectors/memory/**/*
2 changes: 0 additions & 2 deletions .github/workflows/dotnet-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ on:
paths:
- 'dotnet/**'
- 'samples/dotnet/**'
- '**.cs'
- '**.csproj'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/java-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ jobs:
pull-requests: write

steps:
- name: Check for command
id: command
uses: xt0rted/slash-command-action@v2
continue-on-error: true
with:
command: spotless
reaction-type: "eyes"

- name: Get command
env:
BODY: ${{ github.event.comment.body }}
Expand Down Expand Up @@ -77,4 +85,4 @@ jobs:
"
gh pr comment $NUMBER --body "$body"
fi
working-directory: java
working-directory: java
44 changes: 44 additions & 0 deletions .github/workflows/label-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Label issues
on:
issues:
types:
- reopened
- opened

jobs:
label_issues:
name: "Issue: add labels"
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v6
with:
script: |
// Get the issue body and title
const body = context.payload.issue.body
let title = context.payload.issue.title
// Define the labels array
let labels = ["triage"]
// Check if the body or the title contains the word 'python' (case-insensitive)
if (body.match(/python/i) || title.match(/python/i)) {
// Add the 'python' label to the array
labels.push("python")
}
// Check if the body or the title contains the word 'java' (case-insensitive)
if (body.match(/java/i) || title.match(/java/i)) {
// Add the 'java' label to the array
labels.push("java")
}
// Add the labels to the issue
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
});
97 changes: 97 additions & 0 deletions .github/workflows/label-title-prefix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Label title prefix
on:
issues:
types: [ labeled ]
pull_request:
types: [ labeled ]

jobs:
add_title_prefix:
name: "Issue/PR: add title prefix"
# Define a matrix of label and prefix pairs
strategy:
matrix:
include:
- {label: 'python', prefix: 'Python'}
- {label: 'java', prefix: 'Java'}
- {label: '.NET', prefix: '.Net'}
- {label: 'copilot chat', prefix: 'Copilot Chat'}

runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/github-script@v6
name: "Issue/PR: update title"
with:
script: |
// Get the label and prefix from the matrix
const label = '${{ matrix.label }}'
const prefix = '${{ matrix.prefix }}'
labelAdded = context.payload.label.name
// Write the contents of context to console
core.info(JSON.stringify(context, null, 2))
// Get the event name, title and labels
let title
switch(context.eventName) {
case 'issues':
title = context.payload.issue.title
break
case 'pull_request':
title = context.payload.pull_request.title
break
default:
core.setFailed('Unrecognited eventName: ' + context.eventName)
}
let originalTitle = title
// Update the title based on the label and prefix
// Check if the issue or PR has the label
if (labelAdded == label) {
// Check if the title starts with the prefix (case-sensitive)
if (!title.startsWith(prefix + ": ")) {
// If not, check if the first word is the label (case-insensitive)
if (title.match(new RegExp(`^${prefix}`, 'i'))) {
// If yes, replace it with the prefix (case-sensitive)
title = title.replace(new RegExp(`^${prefix}`, 'i'), prefix)
} else {
// If not, prepend the prefix to the title
title = prefix + ": " + title
}
}
}
// Update the issue or PR title, if changed
if (title != originalTitle ) {
switch(context.eventName) {
case 'issues':
github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
title: title
});
break
case 'pull_request':
try {
github.rest.pulls.update({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
title: title
});
}
catch (err) {
core.info("Update PR title failed: " + err.message)
}
break
default:
core.setFailed('Unrecognited eventName: ' + context.eventName)
}
}
6 changes: 2 additions & 4 deletions .github/workflows/node-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ jobs:
yarndirs=()
for lockfile in samples/apps/**/yarn.lock; do # loop over all yarn.lock files
dir=$(dirname "$lockfile") # get the directory of the lock file
if [[ "$dir" != "samples/apps" ]]; then # exclude samples/apps directory
echo "Found yarn project in $dir"
yarndirs+=("$dir") # add the directory to the yarndirs array
fi
echo "Found yarn project in $dir"
yarndirs+=("$dir") # add the directory to the yarndirs array
done
echo "All yarn projects found: '${yarndirs[*]}'"
Expand Down
Loading

0 comments on commit 6397f26

Please sign in to comment.