-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net: Support records with no key, fix issue with Relevance (#6393)
### Motivation and Context When using SemanticTextMemory.SaveReferenceAsync, no value is passed for the `Key` to use. In the Cosmos DB Memory Connector, we treat the "Key" as the Id and PartitionKey, and so it has to have a value. Address this by generating a `GUID` to use if none are provided. ### Description * Assign a GUID key when the passed in `MemoryRecord.Key` is null or empty so that CosmosDB always has a valid PartitionKey. * While adding test coverage for this I noticed two things: 1. `withEmbeddings` is ignored in `AzureCosmosDBNoSQLMemoryStore.GetAsync`. It's not clear whether it's worth changing this, as point reads like the current one tend to be less expensive than queries in Cosmos DB. 2. The SimilarityScore returned from `GetNearestAsync` wasn't actually a similarity, it was a cosine distance. Normalize that. Fixes #6379. ### Contribution Checklist - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Dmytro Struk <[email protected]>
- Loading branch information
1 parent
ddf1d46
commit 4adf3fe
Showing
3 changed files
with
146 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters