Skip to content

Commit 2150747

Browse files
Python: ChromaMemoryStore - Get methods will default to not return embeddings 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 😄
1 parent 293e85e commit 2150747

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

python/semantic_kernel/connectors/memory/chroma/chroma_memory_store.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async def upsert_batch(self, collection_name: str, records: list[MemoryRecord])
181181
# upsert is checking collection existence
182182
return [await self.upsert(collection_name, record) for record in records]
183183

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

203-
async def get_batch(self, collection_name: str, keys: list[str], with_embeddings: bool) -> list[MemoryRecord]:
203+
async def get_batch(
204+
self,
205+
collection_name: str,
206+
keys: list[str],
207+
with_embeddings: bool = False
208+
) -> list[MemoryRecord]:
204209
"""Gets a batch of records.
205210
206211
Args:

0 commit comments

Comments
 (0)