Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python SK: Simplify memory_store_base #684

Merged

Conversation

awharrison-28
Copy link
Contributor

@awharrison-28 awharrison-28 commented Apr 26, 2023

Motivation and Context

This PR significantly reduces the complexity of implementing a new memory store. Previously, memory stores needed to implement EmbeddingIndexBase, DataStoreBase, and MemoryStoreBase. Now, memory stores only need to implement MemoryStoreBase. This PR also brings MemoryStoreBase to parity with the .NET IMemoryStore interface.

Description

  • Removed data_entry.py, data_store_base.py, volatile_data_store.py, and embedding_index_base.py
  • Added with_embedding parameter to all get/search methods. Passing the embedding between the application and storage is not optional and defaults to False
  • MemoryStoreBase (Python SK) == IMemoryStore (.NET SK)
  • Updated volatile_memory_store to implement MemoryStoreBase
  • Removed ABC from MemoryStoreBase
  • Added documentation to memory files

Closes #670

Contribution Checklist

python/semantic_kernel/memory/memory_store_base.py Outdated Show resolved Hide resolved
alexchaomander
alexchaomander previously approved these changes Apr 27, 2023
Copy link
Contributor

@alexchaomander alexchaomander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I think just need to remove the unnecessary TODOs

python/semantic_kernel/memory/memory_store_base.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added the kernel Issues or pull requests impacting the core kernel label Apr 28, 2023
alexchaomander
alexchaomander previously approved these changes Apr 28, 2023
@lemillermicrosoft lemillermicrosoft added the PR: feedback to address Waiting for PR owner to address comments/questions label Apr 28, 2023
@lemillermicrosoft
Copy link
Member

Looks like there are some lint failures to address.

@github-actions github-actions bot removed the kernel Issues or pull requests impacting the core kernel label Apr 28, 2023
@lemillermicrosoft lemillermicrosoft merged commit b6db9a2 into microsoft:main Apr 28, 2023
@awharrison-28 awharrison-28 deleted the python/simplifiy_memory_base branch April 28, 2023 18:10
dluc pushed a commit that referenced this pull request Apr 29, 2023
### Motivation and Context
This PR significantly reduces the complexity of implementing a new
memory store. Previously, memory stores needed to implement
EmbeddingIndexBase, DataStoreBase, and MemoryStoreBase. Now, memory
stores only need to implement MemoryStoreBase. This PR also brings
MemoryStoreBase to parity with the .NET IMemoryStore interface.


### Description
- Removed `data_entry.py`, `data_store_base.py`,
`volatile_data_store.py`, and `embedding_index_base.py`
- Added `with_embedding` parameter to all get/search methods. Passing
the embedding between the application and storage is not optional and
defaults to False
- `MemoryStoreBase` (Python SK) == `IMemoryStore` (.NET SK)
- Updated `volatile_memory_store` to implement `MemoryStoreBase`
- Removed `ABC` from `MemoryStoreBase` 
- Added documentation to memory files

Closes #670
@@ -12,6 +14,7 @@ class MemoryQueryResult:
description: Optional[str]
text: Optional[str]
relevance: float
embedding: Optional[ndarray]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numpy.typing has an NDArray typehint that lets you typehint the dtype too: https://numpy.org/doc/stable/reference/typing.html

it's relatively recent so you may need to verify it works with your numpy version ranges in your dependencies

dehoward pushed a commit to lemillermicrosoft/semantic-kernel that referenced this pull request Jun 1, 2023
### Motivation and Context
This PR significantly reduces the complexity of implementing a new
memory store. Previously, memory stores needed to implement
EmbeddingIndexBase, DataStoreBase, and MemoryStoreBase. Now, memory
stores only need to implement MemoryStoreBase. This PR also brings
MemoryStoreBase to parity with the .NET IMemoryStore interface.


### Description
- Removed `data_entry.py`, `data_store_base.py`,
`volatile_data_store.py`, and `embedding_index_base.py`
- Added `with_embedding` parameter to all get/search methods. Passing
the embedding between the application and storage is not optional and
defaults to False
- `MemoryStoreBase` (Python SK) == `IMemoryStore` (.NET SK)
- Updated `volatile_memory_store` to implement `MemoryStoreBase`
- Removed `ABC` from `MemoryStoreBase` 
- Added documentation to memory files

Closes microsoft#670
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feedback to address Waiting for PR owner to address comments/questions python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to add a vector database for the python bindings?
5 participants