Skip to content

Commit

Permalink
Python: ChromaMemoryStore - Get methods will default to not return em…
Browse files Browse the repository at this point in the history
…beddings in query results (#7563)

### Motivation and Context


Please help reviewers and future users, providing the following
information:
1. Why is this change required? I was working on a project which
leverages SemanticTextMemory to encapsulate ChromaMemoryStore.
SemanticTextMemory calls self._storage.get(collection_name=collection,
key=key) which causes an issue with undefined with_embedding parameters.
In addition, this change aligns the methods with their Python docstring
stating that this param should have a default value.
2. What problem does it solve? Makes the methods consistent with
documentation and allows ChromaMemoryStore to be used by
SemanticTextMemory.
  3. What scenario does it contribute to? ChromaMemoryStore applications

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->
- [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 😄
  • Loading branch information
andrewldesousa committed Aug 26, 2024
1 parent 293e85e commit 2150747
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async def upsert_batch(self, collection_name: str, records: list[MemoryRecord])
# upsert is checking collection existence
return [await self.upsert(collection_name, record) for record in records]

async def get(self, collection_name: str, key: str, with_embedding: bool) -> MemoryRecord:
async def get(self, collection_name: str, key: str, with_embedding: bool = False) -> MemoryRecord:
"""Gets a record.
Args:
Expand All @@ -200,7 +200,12 @@ async def get(self, collection_name: str, key: str, with_embedding: bool) -> Mem
f"Record with key '{key}' does not exist in collection '{collection_name}'"
) from exc

async def get_batch(self, collection_name: str, keys: list[str], with_embeddings: bool) -> list[MemoryRecord]:
async def get_batch(
self,
collection_name: str,
keys: list[str],
with_embeddings: bool = False
) -> list[MemoryRecord]:
"""Gets a batch of records.
Args:
Expand Down

0 comments on commit 2150747

Please sign in to comment.